/* ==========================================================================
   PraktikM Executive Dashboard - Master Stylesheet
   Supports: Light Mode (Default Executive Theme) & Dark Mode
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Base Typography & Fonts
   -------------------------------------------------------------------------- */
body {
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --------------------------------------------------------------------------
   1. Scrollbars
   -------------------------------------------------------------------------- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

/* Dark scrollbars */
html.dark ::-webkit-scrollbar-track {
    background: #11151c;
}
html.dark ::-webkit-scrollbar-thumb {
    background: #252d3d;
    border-radius: 3px;
}
html.dark ::-webkit-scrollbar-thumb:hover {
    background: #3b82f6;
}

/* Light scrollbars (Default) */
html:not(.dark) ::-webkit-scrollbar-track,
html.light ::-webkit-scrollbar-track {
    background: #f1f5f9;
}
html:not(.dark) ::-webkit-scrollbar-thumb,
html.light ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
html:not(.dark) ::-webkit-scrollbar-thumb:hover,
html.light ::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* --------------------------------------------------------------------------
   2. Period Switcher Buttons
   -------------------------------------------------------------------------- */
.period-btn {
    transition: all 0.2s ease;
}

.period-btn.active {
    background-color: #2563eb !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35) !important;
}

/* --------------------------------------------------------------------------
   3. Funnel Animations & Cards
   -------------------------------------------------------------------------- */
.funnel-bar-fill {
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.glow-card {
    position: relative;
}

html.dark .glow-card::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(to bottom right, rgba(255, 255, 255, 0.08), transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

html:not(.dark) .glow-card::after,
html.light .glow-card::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(to bottom right, rgba(0, 0, 0, 0.04), transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

@keyframes pulseSubtle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(1.02); }
}

.pulse-subtle {
    animation: pulseSubtle 3s infinite ease-in-out;
}

/* ==========================================================================
   4. LIGHT MODE DESIGN SYSTEM (Default Executive Theme)
   ========================================================================== */

html:not(.dark),
html.light {
    color-scheme: light;
}

/* Body Background & Base Typography */
html:not(.dark) body,
html.light body {
    background-color: #f8fafc !important; /* slate-50 */
    color: #0f172a !important; /* slate-900 */
}

/* Header & Navigation Bar */
html:not(.dark) header,
html.light header {
    background-color: rgba(255, 255, 255, 0.88) !important;
    border-bottom: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.04) !important;
}

/* Period Switcher Container */
html:not(.dark) .period-btn,
html.light .period-btn {
    color: #64748b !important;
}

html:not(.dark) .period-btn:hover,
html.light .period-btn:hover {
    color: #0f172a !important;
    background-color: #e2e8f0 !important;
}

/* --------------------------------------------------------------------------
   Card Backgrounds - Universal Substring Matching (Matches opacity variants /80, /60, etc.)
   -------------------------------------------------------------------------- */
html:not(.dark) [class*="bg-graphite-950"],
html.light [class*="bg-graphite-950"] {
    background-color: #f8fafc !important;
}

html:not(.dark) [class*="bg-graphite-900"],
html.light [class*="bg-graphite-900"],
html:not(.dark) .bg-graphite-900\/80,
html.light .bg-graphite-900\/80,
html:not(.dark) .bg-graphite-900\/90,
html.light .bg-graphite-900\/90,
html:not(.dark) .bg-graphite-900\/60,
html.light .bg-graphite-900\/60 {
    background-color: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.05), 0 1px 2px -1px rgba(15, 23, 42, 0.05) !important;
}

/* Sub-panels, Card Headers & List Item Backgrounds */
html:not(.dark) [class*="bg-graphite-850"],
html.light [class*="bg-graphite-850"] {
    background-color: #f8fafc !important;
    border-color: #e2e8f0 !important;
}

html:not(.dark) [class*="bg-graphite-800"],
html.light [class*="bg-graphite-800"] {
    background-color: #f1f5f9 !important;
    border-color: #e2e8f0 !important;
}

html:not(.dark) [class*="bg-graphite-750"],
html.light [class*="bg-graphite-750"] {
    background-color: #e2e8f0 !important;
    border-color: #cbd5e1 !important;
}

/* Hover States in Light Mode */
html:not(.dark) [class*="hover:bg-graphite-850"]:hover,
html.light [class*="hover:bg-graphite-850"]:hover {
    background-color: #f1f5f9 !important;
}

html:not(.dark) [class*="hover:bg-graphite-750"]:hover,
html.light [class*="hover:bg-graphite-750"]:hover {
    background-color: #e2e8f0 !important;
}

/* Borders & Dividers */
html:not(.dark) [class*="border-graphite-"],
html.light [class*="border-graphite-"] {
    border-color: #e2e8f0 !important;
}

html:not(.dark) [class*="divide-graphite-"],
html.light [class*="divide-graphite-"] {
    border-color: #e2e8f0 !important;
}

/* --------------------------------------------------------------------------
   Typography Overrides for Light Mode
   -------------------------------------------------------------------------- */
