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

:root {
    /* Dark Theme (Default) */
    --primary: #8b5cf6;
    --primary-glow: rgba(139, 92, 246, 0.4);
    --secondary: #06b6d4;
    --accent: #f43f5e;
    --bg-body: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-input: rgba(0, 0, 0, 0.3);
    --bg-sidebar: rgba(15, 23, 42, 0.95);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-inv: #0f172a;
    --gradient-bg: radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.15) 0px, transparent 50%);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-body: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-input: #ffffff;
    --bg-sidebar: #ffffff;
    --glass-border: rgba(0, 0, 0, 0.1);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-inv: #f8fafc;
    --gradient-bg: radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.05) 0px, transparent 50%);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', 'Noto Kufi Arabic', sans-serif;
}

body {
    background: var(--bg-body);
    background-image: var(--gradient-bg);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    transition: background 0.5s ease;
}

/* Glassmorphism */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
}

/* Layout */
#app {
    width: 100%;
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--glass-border);
    position: fixed;
    height: 100vh;
    background: var(--bg-sidebar);
    z-index: 100;
    transition: var(--transition);
}

.main-content {
    flex: 1;
    margin-right: 280px;
    padding: 40px;
    animation: slideIn 0.5s ease-out;
    transition: var(--transition);
}

/* Sidebar Nav */
.sidebar-logo {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 40px;
    text-align: center;
    background: linear-gradient(to left, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-item {
    padding: 12px 18px;
    border-radius: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
    font-size: 0.95rem;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

/* Inputs & Buttons */
input,
select,
textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    padding: 12px 18px;
    border-radius: 12px;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

button {
    cursor: pointer;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 12px 24px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--primary-glow);
}

.glass.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Tables */
.table-container {
    margin-top: 20px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}

th {
    padding: 12px 20px;
    text-align: right;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
}

td {
    padding: 15px 20px;
    background: var(--bg-card);
}

td:first-child {
    border-radius: 12px 0 0 12px;
}

td:last-child {
    border-radius: 0 12px 12px 0;
}

tr:hover td {
    background: rgba(139, 92, 246, 0.05);
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.badge-primary {
    background: rgba(139, 92, 246, 0.15);
    color: var(--primary);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    width: 90%;
    max-width: 600px;
    padding: 30px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Grid System */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    padding: 25px;
}

.stat-card h4 {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 85px;
    }

    .sidebar-logo span,
    .nav-item span:not(.icon) {
        display: none;
    }

    .main-content {
        margin-right: 85px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
    }

    .main-content {
        margin-right: 0;
        padding: 20px;
    }
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 60px;
    background: var(--bg-sidebar);
    backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--glass-border);
    padding: 0 20px;
    align-items: center;
    justify-content: space-between;
    z-index: 90;
}

#mobile-menu-toggle {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 95;
    display: none;
    opacity: 0;
    transition: var(--transition);
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* RTL Layout Fixes */
[dir="rtl"] .sidebar {
    right: 0;
    left: auto;
    border-right: none;
    border-left: 1px solid var(--glass-border);
}

[dir="rtl"] .main-content {
    margin-right: 280px;
    margin-left: 0;
}

/* Responsive Overrides */
@media (max-width: 1024px) {
    [dir="rtl"] .sidebar { 
        width: 85px; 
    }
    [dir="rtl"] .sidebar .sidebar-logo, 
    [dir="rtl"] .sidebar .nav-item span:not(.icon) { 
        display: none; 
    }
    [dir="rtl"] .main-content { 
        margin-right: 85px; 
    }
}

@media (max-width: 768px) {
    .mobile-header { 
        display: flex; 
        right: 0;
        left: 0;
        z-index: 101;
    }
    
    [dir="rtl"] .sidebar {
        transform: translateX(100%);
        width: 280px !important;
        right: 0 !important;
        left: auto !important;
        box-shadow: -10px 0 30px rgba(0,0,0,0.5);
        z-index: 110;
        transition: transform 0.3s ease;
    }
    
    [dir="rtl"] .sidebar.active {
        transform: translateX(0);
    }
    
    [dir="rtl"] .sidebar .sidebar-logo, 
    [dir="rtl"] .sidebar .nav-item span:not(.icon) { 
        display: block !important; 
    }

    [dir="rtl"] .main-content {
        margin-right: 0 !important;
        padding: 80px 15px 40px 15px;
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* Professional Card Tables */
    .table-container {
        border-radius: 12px;
        background: transparent;
        overflow-x: hidden;
    }

    table, thead, tbody, th, td, tr {
        display: block;
        width: 100%;
    }

    thead tr {
        display: none;
    }

    tr {
        background: var(--bg-card);
        margin-bottom: 20px;
        border-radius: 15px;
        border: 1px solid var(--glass-border);
        padding: 10px;
    }

    td {
        border: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 10px !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    td:last-child {
        border-bottom: none;
        padding: 15px 10px !important;
        justify-content: center;
    }

    td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--primary);
        font-size: 0.85rem;
    }

    td:first-child { border-radius: 0; }
    td:last-child { border-radius: 0; }
}

.theme-toggle {
    position: fixed;
    bottom: 25px;
    left: 25px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}