/**
 * Modern Dashboard Theme
 * Clean, minimal design with top navigation + Dark Mode
 */

/* ===== FONTS ===== */
@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Cairo:wght@200;300;400;500;600;700;800;900&display=swap");

/* ===== CSS VARIABLES (LIGHT MODE) ===== */
:root {
    /* High Contrast Slate & Indigo Palette */
    --bs-primary: #1e293b;
    --bs-primary-rgb: 30, 41, 59;
    --bs-btn-active-bg: #0f172a;
    --bs-btn-active-border-color: #0f172a;

    --primary: #2563eb; /* Modern Indigo for actions */
    --primary-dark: #1d4ed8;
    --primary-light: #60a5fa;
    --secondary: #0f172a; /* Deep Slate for structure */
    --success: #059669; /* Sharp Emerald */
    --danger: #dc2626; /* Sharp Red */
    --warning: #d97706; /* Solid Amber */
    --info: #0891b2;

    /* Backgrounds - Pure and Clean */
    --bg-main: #f8fafc; 
    --bg-surface: #ffffff;
    --bg-hover: #f1f5f9;
    
    /* Text - Maximum Sharpness (Pure Black for readability) */
    --text-primary: #020617; 
    --text-secondary: #1e293b;
    --text-muted: #475569;
    
    /* Borders - Defined and Sharp */
    --border-color: #cbd5e1; 
    --border-light: #e2e8f0;

    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    --nav-active-bg: rgba(37, 99, 235, 0.1);

    --white: #ffffff;

    /* Shadows - Distinct and clean */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.1);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    --navbar-height: 70px;
    --container-padding: 2rem;

    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
    --bg-main: #020617;
    --bg-surface: #0f172a;
    --bg-hover: #1e293b;
    --nav-active-bg: rgba(37, 99, 235, 0.2);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #1e293b;
    --border-light: #0f172a;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.8);
}

/* ===== GLOBAL STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family:
        "Cairo",
        "Space Grotesk",
        sans-serif;
    font-weight: 500; /* Medium weight for better readability on light screens */
    font-size: 0.9375rem;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition:
        background-color 0.3s ease,
        color 0.3s ease;
}

/* Arabic text - use Cairo font */
[lang="ar"],
[dir="rtl"] {
    font-family:
        "Cairo",
        "Space Grotesk",
        -apple-system,
        BlinkMacSystemFont,
        sans-serif;
}

/* English text - use Space Grotesk font */
[lang="en"],
[dir="ltr"] {
    font-family:
        "Space Grotesk",
        "Cairo",
        -apple-system,
        BlinkMacSystemFont,
        sans-serif;
}

/* ===== TOP NAVBAR ===== */
.navbar {
    background: var(--bg-surface);
    box-shadow: var(--shadow);
    height: var(--navbar-height);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}

.navbar-brand {
    display: flex;
    align-items: center;
}

.navbar-brand img {
    height: 40px;
    transition: var(--transition);
}

/* Logo toggle for dark mode */
.logo-light {
    display: block;
}

.logo-dark {
    display: none;
}

[data-theme="dark"] .logo-light {
    display: none;
}

[data-theme="dark"] .logo-dark {
    display: block;
}

.navbar-nav .nav-link {
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.6rem 0.875rem;
    border-radius: var(--radius);
    transition: var(--transition);
    margin: 0 0.25rem;
}

.navbar-nav .nav-link:hover {
    color: var(--primary);
    background: var(--bg-hover);
}

.navbar-nav .nav-link.active {
    color: var(--primary);
    background: var(--nav-active-bg);
    font-weight: 600;
}

/* Navbar Dark Mode Toggle */
.nav-link-dark-toggle {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0 !important;
    border-radius: 50%;
    color: var(--text-secondary);
    transition: var(--transition);
}

.nav-link-dark-toggle:hover {
    color: var(--primary);
    background: var(--nav-active-bg) !important;
}

.nav-link-dark-toggle .nav-dark-icon,
.nav-link-dark-toggle .nav-light-icon {
    font-size: 1.125rem;
}

[data-theme="dark"] .nav-link-dark-toggle .nav-dark-icon {
    display: none !important;
}

[data-theme="dark"] .nav-link-dark-toggle .nav-light-icon {
    display: inline-block !important;
}

.navbar .dropdown-menu {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg);
    padding: 0.5rem;
    margin-top: 0.5rem;
}

.navbar .dropdown-item {
    padding: 0.6rem 0.875rem;
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 600;
    transition: var(--transition);
}

.navbar .dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.navbar .dropdown-item:hover i {
    color: var(--primary);
}

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

.navbar .dropdown-item.active i {
    color: var(--white);
}

