/*
 * ============================================================
 * PROCESS ENGINEERING — PREMIUM FILAMENT THEME
 * Design System: Blue/Red Brand | Glassmorphism | Micro-Animations
 * ============================================================
 */

/* ---- Google Fonts Import ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ============================================================
   1. DESIGN TOKENS (CSS Custom Properties)
   ============================================================ */
:root {
    /* Brand Colors — Blue & Red */
    --brand-blue: 217 91% 60%;       /* #3b82f6 */
    --brand-blue-deep: 221 83% 53%;  /* #2563eb */
    --brand-blue-light: 213 94% 68%; /* #60a5fa */
    --brand-blue-glow: 217 91% 60%;
    --brand-red: 0 84% 60%;          /* #ef4444 */
    --brand-red-deep: 0 72% 51%;     /* #dc2626 */
    --brand-red-light: 0 93% 74%;    /* #fca5a5 */

    /* Neutral Palette */
    --surface-0: #ffffff;
    --surface-1: #f8fafc;
    --surface-2: #f1f5f9;
    --surface-3: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --border-default: #e2e8f0;
    --border-subtle: #f1f5f9;

    /* Glass Properties */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-blur: 12px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    --shadow-blue-glow: 0 0 20px rgba(59, 130, 246, 0.15), 0 0 40px rgba(59, 130, 246, 0.05);
    --shadow-red-glow: 0 0 20px rgba(239, 68, 68, 0.15), 0 0 40px rgba(239, 68, 68, 0.05);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Typography */
    --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

/* Dark Mode Tokens */
.dark {
    --surface-0: #0b1120;
    --surface-1: #111827;
    --surface-2: #1e293b;
    --surface-3: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #64748b;
    --border-default: rgba(255, 255, 255, 0.08);
    --border-subtle: rgba(255, 255, 255, 0.04);

    --glass-bg: rgba(15, 23, 42, 0.75);
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-blur: 16px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
    --shadow-blue-glow: 0 0 25px rgba(59, 130, 246, 0.2), 0 0 50px rgba(59, 130, 246, 0.08);
    --shadow-red-glow: 0 0 25px rgba(239, 68, 68, 0.2), 0 0 50px rgba(239, 68, 68, 0.08);
}

/* ============================================================
   2. GLOBAL RESET & TYPOGRAPHY
   ============================================================ */
body {
    font-family: var(--font-sans) !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--surface-0);
    color: var(--text-primary);
}

code, pre, .font-mono, [class*="mono"] {
    font-family: var(--font-mono) !important;
}

/* ============================================================
   3. SIDEBAR — Premium Glassmorphism Navigation
   ============================================================ */
.fi-sidebar {
    background: var(--surface-1) !important;
    border-right: 1px solid var(--border-default) !important;
    transition: all var(--transition-base);
}

.dark .fi-sidebar {
    background: linear-gradient(180deg, #0d1525 0%, #0b1120 100%) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.04) !important;
}

/* Sidebar Brand/Logo Area */
.fi-sidebar-header {
    padding: 16px 16px 12px !important;
    border-bottom: 1px solid var(--border-subtle);
}

.dark .fi-sidebar-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

/* Navigation Items */
.fi-sidebar-item {
    margin: 2px 8px !important;
    border-radius: var(--radius-md) !important;
    transition: all var(--transition-base) !important;
}

.fi-sidebar-item:hover {
    background: rgba(59, 130, 246, 0.06) !important;
    transform: translateX(2px);
}

.fi-sidebar-item-active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(59, 130, 246, 0.06)) !important;
    border-left: 3px solid hsl(var(--brand-blue)) !important;
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.08);
}

.dark .fi-sidebar-item:hover {
    background: rgba(59, 130, 246, 0.1) !important;
}

.dark .fi-sidebar-item-active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.18), rgba(59, 130, 246, 0.08)) !important;
    box-shadow: var(--shadow-blue-glow), inset 0 0 0 1px rgba(59, 130, 246, 0.12);
}

/* Navigation Group Labels */
.fi-sidebar-group-label {
    font-size: 10px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.8px !important;
    color: var(--text-tertiary) !important;
    padding: 8px 12px 4px !important;
}

/* ============================================================
   4. TOPBAR — Frosted Glass Effect
   ============================================================ */
