/* ════════════════════════════════════════════════════════════
   Dark mode (js/theme.js sets <html data-theme="dark">) and the
   light/dark toggle. Loaded last on every page.
   Most colours come from the Swiss tokens, so the dark palette is
   mostly token values; the rest corrects colours written directly.
   ════════════════════════════════════════════════════════════ */

/* ─── Toggle button ────────────────────────────────────────── */
.theme-toggle {
  order: 2; flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; border: 1px solid var(--sw-rule, #D9D9DE); border-radius: 0;
  background: none; color: var(--sw-ink, #111111); cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background-color 150ms ease;
}
.theme-toggle:hover { border-color: var(--sw-ink, #111111); }
.theme-toggle:focus-visible { outline: 2px solid var(--sw-red, #E4002B); outline-offset: 2px; }
.theme-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-icon-moon { fill: currentColor; stroke: none; }
.theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: block; }
@media (prefers-reduced-motion: no-preference) {
  .theme-toggle .theme-icon { transition: transform 360ms cubic-bezier(0.22, 1, 0.36, 1); }
  .theme-toggle:active .theme-icon { transform: rotate(-30deg) scale(0.9); }
}
/* Header order: brand · navigation · theme · language · (phone) Menu */
.sw-header-row > .i18n-switch { order: 3; }
.sw-header-row > .sw-menu-toggle { order: 4; }
@media (max-width: 768px) {
  .sw-header-row > .theme-toggle { margin-inline-start: auto; }
  .sw-header-row > .i18n-switch { margin-inline-start: 0; }
}
.theme-toggle-auth { position: absolute; top: 20px; inset-inline-end: 20px; }
.admin-auth-main { position: relative; }

/* Theme changes fade instead of snapping (not on first paint) */
html.theme-anim body, html.theme-anim body * { transition: background-color 250ms ease, border-color 250ms ease, color 200ms ease !important; }

/* ─── Dark palette ─────────────────────────────────────────── */
html[data-theme="dark"] { color-scheme: dark; background: #0F0F11; }
html[data-theme="dark"] body.home,
html[data-theme="dark"] body.admin {
  --sw-white: #0F0F11;
  --sw-paper: #18181B;
  --sw-ink: #EDEDEF;
  --sw-ink-2: #A1A1AA;
  --sw-ink-3: #74747C;
  --sw-rule: #2C2C31;
  --sw-red: #FF3355;
  --sw-green: #3FCB7E;
  --sw-amber: #E9A23B;
  --sw-blue: #6EA8FF;
  --sw-glass: rgba(15, 15, 17, 0.78);
  --sw-glass-strong: rgba(15, 15, 17, 0.9);
  background: #0F0F11;
}
/* Admin: style.css variables used by the dashboard's inline styles */
html[data-theme="dark"] body.admin {
  --accent: #FF3355; --accent-light: #FF6B82; --accent-dark: #E4002B; --gold: #FF3355;
  --dark: #0F0F11; --dark-2: #0F0F11; --dark-3: #18181B; --dark-4: #18181B; --dark-5: #222226;
  --white: #EDEDEF; --text: #EDEDEF; --text-muted: #A1A1AA; --text-dim: #74747C;
  --border: #2C2C31; --border-glass: #2C2C31; --glass-bg: #0F0F11; --glass-border: #2C2C31;
  --danger: #FF5A6E; --success: #3FCB7E; --warning: #E9A23B; --info: #6EA8FF;
}

/* Text on red stays white; red accents in text use the brighter red */
html[data-theme="dark"] body.home ::selection, html[data-theme="dark"] body.admin ::selection { color: #FFFFFF; }
html[data-theme="dark"] body.home .sw-btn-accent,
html[data-theme="dark"] body.home .sw-cta,
html[data-theme="dark"] body.home .sw-notify-count,
html[data-theme="dark"] body.admin .btn-primary,
html[data-theme="dark"] body.admin .chat-badge { color: #FFFFFF; }
html[data-theme="dark"] body.home .sw-btn-accent,
html[data-theme="dark"] body.home .sw-cta,
html[data-theme="dark"] body.admin .btn-primary { background-color: var(--sw-accent-fill, #E4002B); border-color: var(--sw-accent-fill, #E4002B); }
html[data-theme="dark"] body.home .sw-btn-accent:hover,
html[data-theme="dark"] body.admin .btn-primary:hover { background: #EDEDEF; border-color: #EDEDEF; color: #0F0F11; }
/* The red call-to-action band keeps its white buttons */
html[data-theme="dark"] body.home .sw-btn-inverse { background: #FFFFFF; color: var(--sw-accent-fill, #E4002B); }
html[data-theme="dark"] body.home .sw-btn-inverse:hover { background: #0F0F11; color: #FFFFFF; }
html[data-theme="dark"] body.home .sw-btn-inverse-line { border-color: #FFFFFF; color: #FFFFFF; }
html[data-theme="dark"] body.home .sw-btn-inverse-line:hover { background: #FFFFFF; color: var(--sw-accent-fill, #E4002B); }
html[data-theme="dark"] body.home .sw-cta :focus-visible { outline-color: #FFFFFF; }

/* Live chat button: a light chip on the dark page */
html[data-theme="dark"] body.home .chat-widget-btn { background: rgba(237, 237, 239, 0.92); color: #0F0F11; border-color: rgba(237, 237, 239, 0.92); }
html[data-theme="dark"] body.home .chat-widget-btn:hover { background: var(--sw-accent-fill, #E4002B); border-color: var(--sw-accent-fill, #E4002B); color: #FFFFFF; }

/* Logo: the liquid-chrome mark needs a black tile in both modes */
html[data-theme="dark"] .sw-mark-tile { background: #000000; box-shadow: inset 0 0 0 1px #2C2C31; }
html[data-theme="dark"] body.home .sw-about-figure { background: #000000; }

/* Glass header and hero panels */
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  html[data-theme="dark"] body.home .sw-header { background: rgba(15, 15, 17, 0.78); border-bottom-color: #3A3A40; }
  html[data-theme="dark"] body.home .sw-kicker, html[data-theme="dark"] body.home .sw-hero-lead { background: rgba(15, 15, 17, 0.6); }
}
html[data-theme="dark"] body.home .sw-header { border-bottom-color: #3A3A40; }
html[data-theme="dark"] body.home .sw-footer { background: #141416; }

/* Muted greys written directly (inactive numbers, placeholders) */
html[data-theme="dark"] :is(.sw-rail li, .sw-guide-steps .sw-guide-no, .sw-history-no, .i18n-menu-code, .sw-policy-toc .sw-toc-no, .rm-item.is-planned .rm-item-no) { color: #5E5E66; }
html[data-theme="dark"] .sw-rail li.is-done { color: var(--sw-ink); }
html[data-theme="dark"] .sw-rail li.is-current { color: var(--sw-red); }
html[data-theme="dark"] .sw-history li:last-child .sw-history-no { color: var(--sw-red); }
html[data-theme="dark"] .sw-guide-steps li[aria-current="step"] .sw-guide-no { color: var(--sw-red); }
html[data-theme="dark"] .sw-guide-steps li.is-done .sw-guide-no { color: var(--sw-ink); }
html[data-theme="dark"] .sw-field input::placeholder, html[data-theme="dark"] body.admin .form-control::placeholder { color: #5E5E66; }

/* Messages */
html[data-theme="dark"] :is(.sw-form-message, .sw-rail-alert, body.admin .login-error) { background: #2A1418; color: #FF9AAA; }
html[data-theme="dark"] .sw-form-message.is-info { background: #18181B; color: #EDEDEF; }
html[data-theme="dark"] body.admin .login-error.is-ok { background: #10241A; color: #7FE0A8; }
html[data-theme="dark"] .sw-notice.is-new { background: linear-gradient(90deg, #2A1418, transparent 60%); }

/* Statuses: brighter blue / amber / green on dark */
html[data-theme="dark"] .sw-ship-status .status-delivered { color: #3FCB7E; }
html[data-theme="dark"] .sw-ship-status :is(.status-in-transit, .status-out-for-delivery) { color: #6EA8FF; }
html[data-theme="dark"] .sw-ship-status :is(.status-processing, .status-in-customs) { color: #E9A23B; }
html[data-theme="dark"] .sw-ship-status :is(.status-on-hold, .status-cancelled) { color: #FF3355; }

/* ─── Route map ────────────────────────────────────────────── */
html[data-theme="dark"] .rm-section { --rm-transit: #6EA8FF; --rm-held: #E9A23B; --rm-stopped: #FF3355; --rm-done: #3FCB7E; --rm-origin: #EDEDEF; --rm-neutral: #A1A1AA; }
html[data-theme="dark"] .rm-frame { background: #121214; border-color: #2C2C31; }
html[data-theme="dark"] .rm-sea { fill: #121214; }
html[data-theme="dark"] .rm-svg image { filter: invert(1) hue-rotate(180deg) brightness(1.55); }   /* light-grey land → neutral dark-grey land */
html[data-theme="dark"] .rm-leg.is-done { stroke: var(--sw-red, #FF3355); }
html[data-theme="dark"] .rm-leg.is-planned { stroke: #EDEDEF; }
html[data-theme="dark"] .rm-pin { box-shadow: 0 0 0 2px #121214; color: #0F0F11; }
html[data-theme="dark"] .rm-pin.tone-planned { background: #121214; color: #EDEDEF; box-shadow: inset 0 0 0 2px #EDEDEF, 0 0 0 2px #121214; }
html[data-theme="dark"] .rm-tag { background: rgba(24, 24, 27, 0.94); color: #EDEDEF; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4); }
html[data-theme="dark"] .rm-tag.is-current { box-shadow: inset 2px 0 0 var(--sw-red, #FF3355), 0 1px 0 rgba(0, 0, 0, 0.4); }
html[data-theme="dark"] :is(.rm-tag.tone-held .rm-tag-status, .rm-item.tone-held .rm-item-no, .rm-event.tone-held .rm-event-status) { color: #E9A23B; }
html[data-theme="dark"] .rm-list { border-top-color: #EDEDEF; }
html[data-theme="dark"] :is(.rm-item, .rm-event time, .rm-event-desc, .rm-item-role, .rm-legend) { border-color: #2C2C31; color: inherit; }
html[data-theme="dark"] :is(.rm-event time, .rm-event-desc, .rm-item-role, .rm-legend, .rm-item-note, .rm-credit) { color: #A1A1AA; }
html[data-theme="dark"] .rm-key.tone-planned i { background: #0F0F11; box-shadow: inset 0 0 0 1.5px #EDEDEF; }
html[data-theme="dark"] .rm-key-line.is-planned i { background: repeating-linear-gradient(90deg, #EDEDEF 0 5px, transparent 5px 9px); }

/* ─── Shipment route sequence (track page animation) ───────── */
html[data-theme="dark"] .sr-overlay { background: #0F0F11; color: #EDEDEF; background-image: linear-gradient(to right, #1E1E22 1px, transparent 1px); background-size: calc(100% / 12) 100%; }
html[data-theme="dark"] :is(.sr-status, .sr-number, .sr-route, .sr-where) { background: #0F0F11; }
html[data-theme="dark"] .sr-overlay.is-arrived .sr-status { color: #EDEDEF; }
html[data-theme="dark"] .sr-overlay :is(.sr-end-label, .sr-stop-label, .sr-skip) { color: #A1A1AA; }
html[data-theme="dark"] .sr-track { background: #2C2C31; }
html[data-theme="dark"] .sr-line { background: #EDEDEF; }
html[data-theme="dark"] .sr-stop::before { background: #2C2C31; }
html[data-theme="dark"] .sr-stop.is-reached::before { background: #EDEDEF; }
html[data-theme="dark"] .sr-stop-no { color: #5E5E66; }
html[data-theme="dark"] .sr-stop.is-reached .sr-stop-no { color: #EDEDEF; }
html[data-theme="dark"] .sr-marker { box-shadow: 0 0 0 4px #0F0F11; }

/* ─── Vault door (Vault Access / Client Portal sign-in) ────── */
html[data-theme="dark"] body.home .vo-overlay { --vo-gold: #EDEDEF; --vo-gold-light: #A1A1AA; --vo-steel-1: #3A3A40; --vo-steel-2: #232327; background: radial-gradient(circle at 50% 45%, #1C1C20 0%, #0B0B0D 75%); }
html[data-theme="dark"] body.home .vo-frame { background: conic-gradient(from 210deg, #2A2A2F, #4A4A52, #232327, #4A4A52, #2A2A2F); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 0 0 1px #000000; }
html[data-theme="dark"] body.home .vo-door { background: radial-gradient(circle at 35% 30%, #55555C, transparent 45%), radial-gradient(circle, #3A3A40 0%, #232327 80%, #18181B 100%); box-shadow: inset 0 0 0 2px #000000, inset 0 0 30px rgba(0, 0, 0, 0.5), 0 12px 40px rgba(0, 0, 0, 0.6); }
html[data-theme="dark"] body.home .vo-door::before { box-shadow: inset 0 0 0 1px #000000; }
html[data-theme="dark"] body.home .vo-bolt { background: linear-gradient(180deg, #8A8A93, #55555C); }
html[data-theme="dark"] body.home .vo-spoke::after { background: radial-gradient(circle at 35% 35%, #A1A1AA, #55555C 70%); }
html[data-theme="dark"] body.home .vo-label { color: #EDEDEF; }
html[data-theme="dark"] body.home .vo-light { background: radial-gradient(circle, #FFFFFF 0%, #FFD0D8 30%, rgba(255, 51, 85, 0.25) 58%, transparent 72%); }

/* ─── Admin ────────────────────────────────────────────────── */
/* The sidebar and the sign-in panel stay black */
html[data-theme="dark"] body.admin .admin-sidebar,
html[data-theme="dark"] body.admin .admin-auth-side { background: #08080A; border-right: 1px solid #2C2C31; }
html[data-theme="dark"] body.admin :is(.sidebar-logo h2, .admin-auth-brand, .admin-auth-title, .sidebar-nav li a:hover, .sidebar-nav li a.active, .sidebar-footer a:hover, .admin-auth-brand:hover, .admin-auth-foot a:hover) { color: #FFFFFF; }
html[data-theme="dark"] body.admin .admin-header { background: rgba(15, 15, 17, 0.9); }
html[data-theme="dark"] body.admin select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23EDEDEF' stroke-width='1.6'/%3E%3C/svg%3E"); }
html[data-theme="dark"] body.admin .form-control:hover { border-color: #4A4A52; }
html[data-theme="dark"] body.admin .modal { box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7); border-top-color: #EDEDEF; }
html[data-theme="dark"] body.admin .modal-overlay { background: rgba(0, 0, 0, 0.7); }
html[data-theme="dark"] body.admin .chat-msg-admin { background: #EDEDEF; color: #0F0F11; }
html[data-theme="dark"] body.admin .chat-msg-admin :is(.chat-msg-time, .chat-msg-sender) { color: rgba(15, 15, 17, 0.6); }
html[data-theme="dark"] body.admin .toast { background: #EDEDEF; color: #0F0F11; }
html[data-theme="dark"] body.admin img[id$="Preview"] { background: #18181B !important; }
html[data-theme="dark"] body.admin .theme-option { background: #18181B; }
.theme-toggle-admin { width: 36px; height: 36px; }
