/* ===================================================
   لوحة التحكم الشاملة | منصة ثامر الرياضية والتربوية
   المدرسة المركزية بالمنطقة الشرقية • إدارة: أ / أحمد الشمراني • إشراف: أ / ثامر العمير
   =================================================== */

:root {
    --primary: #0284c7;
    --primary-dark: #0369a1;
    --primary-light: #38bdf8;
    --secondary: #d97706;
    --secondary-light: #fbbf24;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;

    /* Dark Mode (Default) */
    --dash-bg: #0b1329;
    --dash-sidebar: #0f1c3f;
    --dash-card: #152454;
    --dash-card-hover: #1c3070;
    --dash-border: rgba(255, 255, 255, 0.1);
    --dash-border-glow: rgba(56, 189, 248, 0.4);
    --dash-text: #f8fafc;
    --dash-text-muted: #94a3b8;

    --font-main: 'Cairo', system-ui, sans-serif;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --dash-bg: #f8fafc;
    --dash-sidebar: #ffffff;
    --dash-card: #ffffff;
    --dash-card-hover: #f1f5f9;
    --dash-border: #e2e8f0;
    --dash-border-glow: rgba(2, 132, 199, 0.4);
    --dash-text: #0f172a;
    --dash-text-muted: #64748b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
}

body {
    background-color: var(--dash-bg);
    color: var(--dash-text);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--dash-sidebar);
    border-left: 1px solid var(--dash-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all var(--transition-normal);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--dash-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
}

.sidebar-logo-text h3 {
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.2;
}

.sidebar-logo-text span {
    font-size: 0.74rem;
    color: var(--primary-light);
    font-weight: 700;
}

/* User Profile Badge in Sidebar */
.sidebar-user-box {
    padding: 20px;
    border-bottom: 1px solid var(--dash-border);
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--dash-card);
    border: 2px solid var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.user-meta-info {
    overflow: hidden;
}

.user-display-name {
    font-size: 0.95rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 800;
    margin-top: 3px;
}

.user-role-badge.admin { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.user-role-badge.operator { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.3); }
.user-role-badge.student { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(52, 211, 153, 0.3); }

/* Sidebar Navigation Items */
.sidebar-nav {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.nav-section-label {
    font-size: 0.74rem;
    font-weight: 800;
    color: var(--dash-text-muted);
    padding: 10px 14px 4px;
    text-transform: uppercase;
}

.sidebar-tab-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--dash-text-muted);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    text-align: right;
    width: 100%;
    transition: all var(--transition-fast);
}

.sidebar-tab-btn:hover {
    background: var(--dash-card);
    color: var(--dash-text);
}

.sidebar-tab-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--dash-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Main Dashboard Content Area */
.dashboard-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-y: auto;
}

/* Top Navigation Bar */
.dash-topbar {
    height: 72px;
    background: var(--dash-sidebar);
    border-bottom: 1px solid var(--dash-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.topbar-title-box h2 {
    font-size: 1.3rem;
    font-weight: 900;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-dash {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 800;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-dash-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.btn-dash-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.5);
}

.btn-dash-outline {
    background: transparent;
    border: 1px solid var(--dash-border);
    color: var(--dash-text);
}

.btn-dash-outline:hover {
    background: var(--dash-card);
    border-color: var(--dash-border-glow);
}

.btn-dash-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.btn-dash-danger:hover {
    background: #ef4444;
    color: #ffffff;
}

/* Dashboard Body & Tab Panes */
.dash-content {
    padding: 30px;
    flex: 1;
}

.tab-pane {
    display: none;
    animation: fadeInTab 0.3s ease;
}

.tab-pane.active {
    display: block;
}

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

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

.dash-stat-card {
    background: var(--dash-card);
    border: 1px solid var(--dash-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    transition: all var(--transition-fast);
}

.dash-stat-card:hover {
    border-color: var(--dash-border-glow);
    transform: translateY(-3px);
}

.dash-stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    flex-shrink: 0;
}

.dash-stat-icon.blue { background: rgba(2, 132, 199, 0.18); border: 1px solid rgba(56, 189, 248, 0.35); }
.dash-stat-icon.green { background: rgba(16, 185, 129, 0.18); border: 1px solid rgba(52, 211, 153, 0.35); }
.dash-stat-icon.gold { background: rgba(245, 158, 11, 0.18); border: 1px solid rgba(251, 191, 36, 0.35); }
.dash-stat-icon.purple { background: rgba(139, 92, 246, 0.18); border: 1px solid rgba(167, 139, 250, 0.35); }

.dash-stat-info h3 {
    font-size: 1.8rem;
    font-weight: 900;
    line-height: 1.1;
    margin-bottom: 4px;
}

.dash-stat-info p {
    font-size: 0.84rem;
    color: var(--dash-text-muted);
    font-weight: 700;
}

/* Card Containers */
.dash-card-box {
    background: var(--dash-card);
    border: 1px solid var(--dash-border);
    border-radius: var(--radius-lg);
    padding: 26px;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.3);
    margin-bottom: 30px;
}

.card-box-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--dash-border);
    padding-bottom: 14px;
}

.card-box-header h3 {
    font-size: 1.25rem;
    font-weight: 800;
}

/* Data Tables */
.dash-table-wrapper {
    overflow-x: auto;
}

.dash-table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

.dash-table th, .dash-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--dash-border);
    font-size: 0.9rem;
}

.dash-table th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--primary-light);
    font-weight: 800;
}

.dash-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.table-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 800;
}

.table-tag.active { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.table-tag.inactive { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.table-tag.perm { background: rgba(2, 132, 199, 0.15); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.3); margin: 2px; }

/* Permission Matrix Checkboxes */
.permissions-matrix-box {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    background: rgba(0, 0, 0, 0.2);
    padding: 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--dash-border);
    margin: 16px 0;
}

.perm-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--dash-text);
}

.perm-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content-box {
    background: var(--dash-sidebar);
    border: 1px solid var(--dash-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    animation: modalScale 0.25s ease;
}

@keyframes modalScale {
    from { opacity: 0; transform: scale(0.94); }
    to { opacity: 1; transform: scale(1); }
}

.modal-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
    text-align: right;
}

.modal-form-group label {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--dash-text-muted);
}

.form-input, .form-textarea, .form-select {
    width: 100%;
    background: var(--dash-card);
    border: 1px solid var(--dash-border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--dash-text);
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition-fast);
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

/* Student Portal View Elements */
.student-progress-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(2, 132, 199, 0.15));
    border: 1px solid rgba(52, 211, 153, 0.35);
    border-radius: var(--radius-lg);
    padding: 26px;
    margin-bottom: 25px;
}

/* Toast */
.dash-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--dash-sidebar);
    color: #ffffff;
    border: 1px solid var(--primary-light);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(2, 132, 199, 0.3);
    padding: 14px 24px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.92rem;
    z-index: 20000;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(12px);
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.35s ease;
    opacity: 0;
    pointer-events: none;
}

.dash-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Responsive */
@media (max-width: 900px) {
    .dashboard-layout {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
    }
    .dash-topbar {
        padding: 0 16px;
    }
    .dash-content {
        padding: 16px;
    }
}
