/* ==========================================================================
   SHTEMBERG 2D CAD CONFIGURATOR — LUXURY MINIMALIST STYLES (NO EMOJIS)
   ========================================================================== */

:root {
  --bg: #060c0e;
  --bg-surface: #0a1418;
  --bg-card: #0e1b20;
  --bg-card-hover: #13242a;
  --bg-input: #0b171c;
  --border: rgba(255, 255, 255, 0.08);
  --border-active: rgba(27, 168, 181, 0.6);
  --text: #f1f5f9;
  --text-muted: #829da1;
  --text-dim: #456165;
  --accent: #1ba8b5;
  --accent-glow: #2fe0f0;
  --accent-tint: rgba(27, 168, 181, 0.12);
  --accent-dark: #092e33;
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  min-height: 100%;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── HEADER ─────────────────────────────────────────────────────── */
.app-header {
  height: 60px;
  background: rgba(6, 12, 14, 0.96);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.05em;
}

.logo-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent-glow);
  background: var(--accent-tint);
  border: 1px solid rgba(27, 168, 181, 0.3);
  padding: 2px 7px;
  border-radius: 4px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s var(--ease);
}

.nav-link:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

/* ── WORKSPACE 2-COLUMN LAYOUT ─────────────────────────────────── */
.config-workspace {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 28px;
  align-items: start;
}

/* ── CONTROLS DECK (LEFT) ───────────────────────────────────────── */
.controls-deck {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
}

.deck-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}

.deck-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
}

.deck-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.group-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.group-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.value-badge {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent-glow);
  background: var(--accent-tint);
  border: 1px solid rgba(27, 168, 181, 0.3);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ── CHIPS ROW ──────────────────────────────────────────────────── */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}

.chip-btn:hover {
  background: var(--bg-card-hover);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.chip-btn.active {
  background: var(--accent-tint);
  color: var(--accent-glow);
  border-color: var(--accent);
  font-weight: 600;
}

/* ── SLIDER & PRESETS ───────────────────────────────────────────── */
.range-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #142329;
  outline: none;
  accent-color: var(--accent-glow);
  cursor: pointer;
}

.preset-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 4px;
}

.preset-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.76rem;
  padding: 5px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.preset-btn:hover {
  background: var(--bg-card-hover);
  color: #fff;
}

.preset-btn.active {
  background: var(--accent-tint);
  color: var(--accent-glow);
  border-color: var(--accent);
}

/* ── SEGMENTED CONTROL ──────────────────────────────────────────── */
.segmented-control {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
}

.segment-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.segment-btn:hover {
  color: #fff;
}

.segment-btn.active {
  background: var(--accent);
  color: #04080a;
  font-weight: 600;
}

/* ── COUNTER CHIPS ──────────────────────────────────────────────── */
.sub-counter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sub-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.counter-chips {
  display: flex;
  gap: 6px;
}

.count-chip {
  width: 34px;
  height: 30px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.count-chip:hover {
  background: var(--bg-card-hover);
  color: #fff;
}

.count-chip.active {
  background: var(--accent-tint);
  color: var(--accent-glow);
  border-color: var(--accent);
}

/* ── ZONE BLOCKS GRID (CLEAN TEXT) ──────────────────────────────── */
.zone-blocks-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.zone-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.18s var(--ease);
  user-select: none;
}

.zone-block:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.zone-block.active {
  background: var(--accent-tint);
  border-color: var(--border-active);
}

.zone-block input[type="checkbox"] {
  display: none;
}

.zone-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
}

.zone-block.active .zone-title {
  color: #fff;
}

.zone-block.locked {
  background: rgba(27, 168, 181, 0.18);
  border-color: var(--accent);
  cursor: default;
}

.zone-lock-badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--accent-glow);
  text-transform: uppercase;
}

/* ── ACTION BUTTONS ─────────────────────────────────────────────── */
.deck-action-section {
  margin-top: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-generate-primary {
  width: 100%;
  height: 50px;
  background: linear-gradient(135deg, #1ba8b5, #2fe0f0);
  border: none;
  border-radius: 8px;
  color: #04080a;
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  box-shadow: 0 6px 20px rgba(27, 168, 181, 0.35);
  letter-spacing: 0.02em;
}

.btn-generate-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 8px 26px rgba(47, 224, 240, 0.5);
  transform: translateY(-1px);
}

.action-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.74rem;
  color: var(--text-dim);
}

