/* shared.css - Common styles for all pages */

/* =============================================
   CSS Variables / Theme
   ============================================= */
:root {
    /* Theme Colors - Light Mode Default */
    --primary-green: #004d3e;
    --primary-gold: #cfaa5f;
    --bg-body: #f5f7fa;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --text-main: #333333;
    --text-muted: #666666;
    --border-color: #e0e0e0;
    --hover-color: #f0f0f0;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --danger: #dc2626;
    --warning: #f59e0b;
    --success: #10b981;
    
    /* Spacing */
    --header-height: 90px;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 60px;
}

[data-theme="dark"] {
    --bg-body: #1a1a1a;
    --bg-card: #2d2d2d;
    --bg-sidebar: #242424;
    --text-main: #f5f5f5;
    --text-muted: #e0e0e0;
    --border-color: #404040;
    --hover-color: #3a3a3a;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --primary-green: #4ade80;
}

/* =============================================
   Base Styles
   ============================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Tajawal', 'Cairo', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: all 0.3s ease;
    font-weight: 500;
}

[data-theme="dark"] body {
    font-weight: 500;
}

/* =============================================
   Scrollbar
   ============================================= */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-body);
}
::-webkit-scrollbar-thumb {
    background: var(--primary-gold);
    border-radius: 4px;
}

/* =============================================
   RTL Support
   ============================================= */
body.rtl {
    direction: rtl;
    font-size: 1.05rem;
}

body.rtl .sidebar {
    right: 0;
    left: auto;
    border-left: 1px solid var(--border-color);
    border-right: none;
}

body.rtl .main-content {
    margin-right: var(--sidebar-width);
    margin-left: 0;
}

body.rtl .nav-item {
    border-left: none;
    border-right: 4px solid transparent;
    flex-direction: row-reverse;
}

body.rtl .nav-item:hover, body.rtl .nav-item.active {
    border-right-color: var(--primary-gold);
    border-left-color: transparent;
}

body.rtl .nav-item i {
    margin-right: 10px;
    margin-left: 0;
}

body.rtl footer {
    margin-left: 0;
    margin-right: var(--sidebar-width);
}

body.rtl .page-title::after {
    right: 0;
    left: auto;
}

/* LTR (English) */
body.ltr .sidebar {
    right: 0;
    left: auto;
    border-left: 1px solid var(--border-color);
    border-right: none;
}

body.ltr .main-content {
    margin-right: var(--sidebar-width);
    margin-left: 0;
}

body.ltr .nav-item {
    border-left: none;
    border-right: 4px solid transparent;
    flex-direction: row;
}

body.ltr .nav-item i {
    margin-right: 12px;
    margin-left: 0;
}

body.ltr .nav-item:hover, body.ltr .nav-item.active {
    border-right-color: var(--primary-gold);
    border-left-color: transparent;
}

body.ltr footer {
    margin-right: var(--sidebar-width);
    margin-left: 0;
}

/* =============================================
   Header
   ============================================= */
header {
    height: var(--header-height);
    background-color: var(--bg-card);
    border-bottom: 3px solid var(--primary-gold);
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: var(--shadow);
    justify-content: space-between;
    direction: ltr; /* Fixed layout: left controls, right logo */
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-area {
    height: 65px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    position: relative;
    gap: 2px;
}

.logo-area img {
    max-height: 45px;
}

/* Beta Badge */
.beta-badge {
    background: linear-gradient(135deg, var(--primary-gold), #b8943d);
    color: #1a1a1a;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.55rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    box-shadow: 0 1px 4px rgba(207, 170, 95, 0.4);
    white-space: nowrap;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-muted);
    padding: 8px;
    border-radius: 50%;
    transition: 0.2s;
}

.btn-icon:hover {
    color: var(--primary-gold);
    background-color: var(--hover-color);
}

/* Hide mobile hamburger on desktop */
.mobile-toggle {
    display: none;
}

.theme-toggle {
    display: flex;
    align-items: center;
}

.theme-toggle .btn-icon {
    font-size: 1.3rem;
}

/* Language Selector */
.language-selector select {
    padding: 4px 8px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-main);
    outline: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
}

.live-time {
    font-size: 0.85rem;
    text-align: center;
    line-height: 1.2;
    color: var(--text-muted);
    border-left: 1px solid var(--border-color);
    padding-left: 12px;
    margin-left: 5px;
    min-width: 120px;
    font-variant-numeric: tabular-nums;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-time .clock-icon {
    font-size: 1.1rem;
}

.live-time .clock-text {
    direction: rtl;
}

.live-time .clock-text {
    text-align: center;
}

/* WhatsApp Service Link */
.whatsapp-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    background: #25d366;
    color: #fff;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

.whatsapp-link:hover {
    background: #1da851;
    transform: scale(1.03);
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.4);
}

