/* ───────────────────────────────────────────────────────────────────────────
   RV Basics Bunk Builder — Styles
   Brand: ERVP / RV Basics — white bg, red #dc2626 accent, clean sans-serif
   ─────────────────────────────────────────────────────────────────────────── */

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

:root {
  --red: #dc2626;
  --red-dark: #b91c1c;
  --red-light: #fef2f2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --border-radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #fff;
  color: var(--gray-900);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
#app-header {
  background: #fff;
  border-bottom: 2px solid var(--red);
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 0;
  flex-wrap: wrap;
}

.header-brand {
  font-size: 20px;
  font-weight: 800;
  color: var(--red);
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.header-brand span { color: var(--gray-900); }

.product-toggle {
  display: flex;
  background: var(--gray-100);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.product-toggle button {
  padding: 7px 16px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--gray-500);
  transition: all .15s;
  white-space: nowrap;
}

.product-toggle button.active {
  background: var(--red);
  color: #fff;
  box-shadow: var(--shadow);
}

.header-price {
  margin-left: auto;
  text-align: right;
}

.header-price .price-label { font-size: 11px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; }
.header-price .price-value { font-size: 26px; font-weight: 800; color: var(--red); line-height: 1; }
.header-price .price-sub   { font-size: 11px; color: var(--gray-500); margin-top: 2px; }

/* ── Main layout ──────────────────────────────────────────────────────────── */
#app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 28px;
  align-items: start;
}

@media (max-width: 860px) {
  #app-main { grid-template-columns: 1fr; }
  .preview-panel { order: -1; }
}

/* ── Form panel ───────────────────────────────────────────────────────────── */
.form-panel { display: flex; flex-direction: column; gap: 20px; }

.step-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-title { font-size: 15px; font-weight: 700; color: var(--gray-900); }
.step-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }

/* ── Form fields ──────────────────────────────────────────────────────────── */
.field-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field-full { grid-column: 1 / -1; }

label { font-size: 12px; font-weight: 600; color: var(--gray-700); text-transform: uppercase; letter-spacing: .4px; }

input[type="text"],
input[type="email"],
input[type="number"],
select {
  height: 40px;
  border: 1.5px solid var(--gray-300);
  border-radius: 7px;
  padding: 0 12px;
  font-size: 14px;
  color: var(--gray-900);
  background: #fff;
  outline: none;
  transition: border-color .15s;
  width: 100%;
}

input:focus, select:focus { border-color: var(--red); }

/* ── Sliders ──────────────────────────────────────────────────────────────── */
.slider-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slider-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--red);
  line-height: 1;
}

.slider-unit { font-size: 13px; color: var(--gray-500); }
.slider-range { font-size: 11px; color: var(--gray-400); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  background: var(--gray-200);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--red);
  cursor: pointer;
  box-shadow: var(--shadow);
}

/* ── Thickness buttons ────────────────────────────────────────────────────── */
.thickness-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.thickness-btn {
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  padding: 10px 6px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  transition: all .15s;
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-700);
}

.thickness-btn:hover { border-color: var(--red); color: var(--red); }
.thickness-btn.active { border-color: var(--red); background: var(--red); color: #fff; }

.thickness-btn small { display: block; font-size: 10px; font-weight: 500; margin-top: 2px; opacity: .7; }

/* ── Corner cards ─────────────────────────────────────────────────────────── */
.corner-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.corner-card {
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}

.corner-card-header {
  background: var(--gray-50);
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--gray-200);
}

.corner-card-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; }

.corner-type-buttons {
  display: flex;
  gap: 4px;
}

.corner-type-btn {
  flex: 1;
  padding: 5px 4px;
  border: 1.5px solid var(--gray-200);
  border-radius: 6px;
  background: #fff;
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  text-align: center;
  transition: all .12s;
}

.corner-type-btn:hover { border-color: var(--red); color: var(--red); }
.corner-type-btn.active { border-color: var(--red); background: var(--red); color: #fff; }

.corner-inputs { display: flex; flex-direction: column; gap: 6px; }
.corner-input-row { display: flex; align-items: center; gap: 6px; }
.corner-input-row label { min-width: 50px; font-size: 10px; margin: 0; }
.corner-input-row input { height: 32px; font-size: 13px; }

/* ── Preview panel ────────────────────────────────────────────────────────── */
.preview-panel {
  position: sticky;
  top: 90px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preview-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--gray-900);
  color: #fff;
}

.preview-title { font-size: 13px; font-weight: 600; }

.view-toggle {
  display: flex;
  gap: 4px;
}

.view-btn {
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 5px;
  background: transparent;
  color: rgba(255,255,255,.6);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
}

.view-btn.active { background: var(--red); border-color: var(--red); color: #fff; }

#canvas-2d { display: block; width: 100%; aspect-ratio: 4/3; background: #f8fafc; }
#canvas-3d { display: none; width: 100%; aspect-ratio: 4/3; background: #1e293b; }

/* ── Action card ──────────────────────────────────────────────────────────── */
.action-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lead-time {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--red-light);
  border: 1px solid #fecaca;
  border-radius: 7px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--red-dark);
}

.lead-time::before { content: "🚚"; font-size: 16px; }

.btn-save {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--gray-300);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-700);
  cursor: pointer;
  transition: all .15s;
}

.btn-save:hover { border-color: var(--gray-500); color: var(--gray-900); }
.btn-save:disabled { opacity: .4; cursor: not-allowed; }

.btn-cart {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: background .15s;
  letter-spacing: -.2px;
}

.btn-cart:hover { background: var(--red-dark); }
.btn-cart:disabled { opacity: .4; cursor: not-allowed; }

/* ── Status messages ──────────────────────────────────────────────────────── */
.status-msg {
  font-size: 12px;
  text-align: center;
  color: var(--gray-500);
  min-height: 18px;
}

.status-msg.success { color: #16a34a; }
.status-msg.error { color: var(--red); }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--gray-200);
  margin: 2px 0;
}
