﻿*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #232734;
  --border: #2e3346;
  --text: #e4e7ef;
  --text-muted: #8b90a0;
  --accent: #4f8cff;
  --accent-hover: #6ba0ff;
  --accent-soft: rgba(79,140,255,0.1);
  --danger: #ff4f6d;
  --success: #34d399;
  --shelf-color: #4f8cff;
  --shelf-selected: #6ba0ff;
  --door-color: #f59e0b;
  --aisle-color: rgba(52, 211, 153, 0.08);
  --wall-color: #555a6e;
  --grid-color: rgba(255,255,255,0.04);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== HEADER ===== */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
}
.header-inner { max-width: 1600px; margin: 0 auto; }
.header-top { display: flex; align-items: center; justify-content: space-between; }
header h1 { font-size: 1.4rem; font-weight: 700; }
.subtitle { color: var(--text-muted); font-size: 0.85rem; margin-top: 2px; }

/* Mode Toggle */
.mode-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mode-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: color 0.2s;
  cursor: pointer;
}
.mode-label.active { color: var(--accent); font-weight: 600; }
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--accent);
  border-radius: 26px;
  transition: 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px; width: 20px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--surface2); border: 1px solid var(--border); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }

/* ===== WIZARD / EASY MODE ===== */
.easy-mode { max-width: 700px; margin: 0 auto; padding: 24px; }

.wizard-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 24px;
}

/* Progress Bar */
.wizard-progress { margin-bottom: 32px; }
.progress-bar {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
  width: 20%;
}
.progress-text {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Wizard Steps */
.wizard-step {
  display: none;
  animation: fadeIn 0.3s ease;
}
.wizard-step.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.step-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}
.wizard-step h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.step-description {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
  line-height: 1.6;
}
.step-hint {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 16px;
  font-style: italic;
}

/* Step Inputs */
.step-inputs {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.input-group {
  flex: 1;
  min-width: 140px;
}
.input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.input-with-unit {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s;
}
.input-with-unit:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(79,140,255,0.2);
}
.input-with-unit input {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 10px 12px;
  font-size: 1.1rem;
  font-family: inherit;
  width: 100%;
  text-align: left;
  outline: none;
}
.input-with-unit .unit {
  padding: 0 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}
.input-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  opacity: 0.7;
}

/* Room Builder (SVG interactive preview) */
.room-builder {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.room-svg {
  width: 100%;
  max-width: 400px;
  height: auto;
}
.room-svg .wall-hit:hover { fill: rgba(79,140,255,0.12) !important; cursor: pointer; }
.input-with-unit.small {
  max-width: 120px;
}
.input-with-unit.small input { padding: 6px 8px; font-size: 0.9rem; }

/* Door Slider */
.door-slider-row, .door-width-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}
.door-slider-row label, .door-width-row label {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: fit-content;
}
.door-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  outline: none;
}
.door-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #f59e0b;
  cursor: grab;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.door-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #f59e0b;
  cursor: grab;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Shelf Presets */
.shelf-presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.shelf-preset {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  color: var(--text);
  transition: all 0.15s;
}
.shelf-preset:hover { border-color: var(--accent); }
.shelf-preset.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.preset-size { display: block; font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.preset-label { display: block; font-size: 0.75rem; color: var(--text-muted); }

/* Aisle Presets */
.aisle-presets { display: flex; flex-direction: column; gap: 8px; }
.aisle-preset {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: all 0.15s;
  text-align: left;
}
.aisle-preset:hover { border-color: var(--accent); }
.aisle-preset.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.preset-value { font-size: 1.1rem; font-weight: 700; min-width: 60px; }
.aisle-preset .preset-label { font-size: 0.85rem; color: var(--text-muted); }

/* Result Stats */
.result-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.stat-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

/* Wizard Nav */
.wizard-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.btn-wizard-back, .btn-wizard-next {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  padding: 12px 28px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-wizard-back {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-wizard-back:hover { border-color: var(--accent); color: var(--accent); }
.btn-wizard-next {
  background: var(--accent);
  color: #fff;
}
.btn-wizard-next:hover { background: var(--accent-hover); transform: translateY(-1px); }

.wizard-canvas { max-width: 900px; margin: 0 auto 24px; }

/* ===== ADVANCED MODE ===== */
.advanced-mode { max-width: 1600px; margin: 0 auto; padding: 16px 24px; }

/* CONFIG BAR */
.config-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  align-items: flex-end;
}
.config-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.input-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.input-row label {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.input-row input[type="number"], .input-row select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 6px 8px;
  font-size: 0.85rem;
  font-family: inherit;
  width: 72px;
  text-align: center;
}
.input-row select { width: auto; padding-right: 24px; cursor: pointer; }
.input-row input:focus, .input-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(79,140,255,0.2);
}

/* BUTTONS */
.config-actions { display: flex; gap: 8px; align-items: flex-end; margin-left: auto; }
button {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid transparent; }
.btn-danger:hover { border-color: var(--danger); background: rgba(255,79,109,0.08); }

/* CANVAS AREA */
.planner-area { margin-bottom: 24px; }
.canvas-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
#plannerCanvas, #advancedCanvas {
  display: block;
  width: 100%;
  cursor: crosshair;
}
.canvas-info {
  display: flex;
  gap: 16px;
  padding: 8px 16px;
  background: var(--surface2);
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
  align-items: center;
}
.canvas-info .hint { margin-left: auto; font-style: italic; opacity: 0.6; }
#shelfCount, #advShelfCount { font-weight: 600; color: var(--accent); }

/* AFFILIATE SECTION */
.affiliate-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.affiliate-section h2 { font-size: 1.1rem; margin-bottom: 4px; }
.affiliate-hint { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 16px; }
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.product-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.15s, transform 0.15s;
  display: flex;
  flex-direction: column;
}
.product-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.product-card .brand { font-size: 0.72rem; color: var(--accent); text-transform: uppercase; font-weight: 600; letter-spacing: 0.04em; }
.product-card .name { font-size: 0.9rem; font-weight: 600; margin: 6px 0 4px; line-height: 1.3; }
.product-card .dims { font-size: 0.8rem; color: var(--text-muted); }
.product-card .load { font-size: 0.75rem; color: var(--success); margin-top: 4px; }
.product-card .note { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; font-style: italic; }
.product-card .cta { margin-top: auto; padding-top: 12px; }
.product-card .cta a {
  display: inline-block;
  background: #ff9900;
  color: #111;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.15s, transform 0.15s;
}
.product-card .cta a:hover { background: #ffad33; transform: translateY(-1px); }

/* FOOTER */
footer {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}
footer a { color: var(--accent); text-decoration: none; }
.affiliate-disclosure { margin-top: 4px; opacity: 0.6; }

/* RESPONSIVE */
@media (max-width: 900px) {
  .config-bar { flex-direction: column; }
  .config-actions { margin-left: 0; width: 100%; justify-content: stretch; }
  .config-actions button { flex: 1; }
  .canvas-info { flex-wrap: wrap; }
  .canvas-info .hint { margin-left: 0; width: 100%; }
  .easy-mode { padding: 16px; }
  .wizard-container { padding: 20px; }
  .step-inputs { flex-direction: column; }
  .shelf-presets { grid-template-columns: repeat(2, 1fr); }
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  z-index: 1000;
  transition: transform 0.3s ease;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }
