/* ============================================
   UI Enhancements - Golden Host
   Professional Design System v2.0
   Toast + Loading + Animations + Effects
   ============================================ */

/* ---- Design System Variables ---- */
:root {
    /* Brand Colors */
    --gh-primary: #667eea;
    --gh-primary-dark: #4B3A8C;
    --gh-accent: #8B5CF6; /* canonical violet (was: #E91E8C) */
    --gh-gold: #BF9B59; /* canonical (was: #FFD700) */

    /* Semantic Colors */
    --gh-success: #06B6D4;   /* canonical cyan accent — no emerald green */
    --gh-warning: #F59E0B;
    --gh-danger: #EF4444;
    --gh-info: #3B82F6;

    /* Neutral Colors */
    --gh-bg: #f5f7fa;
    --gh-bg-dark: #1A1A2E;
    --gh-text: #333333;
    --gh-text-muted: #666666;
    --gh-border: #e0e0e0;

    /* Spacing */
    --gh-radius: 16px;
    --gh-radius-sm: 10px;
    --gh-radius-lg: 24px;

    /* Shadows */
    --gh-shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
    --gh-shadow-md: 0 8px 32px rgba(0,0,0,0.12);
    --gh-shadow-lg: 0 20px 60px rgba(0,0,0,0.2);
    --gh-shadow-glow: 0 0 40px rgba(233, 30, 140, 0.15);

    /* Transitions */
    --gh-transition: cubic-bezier(0.4, 0, 0.2, 1);
    --gh-transition-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- Global Smooth Scrolling ---- */
html { scroll-behavior: smooth; }

/* ---- Selection Color ---- */
::selection {
    background: rgba(233, 30, 140, 0.25);
    color: inherit;
}

/* ---- Scrollbar Styling ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(79, 70, 229, 0.35); /* canonical indigo (was: rgba(233, 30, 140, 0.3)) */
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: #4F46E5; } /* canonical indigo (was: rgba(233, 30, 140, 0.5)) */

/* ---- Toast Notification System ---- */
.toast-container {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: 14px;
    color: white;
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2), 0 0 0 1px rgba(255,255,255,0.1) inset;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    animation: toastIn 0.5s var(--gh-transition-bounce);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 420px;
    cursor: pointer;
    pointer-events: auto;
    border: 1px solid rgba(255,255,255,0.15);
    transition: transform 0.2s var(--gh-transition), opacity 0.2s;
}

.toast:hover {
    transform: translateX(4px);
}

.toast-success {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.95), rgba(8, 145, 178, 0.95));
    border-color: rgba(6, 182, 212, 0.3);
}
.toast-error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.95), rgba(185, 28, 28, 0.95));
    border-color: rgba(239, 68, 68, 0.3);
}
.toast-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.95), rgba(217, 119, 6, 0.95));
    color: #000;
    border-color: rgba(245, 158, 11, 0.3);
}
.toast-info {
    background: linear-gradient(135deg, rgba(75, 58, 140, 0.95), rgba(102, 126, 234, 0.95));
    border-color: rgba(102, 126, 234, 0.3);
}

.toast-exit {
    animation: toastOut 0.35s var(--gh-transition) forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-120%) scale(0.9); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to { opacity: 0; transform: translateX(-120%) scale(0.9); }
}

/* ---- Loading Screen ---- */
.loading-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #0F0E1B 0%, #1A1A2E 40%, #4B3A8C 100%);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    transition: opacity 0.6s var(--gh-transition);
}

.loading-screen::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(233, 30, 140, 0.15), transparent 70%);
    border-radius: 50%;
    animation: loadingGlow 3s ease-in-out infinite;
}

@keyframes loadingGlow {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.3); opacity: 0.8; }
}

.loading-screen.hide {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 56px;
    height: 56px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: #4F46E5; /* canonical indigo (was: #E91E8C) */
    border-right-color: #8B5CF6; /* canonical violet (was: #FFD700) */
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    position: relative;
    z-index: 1;
}

