/*
 * Movi Invoice — public website colour themes (loaded after base.css on public pages only; the signed-in
 * app and admin keep the default brand look). A theme remaps the design tokens from base.css: the
 * --orange-* names are the brand accent scale, so every component follows the theme without changes.
 * Each theme sets every token below, so a nested [data-theme] (the picker previews) renders that theme
 * regardless of the page's theme. Contrast is checked by tests/unit/themes.test.js.
 *
 *   --orange-600     primary buttons, links (white text on it ≥ 4.5:1; on page backgrounds ≥ 4.5:1)
 *   --orange-500     accent for large display text and the brand mark (≥ 3:1 on the page background)
 *   --sample-brand   accent of the homepage sample invoice
 * Invoice previews (.inv), PDFs and customer branding use their own colours and are not themed.
 */
[data-theme="aero"] {
  --orange-600: #C2410C; --orange-500: #E8590C; --orange-100: #FFE8D9; --orange-50: #FFF5EE;
  --ink-900: #141414; --ink-800: #232120; --ink-700: #3A3632;
  --bg: #FBF8F4; --surface: #FFFFFF; --surface-2: #F6F2EC; --border: #E8E2DA; --border-strong: #D6CEC4;
  --text: #141414; --text-muted: #625A52; --text-faint: #8A8178;
  --primary-hover: #A8370A; --input-hover: #BDB3A7; --on-dark-muted: #BDB3A7; --accent-on-dark: #E8590C;
  --header-bg: rgba(251, 248, 244, .92); --hero-glow: rgba(232, 89, 12, .12); --focus: 0 0 0 3px rgba(232, 89, 12, 0.35);
  --sample-brand: #E8590C;
}
[data-theme="midnight"] {
  --orange-600: #1D4ED8; --orange-500: #2563EB; --orange-100: #DBE7FE; --orange-50: #EFF5FF;
  --ink-900: #0B1530; --ink-800: #16223F; --ink-700: #2F3B57;
  --bg: #F5F7FB; --surface: #FFFFFF; --surface-2: #EDF1F8; --border: #DCE3EE; --border-strong: #C4CEDD;
  --text: #0B1530; --text-muted: #4B5873; --text-faint: #6F7B93;
  --primary-hover: #1E40AF; --input-hover: #9FB0C9; --on-dark-muted: #A9B6CF; --accent-on-dark: #7AA7FF;
  --header-bg: rgba(245, 247, 251, .92); --hero-glow: rgba(37, 99, 235, .13); --focus: 0 0 0 3px rgba(37, 99, 235, .38);
  --sample-brand: #1D4ED8;
}
[data-theme="emerald"] {
  --orange-600: #047857; --orange-500: #059669; --orange-100: #D3F5E6; --orange-50: #EEFBF5;
  --ink-900: #0E1F19; --ink-800: #182D25; --ink-700: #31463E;
  --bg: #F6FAF8; --surface: #FFFFFF; --surface-2: #ECF4F0; --border: #DAE6E0; --border-strong: #C1D3CA;
  --text: #0E1F19; --text-muted: #4A5D55; --text-faint: #6E8179;
  --primary-hover: #065F46; --input-hover: #9DB5AA; --on-dark-muted: #A7BDB3; --accent-on-dark: #34D399;
  --header-bg: rgba(246, 250, 248, .92); --hero-glow: rgba(5, 150, 105, .13); --focus: 0 0 0 3px rgba(5, 150, 105, .38);
  --sample-brand: #047857;
}
[data-theme="purple"] {
  --orange-600: #6D28D9; --orange-500: #7C3AED; --orange-100: #EBE2FD; --orange-50: #F6F1FF;
  --ink-900: #1A1330; --ink-800: #261C41; --ink-700: #3E3458;
  --bg: #F9F7FC; --surface: #FFFFFF; --surface-2: #F1EDF8; --border: #E3DDEE; --border-strong: #CDC4DE;
  --text: #1A1330; --text-muted: #5A5170; --text-faint: #7D7494;
  --primary-hover: #5B21B6; --input-hover: #ADA2C4; --on-dark-muted: #B8AED0; --accent-on-dark: #B794F6;
  --header-bg: rgba(249, 247, 252, .92); --hero-glow: rgba(124, 58, 237, .13); --focus: 0 0 0 3px rgba(124, 58, 237, .38);
  --sample-brand: #6D28D9;
}
[data-theme="slate"] {
  --orange-600: #334155; --orange-500: #0F766E; --orange-100: #DDE3EA; --orange-50: #F1F4F7;
  --ink-900: #0F172A; --ink-800: #1E293B; --ink-700: #334155;
  --bg: #F8FAFC; --surface: #FFFFFF; --surface-2: #F1F5F9; --border: #E2E8F0; --border-strong: #CBD5E1;
  --text: #0F172A; --text-muted: #475569; --text-faint: #64748B;
  --primary-hover: #1E293B; --input-hover: #94A3B8; --on-dark-muted: #A3B1C4; --accent-on-dark: #5EEAD4;
  --header-bg: rgba(248, 250, 252, .92); --hero-glow: rgba(15, 118, 110, .10); --focus: 0 0 0 3px rgba(15, 118, 110, .38);
  --sample-brand: #334155;
}

