/* =========================================================================
   KAX Platform Global Unified Theme System (Dark, Light, Navy, Emerald)
   ========================================================================= */

:root, html[data-theme="light"] {
    --kax-bg-body: #f8fafc;
    --kax-bg-header: #ffffff;
    --kax-bg-card: #ffffff;
    --kax-bg-card-alt: #f1f5f9;
    --kax-bg-input: #ffffff;
    --kax-bg-th: #f1f5f9;
    --kax-border: #cbd5e1;
    --kax-border-subtle: #e2e8f0;
    --kax-text-main: #0f172a;
    --kax-text-title: #0f172a;
    --kax-text-secondary: #334155;
    --kax-text-muted: #64748b;
    --kax-kbd-bg: #e2e8f0;
    --kax-kbd-text: #b45309;
    --kax-tab-inactive-bg: #ffffff;
    --kax-tab-inactive-text: #475569;
    --kax-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --kax-modal-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

html[data-theme="dark"] {
    --kax-bg-body: #0b0f19;
    --kax-bg-header: #070a12;
    --kax-bg-card: #131b2e;
    --kax-bg-card-alt: #1a243c;
    --kax-bg-input: #0a0e18;
    --kax-bg-th: #162035;
    --kax-border: #23314f;
    --kax-border-subtle: #192338;
    --kax-text-main: #f8fafc;
    --kax-text-title: #ffffff;
    --kax-text-secondary: #cbd5e1;
    --kax-text-muted: #94a3b8;
    --kax-kbd-bg: #0b0f19;
    --kax-kbd-text: #f59e0b;
    --kax-tab-inactive-bg: #131b2e;
    --kax-tab-inactive-text: #cbd5e1;
    --kax-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    --kax-modal-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

html[data-theme="navy"] {
    --kax-bg-body: #070d1e;
    --kax-bg-header: #040814;
    --kax-bg-card: #0e1a38;
    --kax-bg-card-alt: #142552;
    --kax-bg-input: #060c1c;
    --kax-bg-th: #102149;
    --kax-border: #1e3a8a;
    --kax-border-subtle: #172e6b;
    --kax-text-main: #f0f9ff;
    --kax-text-title: #ffffff;
    --kax-text-secondary: #bfdbfe;
    --kax-text-muted: #93c5fd;
    --kax-kbd-bg: #070d1e;
    --kax-kbd-text: #38bdf8;
    --kax-tab-inactive-bg: #0e1a38;
    --kax-tab-inactive-text: #bfdbfe;
    --kax-shadow: 0 10px 25px -5px rgba(2, 6, 23, 0.5);
    --kax-modal-shadow: 0 25px 50px -12px rgba(2, 6, 23, 0.8);
}

html[data-theme="emerald"] {
    --kax-bg-body: #031713;
    --kax-bg-header: #020f0c;
    --kax-bg-card: #082c23;
    --kax-bg-card-alt: #0d3e32;
    --kax-bg-input: #02130f;
    --kax-bg-th: #0a362b;
    --kax-border: #065f46;
    --kax-border-subtle: #044b37;
    --kax-text-main: #ecfdf5;
    --kax-text-title: #ffffff;
    --kax-text-secondary: #a7f3d0;
    --kax-text-muted: #6ee7b7;
    --kax-kbd-bg: #031713;
    --kax-kbd-text: #34d399;
    --kax-tab-inactive-bg: #082c23;
    --kax-tab-inactive-text: #a7f3d0;
    --kax-shadow: 0 10px 25px -5px rgba(2, 44, 34, 0.5);
    --kax-modal-shadow: 0 25px 50px -12px rgba(2, 44, 34, 0.8);
}

/* =========================================================================
   Base Layout Styling
   ========================================================================= */

body {
    background-color: var(--kax-bg-body) !important;
    color: var(--kax-text-main) !important;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Top Navigation Bar */
header.sticky {
    background-color: var(--kax-bg-header) !important;
    border-color: var(--kax-border) !important;
}

/* Sections & Cards */
.pos-section {
    background: var(--kax-bg-card) !important;
    border: 1px solid var(--kax-border) !important;
    box-shadow: var(--kax-shadow);
}

/* Common Tailwind Dark Elements Override */
.bg-slate-900,
.bg-slate-900\/90,
.bg-slate-900\/80 {
    background-color: var(--kax-bg-card) !important;
    border-color: var(--kax-border) !important;
}

.bg-slate-800,
.bg-slate-800\/90,
.bg-slate-800\/80,
.bg-slate-800\/70,
.bg-slate-800\/60 {
    background-color: var(--kax-bg-card-alt) !important;
    border-color: var(--kax-border) !important;
}

.bg-slate-950,
.bg-slate-950\/90,
.bg-slate-950\/80,
.bg-slate-950\/60 {
    background-color: var(--kax-bg-input) !important;
    border-color: var(--kax-border) !important;
}

.border-slate-800,
.border-slate-700,
.border-slate-700\/80,
.border-slate-700\/60,
.border-slate-800\/80,
.border-slate-800\/60,
.border-slate-800\/50 {
    border-color: var(--kax-border) !important;
}

.divide-slate-800 > * + *,
.divide-slate-800\/80 > * + * {
    border-color: var(--kax-border-subtle) !important;
}

/* Inputs, Selects, and Textareas */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="search"],
input[type="email"],
select,
textarea {
    background-color: var(--kax-bg-input) !important;
    border-color: var(--kax-border) !important;
    color: var(--kax-text-main) !important;
}

input:focus, select:focus, textarea:focus {
    outline: none !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25) !important;
}

/* KBD & Badges */
.kbd-badge {
    background: var(--kax-kbd-bg) !important;
    border-color: var(--kax-border) !important;
    color: var(--kax-kbd-text) !important;
}

/* Navigation Tabs */
.tab-btn {
    background-color: var(--kax-tab-inactive-bg);
    color: var(--kax-tab-inactive-text);
    border-color: var(--kax-border);
}
.tab-btn.active {
    background-color: #2563eb !important;
    color: #ffffff !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3) !important;
}

/* Tables */
thead.bg-slate-900,
thead.bg-slate-800,
thead.bg-slate-800\/80 {
    background-color: var(--kax-bg-th) !important;
    border-color: var(--kax-border) !important;
    color: var(--kax-text-muted) !important;
}

tbody tr.hover\:bg-slate-800\/40:hover,
tbody tr.hover\:bg-slate-800\/30:hover {
    background-color: var(--kax-bg-card-alt) !important;
}

/* Modals */
.fixed.inset-0 .bg-slate-900,
.fixed.inset-0 .bg-slate-950 {
    box-shadow: var(--kax-modal-shadow);
}

/* =========================================================================
   COMPREHENSIVE LIGHT THEME COLOR & CONTRAST OVERRIDES
   ========================================================================= */

/* 1. Base Text Colors on Light Theme */
html[data-theme="light"] {
    --kax-text-main: #0f172a;
    --kax-text-title: #0f172a;
    --kax-text-secondary: #334155;
    --kax-text-muted: #64748b;
}

/* Heading & Content Text Overrides */
html[data-theme="light"] h1,
html[data-theme="light"] h2,
html[data-theme="light"] h3,
html[data-theme="light"] h4,
html[data-theme="light"] h5,
html[data-theme="light"] h6 {
    color: #0f172a !important;
}

html[data-theme="light"] .text-white:not(button.bg-blue-600 *):not(button.bg-blue-500 *):not(button.bg-sky-600 *):not(button.bg-emerald-600 *):not(button.bg-emerald-700 *):not(button.bg-rose-600 *):not(button.bg-gradient-to-r *):not(a.bg-blue-600 *):not(a.bg-emerald-600 *):not(span.bg-blue-600 *):not(span.bg-emerald-600 *):not(.bg-blue-600):not(.bg-blue-500):not(.bg-sky-600):not(.bg-emerald-600):not(.bg-emerald-700):not(.bg-rose-600) {
    color: #0f172a !important;
}

html[data-theme="light"] .text-slate-100,
html[data-theme="light"] .text-slate-200 {
    color: #1e293b !important;
}

html[data-theme="light"] .text-slate-300 {
    color: #334155 !important;
}

html[data-theme="light"] .text-slate-400 {
    color: #64748b !important;
}

html[data-theme="light"] .text-slate-500 {
    color: #64748b !important;
}

/* 2. Vibrant & High-Contrast Colors on Light Backgrounds */
/* Yellow / Gold / Amber -> Warm Deep Amber/Bronze */
html[data-theme="light"] .text-yellow-200,
html[data-theme="light"] .text-yellow-300,
html[data-theme="light"] .text-yellow-400,
html[data-theme="light"] .text-yellow-500,
html[data-theme="light"] .text-amber-200,
html[data-theme="light"] .text-amber-300,
html[data-theme="light"] .text-amber-400 {
    color: #b45309 !important;
}

/* Sky / Blue -> Deep Sky & Royal Blue */
html[data-theme="light"] .text-sky-200,
html[data-theme="light"] .text-sky-300,
html[data-theme="light"] .text-sky-400 {
    color: #0369a1 !important;
}

html[data-theme="light"] .text-blue-200,
html[data-theme="light"] .text-blue-300,
html[data-theme="light"] .text-blue-400 {
    color: #1d4ed8 !important;
}

/* Emerald / Green -> Rich Forest Emerald */
html[data-theme="light"] .text-emerald-200,
html[data-theme="light"] .text-emerald-300,
html[data-theme="light"] .text-emerald-400 {
    color: #047857 !important;
}

/* Rose / Red -> Deep Crimson Rose */
html[data-theme="light"] .text-rose-200,
html[data-theme="light"] .text-rose-300,
html[data-theme="light"] .text-rose-400,
html[data-theme="light"] .text-red-400 {
    color: #be123c !important;
}

/* Purple / Indigo */
html[data-theme="light"] .text-indigo-200,
html[data-theme="light"] .text-indigo-300,
html[data-theme="light"] .text-indigo-400 {
    color: #4338ca !important;
}

html[data-theme="light"] .text-purple-200,
html[data-theme="light"] .text-purple-300,
html[data-theme="light"] .text-purple-400 {
    color: #6b21a8 !important;
}

/* 3. Inputs, Textareas, Selects & Placeholders */
html[data-theme="light"] input[type="text"],
html[data-theme="light"] input[type="number"],
html[data-theme="light"] input[type="date"],
html[data-theme="light"] input[type="password"],
html[data-theme="light"] input[type="search"],
html[data-theme="light"] input[type="email"],
html[data-theme="light"] select,
html[data-theme="light"] textarea {
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
}

html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
}

