/**
 * Realvibe Agency OS 2.0 - Design System
 * Supports Light & Dark Modes
 */

/* ==================== CSS Variables ==================== */
:root {
    /* ---------------- Light Mode (Default) ---------------- */

    /* Backgrounds */
    --bg-dark: #f8fafc;
    /* Main background */
    --bg-panel: #ffffff;
    /* Panels/Cards */
    --bg-glass: rgba(255, 255, 255, 0.7);
    --bg-glass-hover: rgba(243, 244, 246, 0.8);

    /* Borders */
    --border: #e2e8f0;
    --border-light: rgba(99, 102, 241, 0.1);

    /* Text */
    --text: #1e293b;
    /* Main text (Slate 800) */
    --text-secondary: #475569;
    /* Secondary text (Slate 600) */
    --text-muted: #94a3b8;
    /* Muted text (Slate 400) */

    /* Brand Colors (Same for both, or slightly adjusted) */
    --primary: #7000ff;
    --primary-hover: #5a00cc;
    --primary-light: rgba(112, 0, 255, 0.1);

    /* Status Colors */
    --success: #059669;
    --success-light: rgba(5, 150, 105, 0.08);
    --warning: #d97706;
    --warning-light: rgba(217, 119, 6, 0.08);
    --danger: #dc2626;
    --danger-light: rgba(220, 38, 38, 0.08);
    --info: #2563eb;
    --info-light: rgba(37, 99, 235, 0.08);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);

    /* Layout & Misc */
    --sidebar-width: 260px;
    --bottom-nav-height: 70px;
    --header-height: 60px;
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
}

/* ---------------- Dark Mode Overrides ---------------- */
html.dark {
    /* Backgrounds */
    --bg-dark: #0d0f14;
    --bg-panel: #151922;
    --bg-glass: rgba(21, 25, 34, 0.6);
    --bg-glass-hover: rgba(30, 35, 45, 0.7);

    /* Borders */
    --border: #2a2f3a;
    --border-light: rgba(255, 255, 255, 0.05);

    /* Text */
    --text: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #6b7280;

    /* Status Colors (Brighter for dark mode) */
    --success: #22c55e;
    --success-light: rgba(34, 197, 94, 0.15);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);
    --info: #3b82f6;
    --info-light: rgba(59, 130, 246, 0.15);

    /* Shadows (More subtle or different color/opacity) */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

/* ==================== Base Styles ==================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition-normal), color var(--transition-normal);
    overflow-x: hidden;
    /* Double safety */
    max-width: 100vw;
}

/* ==================== Glass Components ==================== */
.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
}

.glass-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.glass-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal), background-color var(--transition-normal);
}

html.dark .glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
}

/* Optimize glass effects on mobile to reduce lag */
@media (max-width: 768px) {

    .glass,
    html.dark .glass-card {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: var(--bg-panel) !important;
        /* Fallback to solid color */
    }
}

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

/* ==================== Layout ==================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 1.5rem;
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
}

@media (max-width: 1024px) {
    .main-content {
        margin-left: 0;
        padding-bottom: calc(var(--bottom-nav-height) + 1.5rem);
    }
}

/* ==================== Sidebar ==================== */

/* Hardware accelerated sidebar for smoother animation */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    /* Better mobile viewport support */
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 900;
    /* Increased z-index */
    transform: translateX(0);
    /* Default state for desktop */
    will-change: transform;
    /* Performance hint */
    backface-visibility: hidden;
    /* Reduce flickering */
}

/* On mobile, hidden by default */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        /* Reduce paint cost when hidden */
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
        transition: transform var(--transition-normal);
        pointer-events: auto;
        /* Ensure touches are captured */
        touch-action: pan-y;
        /* Allow vertical scrolling */
    }
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 850;
    /* Below sidebar (900) but above content */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
    /* Lighter blur for performance */
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active,
.sidebar-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.sidebar-logo {
    max-width: 120px;
    height: 32px;
    width: auto;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.sidebar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    -webkit-overflow-scrolling: touch;
    /* Critical for iOS momentum scrolling */
    overscroll-behavior: contain;
}