.loading-spinner::after {
    content: '';
    position: absolute;
    inset: 6px;
    border: 3px solid rgba(255,255,255,0.1);
    border-bottom-color: #667eea;
    border-radius: 50%;
    animation: spin 1.5s linear infinite reverse;
}

.loading-text {
    color: white;
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    font-size: 1.15rem;
    margin-top: 2rem;
    font-weight: 600;
    position: relative;
    z-index: 1;
    letter-spacing: 0.5px;
}

.loading-subtext {
    color: rgba(255,255,255,0.5);
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    position: relative;
    z-index: 1;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Animations Library ---- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.animate-fadeInUp {
    animation: fadeInUp 0.5s var(--gh-transition) backwards;
}

.animate-fadeIn {
    animation: fadeIn 0.4s var(--gh-transition);
}

.animate-fadeInScale {
    animation: fadeInScale 0.4s var(--gh-transition-bounce) backwards;
}

.animate-slideInRight {
    animation: slideInRight 0.4s var(--gh-transition) backwards;
}

.animate-float {
    animation: float 4s ease-in-out infinite;
}

/* Staggered animations for grid items */
.animate-stagger > *:nth-child(1) { animation: fadeInUp 0.5s var(--gh-transition) backwards; animation-delay: 0.05s; }
.animate-stagger > *:nth-child(2) { animation: fadeInUp 0.5s var(--gh-transition) backwards; animation-delay: 0.1s; }
.animate-stagger > *:nth-child(3) { animation: fadeInUp 0.5s var(--gh-transition) backwards; animation-delay: 0.15s; }
.animate-stagger > *:nth-child(4) { animation: fadeInUp 0.5s var(--gh-transition) backwards; animation-delay: 0.2s; }
.animate-stagger > *:nth-child(5) { animation: fadeInUp 0.5s var(--gh-transition) backwards; animation-delay: 0.25s; }
.animate-stagger > *:nth-child(6) { animation: fadeInUp 0.5s var(--gh-transition) backwards; animation-delay: 0.3s; }
.animate-stagger > *:nth-child(7) { animation: fadeInUp 0.5s var(--gh-transition) backwards; animation-delay: 0.35s; }
.animate-stagger > *:nth-child(8) { animation: fadeInUp 0.5s var(--gh-transition) backwards; animation-delay: 0.4s; }

/* ---- Skeleton Loading ---- */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.06) 25%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0.06) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--gh-radius-sm);
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    border-radius: 6px;
}

.skeleton-text:last-child {
    width: 70%;
}

.skeleton-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

/* ---- Button Ripple Effect ---- */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(255,255,255,0.3) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.5s;
}

.btn-ripple:active::after {
    opacity: 1;
    transition: opacity 0s;
}

/* ---- Dark Mode ---- */
[data-theme="dark"] body,
body.dark-mode {
    background: #0F0E1B !important;
    color: #e0e0e0 !important;
}

[data-theme="dark"] .card,
body.dark-mode .card,
[data-theme="dark"] .stat-card,
body.dark-mode .stat-card {
    background: rgba(255,255,255,0.04) !important;
    border-color: rgba(255,255,255,0.08) !important;
    color: #e0e0e0 !important;
}

[data-theme="dark"] .sidebar,
body.dark-mode .sidebar {
    background: #0F0E1B !important;
    color: #e0e0e0 !important;
}

[data-theme="dark"] .nav-link,
body.dark-mode .nav-link,
[data-theme="dark"] .nav-menu a,
body.dark-mode .nav-menu a {
    color: #ccc !important;
}