/* Specific colored numeric inputs on Light theme */
html[data-theme="light"] input.text-emerald-300,
html[data-theme="light"] input.text-emerald-400 {
    color: #047857 !important;
}

html[data-theme="light"] input.text-yellow-300,
html[data-theme="light"] input.text-yellow-400,
html[data-theme="light"] input.text-amber-300,
html[data-theme="light"] input.text-amber-400 {
    color: #b45309 !important;
}

html[data-theme="light"] input.text-rose-300,
html[data-theme="light"] input.text-rose-400 {
    color: #be123c !important;
}

html[data-theme="light"] input.text-white {
    color: #0f172a !important;
}

/* Dropdown Options */
html[data-theme="light"] option {
    background-color: #ffffff !important;
    color: #0f172a !important;
}

/* 4. Badges, Chips & Status Pills (High Contrast Soft Backgrounds) */
html[data-theme="light"] .bg-amber-950,
html[data-theme="light"] .bg-amber-950\/40,
html[data-theme="light"] .bg-amber-950\/60,
html[data-theme="light"] .bg-amber-950\/80,
html[data-theme="light"] .bg-amber-950\/90,
html[data-theme="light"] .bg-amber-950\/30,
html[data-theme="light"] .bg-yellow-950,
html[data-theme="light"] .bg-yellow-950\/40,
html[data-theme="light"] .bg-yellow-950\/60,
html[data-theme="light"] .bg-yellow-950\/80 {
    background-color: #fef3c7 !important;
    border-color: #fcd34d !important;
    color: #92400e !important;
}

