/* ========== Ditasol Lab — theme mapping layer ==========
   Loaded LAST in every layout so it wins. It does NOT invent colours:
   it maps the legacy variable names the older stylesheets use
   (--bg, --card, --text-primary, --border, --light, --dark, --shadow…)
   onto the semantic Design C tokens in apple-tokens.css, which is
   loaded FIRST. Dark values therefore come from the tokens, not from
   hex written here. Toggle behaviour lives in assets/js/theme.js
   (localStorage 'ditasol-theme', data-theme on <html>). Dark is warm
   charcoal #1E1B18 with warm dark-grey cards #2E2A25 — never navy,
   never pure black, teal accent kept bright (#2BC5B4). */

:root {
    color-scheme: light;
    /* Legacy names → HIG tokens (light). */
    --light: var(--bg-grouped);
    --dark: var(--label);
    --border: var(--separator);
    --bg: var(--bg-grouped);
    --card: var(--bg-cell);
    --text-primary: var(--label);
    --text-secondary: var(--text-secondary);
    --success-bg: var(--tint-green-bg);
    --pending-bg: var(--tint-orange-bg);
    --info-bg: var(--tint-blue-bg);
    --purple-bg: var(--tint-purple-bg);
    --orange-bg: var(--tint-orange-bg);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 8px 20px rgba(0, 0, 0, 0.10);
}

html[data-theme="dark"] {
    color-scheme: dark;
    /* Same names, dark token values (warm charcoal base #1E1B18, cards
       #2E2A25 — never pure black, never navy). */
    --light: var(--bg-grouped);
    --dark: var(--label);
    --border: var(--separator);
    --bg: var(--bg-grouped);
    --card: var(--bg-cell);
    --text-primary: var(--label);
    --text-secondary: var(--text-secondary);
    --success-bg: var(--tint-green-bg);
    --pending-bg: var(--tint-orange-bg);
    --info-bg: var(--tint-blue-bg);
    --purple-bg: var(--tint-purple-bg);
    --orange-bg: var(--tint-orange-bg);
    /* Dark elevation is a LIGHTER surface + hairline, not a shadow
       (report §4: a black shadow on black is invisible). */
    --shadow: none;
    --shadow-hover: none;
}

/* ---- Theme toggle: bare icon only, no box (real moon/sun icon) ---- */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: transform 120ms var(--ease-apple-fluid), background-color 150ms var(--ease-apple-fluid),
        color 150ms var(--ease-apple-fluid);
}

.theme-toggle:hover {
    background: var(--fill-3, rgba(128, 128, 128, 0.14));
    color: var(--label);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.theme-toggle svg {
    flex: none;
    width: 20px;
    height: 20px;
}

/* Auth screens have no header, so the toggle sits above the card. */
.auth-theme-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
}

/* ---- Surfaces that still use hardcoded colours in older stylesheets ---- */
html[data-theme="dark"] body {
    background: var(--bg);
    color: var(--text-primary);
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .header-main,
html[data-theme="dark"] .feature-card,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .user-header,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .list-item,
html[data-theme="dark"] .booking-card,
html[data-theme="dark"] .notification-item,
html[data-theme="dark"] .wallet-header {
    background: var(--card);
    border-color: var(--border);
    color: var(--text-primary);
}

html[data-theme="dark"] .testimonial {
    background: var(--card);
    color: var(--text-primary);
}

html[data-theme="dark"] .testimonial .quote,
html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .auth-card .text-muted,
html[data-theme="dark"] .auth-card small,
html[data-theme="dark"] .stat-label {
    color: var(--text-secondary);
}

html[data-theme="dark"] .footer-main {
    color: var(--text-secondary);
}

html[data-theme="dark"] .auth-body {
    background: var(--bg);
}

html[data-theme="dark"] .auth-card h2,
html[data-theme="dark"] .auth-card h3,
html[data-theme="dark"] .auth-card .form-label,
html[data-theme="dark"] .section-title,
html[data-theme="dark"] .user-header h1,
html[data-theme="dark"] .header-tagline,
html[data-theme="dark"] .doctor-header-title,
html[data-theme="dark"] .user-header-title,
html[data-theme="dark"] .stat-value,
html[data-theme="dark"] .drawer-close {
    color: var(--text-primary);
}

/* Forms: inputs, selects and textareas must not stay white-on-white. */
html[data-theme="dark"] .form-control,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background: var(--card);
    color: var(--text-primary);
    border-color: var(--border);
}

/* Placeholder text must stay readable in dark too: --text-secondary
   (7.01:1 on card), never label-3. */
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: var(--text-secondary);
}

/* Tables */
html[data-theme="dark"] table {
    color: var(--text-primary);
}

