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

:root {
  --primary:   #2563EB;
  --primary-dk:#1D4ED8;
  --primary-lt:#EFF6FF;
  --success:   #059669;
  --accent:    #B20000;   /* สีแดง — ใช้เป็น accent เล็กๆ เท่านั้น */
  --gray-100:  #F1F5F9;
  --gray-200:  #E2E8F0;
  --gray-500:  #6B7280;
  --gray-700:  #374151;
}

body {
  font-family: 'Sarabun', 'Noto Sans Thai', sans-serif;
  background: #F8FAFC;
  min-height: 100vh;
  padding: 32px 16px;
  color: #1F2937;
}

.container { max-width: 960px; margin: 0 auto; }

/* =========== Top Bar =========== */
.top-bar {
  text-align: center;
  margin-bottom: 28px;
}

.top-bar .brand-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  vertical-align: middle;
}

.top-bar h1 {
  font-size: 20px; font-weight: 700; color: var(--gray-700);
  display: inline;
}

/* =========== Progress Bar =========== */
.progress-bar { display: flex; gap: 8px; margin-bottom: 24px; }

.step-bubble {
  flex: 1; text-align: center;
  padding: 10px 4px; border-radius: 12px;
  font-size: 13px; font-weight: 600;
  background: #fff;
  color: var(--gray-500);
  border: 2px solid var(--gray-200);
  transition: all 0.3s;
}

.step-bubble.active {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.step-bubble.done {
  background: #DBEAFE; color: var(--primary);
  border-color: #BFDBFE;
}

/* =========== Card =========== */
.card {
  background: #fff; border-radius: 16px;
  padding: 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 8px 24px rgba(0,0,0,0.06);
  border: 1px solid var(--gray-200);
}

.card-title {
  font-size: 20px; font-weight: 700; color: var(--gray-700);
  margin-bottom: 20px; display: flex; align-items: center; gap: 10px;
}

/* =========== Form Grid =========== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label { font-size: 14px; font-weight: 600; color: #4B5563; }

/* สีแดงใช้เฉพาะ required marker */
label .required { color: var(--accent); margin-left: 3px; }

input[type="text"], input[type="email"], input[type="tel"],
input[type="number"], input[type="password"], select, textarea {
  padding: 10px 14px; border: 1.5px solid var(--gray-200); border-radius: 10px;
  font-size: 15px; font-family: inherit; transition: border-color 0.2s, box-shadow 0.2s; outline: none;
  background: #fff;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

textarea { resize: vertical; min-height: 80px; }

/* =========== Radio / Checkbox =========== */
.radio-group, .checkbox-group { display: flex; flex-wrap: wrap; gap: 10px; }

.radio-btn, .check-btn {
  padding: 8px 16px; border: 1.5px solid var(--gray-200); border-radius: 20px;
  cursor: pointer; font-size: 14px; transition: all 0.2s; user-select: none;
  background: #fff; color: var(--gray-700);
}

.radio-btn:hover, .check-btn:hover {
  border-color: var(--primary); background: var(--primary-lt); color: var(--primary);
}

.radio-btn.selected, .check-btn.selected {
  border-color: var(--primary); background: var(--primary); color: #fff;
}

/* =========== Puzzle =========== */
.puzzle-layout { display: grid; grid-template-columns: 300px 1fr; gap: 20px; min-height: 500px; }

.feature-library-panel {
  border: 1.5px solid var(--gray-200); border-radius: 12px;
  overflow-y: auto; max-height: 560px; padding: 16px; background: #FAFAFA;
}

.feature-search {
  width: 100%; padding: 8px 12px; border: 1.5px solid var(--gray-200);
  border-radius: 8px; font-family: inherit; font-size: 14px;
  margin-bottom: 12px; outline: none;
}

.feature-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.feature-category { margin-bottom: 16px; }

.category-title { font-size: 12px; font-weight: 700; margin-bottom: 6px; letter-spacing: 0.5px; }

.feature-card {
  padding: 6px 10px; border: 1.5px solid var(--gray-200); border-radius: 8px;
  font-size: 13px; cursor: pointer; margin-bottom: 6px;
  transition: all 0.18s; user-select: none;
}

.feature-card:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.08); }
.feature-card.selected { font-weight: 600; }