/* ── PREVIEW DECK (RIGHT) ───────────────────────────────────────── */
.preview-deck {
  display: flex;
  flex-direction: column;
}

/* ── LIVE SCHEMATIC CARD ────────────────────────────────────────── */
.schematic-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.schematic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.schematic-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-pulse {
  width: 8px;
  height: 8px;
  background: var(--accent-glow);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-glow);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.schematic-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.schematic-meta {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
}

.schematic-canvas-box {
  background: #020506;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.live-svg-canvas {
  width: 100%;
  height: 100%;
  max-height: 400px;
}

.schematic-footer {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
}

/* ── ASYNC LOADING CARD & STAGES ────────────────────────────────── */
.gen-loading-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 60px 24px;
  text-align: center;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gen-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(27, 168, 181, 0.2);
  border-top-color: var(--accent-glow);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}

.loading-status {
  font-size: 0.88rem;
  color: var(--text-muted);
  max-width: 440px;
}

.loading-stages-bar {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.stage-item {
  font-size: 0.78rem;
  color: var(--text-dim);
  padding: 5px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all 0.2s var(--ease);
}

.stage-item.active {
  color: var(--accent-glow);
  border-color: var(--accent);
  background: var(--accent-tint);
  font-weight: 600;
}

.loading-bar-track {
  width: 100%;
  max-width: 360px;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  margin-top: 20px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-glow);
  animation: loadFill 25s linear forwards;
}

@keyframes loadFill {
  0% { width: 5%; }
  40% { width: 55%; }
  80% { width: 90%; }
  100% { width: 98%; }
}

/* ── ERROR CARD ─────────────────────────────────────────────────── */
.gen-error-card {
  background: var(--bg-surface);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 14px;
  padding: 60px 24px;
  text-align: center;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.error-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.error-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  max-width: 440px;
  margin-bottom: 20px;
}

.btn-retry-error {
  height: 44px;
  padding: 0 24px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 7px;
  color: #04080a;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.btn-retry-error:hover {
  background: var(--accent-glow);
  box-shadow: 0 0 16px rgba(47, 224, 240, 0.4);
}

/* ── RESULT BLUEPRINT CARD ──────────────────────────────────────── */
.result-blueprint-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent-glow);
  background: var(--accent-tint);
  border: 1px solid rgba(27, 168, 181, 0.3);
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 6px;
}

.result-heading {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
}

.result-sub-info {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.result-svg-viewport {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 300px;
}

.result-svg-viewport svg {
  width: 100%;
  height: auto;
  max-height: 65vh;
  display: block;
}

.loading-hint {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin-top: 8px;
}

.loading-bar-indeterminate {
  width: 30%;
  animation: indeterminate 1.8s ease-in-out infinite;
}

@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(200%); }
  100% { transform: translateX(-100%); }
}

.result-action-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-res-primary {
  height: 44px;
  padding: 0 20px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 7px;
  color: #04080a;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: all 0.2s var(--ease);
}

.btn-res-primary:hover {
  background: var(--accent-glow);
  box-shadow: 0 0 16px rgba(47, 224, 240, 0.4);
}

.btn-res-secondary {
  height: 44px;
  padding: 0 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-weight: 500;
  font-size: 0.84rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: all 0.2s var(--ease);
}

.btn-res-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-res-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-res-outline {
  height: 44px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 0.84rem;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.btn-res-outline:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

/* ── MOBILE ADAPTATION (360PX+) ─────────────────────────────────── */
@media (max-width: 960px) {
  .config-workspace {
    padding: 16px 12px 40px;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .controls-deck {
    padding: 18px 14px;
  }

  .deck-title {
    font-size: 1.2rem;
  }

  .zone-blocks-grid {
    grid-template-columns: 1fr;
  }

  .loading-stages-bar {
    flex-direction: column;
    width: 100%;
  }

  .result-action-buttons {
    flex-direction: column;
    width: 100%;
  }

  .btn-res-primary, .btn-res-secondary, .btn-res-outline {
    width: 100%;
    justify-content: center;
  }
}
