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

/* =============================================
   CSS Variables / Theme
   ============================================= */
:root {
    /* Theme Colors - Light Mode Default */
    --primary-green: #15803d;
    --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;
    --stress-th-bg: #1e3a5f;
    --stress-th-color: #e2e8f0;
    
    /* 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: #2d8a58;
    --stress-th-bg: #1e293b;
    --stress-th-color: #cbd5e1;
}

/* =============================================
   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: 6px;
}

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

/* Cozy torch-light shimmer sweep */
.logo-area::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        105deg,
        transparent 30%,
        rgba(207, 170, 95, 0.18) 45%,
        rgba(255, 255, 255, 0.22) 50%,
        rgba(207, 170, 95, 0.18) 55%,
        transparent 70%
    );
    transform: translateX(-120%);
    animation: logo-shine 22s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
    clip-path: inset(0);
}

@keyframes logo-shine {
    0%  { transform: translateX(-120%); }
    4%  { transform: translateX(-120%); }
    9%  { transform: translateX(120%); }
    100% { transform: translateX(120%); }
}

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

/* Beta Badge */
.env-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    white-space: nowrap;
    margin-inline-end: 8px;
}

.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);
}

/* Active Agents Badge */
.active-agents-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    height: 36px;
    box-sizing: border-box;
    border-radius: 10px;
    background: rgba(41, 121, 255, 0.12);
    border: 1px solid rgba(41, 121, 255, 0.3);
    font-size: 0.7rem;
    font-weight: 600;
    color: #2979ff;
    white-space: nowrap;
    transition: all 0.3s;
}

.active-agents-badge .fa-user-circle {
    font-size: 0.85rem;
}

.active-agents-badge .active-agents-label {
    font-family: 'Tajawal', sans-serif;
}

.active-agents-badge .active-agents-count {
    background: #2979ff;
    color: #fff;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0 5px;
}

[data-theme="dark"] .active-agents-badge {
    background: rgba(41, 121, 255, 0.15);
    border-color: rgba(41, 121, 255, 0.35);
}

/* Credit Balance Badge */
.credit-balance-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 4px 14px;
    margin: 0 12px;
    box-sizing: border-box;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    transition: all 0.3s;
}
.credit-balance-label { font-size: 0.6rem; font-weight: 600; opacity: 0.8; }
.credit-balance-row { display: flex; align-items: center; gap: 6px; }
.credit-balance-badge.credit-ok {
    background: rgba(46, 125, 50, 0.12);
    border: 1px solid rgba(46, 125, 50, 0.3);
    color: #2e7d32;
}
.credit-balance-badge.credit-low {
    background: rgba(220, 53, 69, 0.12);
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: #dc3545;
}
.credit-balance-icon { width: 18px; height: 18px; flex-shrink: 0; }
.credit-balance-value { font-size: 0.85rem; font-weight: 800; }
[data-theme="light"] .credit-balance-badge.credit-ok {
    background: rgba(46, 125, 50, 0.15);
    border: 1px solid rgba(46, 125, 50, 0.5);
    color: #1b5e20;
}
[data-theme="light"] .credit-balance-badge.credit-low {
    background: rgba(220, 53, 69, 0.15);
    border: 1px solid rgba(220, 53, 69, 0.5);
    color: #b71c1c;
}
[data-theme="dark"] .credit-balance-badge.credit-ok {
    background: rgba(46, 125, 50, 0.18);
    border-color: rgba(46, 125, 50, 0.4);
    color: #66bb6a;
}
[data-theme="dark"] .credit-balance-badge.credit-low {
    background: rgba(220, 53, 69, 0.18);
    border-color: rgba(220, 53, 69, 0.4);
    color: #ef5350;
}

/* Header vertical divider */
.header-divider {
    width: 1px;
    height: 32px;
    background: rgba(255, 255, 255, 0.35);
    margin: 0 6px;
    flex-shrink: 0;
}
:root:not([data-theme="dark"]) .header-divider {
    background: rgba(0, 0, 0, 0.25);
}