.whatsapp-link .fab.fa-whatsapp {
    font-size: 1.2rem;
}

.whatsapp-link .wa-number {
    direction: ltr;
    font-variant-numeric: tabular-nums;
}

.whatsapp-link .wa-label {
    font-size: 0.7rem;
    opacity: 0.9;
    font-family: 'Tajawal', sans-serif;
}

@media (max-width: 768px) {
    .whatsapp-link .wa-number,
    .whatsapp-link .wa-label {
        display: none;
    }
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 12px;
    border-radius: 20px;
    background: var(--hover-color);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
}

.user-email {
    font-size: 0.85rem;
    color: var(--text-main);
}

.signout-btn {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.signout-btn:hover {
    color: var(--primary-gold);
}

/* =============================================
   Sidebar / Navigation
   ============================================= */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    right: 0;
    border-left: 1px solid var(--border-color);
    padding: 20px 0;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 25px;
    color: var(--text-muted);
    text-decoration: none;
    transition: 0.2s;
    border-right: 4px solid transparent;
}

.nav-item:hover, .nav-item.active {
    color: var(--primary-green);
    background-color: var(--hover-color);
    border-right-color: var(--primary-gold);
}

.nav-item i {
    width: 25px;
    text-align: center;
    margin-left: 10px;
    font-size: 1.1rem;
}

.nav-item span {
    flex: 1;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
}

/* Sidebar Collapse Toggle */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    margin: 0 10px 10px;
    border: none;
    background: var(--hover-color);
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: var(--primary-green);
    color: white;
}

/* Sidebar Version */
.sidebar-version {
    position: absolute;
    bottom: 12px;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.sidebar-version:hover {
    opacity: 1;
}

.sidebar-version i {
    font-size: 0.85rem;
}

/* Collapsed Sidebar */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-version span {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
}

.sidebar.collapsed .nav-item i {
    margin: 0;
    font-size: 1.2rem;
}

.sidebar.collapsed .nav-item span {
    display: none;
}

.sidebar.collapsed .sidebar-toggle span {
    display: none;
}

.sidebar.collapsed .sidebar-toggle {
    margin: 0 8px 10px;
}

/* Adjust main content and footer when sidebar is collapsed */
body.sidebar-collapsed .main-content {
    margin-right: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed footer {
    margin-right: var(--sidebar-collapsed-width);
}

body.rtl.sidebar-collapsed .main-content {
    margin-right: var(--sidebar-collapsed-width);
    margin-left: 0;
}

body.rtl.sidebar-collapsed footer {
    margin-right: var(--sidebar-collapsed-width);
    margin-left: 0;
}

body.ltr.sidebar-collapsed .main-content {
    margin-right: var(--sidebar-collapsed-width);
    margin-left: 0;
}

body.ltr.sidebar-collapsed footer {
    margin-right: var(--sidebar-collapsed-width);
    margin-left: 0;
}

/* =============================================
   Main Content Area
   ============================================= */
.main-content {
    margin-right: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 30px;
    flex-grow: 1;
    transition: all 0.3s ease;
}

.page-title {
    margin-bottom: 25px;
    color: var(--primary-green);
    font-size: 1.8rem;
    position: relative;
    padding-bottom: 10px;
}

.page-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 60px;
    height: 4px;
    background-color: var(--primary-gold);
    border-radius: 2px;
}

/* =============================================
   Footer
   ============================================= */
footer {
    margin-right: var(--sidebar-width);
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.footer-powered {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-weight: 500;
}

.footer-powered img {
    height: 120px;
    transition: transform 0.3s;
}

.footer-powered img:hover {
    transform: scale(1.05);
}

/* =============================================
   Cards
   ============================================= */
.card {
    background-color: var(--bg-card);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
}

/* =============================================
   Auto Refresh Toggle
   ============================================= */
.auto-refresh-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.auto-refresh-toggle .toggle-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    border-radius: 20px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-green);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
        z-index: 1001;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .main-content, footer {
        margin-left: 0;
        margin-right: 0;
    }
    
    body.rtl .main-content {
        margin-right: 0;
    }
    
    body.rtl footer {
        margin-right: 0;
    }
    
    .header-left {
        gap: 10px;
    }
    
    .logo-area {
        height: 50px;
    }

    .mobile-toggle {
        display: inline-flex;
    }
}

/* =============================================
   Animations
   ============================================= */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
