/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --white:              #fff;
  --ultralightgrey:     #f6f7f5;
  --verylightgrey:      #eeeeed;
  --lightgrey:          #dddedd;
  --imagegrey:          #ecedeb;
  --verylightgreytext:  #c0c1bf;
  --lightgreytext:      #9a9b99;
  --middlegreytext:     #767676;
  --darkgreytext:       #5c5e5d;
  --blackmaintext:      #121212;
  --darkgrey:           #3a3c3b;
  --verydarkgrey:       #2a2c2b;
  --leica-red:          #e2001a;

  --color-bg:            var(--ultralightgrey);
  --color-surface:       var(--white);
  --color-surface-2:     var(--ultralightgrey);
  --color-surface-3:     var(--verylightgrey);
  --color-border:        var(--lightgrey);
  --color-border-subtle: var(--verylightgrey);

  --color-accent:        var(--leica-red);
  --color-accent-dim:    rgba(226, 0, 26, 0.07);
  --color-accent-hover:  #c70017;
  --color-accent-muted:  rgba(226, 0, 26, 0.25);
  --color-digital:       #3a6aad;
  --color-digital-dim:   rgba(58, 106, 173, 0.08);

  --color-text-primary:   var(--blackmaintext);
  --color-text-secondary: var(--darkgreytext);
  --color-text-muted:     var(--lightgreytext);

  --color-warning:     #e2001a;
  --color-warning-dim: rgba(226, 0, 26, 0.08);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", "Menlo", monospace;

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;

  --transition: 140ms ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input  { font: inherit; color: inherit; border: none; background: none; outline: none; }
select { font: inherit; }
.mono  { font-family: var(--font-mono); }


/* ── Main layout ───────────────────────────────────────────── */
.layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* ── Top Controls (Model | Wall | Depth — one line) ────────── */
.top-controls {
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 32px;
  height: 76px;
  gap: 0;
}

.top-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.top-divider {
  width: 1px;
  height: 36px;
  background: var(--color-border);
  margin: 0 24px;
  flex-shrink: 0;
}

.top-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lightgreytext);
  white-space: nowrap;
  flex-shrink: 0;
}

.optional {
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  font-size: 10px;
  opacity: 0.7;
}

.projector-ctrl-row { display: flex; align-items: center; gap: 8px; width: 100%; }
.projector-ctrl-row .select-wrapper { flex: 1; }
.top-settings-toggle { display: none; }
.top-settings-drawer { display: contents; }

/* Select */
.select-wrapper {
  position: relative;
  flex: 1;
  max-width: 260px;
}
.select-wrapper select {
  width: 100%;
  appearance: none;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 7px 30px 7px 11px;
  font-size: 13px;
  font-weight: 500;
  color: var(--blackmaintext);
  cursor: pointer;
  transition: border-color var(--transition);
}
.select-wrapper select:hover { border-color: var(--middlegreytext); }
.select-wrapper select:focus { border-color: var(--color-accent); outline: none; }
.select-arrow {
  position: absolute; right: 9px; top: 50%;
  transform: translateY(-50%);
  width: 10px; height: 7px;
  color: var(--middlegreytext); pointer-events: none;
}

/* Wall + depth inputs */
.wall-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.wall-sep {
  color: var(--lightgreytext);
  font-size: 14px;
  flex-shrink: 0;
}
.input-group {
  display: flex;
  align-items: center;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  flex: 1;
  max-width: 120px;
  transition: border-color var(--transition);
}
.input-group:focus-within { border-color: var(--color-accent); }
.input-group input {
  flex: 1; padding: 7px 8px; font-size: 13px;
  font-family: var(--font-mono); min-width: 0;
  color: var(--blackmaintext);
}
.input-group input::placeholder { color: var(--verylightgreytext); font-family: var(--font-sans); }
.input-unit {
  padding: 0 8px;
  font-size: 11px;
  color: var(--lightgreytext);
  border-left: 1px solid var(--color-border);
  background: var(--imagegrey);
  align-self: stretch;
  display: flex; align-items: center;
  white-space: nowrap;
}

/* ── Sliders Container (3 equal columns) ───────────────────── */
.sliders-container {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: row;
  align-items: stretch;
  flex-shrink: 0;
}

.slider-section {
  flex: 1;
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-right: 1px solid var(--color-border);
  min-width: 0;
}
.slider-section:last-child { border-right: none; }

.slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.slider-left  { display: flex; align-items: center; gap: 9px; }
.slider-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.slider-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--lightgreytext);
  letter-spacing: 0.01em;
}
.slider-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--blackmaintext);
  white-space: nowrap;
}
/* Lock button */
.lock-btn {
  display: flex; align-items: center; justify-content: center;
  transition: color var(--transition);
  color: var(--verylightgreytext);
  flex-shrink: 0;
}
.lock-btn:hover { color: var(--middlegreytext); }
.lock-btn.locked { color: var(--color-accent); }
.lock-btn.locked:hover { color: var(--color-accent-hover); }
.lock-icon { width: 13px; height: 15px; }
.lock-btn .lock-closed { display: none; }
.lock-btn.locked .lock-open  { display: none; }
.lock-btn.locked .lock-closed { display: block; }

/* Zone label (inline colored text, no cartouche) */
.zone-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--color-accent);
  transition: color var(--transition);
  white-space: nowrap;
}
.zone-label.digital { color: var(--color-digital); }

/* Unit toggle */
.unit-toggle {
  display: flex;
  background: var(--verylightgrey);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.unit-btn {
  padding: 3px 7px; font-size: 11px; font-weight: 500;
  color: var(--lightgreytext);
  transition: background var(--transition), color var(--transition);
}
.unit-btn:hover { color: var(--darkgreytext); }
.unit-btn.active { background: var(--color-accent); color: var(--white); font-weight: 600; }

/* Size mode select (discrete dropdown) */
.size-mode-wrap { max-width: 96px; flex-shrink: 0; }
.size-mode-wrap select {
  font-size: 11px;
  padding: 4px 24px 4px 8px;
  color: var(--lightgreytext);
  font-weight: 500;
}
.size-mode-wrap select:hover { border-color: var(--middlegreytext); color: var(--darkgreytext); }

/* ── Range Sliders ─────────────────────────────────────────── */
.slider-track-wrap { display: flex; flex-direction: column; gap: 5px; }

.slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 3px; border-radius: 2px;
  outline: none; cursor: pointer;
  background: var(--verylightgrey);
}
.slider:disabled { opacity: 0.35; cursor: default; }

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--white);
  box-shadow: 0 0 0 1px var(--color-accent-muted), 0 1px 4px rgba(0,0,0,0.15);
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
}
.slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 4px var(--color-accent-dim), 0 1px 4px rgba(0,0,0,0.15);
  transform: scale(1.1);
}
.slider:active::-webkit-slider-thumb {
  box-shadow: 0 0 0 6px var(--color-accent-dim);
  transform: scale(1.15);
}
.slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--color-accent); border: 2px solid var(--white);
  box-shadow: 0 0 0 1px var(--color-accent-muted); cursor: pointer;
}

.slider-bounds {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--lightgreytext); padding: 0 2px;
}

/* Zoom zone labels */
.zoom-track-wrap { position: relative; }
.zoom-zone-labels { display: flex; pointer-events: none; height: 13px; }
.zone-label-segment {
  font-size: 9px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  display: flex; align-items: center; justify-content: center; overflow: hidden; white-space: nowrap;
}
.zone-label-segment.optical { color: rgba(226, 0, 26, 0.35); }
.zone-label-segment.digital { color: rgba(58, 106, 173, 0.4); }

/* ── Visualization Row ─────────────────────────────────────── */
.viz-row {
  flex: 1;
  display: flex;
  min-height: 0;
}

.viz-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
}
.viz-panel:last-child { border-right: none; }

.viz-panel-label {
  position: absolute;
  top: 12px;
  left: 14px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--lightgreytext);
  pointer-events: none;
}
.viz-panel-label svg { width: 13px; height: 13px; flex-shrink: 0; }

.viz-canvas-wrap {
  flex: 1;
  background: var(--verylightgrey);
  overflow: hidden;
  min-height: 450px;
  position: relative;
}

.viz-canvas-wrap > svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Gate overlay — shown until configured */
.viz-gate {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--imagegrey);
  z-index: 10;
  border-radius: var(--radius-lg);
}
.viz-gate svg {
  width: 32px; height: 32px;
  color: var(--verylightgreytext);
}
.viz-gate p {
  font-size: 12px;
  color: var(--lightgreytext);
  text-align: center;
  max-width: 200px;
  line-height: 1.5;
}