/* Performance Metrics Badges */
.perf-badges {
    display: grid;
    grid-template-columns: repeat(3, auto);
    grid-template-rows: 1fr 1fr;
    gap: 2px 4px;
    height: 36px;
    box-sizing: border-box;
}

.perf-badge {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-color, #ccc);
    white-space: nowrap;
    transition: all 0.3s;
}

.perf-icon {
    font-size: 0.7rem;
}

.perf-label {
    font-size: 0.58rem;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.perf-cpu { color: #ff9800; }
.perf-ram { color: #26c6da; }
.perf-exec { color: #d4a017; }
.perf-resp { color: #ab47bc; }
.perf-inst { color: #66bb6a; }

.perf-value {
    font-variant-numeric: tabular-nums;
    font-size: 0.74rem;
    font-weight: 700;
}

[data-theme="dark"] .perf-badge {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

[data-theme="dark"] .perf-label {
    color: #e0e0e0;
    opacity: 1;
    font-weight: 700;
    font-size: 0.64rem;
}

[data-theme="dark"] .perf-value {
    color: #fff;
}

:root:not([data-theme="dark"]) .perf-badge {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.15);
    color: #444;
}

:root:not([data-theme="dark"]) .perf-label {
    color: #555;
    opacity: 1;
    font-weight: 600;
    font-size: 0.62rem;
}

:root:not([data-theme="dark"]) .perf-value {
    color: #333;
}

:root:not([data-theme="dark"]) .perf-cpu { color: #e65100; }
:root:not([data-theme="dark"]) .perf-ram { color: #00838f; }
:root:not([data-theme="dark"]) .perf-exec { color: #a67c00; }
:root:not([data-theme="dark"]) .perf-resp { color: #7b1fa2; }
:root:not([data-theme="dark"]) .perf-inst { color: #2e7d32; }

/* Connection Speed Indicator */
.connection-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 3px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    margin-left: 6px;
    transition: border-color 0.3s;
}
.connection-label { display: none; }
.connection-row { display: flex; align-items: center; gap: 4px; }
.connection-quality { font-size: 0.65rem; font-weight: 700; white-space: nowrap; }
.connection-rtt { font-size: 0.58rem; color: var(--text-muted, #999); font-variant-numeric: tabular-nums; }
.connection-icon { font-size: 0.75rem; }

.connection-status.fast { border-color: #28a745; }
.connection-status.fast .connection-icon,
.connection-status.fast .connection-quality { color: #28a745; }

.connection-status.medium { border-color: #ffc107; }
.connection-status.medium .connection-icon,
.connection-status.medium .connection-quality { color: #ffc107; }

.connection-status.slow { border-color: #dc3545; }
.connection-status.slow .connection-icon,
.connection-status.slow .connection-quality { color: #dc3545; }

.connection-status.offline { border-color: #6c757d; }
.connection-status.offline .connection-icon,
.connection-status.offline .connection-quality { color: #6c757d; }

:root:not([data-theme="dark"]) .connection-status {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.15);
}

/* Client Performance Widget */
.client-perf {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 3px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    margin-left: 4px;
    transition: border-color 0.3s;
}
.client-perf-row { display: flex; align-items: center; gap: 4px; }
.client-perf-icon { font-size: 0.7rem; color: var(--text-muted, #999); }
.client-perf-value { font-size: 0.6rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-muted, #999); }

.client-perf.perf-good { border-color: #28a745; }
.client-perf.perf-good .client-perf-icon,
.client-perf.perf-good .client-perf-value { color: #28a745; }

.client-perf.perf-warn { border-color: #ffc107; }
.client-perf.perf-warn .client-perf-icon,
.client-perf.perf-warn .client-perf-value { color: #ffc107; }

.client-perf.perf-bad { border-color: #dc3545; }
.client-perf.perf-bad .client-perf-icon,
.client-perf.perf-bad .client-perf-value { color: #dc3545; }

:root:not([data-theme="dark"]) .client-perf {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.15);
}

/* API Health Timeline */
.health-timeline {
    display: flex; flex-direction: column; gap: 2px; padding: 3px 8px;
    border-radius: 8px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
}
.health-header { display: flex; align-items: center; gap: 4px; }
.health-icon { font-size: 0.7rem; color: #28a745; }
.health-label { font-size: 0.58rem; opacity: 0.6; text-transform: uppercase; letter-spacing: 0.3px; font-weight: 600; }
.health-status { font-size: 0.6rem; font-weight: 700; }
.health-uptime { font-size: 0.55rem; color: var(--text-muted,#999); margin-inline-start: auto; font-variant-numeric: tabular-nums; }
.health-operational { color: #28a745; }
.health-degraded { color: #ffc107; }
.health-down { color: #dc3545; }
.health-bars { display: flex; gap: 1px; height: 14px; align-items: flex-end; }
.health-bar { flex: 1; min-width: 1.5px; height: 100%; border-radius: 1px; transition: opacity 0.2s; cursor: default; }
.health-bar:hover { opacity: 0.7; }
.health-ok { background: #28a745; }
.health-warn { background: #ffc107; }
.health-fail { background: #dc3545; }
.health-nodata { background: rgba(255,255,255,0.12); }
.health-range { display: flex; justify-content: space-between; font-size: 0.45rem; color: var(--text-muted,#666); opacity: 0.5; }
:root:not([data-theme="dark"]) .health-timeline { background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.15); }
:root:not([data-theme="dark"]) .health-nodata { background: rgba(0,0,0,0.1); }

/* Light theme — darken header widgets for contrast */
[data-theme="light"] header {
    background-color: #d0d3da;
    border-bottom-color: var(--primary-gold);
}

[data-theme="light"] .user-profile {
    background: #b8bcc6;
    border-color: #9ea3af;
}

[data-theme="light"] .active-agents-badge {
    background: rgba(20, 50, 140, 0.18);
    border-color: rgba(20, 50, 140, 0.4);
    color: #0d3280;
}

[data-theme="light"] .active-agents-badge .active-agents-count {
    background: #0d3280;
}

[data-theme="light"] .auto-refresh-toggle {
    background: #b8bcc6;
    border-color: #9ea3af;
    color: #111;
}

[data-theme="light"] .theme-toggle .btn-icon {
    color: #222;
}

@media (max-width: 1200px) {
    .perf-badges {
        display: none;
    }
    .health-timeline {
        display: none;
    }
}

@media (max-width: 768px) {
    .active-agents-badge .active-agents-label {
        display: none;
    }
}

/* 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;
}

/* Version Info Button */
.btn-version-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    height: 38px;
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.08), rgba(212, 175, 55, 0.02));
    color: #d4af37;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
    direction: ltr;
}
.btn-version-info:hover {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.18), rgba(212, 175, 55, 0.06));
    border-color: rgba(212, 175, 55, 0.4);
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.15);
}
.btn-version-info i {
    font-size: 0.85rem;
    opacity: 0.8;
}
.btn-version-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
}
.btn-version-text {
    font-variant-numeric: tabular-nums;
    font-size: 0.75rem;
}
.btn-version-label {
    font-size: 0.6rem;
    font-weight: 500;
    opacity: 0.85;
    direction: rtl;
    color: #94a3b8;
}

.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: 6px;
    padding: 4px 10px;
    height: 36px;
    box-sizing: border-box;
    border-radius: 10px;
    background: #1a6b3a;
    color: #b8e6c8;
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
    border: 1px solid rgba(37, 211, 102, 0.25);
}

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

.whatsapp-link .fab.fa-whatsapp {
    font-size: 1.1rem;
    color: #25d366;
}

.whatsapp-link .wa-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.whatsapp-link .wa-number {
    direction: ltr;
    font-variant-numeric: tabular-nums;
    font-size: 0.72rem;
    color: #d4f0de;
}

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

[data-theme="light"] .whatsapp-link {
    background: #e8f5e9;
    color: #1b5e20;
    border-color: rgba(37, 211, 102, 0.3);
}

[data-theme="light"] .whatsapp-link .wa-number { color: #1b5e20; }
[data-theme="light"] .whatsapp-link .fab.fa-whatsapp { color: #1b9e3e; }

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

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    height: 36px;
    box-sizing: border-box;
    border-radius: 10px;
    background: var(--hover-color);
    border: 1px solid var(--border-color);
}

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

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

.signout-btn {
    font-size: 0.65rem;
    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: flex-start;
    padding: 9px 20px;
    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: 22px;
    text-align: center;
    margin-left: 8px;
    font-size: 0.9rem;
    margin-top: 2px;
    flex-shrink: 0;
}

.nav-item span {
    flex: 1;
    font-size: 0.85rem;
    white-space: normal;
    overflow: hidden;
    line-height: 1.35;
}

/* Nav items with badge: position context for badge below */
.nav-item.has-badge {
    position: relative;
    padding-bottom: 20px;
}

/* Nav Badge (Coming Soon, etc.) */
.nav-badge {
    position: absolute;
    bottom: 3px;
    right: 35px;
    left: auto;
    font-size: 0.45rem;
    padding: 0;
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-weight: 400;
    font-style: italic;
    white-space: nowrap;
    line-height: 1;
    letter-spacing: 0.3px;
}

.nav-badge.coming-soon {
    color: var(--primary-gold, #cfaa5f);
    background: none;
}

.nav-badge.coming-soon::before {
    content: '✦ ';
    font-size: 0.4rem;
    vertical-align: middle;
}

.sidebar.collapsed .nav-badge {
    display: none;
}

/* 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 {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 14px;
    margin-top: 12px;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-decoration: none;
    opacity: 0.6;
    transition: opacity 0.2s;
    direction: ltr;
    border-top: 1px solid var(--border-color);
}

.sidebar-version__row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    text-align: left;
}

.sidebar-version__row > i {
    margin-top: 2px;
    flex-shrink: 0;
}

.sidebar-version__info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    text-align: left;
    line-height: 1.5;
    min-width: 0;
}

.sidebar-version__info .ver-label {
    font-weight: 600;
    color: var(--text-secondary, #b0b0b0);
}

.sidebar-version__info .ver-sha {
    font-family: 'Consolas', 'Courier New', monospace;
    letter-spacing: 0.3px;
}

.sidebar-version__info .ver-detail {
    opacity: 0.75;
    font-size: 0.63rem;
}

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

.sidebar-version i {
    font-size: 0.75rem;
    width: 14px;
    text-align: center;
}

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

.sidebar.collapsed .sidebar-version {
    border-top: none;
}

.sidebar.collapsed .sidebar-version__info,
.sidebar.collapsed .sidebar-version__row 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;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 2px 8px;
    height: 36px;
    box-sizing: border-box;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.auto-refresh-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.toggle-switch {
    position: relative;
    width: 28px;
    height: 16px;
    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: 16px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    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(12px);
}

.toggle-status {
    font-size: 0.6rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.btn-update-now {
    font-size: 0.58rem;
    padding: 2px 7px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--hover-color);
    color: var(--text-main);
    cursor: pointer;
    white-space: nowrap;
    transition: 0.2s;
}

.btn-update-now:hover {
    background: var(--primary-gold);
    color: #1a1a1a;
}

.btn-update-now i {
    font-size: 0.55rem;
}

/* =============================================
   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;
    }
}

/* =============================================
   Read-Only Section Enforcement
   ============================================= */
body[data-readonly] button:not([data-allow-readonly]):not([data-tab]):not([data-section]),
body[data-readonly] [class*="-btn"]:not([data-allow-readonly]):not([data-tab]):not([data-section]),
body[data-readonly] input:not([type="search"]):not([type="checkbox"]):not([data-allow-readonly]),
body[data-readonly] textarea:not([data-allow-readonly]),
body[data-readonly] select:not([data-allow-readonly]),
body[data-readonly] [contenteditable]:not([data-allow-readonly]) {
    pointer-events: none !important;
    opacity: 0.45;
    cursor: not-allowed !important;
}

#section-readonly-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    text-align: center;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    letter-spacing: 0.01em;
}

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