html[data-theme="dark"] .table th,
html[data-theme="dark"] .table td,
html[data-theme="dark"] table th,
html[data-theme="dark"] table td {
    border-color: var(--border);
}

/* Flash / status messages */
html[data-theme="dark"] .flash-error,
html[data-theme="dark"] .auth-flash-error {
    background: var(--tint-red-bg);
    border-color: var(--separator-opaque);
    color: var(--text-red);
}

html[data-theme="dark"] .flash-success,
html[data-theme="dark"] .auth-flash-success {
    background: var(--tint-green-bg);
    border-color: var(--separator-opaque);
    color: var(--text-green);
}

html[data-theme="dark"] .flash-info {
    background: var(--tint-blue-bg);
    border-color: var(--separator-opaque);
    color: var(--link);
}

/* Dashboard chrome (mostly token-driven already) */
html[data-theme="dark"] .user-main {
    background: var(--bg);
}

html[data-theme="dark"] .user-sidebar {
    background: var(--bg-cell);
}

html[data-theme="dark"] .user-nav a.active {
    background: var(--fill-2);
}

html[data-theme="dark"] .user-bottom-nav {
    background: var(--card);
    border-color: var(--border);
}

html[data-theme="dark"] .bottom-nav-item {
    color: var(--text-secondary);
}

html[data-theme="dark"] .bottom-nav-item.active {
    color: var(--accent);
}

html[data-theme="dark"] .profile-dropdown-link {
    color: var(--text-primary);
}

html[data-theme="dark"] .profile-dropdown-divider {
    border-color: var(--border);
}

html[data-theme="dark"] .icon-btn {
    background: var(--card);
    border-color: var(--border);
    color: var(--text-primary);
}

/* Hamburger icon is a hardcoded dark fill; lighten it in dark mode. */
html[data-theme="dark"] .more-menu svg rect {
    fill: var(--label);
}

/* Small coloured chips that are hardcoded in the dashboards. */
html[data-theme="dark"] .preferred-badge {
    background: var(--tint-orange-bg);
    color: var(--text-orange);
}

html[data-theme="dark"] .stat-orange .stat-icon {
    background: var(--fill-3);
}

html[data-theme="dark"] .trust-badges {
    background: var(--tint-green-bg);
}

/* The logo artwork is dark-on-light; give it a light chip in dark mode
   so it stays readable on the dark header and sidebar. (DRK-04: a white-
   background image would glow in dark mode — soften it with a chip.) */
html[data-theme="dark"] .doctor-sidebar-logo img,
html[data-theme="dark"] .user-sidebar-logo img,
html[data-theme="dark"] .header-logo-mobile,
html[data-theme="dark"] .header-logo img,
html[data-theme="dark"] .auth-logo img {
    background: #fff;
    border-radius: 8px;
    padding: 4px;
}

/* Round logo badge, like ditasol.com (42px round logo). The logo artwork
   is a circular emblem on white, so a square crop + 50% radius shows the
   ring with no corners. Dark mode keeps the white chip, made round. */
.header-logo img,
.user-sidebar-logo img,
.header-logo-mobile {
    width: 40px;
    height: 40px;
    object-fit: cover;
    object-position: center;
    border-radius: 50%;
    box-sizing: border-box;
}
.header-logo-mobile { width: 32px; height: 32px; }
html[data-theme="dark"] .header-logo img,
html[data-theme="dark"] .user-sidebar-logo img,
html[data-theme="dark"] .header-logo-mobile {
    border-radius: 50%;
    padding: 2px;
}

/* Increase Contrast: stronger separators (HIG). */
@media (prefers-contrast: more) {
    .card, .auth-card, .list-item, .booking-card, .notification-item {
        border-color: var(--separator-opaque);
    }
}

/* ---- Press + hover feedback, site-wide (verified Apple patterns,
   Emil Kowalski / apple-ui-craft press-feedback, 2026-11-29) ----
   PRESS: every pressable element scales to 0.97 on :active, 80-160ms
   var(--ease-apple-fluid) — "press feedback is felt, not seen"
   (never 0.9 — that visibly collapses). :active is NOT gated behind
   hover media queries: it is a real press on touch too.
   The !important is deliberate: view <style> blocks load AFTER every
   stylesheet, so without it their :hover lift (translateY(-2px)) would
   swallow the press scale on equal specificity. Press must win while
   the finger/mouse is down; on release the hover state resumes.
   EXCLUDED: .map-floating-gps-btn — its centering IS a transform
   (translateX(-50%)); scaling it would shove it sideways on press.
   It keeps its own :active state in address_form.php.
   NOT scaled, by design: plain text links (colour/underline only),
   disabled buttons, static badges/chips, non-interactive containers.
   HOVER (pointer devices only): shared-CSS hover lifts/shadows are
   wrapped in @media (hover: hover); view <style> hover lifts were
   wrapped the same way in the Design C pass. Hover lift is
   translateY(-2px) scale(1.01) max + soft shadow, 100-150ms — never
   scale(1.05) or -6px (ballooning). Focus: 2px teal ring via
   :focus-visible (design-system.css + booking.css).
   Liquid Glass (iOS 26) on the web: no SVG distortion / fake
   refraction — the honest approximation is this scale-down + tighter
   shadow on press and a small fill/highlight increase on hover.
   Performance: transform + opacity ONLY, never width/height/margin.
   Reduced motion: design-system.css makes these transitions 0.01ms,
   so press/hover become instant state changes. */