html:not(.dark) .text-white,
html.light .text-white {
    color: #0f172a !important; /* High-contrast Slate-900 */
}

/* Elements that MUST KEEP WHITE text (Buttons, Active items, Logos) */
html:not(.dark) .text-white-keep,
html.light .text-white-keep,
html:not(.dark) .period-btn.active,
html.light .period-btn.active,
html:not(.dark) button[type="submit"] *,
html.light button[type="submit"] *,
html:not(.dark) button[type="submit"],
html.light button[type="submit"],
html:not(.dark) .bg-brand-blue,
html.light .bg-brand-blue,
html:not(.dark) .bg-brand-blue *,
html.light .bg-brand-blue *,
html:not(.dark) .bg-gradient-to-r.from-brand-blue,
html.light .bg-gradient-to-r.from-brand-blue,
html:not(.dark) .bg-gradient-to-r.from-brand-blue *,
html.light .bg-gradient-to-r.from-brand-blue *,
html:not(.dark) .bg-gradient-to-tr.from-brand-blue,
html.light .bg-gradient-to-tr.from-brand-blue,
html:not(.dark) .bg-gradient-to-tr.from-brand-blue *,
html.light .bg-gradient-to-tr.from-brand-blue *,
html:not(.dark) #btnSaveSettings,
html.light #btnSaveSettings,
html:not(.dark) #btnSaveSettings * {
    color: #ffffff !important;
}

/* Brand header text gradient in light mode */
html:not(.dark) .bg-gradient-to-r.from-white,
html.light .bg-gradient-to-r.from-white {
    background-image: linear-gradient(to right, #0f172a, #1e293b, #334155) !important;
}

/* Secondary & Muted Typography */
html:not(.dark) .text-graphite-100,
html.light .text-graphite-100 {
    color: #0f172a !important;
}

html:not(.dark) .text-graphite-200,
html.light .text-graphite-200 {
    color: #1e293b !important;
}

html:not(.dark) .text-graphite-300,
html.light .text-graphite-300 {
    color: #334155 !important;
}

html:not(.dark) .text-graphite-400,
html.light .text-graphite-400 {
    color: #64748b !important; /* Crisp slate-500 */
}

html:not(.dark) .text-graphite-500,
html.light .text-graphite-500 {
    color: #94a3b8 !important;
}

html:not(.dark) .text-graphite-600,
html.light .text-graphite-600 {
    color: #cbd5e1 !important;
}

/* Interactive Control Buttons */
html:not(.dark) #btnSyncNow,
html.light #btnSyncNow,
html:not(.dark) #btnSettingsModal,
html.light #btnSettingsModal,
html:not(.dark) #btnThemeToggle,
html.light #btnThemeToggle,
html:not(.dark) header a[href="/logout"],
html.light header a[href="/logout"],
html:not(.dark) #toggleStalledTableBtn,
html.light #toggleStalledTableBtn {
    background-color: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #334155 !important;
}

html:not(.dark) #btnSyncNow:hover,
html.light #btnSyncNow:hover,
html:not(.dark) #btnSettingsModal:hover,
html.light #btnSettingsModal:hover,
html:not(.dark) #btnThemeToggle:hover,
html.light #btnThemeToggle:hover,
html:not(.dark) #toggleStalledTableBtn:hover,
html.light #toggleStalledTableBtn:hover {
    background-color: #e2e8f0 !important;
    border-color: #94a3b8 !important;
    color: #0f172a !important;
}

html:not(.dark) header a[href="/logout"]:hover,
html.light header a[href="/logout"]:hover {
    background-color: #fee2e2 !important;
    border-color: #fca5a5 !important;
    color: #dc2626 !important;
}

/* --------------------------------------------------------------------------
   5. Status, Risk & Metric Badges in Light Mode
   -------------------------------------------------------------------------- */

/* Critical / Rose & Red */
html:not(.dark) [class*="bg-rose-500"],
html.light [class*="bg-rose-500"],
html:not(.dark) [class*="bg-red-500"],
html.light [class*="bg-red-500"] {
    background-color: #fef2f2 !important;
}
html:not(.dark) [class*="text-rose-"],
html.light [class*="text-rose-"],
html:not(.dark) [class*="text-red-"],
html.light [class*="text-red-"] {
    color: #dc2626 !important;
}
html:not(.dark) [class*="border-rose-500"],
html.light [class*="border-rose-500"],
html:not(.dark) [class*="border-red-500"],
html.light [class*="border-red-500"] {
    border-color: #fecaca !important;
}

/* Warning / Amber */
html:not(.dark) [class*="bg-amber-500"],
html.light [class*="bg-amber-500"],
html:not(.dark) [class*="bg-amber-950"],
html.light [class*="bg-amber-950"] {
    background-color: #fffbeb !important;
}
html:not(.dark) [class*="text-amber-"],
html.light [class*="text-amber-"] {
    color: #d97706 !important;
}
html:not(.dark) [class*="border-amber-500"],
html.light [class*="border-amber-500"] {
    border-color: #fde68a !important;
}