.fi-topbar {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur)) saturate(180%) !important;
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%) !important;
    border-bottom: 1px solid var(--border-default) !important;
    transition: all var(--transition-base);
}

.dark .fi-topbar {
    background: rgba(11, 17, 32, 0.8) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04) !important;
}

/* User Menu Avatar */
.fi-avatar {
    ring: 2px solid hsl(var(--brand-blue)) !important;
    transition: all var(--transition-base);
}

.fi-avatar:hover {
    ring: 2px solid hsl(var(--brand-red)) !important;
    transform: scale(1.05);
}

/* ============================================================
   5. MAIN CONTENT AREA
   ============================================================ */
.fi-main {
    background: var(--surface-1) !important;
}

.dark .fi-main {
    background: linear-gradient(180deg, #0b1120 0%, #0d1525 50%, #0b1120 100%) !important;
}

/* Page Header */
.fi-header {
    margin-bottom: 24px !important;
}

.fi-header-heading {
    font-weight: 800 !important;
    letter-spacing: -0.025em !important;
    color: var(--text-primary) !important;
}

/* ============================================================
   6. CARDS & SECTIONS — Glassmorphism Panels
   ============================================================ */
.fi-section {
    background: var(--surface-0) !important;
    border: 1px solid var(--border-default) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-sm) !important;
    transition: all var(--transition-base) !important;
    position: relative !important;
    overflow: visible !important;
}

.fi-section-content,
.fi-section-content-ctn,
.fi-fo-field-wrp,
.fi-fo-field-wrp-item {
    overflow: visible !important;
}

/* Stacking: elevate any section containing an open dropdown or focused field */
.fi-section:focus-within,
.fi-section:has(.choices.is-open),
.fi-section:has([aria-expanded="true"]) {
    z-index: 50 !important;
}

/* Choices.js Select Dropdown Fixes */
.choices {
    position: relative !important;
    overflow: visible !important;
}

.choices.is-open {
    z-index: 60 !important;
}

.choices__list--dropdown,
.choices[data-type*="select-one"] .choices__list--dropdown,
.choices[data-type*="select-multiple"] .choices__list--dropdown {
    z-index: 99999 !important;
    position: absolute !important;
    background: #1e293b !important;
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.7), 0 8px 10px -6px rgba(0, 0, 0, 0.7) !important;
    border-radius: var(--radius-md) !important;
}

.dark .choices__list--dropdown,
.dark .choices[data-type*="select-one"] .choices__list--dropdown,
.dark .choices[data-type*="select-multiple"] .choices__list--dropdown {
    background: #1e293b !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 25px 30px -5px rgba(0, 0, 0, 0.8) !important;
}

.choices__list--dropdown .choices__item--selectable.is-highlighted {
    background-color: rgba(59, 130, 246, 0.25) !important;
    color: #93c5fd !important;
}

.fi-wi-stats-overview-stat {
    background: var(--surface-0) !important;
    border: 1px solid var(--border-default) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-sm) !important;
    transition: all var(--transition-base) !important;
    overflow: hidden;
}

.fi-section:hover {
    box-shadow: var(--shadow-md) !important;
}

.fi-wi-stats-overview-stat:hover {
    box-shadow: var(--shadow-md) !important;
    transform: translateY(-1px);
}

.dark .fi-section {
    background: #111827 !important;
    border: 1px solid var(--glass-border) !important;
}

.dark .fi-wi-stats-overview-stat {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur)) !important;
    -webkit-backdrop-filter: blur(var(--glass-blur)) !important;
    border: 1px solid var(--glass-border) !important;
}

.dark .fi-section:hover {
    border-color: rgba(59, 130, 246, 0.15) !important;
}

.dark .fi-wi-stats-overview-stat:hover {
    border-color: rgba(59, 130, 246, 0.15) !important;
    box-shadow: var(--shadow-blue-glow) !important;
}

/* Stats Widget Cards — Premium Enhancement */
.fi-wi-stats-overview-stat {
    position: relative;
    overflow: hidden;
}

.fi-wi-stats-overview-stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, hsl(var(--brand-blue)), hsl(var(--brand-red)));
    opacity: 0;
    transition: opacity var(--transition-base);
}

.fi-wi-stats-overview-stat:hover::before {
    opacity: 1;
}

