:root {
    --primary: #0f172a;
    --primary-light: #1e293b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: #dbeafe;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-hover: #f8fafc;
    --border: #e2e8f0;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 4px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.08);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.7;
    overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ===== APP WRAPPER ===== */
.app-wrapper { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow: hidden;
}

.sidebar-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), #818cf8);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -1px;
}

.brand-text {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}

.sidebar-close { color: rgba(255,255,255,0.5); font-size: 18px; }

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-group {
    margin-bottom: 4px;
}

.nav-section {
    padding: 16px 12px 6px;
}

.nav-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 10px 12px 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    user-select: none;
}

.nav-section-toggle:hover {
    background: rgba(255,255,255,0.04);
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-section-toggle:hover .nav-section-title {
    color: rgba(255,255,255,0.5);
}

.nav-section-arrow {
    font-size: 10px;
    color: rgba(255,255,255,0.2);
    transition: transform 0.3s ease;
}

.nav-section-toggle.collapsed .nav-section-arrow {
    transform: rotate(-90deg);
}

.nav-section-items {
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.nav-section-items.collapsed {
    max-height: 0;
    opacity: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.9);
}

.nav-item.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.nav-item i { width: 20px; text-align: center; font-size: 15px; }

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.app-info {
    color: rgba(255,255,255,0.25);
    text-align: center;
    font-size: 12px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

/* ===== TOP NAVBAR ===== */
.top-navbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
    color: var(--text-secondary);
    font-size: 18px;
    padding: 6px;
    border-radius: var(--radius-sm);
}

.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

.page-title {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #818cf8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
}

/* ===== CONTENT AREA ===== */
.content-area {
    flex: 1;
    padding: 24px;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow); }

.card-header {
    padding: 16px 20px;
    background: transparent;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.card-header h5, .card-header h6 {
    margin: 0;
    font-weight: 700;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body { padding: 20px; }

/* ===== STAT CARDS ===== */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.stat-icon.blue { background: var(--accent-light); color: var(--accent); }
.stat-icon.green { background: #d1fae5; color: var(--success); }
.stat-icon.amber { background: #fef3c7; color: var(--warning); }
.stat-icon.red { background: #fee2e2; color: var(--danger); }
.stat-icon.cyan { background: #cffafe; color: var(--info); }
.stat-icon.purple { background: #ede9fe; color: #8b5cf6; }

.stat-info h3 {
    font-size: 24px;
    font-weight: 800;
    margin: 0;
    line-height: 1.2;
}

.stat-info p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

/* ===== TABLES ===== */
.table-responsive { border-radius: var(--radius-sm); overflow: hidden; }

.table {
    margin: 0;
    font-size: 13.5px;
}

.table thead th {
    background: var(--bg-body);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 12px 16px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: var(--accent-glow); }
.table tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
    font-weight: 600;
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 20px;
}

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ===== BUTTONS ===== */
.btn {
    font-family: 'Tajawal', sans-serif;
    font-weight: 600;
    font-size: 13.5px;
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}

.btn-sm { padding: 5px 12px; font-size: 12.5px; }

.btn-action {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 13px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    transition: var(--transition);
}

.btn-action:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.btn-action.edit:hover { border-color: var(--warning); color: var(--warning); background: #fef3c7; }
.btn-action.delete:hover { border-color: var(--danger); color: var(--danger); background: #fee2e2; }

/* ===== FORMS ===== */
.form-control, .form-select {
    font-family: 'Tajawal', sans-serif;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    font-size: 14px;
    color: var(--text-primary);
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* ===== ALERTS ===== */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-size: 14px;
    font-weight: 500;
    padding: 14px 18px;
}

/* ===== FOOTER ===== */
.app-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    font-size: 12.5px;
    color: var(--text-light);
    background: var(--bg-card);
}

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59,130,246,0.15), transparent 70%);
    top: -200px;
    left: -100px;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(129,140,248,0.1), transparent 70%);
    bottom: -200px;
    right: -100px;
}

.login-card {
    background: rgba(255,255,255,0.03);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-brand {
    text-align: center;
    margin-bottom: 36px;
}

.login-brand .brand-icon {
    width: 64px;
    height: 64px;
    font-size: 30px;
    margin: 0 auto 16px;
}

.login-brand h2 {
    color: #fff;
    font-weight: 800;
    font-size: 28px;
    margin-bottom: 4px;
}

.login-brand p {
    color: rgba(255,255,255,0.4);
    font-size: 14px;
}

.login-card .form-control {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 12px 16px;
    font-size: 15px;
    border-radius: 10px;
}

.login-card .form-control::placeholder { color: rgba(255,255,255,0.3); }
.login-card .form-control:focus {
    background: rgba(255,255,255,0.08);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

.login-card .form-label { color: rgba(255,255,255,0.5); }

.login-card .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #818cf8);
    border: none;
}

.login-card .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(59,130,246,0.4);
}

.login-error {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.2);
    color: #fca5a5;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    text-align: center;
    margin-bottom: 20px;
}

/* ===== LICENSE LOCKOUT ===== */
.license-alert {
    background: linear-gradient(135deg, #fef3c7, #fffbeb);
    border: 1px solid #fbbf24;
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
}

.license-alert.expired {
    background: linear-gradient(135deg, #fee2e2, #fef2f2);
    border-color: var(--danger);
}

/* ===== SIDEBAR OVERLAY ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
    backdrop-filter: blur(4px);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .sidebar.show ~ .sidebar-overlay {
        display: block;
    }
    .main-content {
        margin-right: 0;
    }
    .content-area { padding: 16px; }
    .top-navbar { padding: 0 16px; }
    .app-footer { flex-direction: column; text-align: center; gap: 4px; }
}

@media (max-width: 575.98px) {
    .login-card { margin: 16px; padding: 32px 24px; }
    .stat-card { padding: 14px; }
    .stat-icon { width: 44px; height: 44px; font-size: 18px; }
    .stat-info h3 { font-size: 20px; }
    .card-header { padding: 12px 16px; }
    .card-body { padding: 16px; }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.content-area { animation: fadeIn 0.4s ease-out; }
.stat-card { animation: fadeIn 0.5s ease-out backwards; }
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }
.stat-card:nth-child(5) { animation-delay: 0.25s; }
.stat-card:nth-child(6) { animation-delay: 0.3s; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-light);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h6 { color: var(--text-secondary); margin-bottom: 8px; }
