/* Theme: font import, design tokens (:root), dark-mode tokens, theme-toggle states.
   Split from the former public/css/pos.css. Global: loaded first by layouts/app and partials/_auth_theme. */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

/* ==========================================================================
   THEME-AWARE IMAGE VISIBILITY
   Dark-variant images hidden by default; swap on data-theme="dark"
   ========================================================================== */

/* Always hide dark-variant images in light mode */
.theme-img-dark {
    display: none !important;
}

/* Loading screen: simple swap */
[data-theme="dark"] .loading-icon-wrapper .theme-img-dark {
    display: block !important;
}
[data-theme="dark"] .loading-icon-wrapper .theme-img-light {
    display: none !important;
}
[data-theme="dark"] .loading-container > .theme-img-dark {
    display: block !important;
}
[data-theme="dark"] .loading-container > .theme-img-light {
    display: none !important;
}

/* Sidebar open: show full logo only */
[data-theme="dark"]
    .sidebar:not(.closed)
    .sidebar-logo
    .theme-img-dark.sidebar-logo-full {
    display: block !important;
}
[data-theme="dark"]
    .sidebar:not(.closed)
    .sidebar-logo
    .theme-img-light.sidebar-logo-full {
    display: none !important;
}
[data-theme="dark"] .sidebar:not(.closed) .sidebar-logo .sidebar-logo-icon {
    display: none !important;
}

/* Sidebar closed: show icon only */
[data-theme="dark"]
    .sidebar.closed
    .sidebar-logo
    .theme-img-dark.sidebar-logo-icon {
    display: block !important;
    width: 50px;
    height: 50px;
    object-fit: contain;
}
[data-theme="dark"]
    .sidebar.closed
    .sidebar-logo
    .theme-img-light.sidebar-logo-icon {
    display: none !important;
}
[data-theme="dark"] .sidebar.closed .sidebar-logo .sidebar-logo-full {
    display: none !important;
}

/* ==========================================================================
   CSS VARIABLES & GLOBAL TOKENS
   ========================================================================== */
:root {
    /* Fonts */
    --bs-body-font-family: "Inter", sans-serif !important;
    --bs-font-sans-serif: "Inter", sans-serif !important;
    --font-family: "Inter", sans-serif;

    /* Theme colors */
    --primary-color: #0f4c81;
    --primary-hover: #0c3d68;
    --primary-light: #e8f1f8;
    --primary-light-border: #7fa7c6;
    --primary-light-alpha: rgba(15, 76, 129, 0.12);

    --success-color: #16a34a;
    --success-hover: #15803d;
    --success-light: #dcfce7;
    --success-bg: #f0fdf4;
    --success-dark: #276749;
    --success-light-alt: #c6f6d5;

    --warning-color: #ca8a04;
    --warning-hover: #a16207;
    --warning-light: #fef3c7;
    --warning-light-orange: #ffedd5;
    --warning-dark-orange: #ea580c;
    --warning-yellow: #fef9c3;
    --warning-orange-bg: #fed7aa;
    --warning-orange-text: #b45309;
    --gray-light-bg: #e8e8e8;
    --gray-color: #5a5a5a;

    --danger-color: #dc2626;
    --danger-hover: #b91c1c;
    --danger-light: #fee2e2;
    --danger-bg: #fff5f5;
    --danger-border: #fed7d7;
    --danger-border-light: #feb2b2;
    --danger-text-alt: #e53e3e;

    --purple-color: #7c3aed;
    --purple-light: #ede9fe;

    --blue-light-bg: #e8f1f8;

    /* Semantic grays */
    --bg-primary: #f1f5f9;
    --bg-secondary: #e8eef5;
    --bg-card: #fff;
    --bg-light: #f7fafc;
    --bg-hover: #fafafa;
    --border-color: #e2e8f0;
    --border-light: #dbe2ea;
    --border-medium: #e5e7eb;
    --border-dark: #cbd5e0;
    --border-darker: #d1d5db;
    --text-primary: #1a202c;
    --text-muted: #718096;
    --text-dark: #4a5568;
    --text-darker: #1f2937;
    --text-light: #94a3b8;
    --text-gray-light: #64748b;
    --text-gray-dark: #1f2937;
    --text-gray-title: #1f2937;

    /* Border Radii */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 10px;
    --radius-2xl: 12px;
    --radius-3xl: 14px;
    --radius-4xl: 16px;
    --radius-5xl: 18px;
    --radius-6xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 2px 10px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.18);
    --shadow-2xl: 0 18px 40px rgba(15, 23, 42, 0.14);
    --shadow-3xl:
        0 25px 50px rgba(0, 0, 0, 0.15), 0 10px 20px rgba(0, 0, 0, 0.08);
    --shadow-dialog: 0 24px 70px rgba(15, 23, 42, 0.24);

    /* Z-Index Scale */
    --z-base: 1;
    --z-sidebar: 10;
    --z-topbar: 20;
    --z-toast: 100;
    --z-modal-backdrop: 200;
    --z-modal: 9999;
    --z-tooltip: 10000000;
    --z-mobile-sidebar: 500;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.18s ease;
    --transition-medium: 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    --transition-slow: 0.3s ease;
    --transition-slower: 0.35s ease;

    /* Dropdown specific variables */
    --bg-dropdown: rgba(255, 255, 255, 0.93);
    --border-dropdown: rgba(226, 232, 240, 0.8);

    /* Chart specific variables */
    --chart-bg-start: #f8fbff;
    --chart-bg-end: var(--primary-light);
    --chart-border: #e8f1f8;

    /* Tooltip specific variables */
    --bg-tooltip: #1f2937;
    --text-tooltip: #ffffff;

    /* Toast specific variables */
    --bg-toast: #1a202c;
    --text-toast: #ffffff;

    --change-row: #f0fdf4;
}