/* ---------------------------------------------------------------- theme picker (homepage) */
.theme-toggle svg { width: 18px; height: 18px; }
@media (max-width: 520px) { .theme-toggle { width: 42px; padding: 0; } .theme-toggle-label { display: none; } }

.theme-dialog { border: 0; padding: 0; width: min(900px, calc(100vw - 32px)); max-width: none; max-height: calc(100vh - 32px);
  border-radius: var(--r-xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.theme-dialog::backdrop { background: rgba(20, 20, 20, .45); }
.theme-dialog[open] { display: flex; }
.theme-form { display: flex; flex-direction: column; width: 100%; max-height: calc(100vh - 32px); margin: 0; }
.theme-body { padding: var(--s5) var(--s6); overflow-y: auto; }
.theme-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: var(--s5); align-items: start; margin-top: var(--s4); }
.theme-options { display: grid; gap: var(--s2); }

.theme-option { position: relative; display: flex; align-items: center; gap: var(--s3); padding: var(--s3); cursor: pointer;
  border: 1.5px solid var(--border); border-radius: var(--r-lg); background: var(--surface); transition: border-color .15s, background-color .15s; }
.theme-option:hover { border-color: var(--border-strong); background: var(--surface-2); }
.theme-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.theme-option:has(input:checked) { border-color: var(--ink-900); box-shadow: 0 0 0 1px var(--ink-900); }
.theme-option:has(input:focus-visible) { box-shadow: var(--focus), 0 0 0 1px var(--ink-900); }
.theme-option .check-dot { margin-left: auto; width: 20px; height: 20px; flex: none; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; }
.theme-option input:checked ~ .check-dot { border-color: var(--ink-900); background: var(--ink-900); }
.theme-option input:checked ~ .check-dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.theme-meta { display: grid; gap: 2px; min-width: 0; }
.theme-meta b { font-size: var(--fs-sm); display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.theme-meta .small { line-height: 1.35; }
.theme-current { font-weight: 650; }

/* Mini swatch: header bar, heading, accent, card and button in that theme's own colours. */
.theme-swatch { flex: none; width: 76px; height: 56px; border-radius: var(--r-md); overflow: hidden; background: var(--bg);
  border: 1px solid var(--border); display: grid; grid-template-rows: 12px 1fr; }
.theme-swatch .ts-bar { background: var(--ink-900); display: flex; align-items: center; padding: 0 5px; gap: 3px; }
.theme-swatch .ts-bar i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent-on-dark); }
.theme-swatch .ts-body { padding: 5px 6px; display: grid; gap: 4px; align-content: start; }
.theme-swatch .ts-head { height: 5px; width: 80%; border-radius: 3px; background: linear-gradient(90deg, var(--text) 0 55%, var(--orange-500) 55%); }
.theme-swatch .ts-row { display: flex; gap: 4px; align-items: center; }
.theme-swatch .ts-card { flex: 1; height: 16px; border-radius: 4px; background: var(--surface); border: 1px solid var(--border); }
.theme-swatch .ts-btn { width: 22px; height: 10px; border-radius: 3px; background: var(--orange-600); }

