html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem;
}

/* MedClerk Global Design System - v1.0 */

:root {
    /* Color Palette */
    --deep-blue: #020617;
    --slate-950: #020617;
    --slate-900: #0f172a;
    --slate-800: #1e293b;

    --neon-sky: #38bdf8;
    --neon-sky-light: #2563eb;
    /* High Contrast for Light Mode */
    --indigo-glow: #6366f1;
    --clinical-accent: #3b82f6;
    --neon-cyan: #22d3ee;

    /* Glass Tokens */
    --glass-bg: rgba(15, 23, 42, 0.3);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.8);
}

/* Shared Resets & Base Styles */
body {
    background: var(--deep-blue);
    color: #f8fafc;
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

/* Universal Base Classes */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    transition:
        background-color 0.6s cubic-bezier(0.16, 1, 0.3, 1),
        border-color 0.6s cubic-bezier(0.16, 1, 0.3, 1),
        box-shadow 0.6s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    transform: translateZ(0);
    backface-visibility: hidden;
    will-change: transform, box-shadow;
}

.glass-card:hover {
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: 0 60px 120px -20px rgba(0, 0, 0, 0.8), 0 0 40px rgba(56, 189, 248, 0.05);
}

/* Background Systems */
.bg-mesh {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.15) 0, transparent 50%),
        radial-gradient(at 100% 0%, rgba(99, 102, 241, 0.15) 0, transparent 50%),
        radial-gradient(at 100% 100%, rgba(56, 189, 248, 0.1) 0, transparent 50%),
        radial-gradient(at 0% 100%, rgba(99, 102, 241, 0.1) 0, transparent 50%);
    filter: blur(100px);
    z-index: -2;
    pointer-events: none;
    animation: mesh-flow 25s ease-in-out infinite alternate;
    will-change: transform;
}

.bg-grid-pattern {
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: -1;
    pointer-events: none;
}

/* Shared Keyframes */
@keyframes mesh-flow {
    0% {
        transform: scale(1) translate(0, 0);
    }

    100% {
        transform: scale(1.1) translate(20px, 20px);
    }
}

@keyframes float-anim {

    0%,
    100% {
        transform: translateY(0px) rotate(0deg);
    }

    50% {
        transform: translateY(-15px) rotate(2deg);
    }
}

@keyframes pulse-slow {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(1) translate(-50%, 0);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.1) translate(-50%, 0);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.2);
    border-radius: 10px;
    transition: all 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(56, 189, 248, 0.5);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

/* =========================================
   LIGHT MODE: BROAD TAILWIND CLASS TARGETING
   ========================================= */
/* 1. Global Light Background */
html.light-mode body {
    background: #f8fafc !important;
    /* slate-50 */
    color: #0f172a !important;
    /* slate-900 */
}

/* 2. Text Colors */
/* Turn anything trying to be white into dark slate */
html.light-mode [class*="text-white"],
html.light-mode [class*="text-slate-50"],
html.light-mode [class*="text-slate-100"],
html.light-mode [class*="text-slate-200"],
html.light-mode [class*="text-slate-300"] {
    color: #1e293b !important;
    /* slate-800 */
}

/* Turn medium grays into darker grays for contrast */
html.light-mode [class*="text-slate-400"],
html.light-mode [class*="text-slate-500"] {
    color: #475569 !important;
    /* slate-600 */
}

/* Keep colored accents vibrant (buttons, highlights) */
html.light-mode [class*="text-sky-300"],
html.light-mode [class*="text-sky-400"],
html.light-mode [class*="text-sky-500"],
html.light-mode [class*="text-blue-400"],
html.light-mode [class*="text-blue-500"],
html.light-mode .text-sky-400,
html.light-mode .text-blue-400 {
    color: #2563eb !important;
    /* Electric Royal - Approved High Contrast */
}

html.light-mode [class*="text-amber-300"],
html.light-mode [class*="text-amber-400"],
html.light-mode [class*="text-amber-500"] {
    color: #d97706 !important;
    /* amber-600 */
}