/* =========== Blueprint =========== */
.blueprint-panel {
  border: 2px dashed var(--gray-200); border-radius: 12px;
  padding: 16px; background: #FAFCFF; min-height: 400px;
  transition: background 0.2s, border-color 0.2s;
}

.blueprint-panel.drag-over { background: var(--primary-lt); border-color: var(--primary); }

.blueprint-title { font-size: 14px; font-weight: 700; color: var(--primary); margin-bottom: 12px; }
.blueprint-empty { color: #9CA3AF; font-size: 14px; text-align: center; margin-top: 60px; }
.blueprint-chips { display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; }

.blueprint-chip {
  padding: 6px 12px; border: 1.5px solid; border-radius: 20px;
  font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px;
}

.custom-chip { border-color: #6B7280 !important; background: #F9FAFB !important; color: #4B5563 !important; }

.chip-remove { cursor: pointer; font-size: 12px; opacity: 0.6; transition: opacity 0.15s; }
.chip-remove:hover { opacity: 1; }

/* =========== Custom Input =========== */
.custom-input-row {
  display: flex; gap: 8px; margin-top: 16px;
  padding-top: 16px; border-top: 1px solid var(--gray-200);
}

.custom-input-row input {
  flex: 1; padding: 8px 12px; border: 1.5px solid var(--gray-200);
  border-radius: 8px; font-family: inherit; font-size: 14px; outline: none;
}

.custom-input-row input:focus { border-color: var(--primary); }

.btn-add-custom {
  padding: 8px 16px; background: var(--primary); color: #fff;
  border: none; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-family: inherit; font-weight: 600; white-space: nowrap;
}

.btn-add-custom:hover { background: var(--primary-dk); }

/* =========== Live Estimate Bar =========== */
.estimate-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border: 1.5px solid var(--gray-200);
  border-radius: 12px; padding: 14px 20px; margin-top: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.estimate-bar .est-item { text-align: center; }
.estimate-bar .est-label { font-size: 12px; color: var(--gray-500); }
.estimate-bar .est-value { font-size: 18px; font-weight: 700; color: var(--gray-700); }
.estimate-bar .est-value.highlight { color: var(--primary); }

/* accent แดงเล็กๆ ที่ estimate bar */
.estimate-accent {
  display: inline-block; width: 8px; height: 8px;
  background: var(--accent); border-radius: 50%; margin-right: 4px; vertical-align: middle;
}

/* =========== Buttons =========== */
.btn-row { display: flex; justify-content: space-between; margin-top: 28px; gap: 12px; }

.btn-prev, .btn-next, .btn-submit {
  padding: 12px 28px; border-radius: 12px; font-size: 16px;
  font-family: inherit; font-weight: 700; cursor: pointer; transition: all 0.2s; border: none;
}

.btn-prev {
  background: #F1F5F9; color: var(--gray-500);
  border: 1.5px solid var(--gray-200);
}

.btn-prev:hover { background: var(--gray-200); }

.btn-next {
  background: var(--primary); color: #fff;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
  flex: 1; max-width: 280px;
}

.btn-next:hover { background: var(--primary-dk); transform: translateY(-1px); }

/* submit ใช้สีเขียว */
.btn-submit {
  background: #059669; color: #fff;
  box-shadow: 0 4px 12px rgba(5,150,105,0.3);
  flex: 1; max-width: 320px;
}

.btn-submit:hover { background: #047857; transform: translateY(-1px); }

/* =========== Success =========== */
.success-screen { text-align: center; padding: 40px 20px; }
.success-icon   { font-size: 64px; margin-bottom: 16px; }
.success-title  { font-size: 26px; font-weight: 700; color: var(--gray-700); margin-bottom: 8px; }
.success-sub    { font-size: 15px; color: var(--gray-500); margin-bottom: 28px; }

.quote-result-box { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 28px; }

.result-item { background: #F8FAFC; border-radius: 12px; padding: 16px; border: 1.5px solid var(--gray-200); }
.result-label { font-size: 12px; color: var(--gray-500); margin-bottom: 4px; }
.result-value { font-size: 22px; font-weight: 700; color: var(--gray-700); }
.result-value.price { color: var(--primary); }

.verdict-badge {
  display: inline-block; padding: 4px 14px; border-radius: 20px;
  font-size: 13px; font-weight: 600; background: #DBEAFE; color: var(--primary-dk);
}

.btn-download {
  display: inline-block; padding: 12px 32px; background: var(--primary);
  color: #fff; text-decoration: none; border-radius: 12px;
  font-weight: 700; font-size: 16px; font-family: inherit;
  cursor: pointer; border: none; transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.btn-download:hover { background: var(--primary-dk); transform: translateY(-1px); }

/* =========== Summary Box =========== */
.summary-box {
  background: #F8FAFC; border: 1.5px solid var(--gray-200);
  border-radius: 12px; padding: 16px; margin-top: 16px;
  font-size: 14px; line-height: 1.9;
}

/* accent line ซ้ายของ summary */
.summary-box { border-left: 4px solid var(--accent); }

/* =========== Loading =========== */
.loading-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.55);
  z-index: 999; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px; color: #fff;
  font-size: 18px; font-weight: 600; backdrop-filter: blur(2px);
}

.loading-overlay.show { display: flex; }

.spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(255,255,255,0.25);
  border-top-color: #fff; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* =========== Layer Divider =========== */
.layer-divider {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--gray-500);
  text-transform: uppercase;
  padding: 8px 0 6px;
  margin-top: 12px;
  border-top: 1.5px solid var(--gray-200);
}

.layer-hint { font-weight: 400; text-transform: none; opacity: 0.75; }

/* =========== Layer 2 slide-in =========== */
.layer2-fade  { animation: fadeSlideIn 0.3s ease-out; }
.layer2-section { animation: fadeSlideIn 0.35s ease-out; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =========== Blueprint layer labels =========== */
.bp-layer-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.biz-chip { font-weight: 600; }

/* =========== Feature Cards Grid =========== */
.feature-cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

/* =========== Mobile Floating Bar =========== */
.mobile-bp-bar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 200;
  box-shadow: 0 -4px 20px rgba(37,99,235,0.25);
}

.mobile-bp-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  min-width: 0;
}

.mobile-bp-count { font-size: 15px; }
.mobile-bp-sep   { opacity: 0.4; }
.mobile-bp-price { font-size: 14px; opacity: 0.9; }

.mobile-bp-btn {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.4);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}

.mobile-bp-btn:active { background: rgba(255,255,255,0.32); }

/* =========== Responsive =========== */
@media (max-width: 700px) {
  .form-grid         { grid-template-columns: 1fr; }
  .puzzle-layout     { grid-template-columns: 1fr; gap: 16px; }
  .quote-result-box  { grid-template-columns: 1fr; }
  .btn-next, .btn-submit { max-width: none; }

  /* Library: no height cap — let page scroll naturally */
  .feature-library-panel {
    max-height: none;
    overflow: visible;
    padding: 12px;
  }

  /* 2-column card grid on mobile */
  .feature-cards-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  /* Bigger touch targets */
  .feature-cards-grid .feature-card {
    margin-bottom: 0;
    padding: 12px 8px;
    text-align: center;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
  }

  /* Category label smaller on mobile */
  .category-title { font-size: 12px; margin-bottom: 8px; }

  /* Blueprint min size */
  .blueprint-panel { min-height: 80px; }

  /* Floating bar: show on mobile when items selected & on step 1 */
  .mobile-bp-bar.has-items.step-active { display: flex; }

  /* Bottom padding so floating bar doesn't cover Next button */
  body { padding-bottom: 76px; }
}
