/* Light/Dark appearance for the public frontend.
   Light mode keeps the original stylesheets untouched; dark mode only re-maps design tokens and overrides
   the few hard-coded light colors. Loaded last in layouts/public.blade.php.
   Brand colors (--kc-blue, --kc-orange, --kc-red) stay fixed by client request. */

/* ---------- Appearance controls (both themes) ---------- */
.kc-theme-toggle {
    width: 40px;
    padding: 0;
}

.kc-theme-toggle:hover,
.kc-theme-menu[open] .kc-theme-toggle {
    color: var(--kc-blue);
    border-color: var(--kc-blue);
}

.kc-theme-icon {
    display: none;
}

.kc-theme-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

html:not([data-theme="dark"]) .kc-theme-icon[data-theme-icon="light"],
html[data-theme="dark"] .kc-theme-icon[data-theme-icon="dark"] {
    display: flex;
}

.kc-theme-links {
    width: 184px;
}

.kc-account-links .kc-theme-option {
    display: flex;
    align-items: center;
    gap: 10px;
}

.kc-theme-option svg {
    width: 17px;
    height: 17px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.kc-account-links .kc-theme-option[aria-pressed="true"] {
    color: var(--kc-blue);
    font-weight: 700;
}

.kc-theme-links .kc-theme-option[aria-pressed="true"]::after {
    content: '';
    width: 7px;
    height: 7px;
    margin-left: auto;
    border-radius: 50%;
    background: currentColor;
}

/* Mobile Account sheet: segmented System / Light / Dark control. */
.kc-theme-segment {
    margin-top: 6px;
    padding: 10px 4px 4px;
    border-top: 1px solid var(--border);
}

.kc-theme-segment-label {
    display: block;
    padding: 0 8px 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-soft);
}

.kc-theme-segment-options {
    display: flex;
    gap: 4px;
    padding: 3px;
    border-radius: 12px;
    background: var(--surface);
}

.kc-account-links .kc-theme-segment-options .kc-theme-option {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-height: 52px;
    padding: 8px 4px;
    border-radius: 9px;
    font-size: 12px;
    text-align: center;
}

.kc-account-links .kc-theme-segment-options .kc-theme-option:hover {
    background: transparent;
}

.kc-account-links .kc-theme-segment-options .kc-theme-option[aria-pressed="true"] {
    background: var(--surface-card);
    box-shadow: var(--shadow-card);
}

html[data-theme="light"] {
    color-scheme: light;
}

/* ---------- Dark theme (screen only: printing always uses the light palette) ---------- */
@media screen {
    html[data-theme="dark"] {
        color-scheme: dark;
        --kc-blue-tint: #1a2a4a;
        --kc-orange-tint: #3a2216;
        --kc-red-tint: #3d1d24;
        --kc-success: #3ccf95;
        --kc-success-tint: #13322b;
        --ink: #e9edf6;
        --ink-soft: #aeb7cb;
        --ink-faint: #8a94ac;
        --surface: #0e1424;
        --surface-card: #161e31;
        --border: #263048;
        --border-strong: #34405c;
        --overlay: rgba(2, 6, 16, .66);
        --shadow-card: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 20px -14px rgba(0, 0, 0, .7);
        --shadow-float: 0 14px 32px -10px rgba(0, 0, 0, .65);
        --shadow-frame: 0 24px 55px -22px rgba(0, 0, 0, .7), 0 2px 10px rgba(0, 0, 0, .35);
    }

    html[data-theme="dark"] body {
        background: #0a0f1b;
    }

    /* Large brand surface: same hue, lower luminance to avoid glare. */
    html[data-theme="dark"] .kc-page-home .kc-hero-wrap {
        background: var(--surface-card);
        --home-ink: #9cc4ff;
        --ink: var(--home-ink);
        --ink-soft: var(--home-ink);
        --ink-faint: var(--home-ink);
    }

    html[data-theme="dark"] .kc-page-home .kc-searchbar,
    html[data-theme="dark"] .kc-skip-link {
        background: var(--surface-card);
    }

    html[data-theme="dark"] #search-warnings:not(:empty) {
        background: #33270f;
        color: #f6cf86;
    }

    html[data-theme="dark"] .coupon-skeleton-image,
    html[data-theme="dark"] .coupon-skeleton .kc-coupon-card-body>span,
    html[data-theme="dark"] .my-car-shimmer {
        background: linear-gradient(90deg, #1b2438 25%, #243049 50%, #1b2438 75%);
        background-size: 200% 100%;
    }

    html[data-theme="dark"] .coupon-code {
        background: #16284a;
        border-color: #3d63a3;
        color: #a9c8ff;
    }

    html[data-theme="dark"] .kc-page-coupon .kc-coupon-card-expiry {
        background: #3a2a14;
        color: #f5b56d;
    }

    html[data-theme="dark"] .car-sold-badge {
        background: #44202a;
        color: #fca5a5;
    }

    html[data-theme="dark"] img.kc-image-fallback {
        background: #1b2540;
    }

    html[data-theme="dark"] .kc-notice {
        --notice-ink: #fda29b;
        --notice-border: #7a2e26;
        --notice-bg: #2d1519;
    }

    html[data-theme="dark"] .kc-notice[data-tone="success"] {
        --notice-ink: #75e0a7;
        --notice-border: #17573c;
        --notice-bg: #102a20;
    }

    html[data-theme="dark"] .kc-notice[data-tone="info"] {
        --notice-ink: #a4c7ff;
        --notice-border: #284f8f;
        --notice-bg: #142440;
    }

    html[data-theme="dark"] .kc-field-error {
        color: #fda29b;
    }

    html[data-theme="dark"] .kc-input[aria-invalid="true"],
    html[data-theme="dark"] .kc-select[aria-invalid="true"] {
        border-color: #f97066;
        box-shadow: 0 0 0 3px rgba(249, 112, 102, .22);
    }

    html[data-theme="dark"] .public-page-body blockquote {
        border-left-color: var(--border-strong);
    }

    html[data-theme="dark"] .public-page-body hr {
        border-top-color: var(--border-strong);
    }

    html[data-theme="dark"] .kc-feedback-toast,
    html[data-theme="dark"] #coupon-detail {
        box-shadow: 0 22px 60px rgba(0, 0, 0, .6);
    }
}