[data-theme="dark"] .nav-link.active,
body.dark-mode .nav-link.active {
    background: rgba(233, 30, 140, 0.15) !important;
    color: #FF79C6 !important;
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select,
body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select {
    background: rgba(255,255,255,0.06) !important;
    border-color: rgba(255,255,255,0.12) !important;
    color: #e0e0e0 !important;
}

[data-theme="dark"] .header,
body.dark-mode .header {
    background: rgba(15, 14, 27, 0.98) !important;
}

[data-theme="dark"] .data-table th,
body.dark-mode .data-table th {
    background: rgba(75, 58, 140, 0.3) !important;
    color: #e0e0e0 !important;
}

[data-theme="dark"] .data-table td,
body.dark-mode .data-table td {
    border-color: rgba(255,255,255,0.08) !important;
    color: #ccc !important;
}

/* ---- Glass Effect ---- */
.glass-effect {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

[data-theme="dark"] .glass-effect,
body.dark-mode .glass-effect {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.06);
}

/* ---- Gradient Text Utility ---- */
.gradient-text {
    background: linear-gradient(135deg, #4F46E5, #8B5CF6); /* canonical (was: #E91E8C, #FFD700) */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-text-purple {
    background: linear-gradient(135deg, #4F46E5, #8B5CF6); /* canonical (was: #667eea, #E91E8C) */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ---- Pulse Animation ---- */
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.02); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(233, 30, 140, 0.4); }
    50% { box-shadow: 0 0 0 12px rgba(233, 30, 140, 0); }
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-pulse-glow {
    animation: pulseGlow 2s ease-in-out infinite;
}

/* ---- Bounce Animation ---- */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
    60% { transform: translateY(-4px); }
}

.animate-bounce {
    animation: bounce 1.5s infinite;
}

/* ---- Hover Lift ---- */
.hover-lift {
    transition: transform 0.3s var(--gh-transition), box-shadow 0.3s var(--gh-transition);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--gh-shadow-md);
}

/* ---- Hover Glow ---- */
.hover-glow {
    transition: box-shadow 0.3s var(--gh-transition);
}

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

/* ---- Theme Toggle Button (shared) ---- */
.gh-theme-toggle {
    position: fixed;
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    left: auto;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gh-primary), var(--gh-accent));
    color: white;
    border: 2px solid rgba(255,255,255,0.2);
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25), 0 0 0 0 rgba(233, 30, 140, 0.3);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s var(--gh-transition-bounce), box-shadow 0.3s var(--gh-transition);
}

.gh-theme-toggle:hover {
    transform: scale(1.12) rotate(15deg);
    box-shadow: 0 12px 32px rgba(0,0,0,0.35), 0 0 20px rgba(233, 30, 140, 0.2);
}

.gh-theme-toggle:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    .gh-theme-toggle {
        bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
        right: 0.75rem;
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }
}

/* ---- Mobile Responsive ---- */
@media (max-width: 480px) {
    .toast-container {
        left: 0.75rem;
        right: 0.75rem;
    }
    .toast {
        max-width: 100%;
        font-size: 0.85rem;
        padding: 0.8rem 1rem;
    }
}

/* ============================================
   RESPONSIVE & MOBILE-FIRST ENHANCEMENTS v3.0
   ============================================ */

/* ---- Global Mobile Optimizations ---- */
*, *::before, *::after {
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior-y: contain;
}

/* Touch-friendly interactive elements */
button, a, input, select, textarea, [role="button"], [onclick] {
    touch-action: manipulation;
}

/* Minimum touch target size (44px Apple HIG / 48px Material) */
button, .btn, [role="button"], a.nav-link, .tab-btn, .action-btn {
    min-height: 44px;
    min-width: 44px;
}

/* ---- Fluid Typography ---- */
h1, .page-title { font-size: clamp(1.4rem, 4vw, 2.2rem); }
h2, .section-title { font-size: clamp(1.2rem, 3vw, 1.8rem); }
h3, .card-title { font-size: clamp(1rem, 2.5vw, 1.4rem); }
body, p, .body-text { font-size: clamp(0.875rem, 2vw, 1rem); }
small, .text-sm { font-size: clamp(0.75rem, 1.8vw, 0.875rem); }