/* Stat Values */
.fi-wi-stats-overview-stat-value {
    font-weight: 800 !important;
    font-size: 1.5rem !important;
    letter-spacing: -0.025em !important;
}

/* Stat Charts */
.fi-wi-stats-overview-stat-chart {
    opacity: 0.6;
    transition: opacity var(--transition-base);
}

.fi-wi-stats-overview-stat:hover .fi-wi-stats-overview-stat-chart {
    opacity: 1;
}

/* ============================================================
   7. TABLES — Premium Styling
   ============================================================ */
.fi-ta {
    border-radius: var(--radius-lg) !important;
    overflow: hidden;
    border: 1px solid var(--border-default) !important;
}

.dark .fi-ta {
    border: 1px solid var(--glass-border) !important;
}

/* Table Header */
.fi-ta-header-cell {
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    color: var(--text-tertiary) !important;
    background: var(--surface-1) !important;
    border-bottom: 2px solid var(--border-default) !important;
}

.dark .fi-ta-header-cell {
    background: rgba(15, 23, 42, 0.6) !important;
    border-bottom: 2px solid rgba(255, 255, 255, 0.06) !important;
}

/* Table Rows */
.fi-ta-row {
    transition: all var(--transition-fast) !important;
    border-bottom: 1px solid var(--border-subtle) !important;
}

.fi-ta-row:hover {
    background: rgba(59, 130, 246, 0.03) !important;
}

.dark .fi-ta-row:hover {
    background: rgba(59, 130, 246, 0.06) !important;
}

/* Striped rows */
.fi-ta-row:nth-child(even) {
    background: var(--surface-1);
}

.dark .fi-ta-row:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}

/* ============================================================
   8. BADGES — Premium Pill Style
   ============================================================ */
.fi-badge {
    font-weight: 600 !important;
    font-size: 11px !important;
    letter-spacing: 0.025em !important;
    border-radius: var(--radius-full) !important;
    padding: 3px 10px !important;
    transition: all var(--transition-fast) !important;
}

.fi-badge:hover {
    transform: scale(1.05);
}

/* ============================================================
   9. FORMS — Glowing Focus States
   ============================================================ */
.fi-input,
.fi-select,
.fi-textarea {
    border-radius: var(--radius-md) !important;
    border: 1px solid var(--border-default) !important;
    transition: all var(--transition-base) !important;
    font-family: var(--font-sans) !important;
}

.fi-input:focus,
.fi-select:focus,
.fi-textarea:focus {
    border-color: hsl(var(--brand-blue)) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12), var(--shadow-sm) !important;
    outline: none !important;
}

.dark .fi-input:focus,
.dark .fi-select:focus,
.dark .fi-textarea:focus {
    border-color: hsl(var(--brand-blue-light)) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2), var(--shadow-sm) !important;
}

/* ============================================================
   10. BUTTONS — Gradient Fills with Hover Glow
   ============================================================ */
.fi-btn-primary {
    background: linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-blue-deep))) !important;
    border: none !important;
    border-radius: var(--radius-md) !important;
    font-weight: 600 !important;
    box-shadow: var(--shadow-sm) !important;
    transition: all var(--transition-base) !important;
}

.fi-btn-primary:hover {
    box-shadow: var(--shadow-blue-glow), var(--shadow-md) !important;
    transform: translateY(-1px);
}

.fi-btn-primary:active {
    transform: translateY(0);
}

/* Danger Buttons */
.fi-btn-danger,
.fi-color-danger .fi-btn {
    background: linear-gradient(135deg, hsl(var(--brand-red)), hsl(var(--brand-red-deep))) !important;
}

.fi-btn-danger:hover,
.fi-color-danger .fi-btn:hover {
    box-shadow: var(--shadow-red-glow), var(--shadow-md) !important;
}

/* ============================================================
   11. NOTIFICATIONS — Slide-in Glass Panels
   ============================================================ */
.fi-notification {
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-radius: var(--radius-lg) !important;
    border: 1px solid var(--glass-border) !important;
    animation: slideInRight var(--transition-slow) forwards;
}

/* ============================================================
   12. MODAL / DIALOG — Premium Glass
   ============================================================ */
.fi-modal-window {
    border-radius: var(--radius-xl) !important;
    border: 1px solid var(--border-default) !important;
    box-shadow: var(--shadow-xl) !important;
    animation: fadeInScale var(--transition-slow) forwards;
}