.navbar .dropdown-item i {
    margin-inline-end: 0.75rem;
    width: 1.25rem;
    color: var(--text-primary);
}

/* User Avatar */
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.user-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

/* Notification Badge */
.notification-badge {
    position: relative;
}

.notification-badge .badge {
    position: absolute;
    top: -5px;
    inset-inline-end: -5px;
    background: var(--danger);
    color: var(--white);
    border-radius: 10px;
    padding: 0.25rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 700;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    padding: var(--container-padding);
    min-height: calc(100vh - var(--navbar-height) - 80px);
}

.main-content .h1,
.main-content h1,
.main-content .h2,
.main-content h2,
.main-content .h3,
.main-content h3,
.main-content .h4,
.main-content h4,
.main-content .h5,
.main-content h5,
.main-content .h6,
.main-content h6 {
    color: var(--text-primary);
}
.main-content .h1,
.main-content h1 {
    font-size: 1.5rem;
    font-weight: 700;
}
.main-content .h2,
.main-content h2 {
    font-size: 1.25rem;
    font-weight: 700;
}
.main-content .h3,
.main-content h3 {
    font-size: 1.125rem;
    font-weight: 700;
}
.main-content .h4,
.main-content h4 {
    font-size: 1rem;
    font-weight: 700;
}
.main-content .h5,
.main-content h5 {
    font-size: 0.9375rem;
    font-weight: 700;
}
.main-content .h6,
.main-content h6 {
    font-size: 0.875rem;
    font-weight: 700;
}
.main-content .text-muted {
    font-weight: 500;
}

/* ===== BREADCRUMB ===== */
.breadcrumb-page.breadcrumb {
    font-size: 0.8125rem;
    font-weight: 600;
    background: transparent;
    padding: 0;
}

.breadcrumb-page .breadcrumb-item a {
    color: var(--text-secondary);
    transition: var(--transition);
}

.breadcrumb-page .breadcrumb-item a:hover {
    color: var(--primary);
}

.breadcrumb-page .breadcrumb-item.active {
    color: var(--text-primary);
}

.breadcrumb-page .breadcrumb-item + .breadcrumb-item::before {
    color: var(--text-muted);
    font-weight: 400;
}

[dir="rtl"] .breadcrumb-page .breadcrumb-item + .breadcrumb-item::before {
    float: right;
    padding-left: 0.5rem;
    padding-right: 0;
}

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

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

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    background: var(--bg-hover);
    border-top: 1px solid var(--border-color);
}