button:not(.map-floating-gps-btn):active,
input[type="submit"]:active,
input[type="button"]:active,
.btn:active,
.btn-primary:active,
.btn-outline:active,
.btn-book:active,
.btn-view:active,
.btn-block:active,
.btn-card-add:active,
.btn-card-outline:active,
.btn-primary-action:active,
.btn-secondary-action:active,
.btn-save-address:active,
.map-search-submit-btn:active,
.btn-back-chevron:active,
.pill-tab-btn:active,
.slot-card-option:active,
.saved-addr-card:active,
.payment-card-box:active,
.test-catalog-card:active,
.package-catalog-card:active,
.test-card:active,
.package-card:active,
.card-3d:active,
.user-stat-card:active,
.doctor-stat-card:active,
.quick-action-card:active,
.feature-card:active,
.why-item:active,
.step:active,
.contact-card:active,
.faq-item:active,
.list-item:active,
.booking-card:active,
.member-card:active,
.balance-card:active,
.user-nav-link:active,
.doctor-nav-link:active,
.user-nav a:active,
.admin-sidebar a:active,
.bottom-nav-item:active,
.theme-toggle:active,
.fab-circle:active,
.icon-btn:active,
.stepper-item:active,
.profile-dropdown-link:active,
.profile-logout:active,
.avatar-circle:active,
.toggle-slider:active {
    transform: scale(0.97) !important;
}

/* ---- Liquid Glass catch-all: EVERY remaining button class gets the
   mirror sheen — no exceptions (user 29 Nov 20:40 IST). Filled buttons
   get the full gloss (their own colours untouched); ghost / outline /
   chip / icon buttons get the soft gloss + specular rim. .btn-link is
   deliberately excluded (it is a text link, not a button); :disabled
   buttons stay plain. The specific rules below this block win for
   their classes (later in the cascade). ---- */
.btn-save:not(:disabled),
.btn-update:not(:disabled),
.btn-search:not(:disabled),
.btn-withdraw:not(:disabled),
.btn-danger:not(:disabled),
.btn-pay-sm:not(:disabled),
.btn-pay:not(:disabled),
.btn-pay-due:not(:disabled),
.btn-pay-commission:not(:disabled),
.btn-save-bonus:not(:disabled),
.btn-add-bonus:not(:disabled),
.btn-assign:not(:disabled),
.btn-approve:not(:disabled),
.btn-action-primary:not(:disabled),
.btn-action-success:not(:disabled),
.btn-download-report:not(:disabled),
.btn-secondary:not(:disabled) {
    background-image: var(--btn-mirror-gloss) !important;
}
.btn-back:not(:disabled),
.btn-clear:not(:disabled),
.btn-filter:not(:disabled),
.btn-outline-sm:not(:disabled),
.btn-cancel:not(:disabled),
.btn-date-filter:not(:disabled),
.btn-action:not(:disabled),
.btn-location:not(:disabled),
.btn-icon:not(:disabled),
.btn-view-report:not(:disabled),
.btn-view-details:not(:disabled),
.btn-view-sm:not(:disabled),
.btn-view-booking:not(:disabled),
.btn-share:not(:disabled),
.btn-save-address:not(:disabled),
.btn-remove-item:not(:disabled),
.btn-reject:not(:disabled),
.btn-show-mobile:not(:disabled),
.btn-back-chevron:not(:disabled),
.btn-secondary-sm:not(:disabled),
.btn-action-outline:not(:disabled),
.btn-action-danger:not(:disabled),
.btn-copy:not(:disabled),
.btn-directions:not(:disabled),
.btn-cancel-address:not(:disabled),
.btn-card-add:not(.added):not(:disabled) {
    background-image: var(--btn-mirror-gloss-soft) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.30) !important;
}
/* Icon buttons that carry no .btn class (so the shared .btn:hover 3D
   rule does not reach them): same 3D hover as every other button. */