.dark .fi-modal-window {
    background: var(--surface-1) !important;
    border: 1px solid var(--glass-border) !important;
}

/* ============================================================
   13. BREADCRUMBS
   ============================================================ */
.fi-breadcrumbs {
    font-size: 13px !important;
    color: var(--text-tertiary) !important;
}

.fi-breadcrumbs a:hover {
    color: hsl(var(--brand-blue)) !important;
}

/* ============================================================
   14. PAGINATION
   ============================================================ */
.fi-pagination-item-active {
    background: linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-blue-deep))) !important;
    border: none !important;
    box-shadow: var(--shadow-blue-glow) !important;
}

/* ============================================================
   15. SCROLLBAR — Custom Premium
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--brand-blue));
}

.dark ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.5);
}

/* ============================================================
   16. KEYFRAME ANIMATIONS
   ============================================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(59, 130, 246, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.5), 0 0 40px rgba(59, 130, 246, 0.2);
    }
}

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

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

@keyframes ping-pulse {
    75%, 100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

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

@keyframes borderGlow {
    0%, 100% { border-color: rgba(59, 130, 246, 0.2); }
    50% { border-color: rgba(59, 130, 246, 0.5); }
}

/* Staggered entrance for widget cards */
.animate-stagger > *:nth-child(1) { animation: fadeInUp 0.5s 0.05s both; }
.animate-stagger > *:nth-child(2) { animation: fadeInUp 0.5s 0.1s both; }
.animate-stagger > *:nth-child(3) { animation: fadeInUp 0.5s 0.15s both; }
.animate-stagger > *:nth-child(4) { animation: fadeInUp 0.5s 0.2s both; }
.animate-stagger > *:nth-child(5) { animation: fadeInUp 0.5s 0.25s both; }
.animate-stagger > *:nth-child(6) { animation: fadeInUp 0.5s 0.3s both; }

/* ============================================================
   17. UTILITY CLASSES
   ============================================================ */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
}

.gradient-text-brand {
    background: linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-red)));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-border {
    position: relative;
}

.gradient-border::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, hsl(var(--brand-blue)), hsl(var(--brand-red)));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.hover-lift {
    transition: all var(--transition-base);
}

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

.shimmer-bg {
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.05) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

/* ============================================================
   18. FILAMENT WIDGET GRID — Entrance Animation
   ============================================================ */
.fi-wi {
    animation: fadeInUp 0.4s ease-out both;
}

.fi-wi:nth-child(1) { animation-delay: 0.05s; }
.fi-wi:nth-child(2) { animation-delay: 0.1s; }
.fi-wi:nth-child(3) { animation-delay: 0.15s; }
.fi-wi:nth-child(4) { animation-delay: 0.2s; }

/* ============================================================
   19. LOGIN PAGE (if custom login used)
   ============================================================ */
.fi-simple-layout {
    background: linear-gradient(135deg, #0b1120 0%, #111827 50%, #0b1120 100%) !important;
    position: relative;
}

.fi-simple-layout::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(239, 68, 68, 0.06) 0%, transparent 50%);
    pointer-events: none;
}

.fi-simple-main-ctn {
    position: relative;
    z-index: 1;
}

.fi-simple-page {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius-xl) !important;
    box-shadow: var(--shadow-xl), 0 0 60px rgba(59, 130, 246, 0.05) !important;
    animation: fadeInScale 0.5s ease-out;
}

/* ============================================================
   20. RESPONSIVE POLISH
   ============================================================ */
@media (max-width: 768px) {
    .fi-wi-stats-overview-stat-value {
        font-size: 1.25rem !important;
    }

    .fi-header-heading {
        font-size: 1.25rem !important;
    }
}

/* ============================================================
   21. LOADING STATES — Skeleton Shimmer
   ============================================================ */
.skeleton-pulse {
    background: linear-gradient(90deg,
        var(--surface-2) 25%,
        var(--surface-1) 50%,
        var(--surface-2) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* ============================================================
   22. DARK MODE TOGGLE BUTTON STYLING
   ============================================================ */
.fi-theme-switcher {
    transition: all var(--transition-base);
}

.fi-theme-switcher:hover {
    color: hsl(var(--brand-blue)) !important;
}
