/* ==========================================================================
   FleetO CSMS Theme & Readability System (Light & Dark Mode)
   ========================================================================== */

/* Typography & Smoothing */
html {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', 'Kantumruy Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.5;
}

:lang(km), [lang="km"], .font-khmer {
    font-family: 'Kantumruy Pro', 'Inter', system-ui, sans-serif;
    line-height: 1.6;
}

/* Scrollbars */
html.dark ::-webkit-scrollbar { width: 6px; height: 6px; }
html.dark ::-webkit-scrollbar-track { background: #0f172a; }
html.dark ::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
html.dark ::-webkit-scrollbar-thumb:hover { background: #475569; }

html.light ::-webkit-scrollbar { width: 6px; height: 6px; }
html.light ::-webkit-scrollbar-track { background: #f8fafc; }
html.light ::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
html.light ::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ==========================================================================
   DARK MODE CONTRAST BOOST (High-legibility dark theme)
   ========================================================================== */
html.dark {
    color-scheme: dark;
}
html.dark .text-slate-400 {
    color: #94a3b8 !important; /* higher contrast light silver */
}
html.dark .text-slate-500 {
    color: #64748b !important;
}

/* ==========================================================================
   LIGHT MODE DESIGN SYSTEM
   ========================================================================== */
html.light {
    color-scheme: light;
}

/* Page Background & Base Text */
html.light body {
    background-color: #f8fafc !important; /* Slate 50 clean light background */
    color: #0f172a !important;            /* Slate 900 ultra readable */
}

/* Sidebar */
html.light aside {
    background-color: #ffffff !important;
    border-right-color: #e2e8f0 !important;
    box-shadow: 2px 0 12px 0 rgba(15, 23, 42, 0.03) !important;
}
html.light aside .border-b,
html.light aside .border-t {
    border-color: #f1f5f9 !important;
}
html.light aside nav a:not(.bg-emerald-600) {
    color: #334155 !important;
}
html.light aside nav a:not(.bg-emerald-600):hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}

/* Top Header */
html.light header {
    background-color: rgba(255, 255, 255, 0.92) !important;
    border-bottom-color: #e2e8f0 !important;
    backdrop-filter: blur(12px) !important;
    box-shadow: 0 1px 2px 0 rgba(15, 23, 42, 0.03) !important;
}
html.light header h1 {
    color: #0f172a !important;
}

/* Footer */
html.light footer {
    background-color: #ffffff !important;
    border-top-color: #e2e8f0 !important;
    color: #64748b !important;
}

/* Cards & Surfaces */
html.light .bg-slate-900,
html.light .bg-slate-900\/80,
html.light .bg-slate-900\/85,
html.light .bg-slate-900\/90,
html.light .bg-slate-900\/95 {
    background-color: #ffffff !important;
    box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.05), 0 1px 2px -1px rgba(15, 23, 42, 0.03) !important;
}

/* Inner Panels & Backgrounds */
html.light .bg-slate-950,
html.light .bg-slate-950\/40,
html.light .bg-slate-950\/50,
html.light .bg-slate-950\/60,
html.light .bg-slate-950\/70,
html.light .bg-slate-950\/80 {
    background-color: #f8fafc !important;
}

html.light .bg-slate-800,
html.light .bg-slate-800\/30,
html.light .bg-slate-800\/40,
html.light .bg-slate-800\/50,
html.light .bg-slate-800\/60,
html.light .bg-slate-800\/80,
html.light .bg-slate-850\/80 {
    background-color: #f1f5f9 !important;
}

/* Borders & Dividers */
html.light .border-slate-800,
html.light .border-slate-800\/60,
html.light .border-slate-800\/80,
html.light .border-slate-700,
html.light .border-slate-700\/60,
html.light .border-slate-700\/70,
html.light .border-slate-700\/80,
html.light .border-slate-900 {
    border-color: #e2e8f0 !important;
}

html.light .divide-slate-800\/60 > :not(:last-child),
html.light .divide-slate-800 > :not(:last-child) {
    border-color: #f1f5f9 !important;
}

/* High Contrast Text Clarity */
html.light .text-white:not(
    .bg-emerald-600, .bg-emerald-500, .bg-blue-600, .bg-blue-500, .bg-amber-600, .bg-rose-600, .bg-rose-700, .bg-red-600,
    .bg-gradient-to-tr,
    button.bg-emerald-600 *, button.bg-emerald-500 *, a.bg-emerald-600 *, button.bg-blue-600 *, button.bg-rose-600 *, button.bg-rose-700 *,
    [class*="bg-emerald-600"] *, [class*="bg-blue-600"] *, [class*="bg-amber-600"] *, [class*="bg-rose-600"] *
) {
    color: #0f172a !important;
}

html.light .text-slate-100 {
    color: #0f172a !important;
}
html.light .text-slate-200 {
    color: #1e293b !important;
}
html.light .text-slate-300 {
    color: #334155 !important;
}
html.light .text-slate-400 {
    color: #475569 !important;
    font-weight: 500 !important;
}
html.light .text-slate-500 {
    color: #64748b !important;
}

/* Ensure colored primary buttons always retain solid backgrounds and crisp white text */
.bg-rose-600, button.bg-rose-600 {
    background-color: #e11d48 !important;
    color: #ffffff !important;
}
.bg-rose-600:hover, button.bg-rose-600:hover {
    background-color: #f43f5e !important;
    color: #ffffff !important;
}
.bg-rose-700, button.bg-rose-700 {
    background-color: #be123c !important;
    color: #ffffff !important;
}
.bg-rose-700:hover, button.bg-rose-700:hover {
    background-color: #e11d48 !important;
    color: #ffffff !important;
}

html.light .bg-emerald-600,
html.light .bg-emerald-500,
html.light .bg-blue-600,
html.light .bg-blue-500,
html.light .bg-amber-600,
html.light .bg-rose-600,
html.light .bg-rose-700,
html.light button.bg-rose-600,
html.light button.bg-rose-700,
html.light [class*="bg-emerald-600"],
html.light [class*="bg-rose-600"] {
    color: #ffffff !important;
}
html.light .bg-emerald-600 *,
html.light .bg-emerald-500 *,
html.light .bg-blue-600 *,
html.light .bg-rose-600 *,
html.light .bg-rose-700 *,
html.light button.bg-rose-600 *,
html.light button.bg-rose-700 *,
html.light [class*="bg-emerald-600"] *,
html.light [class*="bg-rose-600"] * {
    color: #ffffff !important;
}

/* Secondary & Action Buttons */
html.light button.bg-slate-800,
html.light a.bg-slate-800 {
    background-color: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #1e293b !important;
}
html.light button.bg-slate-800:hover,
html.light a.bg-slate-800:hover {
    background-color: #e2e8f0 !important;
    color: #0f172a !important;
}

/* Tables */
html.light table thead {
    background-color: #f8fafc !important;
    border-bottom: 2px solid #e2e8f0 !important;
}
html.light table thead tr {
    background-color: #f8fafc !important;
}
html.light table thead th {
    color: #475569 !important;
    font-weight: 700 !important;
}
html.light table tbody tr {
    border-bottom: 1px solid #f1f5f9 !important;
}
html.light table tbody tr:hover {
    background-color: #f8fafc !important;
}

/* Form Controls (Inputs, Selects, Textareas) */
html.light input:not([type="checkbox"]):not([type="radio"]),
html.light select,
html.light textarea {
    background-color: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
    font-weight: 500 !important;
    box-shadow: 0 1px 2px 0 rgba(15, 23, 42, 0.04) !important;
}
html.light input:focus,
html.light select:focus,
html.light textarea:focus {
    background-color: #ffffff !important;
    border-color: #10b981 !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18) !important;
}
html.light input::placeholder,
html.light textarea::placeholder {
    color: #94a3b8 !important;
}
html.light select option {
    background-color: #ffffff !important;
    color: #0f172a !important;
}

/* High Contrast Badges in Light Mode */
html.light .text-emerald-400 {
    color: #047857 !important;
}
html.light .bg-emerald-500\/10,
html.light .bg-emerald-500\/15,
html.light .bg-emerald-500\/20 {
    background-color: #ecfdf5 !important;
    border-color: #a7f3d0 !important;
}

html.light .text-blue-400 {
    color: #1d4ed8 !important;
}
html.light .bg-blue-500\/10,
html.light .bg-blue-500\/15 {
    background-color: #eff6ff !important;
    border-color: #bfdbfe !important;
}

html.light .text-cyan-400 {
    color: #0e7490 !important;
}
html.light .bg-cyan-500\/10,
html.light .bg-cyan-500\/15 {
    background-color: #ecfeff !important;
    border-color: #a5f3fc !important;
}

html.light .text-amber-400 {
    color: #b45309 !important;
}
html.light .bg-amber-500\/10,
html.light .bg-amber-500\/15 {
    background-color: #fffbeb !important;
    border-color: #fde68a !important;
}

html.light .text-rose-400 {
    color: #be123c !important;
}
html.light .bg-rose-500\/10,
html.light .bg-rose-500\/15 {
    background-color: #fff1f2 !important;
    border-color: #fecdd3 !important;
}

html.light .text-purple-400 {
    color: #7e22ce !important;
}
html.light .bg-purple-500\/10,
html.light .bg-purple-500\/15 {
    background-color: #faf5ff !important;
    border-color: #e9d5ff !important;
}

/* Modals */
html.light #createDriverModal,
html.light #editDriverModal,
html.light #adjustModal,
html.light #passwordModal,
html.light .modal-backdrop {
    background-color: rgba(15, 23, 42, 0.45) !important;
}

html.light #createDriverModal > div,
html.light #editDriverModal > div,
html.light #adjustModal > div,
html.light #passwordModal > div,
html.light .modal-content {
    background-color: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.08) !important;
}

/* Dashboard Top Banners */
html.light .bg-gradient-to-r.from-slate-900 {
    background-image: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%) !important;
    border-color: #e2e8f0 !important;
}
html.light .bg-gradient-to-r.from-emerald-950\/60 {
    background-image: linear-gradient(135deg, #f0fdf4 0%, #ffffff 50%, #ecfdf5 100%) !important;
    border-color: #a7f3d0 !important;
}
html.light .bg-gradient-to-r.from-emerald-950\/60 .text-emerald-400 {
    color: #047857 !important;
}
html.light .bg-gradient-to-r.from-emerald-950\/60 .text-white {
    color: #065f46 !important;
}

/* Login Page Ambient Light Mode */
html.light .login-card {
    background-color: rgba(255, 255, 255, 0.95) !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.15) !important;
}