html[data-theme="light"] .bg-emerald-950,
html[data-theme="light"] .bg-emerald-950\/40,
html[data-theme="light"] .bg-emerald-950\/60,
html[data-theme="light"] .bg-emerald-950\/80,
html[data-theme="light"] .bg-emerald-950\/90,
html[data-theme="light"] .bg-emerald-950\/30 {
    background-color: #d1fae5 !important;
    border-color: #6ee7b7 !important;
    color: #065f46 !important;
}

html[data-theme="light"] .bg-sky-950,
html[data-theme="light"] .bg-sky-950\/40,
html[data-theme="light"] .bg-sky-950\/60,
html[data-theme="light"] .bg-sky-950\/80,
html[data-theme="light"] .bg-sky-950\/90 {
    background-color: #e0f2fe !important;
    border-color: #7dd3fc !important;
    color: #0369a1 !important;
}

html[data-theme="light"] .bg-blue-950,
html[data-theme="light"] .bg-blue-950\/40,
html[data-theme="light"] .bg-blue-950\/60,
html[data-theme="light"] .bg-blue-950\/80 {
    background-color: #dbeafe !important;
    border-color: #93c5fd !important;
    color: #1e40af !important;
}

html[data-theme="light"] .bg-rose-950,
html[data-theme="light"] .bg-rose-950\/40,
html[data-theme="light"] .bg-rose-950\/60,
html[data-theme="light"] .bg-rose-950\/80 {
    background-color: #ffe4e6 !important;
    border-color: #fda4af !important;
    color: #9f1239 !important;
}