/* ---- Safe Area Support (notch devices) ---- */
.main-content, .sidebar, .header, .footer {
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

.footer, .bottom-bar, .toast-container-bottom {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---- Improved Modal for All Screens ---- */
.modal, .overlay-panel, .popup {
    max-width: min(95vw, 800px);
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.modal-close, .close-btn, [aria-label="Close"], [aria-label="إغلاق"] {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* ---- Responsive Containers ---- */
.container, .page-container, .main-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding-inline: clamp(0.75rem, 3vw, 2rem);
}

/* ---- Responsive Grid Utilities ---- */
.responsive-grid {
    display: grid;
    gap: clamp(0.75rem, 2vw, 1.5rem);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.responsive-grid-sm {
    display: grid;
    gap: clamp(0.5rem, 1.5vw, 1rem);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
}

/* ---- Responsive Tables ---- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.table-responsive table {
    min-width: 600px;
}

/* ---- Pull to Refresh Prevention ---- */
.no-overscroll {
    overscroll-behavior: none;
}

/* ---- Responsive Images ---- */
img, video, svg {
    max-width: 100%;
    height: auto;
}

/* ============================================
   BREAKPOINT: Large Desktop (1200px+)
   ============================================ */
@media (min-width: 1200px) {
    .stats-grid, .kpi-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============================================
   BREAKPOINT: Tablet Landscape (1024px)
   ============================================ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(100%);
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px;
        z-index: 9999;
        transition: transform 0.3s var(--gh-transition);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        z-index: 9998;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    .main-content {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }

    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border: none;
        background: rgba(233, 30, 140, 0.1);
        border-radius: var(--gh-radius-sm);
        cursor: pointer;
        font-size: 1.3rem;
    }
}

/* ============================================
   BREAKPOINT: Tablet Portrait (768px)
   ============================================ */
@media (max-width: 768px) {
    /* Spacing reduction */
    .header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .header-title {
        font-size: clamp(1rem, 3.5vw, 1.4rem);
    }

    /* Stats grid: 2 columns */
    .stats-grid, .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    /* Card improvements */
    .card, .stat-card, .kpi-card {
        padding: clamp(0.75rem, 2.5vw, 1.25rem);
        border-radius: var(--gh-radius-sm);
    }

    /* Tabs scrollable */
    .tabs, .tab-nav, .nav-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap;
        gap: 0.25rem;
    }

    .tabs::-webkit-scrollbar,
    .tab-nav::-webkit-scrollbar,
    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-btn, .nav-tab {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    /* Form improvements */
    input, select, textarea {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
        padding: 0.75rem;
        border-radius: var(--gh-radius-sm);
    }

    /* Button spacing */
    .btn-group, .action-buttons {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .btn, button:not(.gh-theme-toggle) {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    /* Toast adjustments */
    .toast-container {
        left: 0.75rem;
        right: 0.75rem;
        top: calc(0.75rem + env(safe-area-inset-top, 0px));
    }

    .toast {
        max-width: 100%;
        font-size: 0.85rem;
        padding: 0.8rem 1rem;
    }

    /* Theme toggle */
    .gh-theme-toggle {
        bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
        right: 0.75rem;
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    /* Charts side by side → stacked */
    .charts-row, .chart-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================
   BREAKPOINT: Small Tablet / Large Phone (600px)
   ============================================ */
@media (max-width: 600px) {
    /* Stats: still 2 columns but tighter */
    .stats-grid, .kpi-grid {
        gap: 0.5rem;
    }

    .stat-card .stat-value, .kpi-value {
        font-size: clamp(1.2rem, 5vw, 1.8rem);
    }

    .stat-card .stat-label, .kpi-label {
        font-size: 0.75rem;
    }

    /* Employee cards: single column */
    .employee-grid {
        grid-template-columns: 1fr;
    }

    /* Modal full width */
    .modal, .overlay-panel, .popup {
        width: 100vw;
        max-width: 100vw;
        min-height: 50vh;
        border-radius: var(--gh-radius) var(--gh-radius) 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        transform: translateY(0);
    }

    /* Date filters stack */
    .date-filter, .filter-row, .filter-group {
        flex-direction: column;
        gap: 0.5rem;
    }

    .date-filter input, .filter-row input, .filter-row select {
        width: 100%;
    }
}

/* ============================================
   BREAKPOINT: Mobile (480px)
   ============================================ */
@media (max-width: 480px) {
    /* Full-width stats */
    .stats-grid, .kpi-grid {
        grid-template-columns: 1fr;
    }

    /* Compact header */
    .header {
        padding: 0.5rem 0.75rem;
    }

    /* Reduce card padding */
    .card, .stat-card {
        padding: 0.75rem;
    }

    /* Table compact */
    .data-table th, .data-table td {
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    /* Action buttons stack */
    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
        justify-content: center;
    }

    /* Loading screen */
    .loading-spinner {
        width: 44px;
        height: 44px;
    }

    .loading-text {
        font-size: 1rem;
    }

    /* Hide non-essential elements */
    .hide-mobile {
        display: none !important;
    }
}

/* ============================================
   BREAKPOINT: Very Small Mobile (360px)
   ============================================ */
@media (max-width: 360px) {
    body {
        font-size: 14px;
    }

    .header-title {
        font-size: 0.95rem;
    }

    .btn, button {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .tab-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.75rem;
    }
}

/* ============================================
   LANDSCAPE MODE
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .loading-screen {
        flex-direction: row;
        gap: 2rem;
    }

    .loading-spinner {
        width: 40px;
        height: 40px;
    }

    .modal, .overlay-panel {
        max-height: 95vh;
    }

    .header {
        padding: 0.25rem 1rem;
    }
}

/* ============================================
   HIGH DPI / RETINA
   ============================================ */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
}

/* ============================================
   HOVER VS TOUCH DETECTION
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Touch devices: remove hover effects that cause sticky hover */
    .hover-lift:hover {
        transform: none;
    }

    .hover-glow:hover {
        box-shadow: none;
    }

    /* Increase tap targets */
    .nav-link, .tab-btn, .action-btn {
        padding: 0.75rem 1rem;
    }

    /* Disable hover animations on cards */
    .card:hover, .stat-card:hover {
        transform: none;
    }
}

@media (hover: hover) and (pointer: fine) {
    /* Mouse devices: keep hover effects */
    .card, .stat-card {
        transition: transform 0.2s var(--gh-transition), box-shadow 0.2s var(--gh-transition);
    }

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

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .sidebar, .gh-theme-toggle, .toast-container,
    .loading-screen, .mobile-menu-toggle, .no-print {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
    }

    body {
        background: white !important;
        color: black !important;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================
   ANTD-INSPIRED COMPONENTS
   Message · Tag · Statistic · Segmented · Badge · Avatar · Popconfirm
   ============================================ */

/* ---- Message (top-centered notification) ---- */
.gh-message-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10010;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
    width: max-content;
    max-width: 90vw;
}
.gh-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #fff;
    color: #333;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.08), 0 3px 6px rgba(0,0,0,0.06);
    font-family: 'IBM Plex Sans Arabic', 'Cairo', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    pointer-events: auto;
    animation: ghMsgIn 0.25s ease;
}
.gh-message-icon { font-size: 1rem; line-height: 1; display: inline-flex }
.gh-message-success .gh-message-icon { color: var(--gh-success, #06B6D4) }
.gh-message-error   .gh-message-icon { color: var(--gh-danger,  #EF4444) }
.gh-message-warning .gh-message-icon { color: var(--gh-warning, #F59E0B) }
.gh-message-info    .gh-message-icon { color: var(--gh-info,    #3B82F6) }
.gh-message-loading .gh-message-icon {
    color: var(--gh-primary, #667eea);
    animation: spin 0.9s linear infinite;
}
.gh-message-exit { animation: ghMsgOut 0.2s ease forwards }
@keyframes ghMsgIn  { from{opacity:0;transform:translateY(-8px)} to{opacity:1;transform:translateY(0)} }
@keyframes ghMsgOut { from{opacity:1;transform:translateY(0)}    to{opacity:0;transform:translateY(-8px)} }

/* ---- Tag ---- */
.gh-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    font-size: 0.75rem;
    line-height: 1.5;
    font-weight: 500;
    border-radius: 4px;
    border: 1px solid transparent;
    background: #fafafa;
    color: #595959;
    white-space: nowrap;
}
.gh-tag-default { background:#fafafa; color:#595959; border-color:#d9d9d9 }
.gh-tag-success { background:#f6ffed; color:#389e0d; border-color:#b7eb8f }
.gh-tag-warning { background:#fffbe6; color:#ad6800; border-color:#ffe58f }
.gh-tag-error   { background:#fff1f0; color:#cf1322; border-color:#ffa39e }
.gh-tag-info    { background:#e6f4ff; color:#0958d9; border-color:#91caff }
.gh-tag-processing { background:#e6f4ff; color:#0958d9; border-color:#91caff }
.gh-tag-processing::before {
    content:''; width:6px; height:6px; border-radius:50%;
    background:#0958d9; animation:ghPulse 1.5s ease infinite;
}
.gh-tag-close {
    cursor:pointer; padding:0 2px; margin-inline-start:2px;
    opacity:0.55; transition:opacity .15s; border:none; background:transparent;
    color:inherit; font-size:.85rem; line-height:1;
}
.gh-tag-close:hover { opacity:1 }
@keyframes ghPulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.5;transform:scale(1.4)} }

/* ---- Statistic ---- */
.gh-statistic { display:inline-flex; flex-direction:column; gap:4px }
.gh-statistic-title {
    font-size: 0.75rem;
    color: #8c8c8c;
    font-weight: 500;
    letter-spacing: .3px;
}
.gh-statistic-content {
    display:flex; align-items:baseline; gap:4px;
    font-variant-numeric: tabular-nums;
    color: #262626;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
}
.gh-statistic-prefix, .gh-statistic-suffix {
    font-size: 0.875rem;
    color: #8c8c8c;
    font-weight: 500;
}
.gh-statistic-trend-up   { color: var(--gh-success, #06B6D4) }
.gh-statistic-trend-down { color: var(--gh-danger,  #EF4444) }

/* ---- Segmented ---- */
.gh-segmented {
    display: inline-flex;
    padding: 2px;
    background: #f5f5f5;
    border-radius: 8px;
    gap: 2px;
}
.gh-segmented-item {
    padding: 6px 14px;
    font-size: 0.875rem;
    font-family: inherit;
    font-weight: 500;
    color: #595959;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: .2s var(--gh-transition, ease);
    white-space: nowrap;
}
.gh-segmented-item:hover { color: #262626 }
.gh-segmented-item.active {
    background: #fff;
    color: #262626;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.gh-segmented-item:disabled { opacity:.4; cursor:not-allowed }

/* ---- Badge (dot / count overlay) ---- */
.gh-badge {
    position: relative;
    display: inline-flex;
    line-height: 1;
}
.gh-badge-dot, .gh-badge-count {
    position: absolute;
    top: -2px;
    inset-inline-end: -4px;
    transform: translate(30%, -30%);
    background: var(--gh-danger, #ff4d4f);
    color: #fff;
    border: 2px solid #fff;
    border-radius: 10px;
    z-index: 1;
    pointer-events: none;
}
.gh-badge-dot {
    width: 8px; height: 8px;
    border-width: 1px;
}
.gh-badge-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 14px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.gh-badge-count[data-overflow="true"]::after { content:"+" }
.gh-badge-pulse::before {
    content:''; position:absolute; inset-inline-end:-4px; top:-2px;
    width:10px; height:10px; border-radius:50%;
    background: var(--gh-danger, #ff4d4f);
    opacity:.45;
    transform: translate(30%, -30%);
    animation: ghBadgePulse 1.6s ease infinite;
}
@keyframes ghBadgePulse {
    0%   { transform:translate(30%,-30%) scale(.8); opacity:.5 }
    70%  { transform:translate(30%,-30%) scale(2.2); opacity:0 }
    100% { opacity:0 }
}

/* ---- Avatar ---- */
.gh-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e6e9f0;
    color: #595959;
    font-weight: 600;
    font-size: 0.875rem;
    overflow: hidden;
    flex-shrink: 0;
    line-height: 1;
    user-select: none;
}
.gh-avatar img { width:100%; height:100%; object-fit:cover }
.gh-avatar-xs { width:24px; height:24px; font-size:0.7rem }
.gh-avatar-sm { width:28px; height:28px; font-size:0.75rem }
.gh-avatar-lg { width:44px; height:44px; font-size:1rem }
.gh-avatar-xl { width:56px; height:56px; font-size:1.15rem }
.gh-avatar-group { display:inline-flex; direction:ltr }
.gh-avatar-group .gh-avatar {
    border: 2px solid #fff;
    margin-inline-start: -8px;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.04);
}
.gh-avatar-group .gh-avatar:first-child { margin-inline-start:0 }

/* ---- Popconfirm ---- */
.gh-popconfirm {
    position: absolute;
    z-index: 1050;
    min-width: 240px;
    max-width: 320px;
    background: #fff;
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.08), 0 3px 6px rgba(0,0,0,0.06);
    font-family: 'IBM Plex Sans Arabic', 'Cairo', sans-serif;
    animation: ghPopIn 0.18s ease;
}
.gh-popconfirm::before {
    content:''; position:absolute; top:-6px; inset-inline-start:16px;
    width:12px; height:12px; background:#fff;
    transform: rotate(45deg);
    box-shadow: -2px -2px 5px rgba(0,0,0,0.04);
}
.gh-popconfirm-title {
    display:flex; align-items:flex-start; gap:8px;
    font-size: 0.875rem; color:#262626; font-weight:500;
    margin-bottom: 10px; line-height:1.5;
}
.gh-popconfirm-icon { color: var(--gh-warning, #faad14); font-size:1rem; flex-shrink:0; margin-top:2px }
.gh-popconfirm-actions {
    display:flex; gap:8px; justify-content:flex-end;
}
.gh-popconfirm-btn {
    padding: 4px 12px;
    font-size: 0.8rem;
    font-family: inherit;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid #d9d9d9;
    background: #fff;
    color: #595959;
    font-weight: 500;
    transition: .15s;
}
.gh-popconfirm-btn:hover { color:#262626; border-color:#bfbfbf }
.gh-popconfirm-btn-primary {
    background: var(--gh-primary, #1677ff);
    border-color: var(--gh-primary, #1677ff);
    color: #fff;
}
.gh-popconfirm-btn-primary:hover {
    background: var(--gh-primary-dark, #4B3A8C);
    border-color: var(--gh-primary-dark, #4B3A8C);
    color: #fff;
}
.gh-popconfirm-btn-danger {
    background: var(--gh-danger, #EF4444);
    border-color: var(--gh-danger, #EF4444);
    color: #fff;
}
.gh-popconfirm-btn-danger:hover { filter: brightness(.92); color:#fff }
@keyframes ghPopIn {
    from { opacity:0; transform:scale(.92) translateY(-4px) }
    to   { opacity:1; transform:scale(1)    translateY(0)  }
}
