/* ==========================================================================
   Crystal Connect - Complete Centralized Theme & Dark Mode Utility CSS
   ========================================================================== */

:root {
    /* ── Store Theme Base Palette Variables (Teal Classic Default) ── */
    --teal: #196766;
    --deep: #0c2d30;
    --deep-2: #071e20;
    --teal-accent: #2ab5ab;
    --teal-accent-rgb: 42, 181, 171;
    --gold: #d4a34b;
    --gold-rgb: 212, 163, 75;
    --teal-light: #e6f3f2;

    /* ── Surface, Background & Ink Variables ── */
    --paper: #ffffff;
    --white: #ffffff;
    --ink: #0f172a;
    --muted: #64748b;
    --line: rgba(0, 0, 0, 0.08);

    /* ── Semantic System Variables ── */
    --bg-main: #f8fafb;
    --bg-card: #ffffff;
    --bg-header: rgba(252, 251, 250, 0.95);
    --bg-topbar: var(--deep-2);
    --bg-footer: #0d282b;
    --bg-input: #ffffff;
    --bg-modal: #ffffff;

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-heading: #0f172a;
    --border-color: rgba(0, 0, 0, 0.08);

    /* ── Button Variables ── */
    --btn-primary-bg: var(--teal);
    --btn-primary-text: #ffffff;
    --btn-primary-hover: var(--deep);
    --btn-secondary-bg: var(--teal-light);
    --btn-secondary-text: var(--teal);

    /* ── Common Header System Variables ── */
    --header-ink: var(--ink);
    --header-muted: var(--muted);
    --header-deep: var(--deep);
    --header-deep-2: var(--deep-2);
    --header-teal: var(--teal);
    --header-teal-light: var(--teal-light);
    --header-teal-accent: var(--teal-accent);
    --header-line: var(--line);
    --header-white: var(--paper);
}

/* ==========================================================================
   ACTUAL DARK MODE THEME OVERRIDES ([data-theme-mode="dark"])
   ========================================================================== */
[data-theme-mode="dark"] {
    --paper: #162022;
    --white: #1b2628;
    --ink: #f1f5f9;
    --muted: #94a3b8;
    --line: rgba(255, 255, 255, 0.12);

    --bg-main: #0b1214;
    --bg-card: #151e20;
    --bg-header: rgba(18, 27, 29, 0.96);
    --bg-topbar: #080e10;
    --bg-footer: #080e10;
    --bg-input: #1f2b2e;
    --bg-modal: #151e20;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-heading: #ffffff;
    --border-color: rgba(255, 255, 255, 0.12);

    --btn-primary-bg: var(--teal-accent);
    --btn-primary-text: #071e20;
    --btn-primary-hover: #ffffff;
    --btn-secondary-bg: #223235;
    --btn-secondary-text: #87d6cd;

    --header-ink: #f1f5f9;
    --header-muted: #94a3b8;
    --header-deep: #151e20;
    --header-deep-2: #080e10;
    --header-teal: var(--teal-accent);
    --header-teal-light: #223235;
    --header-teal-accent: #2ab5ab;
    --header-line: rgba(255, 255, 255, 0.12);
    --header-white: #151e20;
}

/* ── Global Body & Backgrounds ── */
[data-theme-mode="dark"] body,
[data-theme-mode="dark"] html,
[data-theme-mode="dark"] main,
[data-theme-mode="dark"] #pageContent {
    background-color: var(--bg-main) !important;
    color: var(--text-primary) !important;
}

/* ── Header & Navigation ── */
[data-theme-mode="dark"] .header,
[data-theme-mode="dark"] header {
    background: var(--bg-header) !important;
    border-bottom-color: var(--border-color) !important;
}

[data-theme-mode="dark"] .topbar {
    background: var(--bg-topbar) !important;
    border-bottom-color: var(--border-color) !important;
    color: #cbd5e1 !important;
}

[data-theme-mode="dark"] .brand span strong {
    color: #ffffff !important;
}

[data-theme-mode="dark"] .brand img {
    background: #1b2628 !important;
    border-color: var(--border-color) !important;
}

[data-theme-mode="dark"] .profile-menu,
[data-theme-mode="dark"] .profile-dropdown,
[data-theme-mode="dark"] .mobile-menu {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5) !important;
}