/* Stat Card */
.stat-card {
    padding: 1.75rem;
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.stat-icon.primary {
    background: rgba(249, 115, 22, 0.12);
    color: var(--primary);
}

.stat-icon.success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.stat-icon.warning {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

.stat-icon.danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.stat-value {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.375rem;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-change {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-top: 0.375rem;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--danger);
}

/* ===== BUTTONS ===== */
.btn {
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.8125rem;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover,
.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 6px -1px rgb(249 115 22 / 0.3);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background: var(--primary-dark);
    color: var(--white);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgb(249 115 22 / 0.4);
}

.btn-primary:active,
.btn-primary:focus,
.btn-primary.active {
    background: var(--primary-dark) !important;
    color: var(--white) !important;
    border-color: var(--primary-dark) !important;
    box-shadow: 0 0 0 0.25rem rgb(249 115 22 / 0.25) !important;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
    background: var(--primary);
    color: var(--white);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

/* ===== TOGGLE SWITCH (form-switch) ===== */
.form-switch .form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-switch .form-check-input:focus {
    box-shadow: 0 0 0 0.25rem rgb(249 115 22 / 0.25);
    border-color: var(--primary);
}

/* ===== BADGES ===== */
.badge {
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge i {
    font-size: 0.875rem;
}

.badge-primary {
    background: rgba(11, 79, 108, 0.08);
    color: var(--primary);
}

.badge-success {
    background: #d1fae5;
    color: var(--success);
}

.badge-warning {
    background: #fef3c7;
    color: var(--warning);
}

.badge-danger {
    background: #fee2e2;
    color: var(--danger);
}

/* ===== TABLES ===== */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    background: var(--bg-hover);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1.25rem;
    border-bottom: 2px solid var(--border-color);
}

.table tbody td {
    padding: 0.75rem 1.25rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.table tbody tr:hover {
    background: var(--bg-hover);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Modern table (card wrapper) */
.card-table-wrapper {
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.card-table-wrapper .table-modern {
    margin-bottom: 0;
}

.card-table-wrapper .table-modern thead th {
    background: var(--gray-100);
    padding: 1rem 1.25rem;
    font-size: 0.8125rem;
    letter-spacing: 0.02em;
    border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] .card-table-wrapper .table-modern thead th {
    background: var(--bg-hover);
}

.card-table-wrapper .table-modern tbody td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition);
}

.card-table-wrapper .table-modern tbody tr {
    transition: var(--transition);
}

.card-table-wrapper .table-modern tbody tr:hover {
    background: var(--bg-hover);
}

.card-table-wrapper .table-modern tbody tr:last-child td {
    border-bottom: none;
}

.card-table-wrapper .table-modern .btn-sm {
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius);
    transition: var(--transition);
}

.card-table-wrapper .table-modern .btn-sm:hover {
    transform: translateY(-1px);
}

/* Filter form: buttons match small input height */
.filter-btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.status-toggle-btn {
    cursor: pointer;
    transition: var(--transition);
}

.status-toggle-btn:hover {
    opacity: 0.9;
}

/* Toggle section buttons (Statistics / Filter): active when expanded */
.toggle-section-btn[aria-expanded="true"] {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.toggle-section-btn[aria-expanded="true"]:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: var(--white);
}

/* Stats cards (icon + number) */
.stats-card {
    transition: var(--transition);
}

.stats-card:hover {
    box-shadow: var(--shadow-md) !important;
}

.stats-card-icon {
    width: 2rem;
    height: 2rem;
    background: var(--nav-active-bg);
    color: var(--primary);
    font-size: 1rem;
}

.stats-card-value {
    font-size: 1.125rem;
    color: var(--text-primary);
}

/* ===== FORMS ===== */
.form-control {
    padding: 0.6rem 0.875rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 600;
    width: 100%;
    transition: var(--transition);
    color: var(--text-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(249 115 22 / 0.15);
}

/* Select - improved UI */
.form-select {
    padding: 0.6rem 2.25rem 0.6rem 0.875rem;
    background-color: var(--bg-surface);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    width: 100%;
    min-height: 2.5rem;
    transition: var(--transition);
    cursor: pointer;
    appearance: none;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(249 115 22 / 0.15);
}

.form-select:hover {
    border-color: var(--gray-400);
}

.form-select option {
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    background: var(--bg-surface);
    color: var(--text-primary);
}

.form-select.is-invalid {
    border-color: var(--danger);
}

.form-select.is-invalid:focus {
    box-shadow: 0 0 0 3px rgb(239 68 68 / 0.15);
}

[dir="rtl"] .form-select {
    background-position: left 0.75rem center;
    padding-left: 2.25rem;
    padding-right: 0.875rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-primary);
}

/* ===== UTILITIES ===== */
.text-primary {
    color: var(--primary) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.text-success {
    color: var(--success) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-warning {
    color: var(--warning) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.bg-primary {
    background: var(--primary) !important;
}

.bg-light {
    background: var(--bg-hover) !important;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    margin-top: 3rem;
}

/* Dark Mode Toggle Button */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 992px) {
    :root {
        --container-padding: 1.5rem;
    }

    .navbar {
        height: auto;
        min-height: var(--navbar-height);
        padding: 0.5rem 0;
    }

    .navbar-nav {
        padding: 1rem 0;
    }

    .navbar-nav .nav-link {
        margin: 0.25rem 0;
        padding: 0.75rem 1rem;
    }

    .navbar-collapse {
        background: var(--bg-surface);
        padding: 1rem;
        border-radius: var(--radius-lg);
        margin-top: 0.5rem;
        box-shadow: var(--shadow-lg);
    }
}

@media (max-width: 768px) {
    :root {
        --container-padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .navbar-brand {
        font-size: 1.25rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .card-body {
        padding: 1rem;
    }
}

@media (max-width: 576px) {
    .stat-icon {
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
    }

    .table {
        font-size: 0.8125rem;
    }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
/* ===== PREMIUM CARD STYLE (Header on Border) ===== */
.card-premium {
    position: relative;
    border: 1.2px solid var(--primary) !important;
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    margin-top: 2rem;
    transition: var(--transition);
    overflow: visible !important; /* CRITICAL: Allows the absolute header to show outside boundaries */
}

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

.card-header-premium {
    position: absolute;
    top: -18px;
    inset-inline-start: 1.5rem; /* يضمن الظهور جهة اليمين في العربي وجهة اليسار في الإنجليزي */
    padding: 0;
    z-index: 5;
}

.card-title-premium {
    font-size: 0.8125rem;
    font-weight: 800;
    color: var(--primary);
    margin: 0;
    letter-spacing: 0.02em;
    border: 1.5px solid var(--primary); /* المربع أو البرواز حول الكلمة */
    padding: 0.25rem 0.75rem;
    border-radius: 8px; /* زوايا منحنية للبرواز */
    background: var(--bg-surface);
}

.card-premium .card-body {
    padding: 1.5rem;
}