/* Webkit scrollbar for sidebar */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.nav-section {
    margin-bottom: 1.5rem;
}

/* Sidebar Header stays fixed at top */
.sidebar-header {
    flex-shrink: 0;
}

/* Sidebar Footer stays fixed at bottom */
.sidebar-footer {
    flex-shrink: 0;
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-item:hover {
    background: var(--bg-glass-hover);
    color: var(--text);
}

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

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

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-full);
}

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

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

/* ==================== Bottom Navigation (Mobile) ==================== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 0.5rem;
    padding-bottom: env(safe-area-inset-bottom, 0.5rem);
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.bottom-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 100%;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
    transition: color var(--transition-fast);
    position: relative;
}

.bottom-nav-item i {
    font-size: 1.25rem;
}

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

.bottom-nav-item .nav-dot {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
}

@media (max-width: 1024px) {
    .bottom-nav {
        display: block;
    }
}

/* ==================== Page Header ==================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text);
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.page-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    /* Cross-device touch/click improvements */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

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

.btn-success:hover {
    filter: brightness(1.1);
}

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

.btn-danger:hover {
    filter: brightness(1.1);
}

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

.btn-ghost:hover {
    background: var(--bg-glass-hover);
    color: var(--text);
}

.btn-icon {
    padding: 0.625rem;
    aspect-ratio: 1;
}

.btn-sm {
    padding: 0.5rem 0.875rem;
    font-size: 0.8rem;
}

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

/* ==================== Common Components ==================== */
/* Make inputs react to theme */
input,
select,
textarea,
.form-input,
.form-select,
.form-textarea {
    background-color: var(--bg-dark);
    /* or bg-panel if you prefer contrast */
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-normal);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* ==================== Login/Auth Forms ==================== */
.auth-input {
    width: 100%;
    background-color: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    color: var(--text);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.auth-input::placeholder {
    color: var(--text-muted);
}

.auth-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.auth-checkbox {
    border-radius: 4px;
    border: 1px solid var(--border);
    background-color: var(--bg-dark);
    color: var(--primary);
}

.auth-title {
    color: var(--text);
}

.auth-divider {
    border-color: var(--border);
}

/* Tables */
.data-table th {
    color: var(--text-muted);
}

.data-table td {
    color: var(--text);
    border-top: 1px solid var(--border-light);
}

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

/* Utilities */
.text-muted {
    color: var(--text-muted);
}

.border-b {
    border-bottom: 1px solid var(--border);
}

/* ==================== Responsive Tables (Card View) ==================== */
@media (max-width: 768px) {
    .data-table-responsive thead {
        display: none;
    }

    .data-table-responsive tr {
        display: flex;
        flex-direction: column;
        background: var(--bg-panel);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 1rem;
        padding: 1rem;
        box-shadow: var(--shadow-sm);
    }

    .data-table-responsive td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border: none;
        border-bottom: 1px solid var(--border-light);
    }

    .data-table-responsive td:last-child {
        border-bottom: none;
    }

    .data-table-responsive td::before {
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 700;
        color: var(--text-muted);
        text-transform: uppercase;
        margin-right: 1rem;
    }
}

/* ==================== Visibility Utilities ==================== */
.mobile-only {
    display: none !important;
}

.desktop-only {
    display: block !important;
}

@media (max-width: 1024px) {
    .mobile-only {
        display: block !important;
    }

    .desktop-only {
        display: none !important;
    }
}

/* ==================== Toasts ==================== */
.toast-container {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 1.5rem);
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

@media (min-width: 768px) {
    .toast-container {
        bottom: 1.5rem;
    }
}