[data-theme-mode="dark"] .profile-dropdown-item {
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .profile-dropdown-item:hover {
    background-color: #223235 !important;
    color: var(--teal-accent) !important;
}

/* ── Headings & Typography ── */
[data-theme-mode="dark"] h1,
[data-theme-mode="dark"] h2,
[data-theme-mode="dark"] h3,
[data-theme-mode="dark"] h4,
[data-theme-mode="dark"] h5,
[data-theme-mode="dark"] h6,
[data-theme-mode="dark"] .text-dark,
[data-theme-mode="dark"] .merchant-name,
[data-theme-mode="dark"] .product-title,
[data-theme-mode="dark"] .section-title {
    color: var(--text-heading) !important;
}

[data-theme-mode="dark"] p,
[data-theme-mode="dark"] span:not(.badge):not(.btn),
[data-theme-mode="dark"] label,
[data-theme-mode="dark"] .text-muted,
[data-theme-mode="dark"] .product-desc,
[data-theme-mode="dark"] .merchant-tagline {
    color: var(--text-secondary) !important;
}

/* ── Cards & Containers ── */
[data-theme-mode="dark"] .bg-white,
[data-theme-mode="dark"] .card,
[data-theme-mode="dark"] .merchant-card,
[data-theme-mode="dark"] .product-card,
[data-theme-mode="dark"] .domain-card,
[data-theme-mode="dark"] .principle-card,
[data-theme-mode="dark"] .checkout-box,
[data-theme-mode="dark"] .checkout-card,
[data-theme-mode="dark"] .city-stat,
[data-theme-mode="dark"] .cart-drawer,
[data-theme-mode="dark"] .modal-content,
[data-theme-mode="dark"] .filter-sidebar,
[data-theme-mode="dark"] .category-pill {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

[data-theme-mode="dark"] .merchant-card:hover,
[data-theme-mode="dark"] .product-card:hover,
[data-theme-mode="dark"] .domain-card:hover {
    border-color: var(--teal-accent) !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4) !important;
}

/* ── Form Controls & Inputs ── */
[data-theme-mode="dark"] input:not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]),
[data-theme-mode="dark"] select,
[data-theme-mode="dark"] textarea,
[data-theme-mode="dark"] .form-control,
[data-theme-mode="dark"] .form-select,
[data-theme-mode="dark"] .hero-field input,
[data-theme-mode="dark"] .search-box input,
[data-theme-mode="dark"] .branch-select-dropdown,
[data-theme-mode="dark"] .biz-input {
    background-color: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

[data-theme-mode="dark"] input::placeholder,
[data-theme-mode="dark"] textarea::placeholder {
    color: #64748b !important;
}

[data-theme-mode="dark"] input:focus,
[data-theme-mode="dark"] select:focus,
[data-theme-mode="dark"] textarea:focus {
    border-color: var(--teal-accent) !important;
    box-shadow: 0 0 0 3px rgba(42, 181, 171, 0.25) !important;
}

/* ── Buttons ── */
[data-theme-mode="dark"] .primary-btn,
[data-theme-mode="dark"] .btn-theme,
[data-theme-mode="dark"] .btn-primary {
    background-color: var(--teal-accent) !important;
    color: #071e20 !important;
    border-color: var(--teal-accent) !important;
    font-weight: 700 !important;
}

[data-theme-mode="dark"] .primary-btn:hover,
[data-theme-mode="dark"] .btn-theme:hover,
[data-theme-mode="dark"] .btn-primary:hover {
    background-color: #ffffff !important;
    color: #071e20 !important;
}

[data-theme-mode="dark"] .btn-secondary,
[data-theme-mode="dark"] .btn-outline-secondary,
[data-theme-mode="dark"] .cart-btn,
[data-theme-mode="dark"] .back-to-market,
[data-theme-mode="dark"] .icon-btn {
    background-color: #1e2b2e !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

[data-theme-mode="dark"] .btn-secondary:hover,
[data-theme-mode="dark"] .cart-btn:hover,
[data-theme-mode="dark"] .back-to-market:hover {
    background-color: #26363a !important;
    color: var(--teal-accent) !important;
}

/* ── Footer ── */
[data-theme-mode="dark"] .footer,
[data-theme-mode="dark"] footer {
    background-color: var(--bg-footer) !important;
    border-top-color: var(--border-color) !important;
    color: #94a3b8 !important;
}

[data-theme-mode="dark"] .footer-col h4 {
    color: #ffffff !important;
}

[data-theme-mode="dark"] .footer-links a,
[data-theme-mode="dark"] .footer-bottom {
    color: #94a3b8 !important;
}

[data-theme-mode="dark"] .footer-links a:hover {
    color: var(--gold) !important;
}

/* ── Modals & Popups ── */
[data-theme-mode="dark"] .modal-header,
[data-theme-mode="dark"] .modal-footer {
    border-color: var(--border-color) !important;
}

[data-theme-mode="dark"] .swal2-popup {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

/* ── Store Theme & Mode Picker Bar ── */
.theme-picker {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.theme-picker-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.theme-picker-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.theme-picker-label {
    font-size: 11.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.theme-picker-dots {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.theme-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 1px var(--line), 0 2px 4px rgba(0,0,0,0.1);
    padding: 0;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
    position: relative;
}

.theme-dot:hover {
    transform: scale(1.18);
}

.theme-dot.active {
    box-shadow: 0 0 0 1px var(--line), 0 0 0 2px white, 0 0 0 4px var(--teal);
    transform: scale(1.12);
}

.theme-mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 99px;
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink);
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.theme-mode-btn:hover {
    background: var(--teal-light);
    color: var(--teal);
    border-color: var(--teal-accent);
}

[data-theme-mode="dark"] .theme-mode-btn {
    background: #1e292b !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: #ffd166 !important;
}

[data-theme-mode="dark"] .theme-mode-btn:hover {
    background: #273639 !important;
    border-color: #ffd166 !important;
}