html.light-mode [class*="text-emerald-300"],
html.light-mode [class*="text-emerald-400"],
html.light-mode [class*="text-emerald-500"] {
    color: #059669 !important;
    /* emerald-600 */
}

html.light-mode [class*="text-rose-300"],
html.light-mode [class*="text-rose-400"],
html.light-mode [class*="text-rose-500"] {
    color: #e11d48 !important;
    /* rose-600 */
}

html.light-mode [class*="text-indigo-300"],
html.light-mode [class*="text-indigo-400"],
html.light-mode [class*="text-indigo-500"] {
    color: #4f46e5 !important;
    /* indigo-600 */
}

html.light-mode [class*="text-red-300"],
html.light-mode [class*="text-red-400"],
html.light-mode [class*="text-red-500"] {
    color: #dc2626 !important;
    /* red-600 */
}

html.light-mode [class*="text-purple-300"],
html.light-mode [class*="text-purple-400"],
html.light-mode [class*="text-purple-500"] {
    color: #9333ea !important;
    /* purple-600 */
}

/* Dashboard stat card icons: force dark in light mode for consistency */
html.light-mode .analytics-btn svg,
html.light-mode .analytics-btn [data-lucide] {
    color: #1e293b !important;
    stroke: currentColor !important;
}

/* BUT restore pure white text inside colored action buttons */
html.light-mode [class*="bg-sky-"] [class*="text-white"],
html.light-mode [class*="bg-blue-"] [class*="text-white"],
html.light-mode [class*="bg-indigo-"] [class*="text-white"],
html.light-mode [class*="bg-emerald-"] [class*="text-white"],
html.light-mode [class*="bg-green-"] [class*="text-white"],
html.light-mode [class*="bg-amber-"] [class*="text-white"],
html.light-mode [class*="bg-rose-"] [class*="text-white"],
html.light-mode [class*="bg-red-"] [class*="text-white"] {
    color: #ffffff !important;
}

/* 3. Dark Backgrounds */
/* Turn dark slate into bright whites/light grays */
html.light-mode [class*="bg-slate-900"],
html.light-mode [class*="bg-slate-950"],
html.light-mode [class*="bg-[#0f172a]"] {
    background-color: rgba(255, 255, 255, 0.95) !important;
}

html.light-mode [class*="bg-slate-800"] {
    background-color: rgba(241, 245, 249, 0.95) !important;
    /* slate-100 */
}

html.light-mode [class*="bg-slate-700"] {
    background-color: rgba(226, 232, 240, 0.95) !important;
    /* slate-200 */
}

/* 4. Translucents (Overlays, Hover effects) */
html.light-mode [class*="bg-white/5"] {
    background-color: rgba(0, 0, 0, 0.03) !important;
}

html.light-mode [class*="bg-white/10"] {
    background-color: rgba(0, 0, 0, 0.06) !important;
}

html.light-mode [class*="bg-white/20"] {
    background-color: rgba(0, 0, 0, 0.08) !important;
}

html.light-mode [class*="bg-black/20"] {
    background-color: rgba(0, 0, 0, 0.04) !important;
}

html.light-mode [class*="bg-black/40"] {
    background-color: rgba(0, 0, 0, 0.06) !important;
}

html.light-mode [class*="hover:bg-white/5"]:hover {
    background-color: rgba(0, 0, 0, 0.05) !important;
}

html.light-mode [class*="hover:bg-white/10"]:hover {
    background-color: rgba(0, 0, 0, 0.08) !important;
}

html.light-mode [class*="hover:bg-white/20"]:hover {
    background-color: rgba(0, 0, 0, 0.1) !important;
}

html.light-mode [class*="hover:bg-black/40"]:hover {
    background-color: rgba(0, 0, 0, 0.08) !important;
}

/* 5. Borders and Dividers */
html.light-mode [class*="border-white"] {
    border-color: rgba(0, 0, 0, 0.08) !important;
}

html.light-mode [class*="border-slate-700"],
html.light-mode [class*="border-slate-800"] {
    border-color: rgba(0, 0, 0, 0.12) !important;
}