html[data-theme="light"] .bg-purple-950,
html[data-theme="light"] .bg-purple-950\/40,
html[data-theme="light"] .bg-purple-950\/60,
html[data-theme="light"] .bg-purple-950\/80,
html[data-theme="light"] .bg-indigo-950 {
    background-color: #ede9fe !important;
    border-color: #c4b5fd !important;
    color: #5b21b6 !important;
}

html[data-theme="light"] .bg-slate-800,
html[data-theme="light"] .bg-slate-800\/80,
html[data-theme="light"] .bg-slate-800\/70,
html[data-theme="light"] .bg-slate-800\/60 {
    background-color: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #334155 !important;
}

/* Semi-transparent button & indicator highlights */
html[data-theme="light"] .bg-sky-500\/20,
html[data-theme="light"] .bg-sky-600\/20 {
    background-color: #e0f2fe !important;
    color: #0369a1 !important;
    border-color: #7dd3fc !important;
}

html[data-theme="light"] .bg-blue-500\/20,
html[data-theme="light"] .bg-blue-600\/20 {
    background-color: #dbeafe !important;
    color: #1d4ed8 !important;
    border-color: #93c5fd !important;
}

html[data-theme="light"] .bg-emerald-500\/20,
html[data-theme="light"] .bg-emerald-500\/30 {
    background-color: #d1fae5 !important;
    color: #047857 !important;
    border-color: #6ee7b7 !important;
}

html[data-theme="light"] .bg-amber-500\/20,
html[data-theme="light"] .bg-amber-500\/30 {
    background-color: #fef3c7 !important;
    color: #b45309 !important;
    border-color: #fcd34d !important;
}

html[data-theme="light"] .bg-purple-500\/20,
html[data-theme="light"] .bg-indigo-500\/20 {
    background-color: #ede9fe !important;
    color: #5b21b6 !important;
    border-color: #c4b5fd !important;
}

/* 5. Cart Items & Dynamic Previews on Light Theme */
html[data-theme="light"] #cartItemsList > div,
html[data-theme="light"] .bg-slate-950\/60 {
    background-color: #f8fafc !important;
    border-color: #e2e8f0 !important;
}

html[data-theme="light"] #fxPayoutPreview,
html[data-theme="light"] #goldPayoutPreview {
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
}

/* 6. Solid Accent Buttons Text Color Preservation */
html[data-theme="light"] .bg-blue-600,
html[data-theme="light"] .bg-blue-500,
html[data-theme="light"] .bg-sky-600,
html[data-theme="light"] .bg-emerald-600,
html[data-theme="light"] .bg-emerald-700,
html[data-theme="light"] .bg-rose-600 {
    color: #ffffff !important;
}
html[data-theme="light"] .bg-blue-600 *,
html[data-theme="light"] .bg-blue-500 *,
html[data-theme="light"] .bg-sky-600 *,
html[data-theme="light"] .bg-emerald-600 *,
html[data-theme="light"] .bg-emerald-700 *,
html[data-theme="light"] .bg-rose-600 * {
    color: #ffffff !important;
}

html[data-theme="light"] .bg-amber-500,
html[data-theme="light"] .bg-amber-400,
html[data-theme="light"] .bg-yellow-500,
html[data-theme="light"] .bg-yellow-400 {
    color: #0f172a !important;
}
html[data-theme="light"] .bg-amber-500 *,
html[data-theme="light"] .bg-amber-400 *,
html[data-theme="light"] .bg-yellow-500 *,
html[data-theme="light"] .bg-yellow-400 * {
    color: #0f172a !important;
}

/* 7. Modal Windows Backgrounds */
html[data-theme="light"] .fixed.inset-0 .bg-slate-900,
html[data-theme="light"] .fixed.inset-0 .bg-slate-950 {
    background-color: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}

/* Theme Selector Component */
.theme-selector-select {
    background-color: var(--kax-bg-input) !important;
    border: 1px solid var(--kax-border) !important;
    color: var(--kax-text-main) !important;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 0.75rem;
    padding: 0.35rem 1.75rem 0.35rem 0.6rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23eab308'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    background-size: 0.85rem;
    transition: all 0.15s ease;
}
.theme-selector-select:hover {
    border-color: #3b82f6 !important;
}