.toast {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    max-width: 400px;
    pointer-events: auto;
    animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 4px solid var(--primary);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast.info {
    border-left-color: var(--info);
}

.toast-icon {
    font-size: 1.25rem;
}

.toast.success .toast-icon {
    color: var(--success);
}

.toast.error .toast-icon {
    color: var(--danger);
}

.toast.warning .toast-icon {
    color: var(--warning);
}

.toast.info .toast-icon {
    color: var(--info);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(1rem) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ==================== Skeletons ==================== */
.skeleton {
    background: var(--bg-glass-hover);
    border-radius: var(--radius-sm);
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

.skeleton-text {
    height: 1em;
    width: 100%;
    border-radius: 4px;
}

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

.skeleton-rect {
    width: 100%;
    height: 200px;
}

/* ==================== Premium UI Enhancements ==================== */
.bg-gradient-premium {
    background: linear-gradient(135deg, var(--bg-panel) 0%, rgba(255, 255, 255, 0.03) 100%);
}

.text-gradient {
    background: linear-gradient(to right, #c084fc, #6366f1);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.card-gradient-1 {
    background: linear-gradient(135deg, rgba(112, 0, 255, 0.1) 0%, rgba(59, 130, 246, 0.05) 100%);
    border: 1px solid rgba(112, 0, 255, 0.2);
}

.card-gradient-2 {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(6, 182, 212, 0.05) 100%);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.card-gradient-3 {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(239, 68, 68, 0.05) 100%);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Quick Action Hover Effect */
.action-card {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-card:hover {
    transform: translateY(-4px);
    background: var(--bg-glass-hover);
    border-color: var(--primary);
    box-shadow: 0 10px 30px -10px var(--primary-light);
}

/* ==================== Dropdown Menu ==================== */
.dropdown {
    position: relative;
}

.dropdown-menu {
    pointer-events: none;
}

.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.dropdown-trigger:focus+.dropdown-menu,
.dropdown-menu:hover {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ==================== Modal ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

.modal {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform 0.2s ease;
    /* Ensure clicks inside modal don't pass through to overlay */
    pointer-events: auto;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: var(--bg-panel);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

/* ==================== Stats & Cards ==================== */
.stat-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-6px);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card-icon {
    width: 56px;
    height: 56px;
    min-width: 56px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.stat-card:hover .stat-card-icon {
    transform: scale(1.1) rotate(5deg);
    background: var(--primary-light);
    color: white;
}

.stat-card-content {
    flex: 1;
}

.stat-card-label {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.stat-card-value {
    font-size: 1.35rem;
    font-weight: 900;
    color: var(--text);
    line-height: 1.2;
}

.stat-card-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    opacity: 0.8;
}

/* Action Cards (Dashboard/Hub Grids) */
.action-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.action-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.action-card i {
    font-size: 2rem;
    color: var(--primary);
    transition: transform 0.3s ease;
}

.action-card:hover i {
    transform: scale(1.1);
}

/* ==================== Utility Classes (Replacing Tailwind) ==================== */

/* --- Grid System --- */
.grid {
    display: grid;
}

.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.gap-3 {
    gap: 0.75rem;
}

.gap-4 {
    gap: 1rem;
}

.gap-6 {
    gap: 1.5rem;
}

/* Responsive Grid */
@media (min-width: 768px) {
    .md\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .md\:flex-row {
        flex-direction: row;
    }

    .md\:items-center {
        align-items: center;
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .lg\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .lg\:hidden {
        display: none;
    }

    .lg\:block {
        display: block;
    }

    .lg\:col-span-2 {
        grid-column: span 2 / span 2;
    }
}

/* --- Flexbox --- */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-row {
    flex-direction: row;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.flex-1 {
    flex: 1 1 0%;
}

.gap-2 {
    gap: 0.5rem;
}

/* --- Colors & Backgrounds --- */
.bg-glass {
    background: var(--bg-glass);
}

.bg-panel {
    background: var(--bg-panel);
}

.bg-primary\/10 {
    background: var(--primary-light);
}

.bg-success\/10 {
    background: var(--success-light);
}

.bg-warning\/10 {
    background: var(--warning-light);
}

.bg-danger\/10 {
    background: var(--danger-light);
}

.bg-info\/10 {
    background: var(--info-light);
}

.bg-blue-500\/10 {
    background: rgba(59, 130, 246, 0.1);
}

.bg-emerald-500\/10 {
    background: rgba(16, 185, 129, 0.1);
}

.bg-orange-500\/10 {
    background: rgba(249, 115, 22, 0.1);
}

.bg-purple-500\/10 {
    background: rgba(139, 92, 246, 0.1);
}

.bg-cyan-500\/10 {
    background: rgba(6, 182, 212, 0.1);
}

.bg-rose-500\/10 {
    background: rgba(244, 63, 94, 0.1);
}

.bg-red-500\/10 {
    background: rgba(239, 68, 68, 0.1);
}

/* Text Colors */
.text-primary {
    color: var(--primary);
}

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

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

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

.text-info {
    color: var(--info);
}

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

.text-text {
    color: var(--text);
}

.text-blue-500 {
    color: #3b82f6;
}

.text-emerald-500 {
    color: #10b981;
}

.text-orange-500 {
    color: #f97316;
}

.text-purple-500 {
    color: #8b5cf6;
}

.text-cyan-500 {
    color: #06b6d4;
}

.text-rose-500 {
    color: #f43f5e;
}

.text-red-500 {
    color: #ef4444;
}

/* --- Spacing & Sizing --- */
.w-full {
    width: 100%;
}

.h-full {
    height: 100%;
}

.p-4 {
    padding: 1rem;
}

.p-6 {
    padding: 1.5rem;
}

.py-8 {
    padding-top: 2rem;
    padding-bottom: 2rem;
}

.mb-6 {
    margin-bottom: 1.5rem;
}

.mb-8 {
    margin-bottom: 2rem;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.max-w-7xl {
    max-width: 80rem;
}

.rounded-2xl {
    border-radius: 1rem;
}

.rounded-full {
    border-radius: 9999px;
}

/* --- Stats Grid Fix --- */
.stat-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* ==================== Mobile Touch Target Utilities ==================== */
.min-w-\[44px\] {
    min-width: 44px;
}

.min-h-\[44px\] {
    min-height: 44px;
}

/* ==================== Animation Utilities ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.15s ease-out;
}

/* ==================== Light Mode Specific Fixes ==================== */
/* Ensure text is visible on light backgrounds */
:root .glass-panel h3,
:root .glass-panel .font-bold,
:root .stat-card-value {
    color: var(--text);
}

/* Fix hover states in light mode */
:root .hover\:bg-white\/10:hover {
    background: rgba(0, 0, 0, 0.05);
}

html.dark .hover\:bg-white\/10:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Buttons in light mode should have proper contrast */
:root .btn-icon {
    color: var(--text-secondary);
}

:root .btn-icon:hover {
    color: var(--text);
}

html.dark .btn-icon {
    color: var(--text-muted);
}

html.dark .btn-icon:hover {
    color: var(--text);
}

/* ==================== Responsive Table Wrapper ==================== */
.data-table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: var(--radius);
}

.data-table-responsive table {
    width: 100%;
    min-width: 600px;
    /* Force minimum width to trigger scroll if needed */
    border-collapse: collapse;
}

/* Fix table header alignment */
.data-table th,
.data-table td {
    white-space: nowrap;
    /* Prevent awkward wrapping in dense tables */
    padding: 1rem;
    vertical-align: middle;
}

/* Allow wrapping for specific long content if marked */
.data-table td.wrap-content {
    white-space: normal;
    min-width: 200px;
}

/* ==================== Responsive Improvements ==================== */
@media (max-width: 768px) {

    /* Larger touch targets on mobile */
    .modal-header button {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Better spacing for form elements */
    .form-input,
    .form-select {
        padding: 0.875rem 1rem;
        font-size: 16px;
        /* Prevents iOS zoom on focus */
    }
}