html.light-mode [class*="divide-white"]> :not([hidden])~ :not([hidden]),
html.light-mode [class*="divide-slate-"]> :not([hidden])~ :not([hidden]) {
    border-color: rgba(0, 0, 0, 0.08) !important;
}

/* 6. Fix specific Glass Tokens */
html.light-mode .glass-card {
    background: rgba(255, 255, 255, 0.85) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05) !important;
}

html.light-mode .glass-card:hover {
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.1), 0 0 20px rgba(56, 189, 248, 0.1) !important;
}

/* 7. Forms & Inputs (Light Mode Glassmorphism) */
html.light-mode .glass-input-wrapper,
html.light-mode .form-control-glass {
    background: rgba(255, 255, 255, 0.6) !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
    color: #1e293b !important;
    /* text-slate-800 */
}

html.light-mode .form-control-glass:focus {
    border-color: #2563eb !important;
    /* Approved Electric Royal */
    box-shadow: 0 0 0 1px #2563eb !important;
}

html.light-mode .form-control-glass::placeholder,
html.light-mode input::placeholder,
html.light-mode textarea::placeholder {
    color: #9ca3af !important;
    /* text-slate-400 */
    opacity: 1 !important;
}

/* 8. TomSelect Global Colors */
/* Default (Dark Mode) - Typing text must be white */
.ts-control>input {
    color: #ffffff !important;
}

/* Light Mode - Typing text must be dark slate */
html.light-mode .ts-control>input {
    color: #1e293b !important;
}

/* Safety: Force light background on focus in Light Mode */
html.light-mode .ts-wrapper.focus .ts-control,
html.light-mode .glass-input:focus,
html.light-mode input:focus {
    background: rgba(255, 255, 255, 0.95) !important;
    color: #1e293b !important;
}

html.light-mode .ts-control>input::placeholder {
    color: #9ca3af !important;
}

html.light-mode .form-label {
    color: #475569 !important;
    /* text-slate-600 */
}

/* Dropdown native options */
html.light-mode .form-control-glass option {
    background-color: #ffffff !important;
    color: #1e293b !important;
}

/* 8. TomSelect Overrides for Light Mode */
html.light-mode .ts-control.single .ts-input,
html.light-mode .ts-control input {
    color: #1e293b !important;
}

html.light-mode .ts-control input::placeholder {
    color: #9ca3af !important;
}

html.light-mode .ts-dropdown {
    background-color: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    color: #1e293b !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1) !important;
}

html.light-mode .ts-dropdown .option {
    color: #475569 !important;
    /* slate-600 */
}

html.light-mode .ts-dropdown .option:hover,
html.light-mode .ts-dropdown .active {
    background-color: rgba(56, 189, 248, 0.15) !important;
    color: #0284c7 !important;
    /* sky-600 */
}

html.light-mode .neon-accent-rose {
    color: #FF3366 !important;
    filter: drop-shadow(0 0 4px rgba(255, 51, 102, 0.4));
}

/* 10. Interactive Button Hover System (Light Mode) */
/* Primary Buttons (Sky/Blue) */
html.light-mode button[class*="bg-sky-"],
html.light-mode button[class*="bg-blue-"],
html.light-mode .btn-primary {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

html.light-mode button[class*="bg-sky-"]:hover,
html.light-mode button[class*="bg-blue-"]:hover,
html.light-mode .btn-primary:hover {
    background-color: #1d4ed8 !important;
    /* Deeper Blue */
    transform: translateY(-2px) scale(1.02) !important;
    box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.4) !important;
}

/* Secondary / Translucent Buttons */
html.light-mode button[class*="bg-white/10"],
html.light-mode .btn-secondary {
    background-color: rgba(0, 0, 0, 0.05) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    color: #1e293b !important;
    transition: all 0.3s ease !important;
}

html.light-mode button[class*="bg-white/10"]:hover,
html.light-mode .btn-secondary:hover {
    background-color: rgba(0, 0, 0, 0.08) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05) !important;
}

/* Hover Scale Utility */
html.light-mode [class*="hover:scale-"] {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

/* Active / Pressed States */
html.light-mode button:active {
    transform: translateY(0px) scale(0.98) !important;
    transition: all 0.1s ease !important;
}