/* ==========================================================================
   DARK MODE CUSTOMIZATIONS
   ========================================================================== */
[data-theme="dark"] {
    /* Primary Color Modifiers */
    --primary-color: #06b6d4;
    --primary-hover: #36c6e2;
    --primary-light: rgba(6, 182, 212, 0.15);
    --primary-light-border: #06b6d4;
    --primary-light-alpha: rgba(6, 182, 212, 0.2);

    /* Grays & Backgrounds */
    --bg-primary: #1f2937;
    --bg-secondary: #17212f;
    --bg-card: #243447;
    --bg-light: #1e293b;
    --bg-hover: #334155;
    --border-color: #334155;
    --border-light: #1e293b;
    --border-medium: #334155;
    --border-dark: #475569;
    --border-darker: #64748b;

    /* Text Scale */
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #cbd5e1;
    --text-darker: #f8fafc;
    --text-light: #64748b;
    --text-gray-light: #94a3b8;
    --text-gray-dark: #f8fafc;
    --text-gray-title: #f8fafc;

    /* Dropdowns specific overrides */
    --bg-dropdown: rgba(30, 41, 59, 0.95);
    --border-dropdown: rgba(51, 65, 85, 0.8);

    /* Alerts and status backgrounds */
    --success-bg: rgba(22, 163, 74, 0.1);
    --success-light: rgba(22, 163, 74, 0.2);
    --success-dark: #4ade80;

    --danger-bg: rgba(220, 38, 38, 0.1);
    --danger-light: rgba(220, 38, 38, 0.2);
    --danger-border: rgba(220, 38, 38, 0.3);

    --warning-light: rgba(202, 138, 4, 0.15);
    --warning-light-orange: rgba(234, 88, 12, 0.15);

    /* Chart specific variables */
    --chart-bg-start: #1e293b;
    --chart-bg-end: rgba(6, 182, 212, 0.05);
    --chart-border: var(--border-color);

    /* Tooltip specific variables */
    --bg-tooltip: #0f172a;
    --text-tooltip: #f8fafc;

    /* Toast specific variables */
    --bg-toast: #0f172a;
    --text-toast: #f8fafc;

    --change-row: #15191f;
}

/* Theme Toggle Button Layout & Animations */
.theme-toggle-btn {
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    overflow: hidden;
    position: relative;
    padding: 0;
}

.theme-toggle-btn:hover {
    background: var(--bg-light);
    border-color: var(--border-dark);
    color: var(--primary-color);
}

.theme-toggle-icon {
    position: relative;
    width: 18px;
    height: 18px;
    overflow: hidden;
}

.theme-toggle-icon i {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    will-change: transform, opacity;
    /* Fallback transition for initial theme restore (no animation class) */
    transition:
        opacity 0.15s ease,
        transform 0.15s ease;
}

/* ── REST STATES ──────────────────────────────────────────────── */
/* Light mode: Sun is active; Moon is parked above (ready to drop in on next click) */
html:not([data-theme="dark"]) .sun-icon {
    opacity: 1;
    transform: translateY(0) scale(1);
    color: #f59e0b;
}
html:not([data-theme="dark"]) .moon-icon {
    opacity: 0;
    transform: translateY(-22px) scale(0.75);
}

/* Dark mode: Moon is active; Sun is parked above (ready to drop in on next click) */
html[data-theme="dark"] .sun-icon {
    opacity: 0;
    transform: translateY(-22px) scale(0.75);
    color: #f59e0b;
}
html[data-theme="dark"] .moon-icon {
    opacity: 1;
    transform: translateY(0) scale(1);
    color: #c7d2fe;
}

/* ── KEYFRAMES ────────────────────────────────────────────────── */

/* Icon exits upward (sun leaves when going dark) */
@keyframes tt-exit-up {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    30% {
        opacity: 1;
        transform: translateY(-6px) scale(0.95);
    }
    100% {
        opacity: 0;
        transform: translateY(-24px) scale(0.7);
    }
}

/* Icon exits downward (moon leaves when going light) */
@keyframes tt-exit-down {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    30% {
        opacity: 1;
        transform: translateY(6px) scale(0.95);
    }
    100% {
        opacity: 0;
        transform: translateY(24px) scale(0.7);
    }
}

/* Icon enters from above with bounce (both sun and moon enter this way) */
@keyframes tt-enter-above {
    0% {
        opacity: 0;
        transform: translateY(-24px) scale(0.7);
    }
    55% {
        opacity: 1;
        transform: translateY(4px) scale(1.15);
    }
    75% {
        opacity: 1;
        transform: translateY(-2px) scale(0.97);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── ANIMATION UTILITY CLASSES (applied by JS) ─────────────────── */

.tt-exit-up {
    animation: tt-exit-up 0.32s cubic-bezier(0.4, 0, 0.6, 1) forwards !important;
    transition: none !important;
}

.tt-exit-down {
    animation: tt-exit-down 0.32s cubic-bezier(0.4, 0, 0.6, 1) forwards !important;
    transition: none !important;
}

.tt-enter-above {
    animation: tt-enter-above 0.44s cubic-bezier(0.34, 1.56, 0.64, 1) forwards !important;
    transition: none !important;
}

/* Smooth color transition when toggling themes */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
    transition:
        background-color 400ms cubic-bezier(0.4, 0, 0.2, 1),
        border-color 400ms cubic-bezier(0.4, 0, 0.2, 1),
        color 400ms cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 400ms cubic-bezier(0.4, 0, 0.2, 1),
        fill 400ms cubic-bezier(0.4, 0, 0.2, 1),
        stroke 400ms cubic-bezier(0.4, 0, 0.2, 1) !important;
}