/* Larger preview of representative website elements. */
.theme-preview-wrap { position: sticky; top: 0; }
.theme-caption { margin: 0 0 var(--s2); font-weight: 600; }
.theme-preview { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--bg); color: var(--text); font-size: var(--fs-sm); }
.theme-preview .tp-header { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); padding: 10px 14px; background: var(--header-bg); border-bottom: 1px solid var(--border); }
.theme-preview .tp-brand { font-weight: 800; letter-spacing: -0.02em; color: var(--ink-900); }
.theme-preview .tp-brand b { color: var(--orange-500); }
.theme-preview .tp-nav { display: flex; gap: 10px; color: var(--ink-700); font-weight: 600; font-size: var(--fs-xs); }
.theme-preview .tp-hero { padding: 16px 14px 14px; background: radial-gradient(360px 180px at 95% 0%, var(--hero-glow), transparent 70%), var(--bg); }
.theme-preview .tp-eyebrow { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--orange-600);
  background: var(--orange-50); border: 1px solid var(--orange-100); padding: 2px 8px; border-radius: 999px; }
.theme-preview .tp-title { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; margin: 8px 0 4px; }
.theme-preview .tp-title span { color: var(--orange-500); }
.theme-preview .tp-text { color: var(--text-muted); margin: 0 0 10px; font-size: var(--fs-xs); }
.theme-preview .tp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-preview .tp-btn { display: inline-flex; align-items: center; min-height: 30px; padding: 0 12px; border-radius: var(--r-sm); font-weight: 600; font-size: var(--fs-xs); border: 1px solid transparent; }
.theme-preview .tp-btn.primary { background: var(--orange-600); color: #fff; }
.theme-preview .tp-btn.secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.theme-preview .tp-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 14px 14px; }
.theme-preview .tp-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px; display: grid; gap: 4px; align-content: start; }
.theme-preview .tp-icon { width: 24px; height: 24px; border-radius: 7px; background: var(--ink-900); color: var(--accent-on-dark); display: grid; place-items: center; font-weight: 800; font-size: 11px; }
.theme-preview .tp-card .muted { font-size: 11px; line-height: 1.35; }
.theme-preview .tp-price { font-weight: 800; font-size: 1.05rem; }
.theme-preview .tp-price small { font-weight: 500; color: var(--text-muted); font-size: 10px; }
.theme-preview .tp-link { color: var(--orange-600); font-weight: 600; font-size: 11px; text-decoration: underline; text-underline-offset: 2px; }
.theme-preview .tp-faq { margin: 0 14px 14px; border-top: 1px solid var(--border); padding-top: 8px; display: flex; justify-content: space-between; font-weight: 650; font-size: var(--fs-xs); }
.theme-preview .tp-faq span { color: var(--orange-600); }
.theme-preview .tp-band { background: var(--ink-900); color: #fff; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; font-size: var(--fs-xs); }
.theme-preview .tp-band small { display: block; color: var(--on-dark-muted); font-weight: 500; }

@media (max-width: 720px) {
  .theme-layout { grid-template-columns: minmax(0, 1fr); }
  /* The preview stays visible above the list while the options scroll. */
  .theme-preview-wrap { order: -1; z-index: 1; background: var(--surface); padding: var(--s2) 0 var(--s3); }
  .theme-preview .tp-text, .theme-preview .tp-card .muted, .theme-preview .tp-band small { display: none; }
}
@media (max-width: 600px) {
  .theme-dialog { width: 100vw; max-height: 94vh; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .theme-form { max-height: 94vh; }
  .theme-body { padding: var(--s4); }
  .theme-preview .tp-cards { grid-template-columns: 1fr 1fr; }
  .theme-preview .tp-faq { display: none; }
  .theme-swatch { width: 60px; height: 48px; }
}