/* SVG text classes */
.viz-dim       { font-family: var(--font-mono); font-size: 8px; fill: var(--lightgreytext); }
.viz-dim-muted { font-family: var(--font-mono); font-size: 9px; fill: var(--verylightgreytext); }
.viz-diag-label {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  fill: rgba(255,255,255,0.95);
  paint-order: stroke fill;
  stroke: rgba(0,0,0,0.35);
  stroke-width: 2.5px;
  stroke-linejoin: round;
}
.viz-throw-label { font-family: var(--font-mono); font-size: 10px; fill: var(--lightgreytext); }
.viz-warning    { font-family: var(--font-sans); font-size: 11px; font-weight: 600; fill: var(--leica-red); }
.viz-warn-badge rect { fill: var(--leica-red); }
.viz-warn-badge text { font-family: var(--font-sans); font-size: 10px; font-weight: 600; fill: #fff; letter-spacing: 0.02em; }
.viz-zone-label { font-family: var(--font-mono); font-size: 9px; font-weight: 600; fill: var(--middlegreytext); letter-spacing: 0.05em; }
.viz-room-label { font-family: var(--font-mono); font-size: 10px; fill: var(--lightgreytext); }

/* ── Sofa popover ──────────────────────────────────────────── */
.sofa-popover {
  position: absolute;
  z-index: 30;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  padding: 10px 12px;
  width: 170px;
  pointer-events: all;
}
.sofa-pop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.sofa-pop-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--darkgreytext);
}
.sofa-pop-close {
  font-size: 16px;
  line-height: 1;
  color: var(--lightgreytext);
  padding: 0 2px;
  transition: color var(--transition);
}
.sofa-pop-close:hover { color: var(--color-accent); }
.sofa-pop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.sofa-pop-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--lightgreytext);
  letter-spacing: 0.02em;
}
.sofa-pop-val {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--blackmaintext);
}
.sofa-seats-btns {
  display: flex;
  background: var(--verylightgrey);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.sofa-seat-btn {
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--lightgreytext);
  transition: background var(--transition), color var(--transition);
}
.sofa-seat-btn:hover { color: var(--darkgreytext); }
.sofa-seat-btn.active { background: var(--color-accent); color: var(--white); font-weight: 600; }
.sofa-popover .slider { margin-top: 4px; }

/* Arc slider handle — matches HTML range thumb */
#tv-arc-handle {
  cursor: grab;
  filter: drop-shadow(0 0 0 1px rgba(226,0,26,0.25)) drop-shadow(0 1px 4px rgba(0,0,0,0.15));
}
#tv-arc-handle:active { cursor: grabbing; }

#tv-arc-header-lbl {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  fill: var(--lightgreytext);
}

/* ── Drawer header + tab bar (hidden on desktop) ───────────── */
.viz-drawer-header { display: none; }
.viz-tab-bar       { display: none; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .sliders-container { flex-direction: column; }
  .slider-section { border-right: none; border-bottom: 1px solid var(--color-border-subtle); padding: 16px 24px; }
  .slider-section:last-child { border-bottom: none; }
}

@media (max-width: 900px) {
  .header { padding: 0 16px; }
  .top-controls { height: auto; flex-wrap: wrap; padding: 12px 16px; gap: 12px; }
  .top-divider  { display: none; }
  .top-block    { flex: unset; width: 100%; }
  .viz-row { flex-direction: column; }
  .viz-panel { border-right: none; border-bottom: 1px solid var(--color-border); }
  .viz-panel:last-child { border-bottom: none; }
}

@media (max-width: 600px) {
  .slider-right { gap: 5px; }
  .size-mode-wrap { display: none; }
}

