/* Dixie Door Quote — light / dark / auto themes
   Brand: dixiedooronline.com — signature red #e5132e
   Dark mode keeps the rich navy/green palette you liked.
*/

:root {
  --radius: 14px;
  --brand-red: #e5132e;
  --brand-red-deep: #b01024;
  --brand-ink: #1a1a1a;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ===== DARK (default preference when forced, or system dark in auto) ===== */
html[data-theme="dark"],
html[data-theme="auto"] {
  color-scheme: dark;
  --bg: #0f1419;
  --card: #1a222c;
  --border: #2c3a4a;
  --text: #e8eef4;
  --muted: #8b9aab;
  --accent: #3b82f6;
  --accent2: #4ade80;
  /* Without tax = cool blue-slate; with tax = warmer emerald (not the same green) */
  --price-no-tax: #93c5fd;
  --price-no-tax-bg: #1e3a5f;
  --price-final: #34d399;
  --price-final-bg: #064e3b;
  --warn: #f59e0b;
  --input-bg: #0d1218;
  --header-bg: linear-gradient(135deg, #1a1518 0%, #141c28 45%, #0f1a16 100%);
  --glow-a: #1e3a5f;
  --glow-b: #163528;
  --glow-brand: rgba(229, 19, 46, 0.18);
  --badge-bg: #2a2110;
  --badge-live-bg: #102a1a;
  --badge-live-fg: #86efac;
  --metric-bg: #0d1218;
  --formula-bg: #102a1a;
  --formula-border: #166534;
  --formula-fg: #bbf7d0;
  --total-row-bg: #14532d;
  --total-row-fg: #bbf7d0;
  --error-bg: #2a1212;
  --error-border: #7f1d1d;
  --error-fg: #fecaca;
  --seg-active-bg: #13233a;
  --voice-bg: #1e3a2f;
  --voice-fg: #86efac;
  --export-bg: #1e293b;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  --card-title: #c5d4e4;
  --link: #93c5fd;
  --cost-val: #93c5fd;
  --list-val: #e2e8f0;
  --primary-btn: linear-gradient(180deg, #ef334a, var(--brand-red-deep));
  --primary-btn-alt: linear-gradient(180deg, #4f8ff7, #2563eb);
}

/* ===== LIGHT (outdoor-readable: darker ink) ===== */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #e8eaee;
  --card: #ffffff;
  --border: #9aa5b1;
  --text: #0b0f14;
  --muted: #2a3540;
  --accent: #1d4ed8;
  --accent2: #047857;
  /* Without tax = deep blue-ink; with tax = deep emerald (different, outdoor-readable) */
  --price-no-tax: #1e3a8a;
  --price-no-tax-bg: #dbeafe;
  --price-final: #065f46;
  --price-final-bg: #6ee7b7;
  --warn: #92400e;
  --input-bg: #ffffff;
  --header-bg: linear-gradient(135deg, #ffe8eb 0%, #ffffff 48%, #e8f0ff 100%);
  --glow-a: #fecdd3;
  --glow-b: #bfdbfe;
  --glow-brand: rgba(229, 19, 46, 0.14);
  --badge-bg: #fff1e0;
  --badge-live-bg: #a7f3d0;
  --badge-live-fg: #064e3b;
  --metric-bg: #f1f5f9;
  --formula-bg: #d1fae5;
  --formula-border: #047857;
  --formula-fg: #064e3b;
  --total-row-bg: #a7f3d0;
  --total-row-fg: #064e3b;
  --error-bg: #fee2e2;
  --error-border: #b91c1c;
  --error-fg: #7f1d1d;
  --seg-active-bg: #dbeafe;
  --voice-bg: #d1fae5;
  --voice-fg: #064e3b;
  --export-bg: #e2e8f0;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
  --card-title: #0f172a;
  --link: #1e3a8a;
  --cost-val: #1e3a8a;
  --list-val: #0b0f14;
  --primary-btn: linear-gradient(180deg, #ef334a, var(--brand-red-deep));
  --primary-btn-alt: linear-gradient(180deg, #3b82f6, #1d4ed8);
}

/* System preference when auto → light */
@media (prefers-color-scheme: light) {
  html[data-theme="auto"] {
    color-scheme: light;
    --bg: #e8eaee;
    --card: #ffffff;
    --border: #9aa5b1;
    --text: #0b0f14;
    --muted: #2a3540;
    --accent: #1d4ed8;
    --accent2: #047857;
    --price-no-tax: #1e3a8a;
    --price-no-tax-bg: #dbeafe;
    --price-final: #065f46;
    --price-final-bg: #6ee7b7;
    --warn: #92400e;
    --input-bg: #ffffff;
    --header-bg: linear-gradient(135deg, #ffe8eb 0%, #ffffff 48%, #e8f0ff 100%);
    --glow-a: #fecdd3;
    --glow-b: #bfdbfe;
    --glow-brand: rgba(229, 19, 46, 0.14);
    --badge-bg: #fff1e0;
    --badge-live-bg: #a7f3d0;
    --badge-live-fg: #064e3b;
    --metric-bg: #f1f5f9;
    --formula-bg: #d1fae5;
    --formula-border: #047857;
    --formula-fg: #064e3b;
    --total-row-bg: #a7f3d0;
    --total-row-fg: #064e3b;
    --error-bg: #fee2e2;
    --error-border: #b91c1c;
    --error-fg: #7f1d1d;
    --seg-active-bg: #dbeafe;
    --voice-bg: #d1fae5;
    --voice-fg: #064e3b;
    --export-bg: #e2e8f0;
    --shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
    --card-title: #0f172a;
    --link: #1e3a8a;
    --cost-val: #1e3a8a;
    --list-val: #0b0f14;
    --primary-btn: linear-gradient(180deg, #ef334a, var(--brand-red-deep));
    --primary-btn-alt: linear-gradient(180deg, #3b82f6, #1d4ed8);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 0% -5%, var(--glow-brand), transparent 55%),
    radial-gradient(1100px 520px at 12% -8%, var(--glow-a) 0%, transparent 52%),
    radial-gradient(900px 480px at 100% 0%, var(--glow-b) 0%, transparent 48%),
    var(--bg);
  color: var(--text);
  line-height: 1.45;
  transition: background 0.2s ease, color 0.2s ease;
}

.wrap { max-width: 960px; margin: 0 auto; padding: 20px 16px 60px; }

/* Brand header */
.brand-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  margin: 0 0 8px;
  border-radius: var(--radius);
  background: var(--header-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-top: 3px solid var(--brand-red);
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  height: 44px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
  display: block;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.brand-text p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.brand-text a {
  color: var(--brand-red);
  text-decoration: none;
  font-weight: 600;
}
.brand-text a:hover { text-decoration: underline; }

.brand-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.theme-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--input-bg);
}

.theme-switch button {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 0;
}

.theme-switch button.active {
  background: var(--brand-red);
  color: #fff;
}

.badge {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: var(--badge-bg);
  color: var(--warn);
  border: 1px solid var(--border);
}
.badge.live {
  background: var(--badge-live-bg);
  color: var(--badge-live-fg);
  border-color: var(--formula-border);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--card-title);
}

label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  font-weight: 500;
}
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea {
  font-weight: 600;
  color: #0b0f14;
}
@media (prefers-color-scheme: light) {
  html[data-theme="auto"] input,
  html[data-theme="auto"] select,
  html[data-theme="auto"] textarea {
    font-weight: 600;
    color: #0b0f14;
  }
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px rgba(229, 19, 46, 0.2);
}
textarea { min-height: 64px; resize: vertical; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1.4fr 0.7fr 0.7fr; gap: 12px; }
@media (max-width: 640px) {
  .grid2, .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 .span-all { grid-column: 1 / -1; }
  .brand-logo { height: 36px; }
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  align-items: center;
}

button {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: var(--primary-btn);
  color: white;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-voice {
  background: var(--voice-bg);
  color: var(--voice-fg);
  border: 1px solid var(--formula-border);
}
.btn-voice.listening {
  background: #3f1d1d;
  color: #fecaca;
  border-color: #7f1d1d;
  animation: pulse 1s infinite;
}
@keyframes pulse { 50% { opacity: 0.75; } }
.btn-export {
  background: var(--export-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.seg-pick { display: flex; gap: 10px; }
.seg-pick label {
  flex: 1;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
  background: var(--input-bg);
  user-select: none;
  transition: 0.15s ease;
}
.seg-pick input { display: none; }
.seg-pick label:has(input:checked) {
  border-color: var(--brand-red);
  background: var(--seg-active-bg);
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(229, 19, 46, 0.15);
}
.seg-pick:has(input[value="residential"]:checked) label[data-seg="commercial"],
.seg-pick:has(input[value="commercial"]:checked) label[data-seg="residential"] {
  opacity: 0.35;
  filter: grayscale(0.6);
}

.checkrow {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin-top: 10px;
}
.checkrow label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
  cursor: pointer;
}
.checkrow input[type="checkbox"] {
  width: auto;
  accent-color: var(--brand-red);
}

.result-hero {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}
.result-hero[style*="1fr 1fr"] {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 640px) {
  .result-hero { grid-template-columns: 1fr; }
  .result-hero[style*="1fr 1fr"] { grid-template-columns: 1fr; }
}
.metric {
  background: var(--metric-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.metric .lbl {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.metric .val {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.metric.cost .val { color: var(--cost-val); }
.metric.list .val { color: var(--list-val); font-size: 1.4rem; }

/* WITHOUT tax — blue family (not the final green) */
.metric.no-tax {
  background: var(--price-no-tax-bg);
  border-color: var(--price-no-tax);
}
.metric.no-tax .lbl {
  color: var(--price-no-tax);
  font-weight: 700;
  letter-spacing: 0.06em;
}
.metric.no-tax .val {
  color: var(--price-no-tax);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* WITH tax — emerald final (draws the eye, different from without) */
.metric.margin {
  border: 1px solid rgba(234, 179, 8, 0.45);
}
.metric.margin .lbl {
  color: #ca8a04;
  font-weight: 600;
}
.metric.margin .val {
  color: #eab308;
  font-size: 1.65rem;
}
.metric.margin.margin-ok .val { color: #4ade80; }
.metric.margin.margin-tight .val { color: #fbbf24; }
.metric.margin.margin-low .val { color: #f87171; }
html[data-theme="light"] .metric.margin .val { color: #a16207; }
html[data-theme="light"] .metric.margin.margin-ok .val { color: #15803d; }
html[data-theme="light"] .metric.margin.margin-tight .val { color: #b45309; }
html[data-theme="light"] .metric.margin.margin-low .val { color: #b91c1c; }
.metric.margin-list .val { color: var(--muted); }
.meet-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--metric-bg);
  border: 1px dashed var(--border, #334155);
}
.meet-box input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, #475569);
  background: var(--input-bg, transparent);
  color: inherit;
  font-size: 1rem;
}
.metric.total {
  background: var(--price-final-bg);
  border-color: var(--price-final);
}
.metric.total .lbl {
  color: var(--price-final);
  font-weight: 700;
  letter-spacing: 0.06em;
}
.metric.total .val {
  color: var(--price-final);
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
html[data-theme="light"] .metric.no-tax .val {
  color: #1e3a8a;
}
html[data-theme="light"] .metric.total .val {
  color: #064e3b;
}
@media (prefers-color-scheme: light) {
  html[data-theme="auto"] .metric.no-tax .val { color: #1e3a8a; }
  html[data-theme="auto"] .metric.total .val { color: #064e3b; }
}

.price-final {
  color: var(--price-final, var(--accent2));
  font-weight: 800;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}
html[data-theme="light"] .price-final {
  color: #064e3b;
}
@media (prefers-color-scheme: light) {
  html[data-theme="auto"] .price-final {
    color: #064e3b;
  }
  html[data-theme="auto"] .metric.total .val {
    color: #064e3b;
  }
  html[data-theme="auto"] .breakdown .row.total strong {
    color: #064e3b;
    font-size: 1.25rem;
  }
}

.breakdown {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.breakdown .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
}
.breakdown .row:first-child { border-top: none; }
.breakdown .row strong { font-variant-numeric: tabular-nums; }
.breakdown .row.total {
  background: var(--total-row-bg);
  color: var(--total-row-fg);
  font-weight: 800;
  font-size: 1.08rem;
}
.breakdown .row.total strong {
  font-size: 1.2rem;
  color: var(--price-final, var(--total-row-fg));
}
.breakdown .row.no-tax-total {
  background: var(--price-no-tax-bg);
  color: var(--price-no-tax);
  font-weight: 800;
  font-size: 1.05rem;
}
.breakdown .row.no-tax-total strong {
  font-size: 1.15rem;
  color: var(--price-no-tax);
}
html[data-theme="light"] .breakdown .row.total strong {
  color: #064e3b;
  font-size: 1.25rem;
}
html[data-theme="light"] .breakdown .row.no-tax-total strong {
  color: #1e3a8a;
  font-size: 1.2rem;
}
.breakdown .row.muted { color: var(--muted); font-size: 0.88rem; }

.formula {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--formula-bg);
  border: 1px solid var(--formula-border);
  border-radius: 10px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.9rem;
  color: var(--formula-fg);
}

.steps {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.steps li {
  counter-increment: step;
  position: relative;
  padding: 8px 12px 8px 42px;
  border-top: 1px solid var(--border);
  font-size: 0.92rem;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 10px;
  top: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-red);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.meta { color: var(--muted); font-size: 0.85rem; margin-top: 10px; }
.meta a, a.meta { color: var(--link); }

.error {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: 10px;
  color: var(--error-fg);
}

.alts { margin-top: 10px; font-size: 0.9rem; color: var(--muted); }
.alts ul { margin: 6px 0 0; padding-left: 18px; }
.hidden { display: none !important; }

.heard {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--input-bg);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--cost-val);
  border: 1px dashed var(--border);
}

footer {
  margin-top: 24px;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
footer .brand-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  margin-bottom: 8px;
}
footer a { color: var(--brand-red); font-weight: 600; text-decoration: none; }
footer a:hover { text-decoration: underline; }
