@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Cairo:wght@400;600;700;800&display=swap');

:root {
    /* --- Modern Premium Tokens: Light Mode --- */
    --font-primary: 'Cairo', 'Outfit', system-ui, sans-serif;
    
    /* Backgrounds */
    --bg-app: #f4f6f9;
    --bg-panel: #ffffff;
    --bg-element: #f8fafc;
    --bg-hover: #f1f5f9;

    /* Text */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    /* Borders */
    --border-color: #e2e8f0;
    --border-focus: #6366f1;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.025);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.05), 0 10px 10px -5px rgba(0,0,0,0.02);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.2);

    /* Brand Colors - Indigo / Purple vibe */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    
    /* Utilities */
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --info: #3b82f6;
    --info-bg: #dbeafe;

    /* Dimensions */
    --sidebar-w: 260px;
    --header-h: 70px;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius: var(--radius-md);

    /* Z-Index */
    --z-sidebar: 1000;
    --z-header: 900;
    --z-overlay: 950;
}

[data-theme="dark"] {
    /* --- Modern Premium Tokens: Dark Mode --- */
    --bg-app: #0f172a;
    --bg-panel: #1e293b;
    --bg-element: #334155;
    --bg-hover: #334155;

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    --border-color: #334155;
    --primary-light: rgba(79, 70, 229, 0.15);
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.2);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.3);
    
    --success-bg: rgba(16, 185, 129, 0.15);
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger-bg: rgba(239, 68, 68, 0.15);
    --info-bg: rgba(59, 130, 246, 0.15);
}

/* Base Reset */
* {
    margin: 0; padding: 0; box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-app);
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a { text-decoration: none; color: inherit; transition: 0.2s; }
ul { list-style: none; }
h1, h2, h3, h4 { color: var(--text-primary); font-weight: 700; }
.text-muted { color: var(--text-muted) !important; }
.text-sm { font-size: 0.875rem; }
.font-bold { font-weight: 700; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-panel);
    border-left: 1px solid var(--border-color);
    position: fixed;
    top: 0; bottom: 0; right: 0;
    z-index: var(--z-sidebar);
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(100%); /* Hidden by default on mobile */
    }
    .sidebar.open {
        transform: translateX(0);
    }
}

.sidebar-header {
    height: var(--header-h);
    display: flex; align-items: center; padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-content {
    flex: 1; padding: 20px; overflow-y: auto;
}

.nav-link {
    display: flex; align-items: center; padding: 12px 16px;
    margin-bottom: 8px; border-radius: 12px;
    color: var(--text-secondary); font-weight: 600;
    transition: all 0.25s ease;
}

.nav-link i { margin-left: 12px; font-size: 1.25rem; transition: 0.25s; }
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); transform: translateX(-4px); }
.nav-link.active { background: var(--primary); color: white; box-shadow: var(--shadow-md); }
.nav-link.active i { color: white; }

/* Mobile Overlay */
.sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: var(--z-overlay); opacity: 0; visibility: hidden;
    transition: 0.3s; backdrop-filter: blur(4px);
}
.sidebar-overlay.open { opacity: 1; visibility: visible; }

/* Main Content */
.main-wrapper {
    flex: 1;
    margin-right: var(--sidebar-w);
    min-height: 100vh;
    display: flex; flex-direction: column;
    transition: margin-right 0.3s;
}

@media (max-width: 1024px) {
    .main-wrapper { margin-right: 0; }
}

.top-header {
    height: var(--header-h);
    background: rgba(var(--bg-panel), 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; position: sticky; top: 0; z-index: var(--z-header);
}

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

.toggle-sidebar-btn {
    display: none;
    background: transparent; border: none; cursor: pointer;
    font-size: 1.5rem; color: var(--text-primary);
}

@media (max-width: 1024px) {
    .toggle-sidebar-btn { display: block; }
}

.page-content { padding: 32px; flex: 1; }
@media (max-width: 768px) { .page-content { padding: 16px; } }

/* Cards */
.card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    transition: 0.3s;
    overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-header { padding: 20px 24px; border-bottom: 1px solid var(--border-color); }
.card-body { padding: 24px; }

/* Metrics */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; margin-bottom: 32px; }
.metric-card {
    background: var(--bg-panel); padding: 24px;
    border-radius: var(--radius); border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm); transition: 0.3s;
}
.metric-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--primary-light); }
.metric-title { font-size: 0.9rem; color: var(--text-muted); font-weight: 600; margin-bottom: 12px; }
.metric-value { font-size: 2.2rem; font-weight: 800; color: var(--text-primary); margin-bottom: 8px; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 24px; font-weight: 600; border-radius: 12px; border: none;
    cursor: pointer; transition: 0.3s; font-family: inherit; font-size: 0.95rem;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white; box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(79, 70, 229, 0.4); }
.btn-secondary { background: var(--bg-element); color: var(--text-primary); }
.btn-secondary:hover { background: var(--border-color); }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; border-radius: 8px; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-label { display: block; margin-bottom: 8px; font-weight: 600; color: var(--text-secondary); }
.form-control {
    width: 100%; padding: 12px 16px; border: 1px solid var(--border-color);
    border-radius: 12px; background: var(--bg-element); color: var(--text-primary);
    font-family: inherit; font-size: 0.95rem; transition: 0.3s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); outline: none; }

/* Table */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { background: var(--bg-element); color: var(--text-secondary); padding: 16px; text-align: right; font-weight: 700; border-bottom: 1px solid var(--border-color); }
.table td { padding: 16px; border-bottom: 1px solid var(--border-color); }

/* Badges */
.badge { padding: 6px 12px; border-radius: 8px; font-size: 0.75rem; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--bg-element); color: var(--text-secondary); }

/* Utility */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.mb-4 { margin-bottom: 24px; }
.w-full { width: 100%; }

/* Alerts */
.alert { padding: 16px; border-radius: 12px; margin-bottom: 24px; font-weight: 600; display: flex; align-items: center; gap: 12px; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }

/* Animations */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade { animation: fadeInUp 0.4s ease forwards; }

.lucide { width: 1.2em; height: 1.2em; vertical-align: middle; }