/* ── Mobile (phone) ─────────────────────────────────────────── */
@media (max-width: 768px) {

  body    { height: auto; overflow: auto; }
  .layout { height: auto; overflow: visible; }

  /* ── Top controls: projector row + inline toggle ── */
  .top-controls {
    display: flex;
    flex-direction: column;
    height: auto;
    padding: 10px 14px;
    gap: 0;
    align-items: stretch;
  }

  .top-block {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    flex: unset;
    width: 100%;
    min-width: 0;
  }

  /* Settings toggle — inline right of the select */
  .top-settings-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface-2);
    color: var(--lightgreytext);
    transition: color var(--transition), border-color var(--transition);
  }
  .top-settings-toggle svg {
    width: 12px; height: 8px;
    transition: transform var(--transition);
  }
  .top-settings-toggle.open svg { transform: rotate(180deg); }
  .top-settings-toggle:hover { border-color: var(--middlegreytext); color: var(--darkgreytext); }

  /* Settings drawer — collapsed by default */
  .top-settings-drawer {
    display: flex;
    gap: 10px;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.28s ease, padding-top 0.28s ease;
  }
  .top-settings-drawer.open {
    max-height: 120px;
    padding-top: 10px;
  }
  .top-settings-drawer .top-block { flex: 1; min-width: 0; }
  .top-settings-drawer .top-block:first-child { flex: 2; }
  .top-settings-drawer .top-divider { display: none; }

  .wall-inputs { gap: 4px; }
  .input-group { max-width: 100%; min-width: 0; }
  .input-group input { font-size: 16px; padding: 7px 5px; } /* 16px → no iOS zoom */
  .input-unit  { padding: 0 5px; }

  .select-wrapper { max-width: 100%; }
  .select-wrapper select { font-size: 16px; }
  .projector-ctrl-row .select-wrapper { max-width: none; } /* fill row → button pushed to right edge */

  /* ── Tab bar ─────────────────────────────────────────────── */
  .viz-tab-bar {
    display: flex;
    flex-shrink: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
  }
  .viz-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 11px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--lightgreytext);
    border-bottom: 2px solid transparent;
    transition: color var(--transition), border-color var(--transition);
  }
  .viz-tab:first-child { border-right: 1px solid var(--color-border); }
  .viz-tab svg { width: 13px; height: 13px; flex-shrink: 0; }
  .viz-tab.active { color: var(--color-accent); border-bottom-color: var(--color-accent); }

  /* ── Viz-row: at least 50% screen height ───────────────────── */
  .viz-row {
    min-height: 50dvh;
    flex-shrink: 0;
    display: flex;
    overflow: hidden;
  }
  .viz-canvas-wrap { min-height: 0; }

  /* Panels: only active one visible */
  .viz-panel {
    display: none;
    flex-direction: column;
    border-right: none;
    border-bottom: none;
  }
  .viz-panel.open {
    display: flex;
    flex: 1;
    overflow: hidden;
  }
  .viz-canvas-wrap { max-height: none; overflow: hidden; }

  /* Floating label inside canvas */
  .viz-panel-label { display: none; }

  /* ── Sliders: compact ─────────────────────────────────────── */
  .sliders-container { overflow-y: auto; }
  .slider-section { padding: 8px 16px; gap: 7px; }

  /* SVG dimension labels: doubled because the SVG is scaled ~58% on mobile */
  .viz-dim       { font-size: 16px; }
  .viz-dim-muted { font-size: 18px; }
  #tv-arc-header-lbl { font-size: 20px; }
}

/* ── Logo ─────────────────────────────────────────────────── */
#logo-liva {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
  margin-right: 24px;
}
#navBar #logo-liva img {
  width: 100%;
  height: 100%;
  max-height: 28px;
}

/* ── CTA Section ──────────────────────────────────────────── */
.cta-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px 24px;
  border-top: 1px solid var(--color-border);
  background: var(--white);
}

.cta-reassurance {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cta-reassurance-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin: 0;
}
.cta-reassurance-link {
  font-size: 12px;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.cta-reassurance-link:hover { color: var(--color-text-secondary); }

.cta-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.cta-card {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  text-align: right;
}

.cta-label {
  margin: 0;
  font-size: 12px;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

.cta-btn {
  display: inline-block;
  padding: 9px 20px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: opacity 0.15s;
}

.cta-btn:hover { opacity: 0.82; }


.cta-btn--primary {
  background: var(--leica-red);
  color: #fff;
  border: 1.5px solid var(--leica-red);
}

.cta-btn--secondary {
  background: transparent;
  color: var(--leica-red);
  border: 1.5px solid var(--leica-red);
}

@media (max-width: 768px) {
  #logo-liva { display: none; }
  .cta-reassurance { display: none; }
  .cta-section {
    justify-content: center;
    padding: 12px 16px 20px;
  }
  .cta-actions {
    justify-content: center;
    flex-wrap: wrap;
  }
  .cta-card { align-items: center; text-align: center; }
}