@media (hover: hover) and (pointer: fine) {
    .btn-back-chevron:hover, .more-menu:hover, .drawer-close:hover, .fab-circle:hover {
        transform: perspective(800px) rotateX(4deg) translateY(-2px);
    }
}

/* ---- Mirror finish for buttons whose own stylesheet / view <style>
   re-declares a filled background AFTER design-system.css ----
   design-system.css already mirrors the shared classes, but these
   re-declare `background:` later in the cascade: booking.css loads
   after design-system.css, and .td-book/.pd-book live in view
   <style> blocks, which render after every stylesheet. The
   !important here is deliberate and narrow (background-image /
   box-shadow only) — same reason as the site-wide press rule above:
   view styles load last. Colours are NOT changed: navy buttons keep
   navy (gloss only), teal buttons keep teal, red/green small buttons
   keep their colour (gloss only). Disabled buttons are excluded, so
   their grey fill stays plain. */
.td-book, .pd-book {
    position: relative;
    overflow: hidden;
    background-image: var(--btn-mirror-gloss) !important;
    box-shadow: var(--btn-mirror-shadow) !important;
}
.td-book:hover, .pd-book:hover {
    background-image: var(--btn-mirror-gloss-hover) !important;
    box-shadow: var(--btn-mirror-shadow-hover) !important;
}
@media (hover: hover) and (pointer: fine) {
    /* 3D hover for the detail-page book buttons (their hover rules live
       here, not in a view <style>, so the bulk 3D pass does not reach
       them). Same fixed tilt as the other cards. */
    .td-book:hover, .pd-book:hover {
        transform: perspective(900px) rotateX(var(--rx, 3deg)) rotateY(var(--ry, -3deg)) translateY(-4px);
    }
}
.td-book:active, .pd-book:active {
    background-image: var(--btn-mirror-gloss-active) !important;
    box-shadow: var(--btn-mirror-shadow-active) !important;
}
.td-book::after, .pd-book::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 45%;
    background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.5), transparent);
    transform: translateX(-240%) skewX(-18deg);
    transition: transform 0.65s ease;
    pointer-events: none;
}
@media (hover: hover) {
    .td-book:hover::after, .pd-book:hover::after { transform: translateX(340%) skewX(-18deg); }
}
html[data-theme="dark"] .td-book,
html[data-theme="dark"] .pd-book {
    box-shadow: var(--btn-mirror-shadow-dark) !important;
}
html[data-theme="dark"] .td-book:hover,
html[data-theme="dark"] .pd-book:hover {
    box-shadow: var(--btn-mirror-shadow-dark-hover) !important;
}
/* Navy wizard buttons: gloss sheen only, navy fill untouched. */
.btn-primary-action:not(:disabled),
.map-search-submit-btn:not(:disabled),
.btn-card-add.added:not(:disabled) {
    background-image: var(--btn-mirror-gloss) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.30) !important;
}
/* Outline wizard buttons: soft gloss sheen only. */
.btn-secondary-action:not(:disabled),
.btn-card-outline:not(:disabled) {
    background-image: var(--btn-mirror-gloss-soft) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.30) !important;
}
/* Small filled action buttons (view-local classes): gloss sheen only,
   so their own colours stay exactly as they are. */
.btn-primary-sm:not(:disabled),
.btn-danger-sm:not(:disabled),
.btn-success-sm:not(:disabled),
.btn-submit:not(:disabled),
.btn-pay-now-lg:not(:disabled) {
    background-image: var(--btn-mirror-gloss) !important;
}
/* v21: language switcher (EN / हिंदी) in the header. */
/* v22: language switch — a sliding Liquid Glass toggle (EN / हिंदी).
   Frosted glass track (real blur), a teal knob that slides to the active
   language. The knob is positioned by the .lang-hi class on the track. */
.lang-switch { position: relative; display: inline-flex; align-items: center; height: 36px; padding: 3px; border-radius: 999px; background: var(--glass-fill); -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4); border: 1px solid var(--glass-edge, rgba(255, 255, 255, 0.35)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 4px 14px rgba(0, 0, 0, 0.10); }
.lang-switch .lang-knob { position: absolute; top: 3px; left: 3px; width: 48px; height: 30px; border-radius: 999px; background: #0E7C7B; box-shadow: 0 2px 8px rgba(14, 124, 123, 0.45); transition: transform 200ms var(--ease-apple-fluid); }
.lang-switch.lang-hi .lang-knob { transform: translateX(48px); }
.lang-switch a { position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 30px; padding: 0; border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--text-muted); text-decoration: none; line-height: 1; }
.lang-switch a.active { color: #fff; }