/* Good / Emerald */
html:not(.dark) [class*="bg-emerald-500"],
html.light [class*="bg-emerald-500"] {
    background-color: #f0fdf4 !important;
}
html:not(.dark) [class*="text-emerald-"],
html.light [class*="text-emerald-"] {
    color: #16a34a !important;
}
html:not(.dark) [class*="border-emerald-500"],
html.light [class*="border-emerald-500"] {
    border-color: #bbf7d0 !important;
}

/* Cyan / Info */
html:not(.dark) [class*="bg-cyan-500"],
html.light [class*="bg-cyan-500"] {
    background-color: #f0f9ff !important;
}
html:not(.dark) [class*="text-cyan-"],
html.light [class*="text-cyan-"] {
    color: #0284c7 !important;
}
html:not(.dark) [class*="border-cyan-500"],
html.light [class*="border-cyan-500"] {
    border-color: #bae6fd !important;
}

/* Purple (Prepayment breakdown) */
html:not(.dark) [class*="text-purple-"],
html.light [class*="text-purple-"] {
    color: #7c3aed !important; /* purple-600 */
}
html:not(.dark) [class*="bg-purple-500"],
html.light [class*="bg-purple-500"] {
    background-color: #faf5ff !important;
}
html:not(.dark) [class*="border-purple-500"],
html.light [class*="border-purple-500"] {
    border-color: #e9d5ff !important;
}

/* Brand Blue / Violet Tint */
html:not(.dark) [class*="bg-brand-blue/"],
html.light [class*="bg-brand-blue/"] {
    background-color: #eff6ff !important;
}
html:not(.dark) [class*="border-brand-blue/"],
html.light [class*="border-brand-blue/"] {
    border-color: #bfdbfe !important;
}
html:not(.dark) .text-brand-cyan,
html.light .text-brand-cyan {
    color: #0284c7 !important;
}

/* --------------------------------------------------------------------------
   6. Tables Styling in Light Mode
   -------------------------------------------------------------------------- */
html:not(.dark) thead,
html.light thead {
    background-color: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0 !important;
}
html:not(.dark) thead th,
html.light thead th {
    color: #475569 !important;
    font-weight: 600 !important;
}
html:not(.dark) tbody tr,
html.light tbody tr {
    border-color: #f1f5f9 !important;
}
html:not(.dark) tbody tr:hover,
html.light tbody tr:hover {
    background-color: #f8fafc !important;
}

/* --------------------------------------------------------------------------
   7. Block 4: Complaints & PNR Details in Light Mode
   -------------------------------------------------------------------------- */
html:not(.dark) #complaintsList > div,
html.light #complaintsList > div {
    border-color: #f1f5f9 !important;
}
html:not(.dark) #complaintsList > div:hover,
html.light #complaintsList > div:hover {
    background-color: #f8fafc !important;
}
html:not(.dark) #complaintsList a,
html.light #complaintsList a {
    background-color: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #334155 !important;
}
html:not(.dark) #complaintsList a:hover,
html.light #complaintsList a:hover {
    background-color: #e2e8f0 !important;
    border-color: #94a3b8 !important;
    color: #0f172a !important;
}

/* PNR Card Items */
html:not(.dark) #pnrList > div,
html.light #pnrList > div {
    background-color: #f8fafc !important;
    border-color: #e2e8f0 !important;
}

/* --------------------------------------------------------------------------
   8. Settings Modal & Dialogs
   -------------------------------------------------------------------------- */
html:not(.dark) #settingsModal > div,
html.light #settingsModal > div {
    background-color: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.15) !important;
}
html:not(.dark) #settingMonthlyPlan,
html.light #settingMonthlyPlan,
html:not(.dark) #settingMarginPct,
html.light #settingMarginPct {
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}
html:not(.dark) #settingMonthlyPlan:focus,
html.light #settingMonthlyPlan:focus,
html:not(.dark) #settingMarginPct:focus,
html.light #settingMarginPct:focus {
    background-color: #ffffff !important;
    border-color: #2563eb !important;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15) !important;
}

/* --------------------------------------------------------------------------
   9. Footer in Light Mode
   -------------------------------------------------------------------------- */
html:not(.dark) footer,
html.light footer {
    background-color: #ffffff !important;
    border-color: #e2e8f0 !important;
}

/* --------------------------------------------------------------------------
   10. Login Page in Light Mode
   -------------------------------------------------------------------------- */
html:not(.dark) .login-card,
html.light .login-card {
    background-color: rgba(255, 255, 255, 0.94) !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04) !important;
}
html:not(.dark) input[type="text"],
html.light input[type="text"],
html:not(.dark) input[type="password"],
html.light input[type="password"] {
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}
html:not(.dark) input[type="text"]::placeholder,
html.light input[type="text"]::placeholder,
html:not(.dark) input[type="password"]::placeholder,
html.light input[type="password"]::placeholder {
    color: #94a3b8 !important;
}
html:not(.dark) input[type="text"]:focus,
html.light input[type="text"]:focus,
html:not(.dark) input[type="password"]:focus,
html.light input[type="password"]:focus {
    background-color: #ffffff !important;
    border-color: #2563eb !important;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15) !important;
}
