/* ==========================================================================
   style-v2.css — Price Calculator V2
   Tasks: 5.1, 6.1, 7.1, 8.1
   ========================================================================== */

/* ==========================================================================
   1. CSS Custom Properties (Design Tokens)
   ========================================================================== */

:root {
  --color-accent:       #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-tint:  #eff6ff;
  --color-accent-bg:    #f0f7ff;

  --color-bg:       #f8fafc;
  --color-surface:  #ffffff;
  --color-border:   #e2e8f0;
  --color-border-md:#cbd5e1;

  --color-text-base:    #1e293b;
  --color-text-muted:   #64748b;
  --color-text-dim:     #94a3b8;
  --color-text-strong:  #334155;

  --color-error:    #dc2626;
  --color-wa:       #25D366;
  --color-wa-hover: #1ebe5d;

  --radius:  8px;
  --shadow:  0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   2. Base Reset & Body
   ========================================================================== */

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

body {
  background: var(--color-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text-base);
  min-height: 100vh;
}

/* ==========================================================================
   3. App Container & Step Visibility
   ========================================================================== */

#app {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

/* Step containers — shown/hidden by JS via .hidden class */
.step {
  padding: 0;
}

.hidden {
  display: none !important;
}

/* Disable pointer interaction + visual cue */
.disabled {
  pointer-events: none;
  opacity: 0.5;
}

/* ==========================================================================
   4. Utility: Step Title & Section
   ========================================================================== */

.step-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text-base);
  margin-bottom: 12px;
}

/* Section container with bottom spacing */
.step-section {
  margin-bottom: 24px;
}

/* Section header — colored left-border visual divider */
.section-header {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-base);
  padding-left: 10px;
  border-left: 3px solid var(--color-accent);
  margin-bottom: 10px;
  margin-top: 20px;
  line-height: 1.4;
}

.section-header:first-child {
  margin-top: 0;
}

/* ==========================================================================
   5. Product Grid & Card Styles   (Task 5.1 — Req 1.1, 1.2, 2.1)
   ========================================================================== */

/* Grid: 2 columns on mobile, 4 columns ≥768px (media query in task 11.1) */
.produk-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

/* 4-column breakpoint needed here since task 11.1 handles other breakpoints */
@media (min-width: 768px) {
  .produk-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Product card */
.card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  text-align: center;
  transition:
    border-color 0.15s ease,
    box-shadow   0.15s ease,
    background   0.15s ease;
  user-select: none;
}

.card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow);
}

/* Selected card state */
.card--selected,
.card[aria-selected="true"] {
  border: 2px solid var(--color-accent);
  background: var(--color-accent-tint);
  box-shadow: var(--shadow);
}

/* Card product name */
.card__name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
  color: var(--color-text-base);
}

/* Card price range (small tertiary text) */
.card__price {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ==========================================================================
   6. Model Section   (Task 5.1 — Req 2.1)
   Appears below the product grid with a fade-in animation after a product
   is selected. Uses a radio group styled as pill/option rows.
   ========================================================================== */

/* Animate the model section in when it appears */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.model-section {
  margin-top: 20px;
  animation: fadeInDown 0.2s ease both;
}

/* Model section heading */
.model-section__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-base);
  padding-left: 10px;
  border-left: 3px solid var(--color-accent);
  margin-bottom: 10px;
  line-height: 1.4;
}

/* ==========================================================================
   7. Radio Group — Base (shared by Bahan, Sablon, Bordir, Model)
   ========================================================================== */

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

/* Pill/option-row style radio label */
.radio-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--color-surface);
  transition:
    border-color 0.15s ease,
    background   0.15s ease;
  user-select: none;
  font-size: 0.9rem;
  color: var(--color-text-base);
}

.radio-label:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-bg);
}

/* Hide native radio; replaced by styled circle below */
.radio-label input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-text-dim);
  border-radius: 50%;
  flex-shrink: 0;
  transition:
    border-color  0.15s ease,
    background    0.15s ease;
}

/* Filled dot when selected */
.radio-label input[type="radio"]:checked {
  border-color: var(--color-accent);
  background: var(--color-accent);
  box-shadow: inset 0 0 0 3px var(--color-surface);
}

/* Highlight row border when selected */
.radio-label:has(input[type="radio"]:checked) {
  border-color: var(--color-accent);
  background: var(--color-accent-tint);
}

/* ==========================================================================
   8. Bahan Group Headers   (Task 6.1 — Req 3.6, 4.7)
   Fleece-based / Cotton-based group headers for Crewneck & Hoodie.
   ========================================================================== */

/* Container grouping bahan by fabric type */
.bahan-group {
  margin-bottom: 12px;
}

/* Group header: "Fleece-based" / "Cotton-based" */
.bahan-group__header {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 5px;
  margin-bottom: 8px;
}

/* ==========================================================================
   9. Slider & Quantity Input   (Task 6.1 — Req 3.1, 4.1, 4.2)
   Slider (input[type=range]) + synced number input in flex row.
   ========================================================================== */

/* Wrapper: slider + number input side by side */
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Custom range slider */
.input-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--color-border);
  outline: none;
  cursor: pointer;
  accent-color: var(--color-accent);

  /* Fill progress up to thumb using accent color — WebKit */
  background-image: linear-gradient(
    var(--color-accent),
    var(--color-accent)
  );
  background-size: 0% 100%;
  background-repeat: no-repeat;
}

/* Thumb — WebKit */
.input-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--color-surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.input-slider::-webkit-slider-thumb:hover,
.input-slider:active::-webkit-slider-thumb {
  transform: scale(1.15);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

/* Thumb — Firefox */
.input-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--color-surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.input-slider::-moz-range-thumb:hover {
  transform: scale(1.15);
}

/* Track — Firefox */
.input-slider::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--color-border);
}

/* Number input container with unit label */
.input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Quantity number input */
.input-qty {
  width: 80px;
  padding: 8px 10px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-base);
  text-align: center;
  background: var(--color-surface);
  transition: border-color 0.15s ease;
  outline: none;
}

.input-qty:focus {
  border-color: var(--color-accent);
}

.input-qty:invalid {
  border-color: var(--color-error);
}

/* Inline error message */
.error-msg {
  display: block;
  color: var(--color-error);
  font-size: 0.8rem;
  margin-top: 6px;
}

/* ==========================================================================
   10. Tier Discount Badge   (Task 6.1 — Req 4.7)
   Active tier shown as a highlighted chip below the slider.
   ========================================================================== */

.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-accent);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  margin-top: 8px;
  letter-spacing: 0.01em;
}

/* ==========================================================================
   11. Checkbox Group   (shared: Finishing multi-select)
   ========================================================================== */

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

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  transition:
    border-color 0.15s ease,
    background   0.15s ease;
  user-select: none;
  font-size: 0.9rem;
  color: var(--color-text-base);
}

.checkbox-label:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-bg);
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--color-accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}

.checkbox-label:has(input[type="checkbox"]:checked) {
  border-color: var(--color-accent);
  background: var(--color-accent-tint);
}

/* ==========================================================================
   12. Price Preview   (Step 2 & 3)
   ========================================================================== */

.price-preview {
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-top: 8px;
}

.price-preview__label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.price-preview__harga {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-accent);
}

/* ==========================================================================
   13. Sablon / Bordir / Finishing Section   (Task 7.1 — Req 5.1, 6.1, 7.1)
   Section headers with visual divider; radio + checkbox labels already
   covered above. Price preview reused from section 12.
   ========================================================================== */

/* Sablon, Bordir, Finishing each live inside .step-section.
   The .section-header already provides the visual separator (left border).
   No extra rules needed beyond shared components above, but we add a
   subtle background tint to the whole Step 3 addon block for visual clarity. */

.addon-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

/* Section title within addon block — slightly smaller than .section-header */
.addon-section__title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text-strong);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Decorative line separator under addon title */
.addon-section__title::after {
  content: "";
  display: block;
  flex: 1;
  height: 1px;
  background: var(--color-border);
  margin-left: 6px;
}

/* ==========================================================================
   14. Result Card   (Task 8.1 — Req 9.3, 10.1)
   Large per-pcs price, total below, meta (qty + discount%) tertiary.
   ========================================================================== */

.result-card {
  background: var(--color-surface);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  text-align: center;
}

/* Optional label above the price */
.result-card__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

/* Main per-pcs price — large & prominent */
.result-harga {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--color-accent);
  line-height: 1.2;
  margin-bottom: 6px;
}

/* Total price — medium weight, secondary */
.result-total {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text-strong);
  margin-bottom: 4px;
}

/* Meta line: qty + discount% — small, tertiary */
.result-meta {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ==========================================================================
   15. Breakdown List   (Task 8.1 — Req 9.3)
   Monospace font, ├ / └ prefix icons.
   ========================================================================== */

.breakdown-list {
  list-style: none;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.85rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 20px;
}

/* Each breakdown row */
.breakdown-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0;
  color: var(--color-text-strong);
}

/* ├ prefix for non-last items */
.breakdown-item::before {
  content: "├";
  color: var(--color-text-dim);
  flex-shrink: 0;
}

/* └ prefix for last item */
.breakdown-item--last::before {
  content: "└";
  color: var(--color-text-dim);
}

/* Label — left side, truncate if too long */
.breakdown-item__label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Value — right side, aligned, tabular numbers */
.breakdown-item__value {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ==========================================================================
   16. Summary Grid   (Task 8.1 — Req 10.1)
   2-column key–value layout.
   ========================================================================== */

.summary-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  font-size: 0.88rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 20px;
  color: var(--color-text-strong);
}

.summary-grid__key {
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.summary-grid__val {
  color: var(--color-text-base);
}

/* ==========================================================================
   17. Buttons   (Task 8.1 — Req 10.1)
   Primary, WA (green), secondary/outline, back, reset.
   ========================================================================== */

/* Base button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background    0.15s ease,
    color         0.15s ease,
    border-color  0.15s ease,
    opacity       0.15s ease,
    box-shadow    0.15s ease;
  user-select: none;
  text-decoration: none;
  white-space: nowrap;
}

/* Primary — filled accent */
.btn--primary {
  background: var(--color-accent);
  color: #ffffff;
  border-color: var(--color-accent);
}

.btn--primary:hover:not(:disabled):not(.disabled) {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

/* Secondary / outline */
.btn--secondary {
  background: transparent;
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.btn--secondary:hover:not(:disabled):not(.disabled) {
  background: var(--color-accent-tint);
}

/* WhatsApp — green solid, full-width in action group */
.btn--wa {
  background: var(--color-wa);
  color: #ffffff;
  border-color: var(--color-wa);
  width: 100%;
  font-size: 1rem;
  padding: 12px 20px;
}

.btn--wa:hover:not(:disabled) {
  background: var(--color-wa-hover);
  border-color: var(--color-wa-hover);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
}

/* Reset / Hitung Ulang — ghost secondary, full-width */
.btn--reset {
  background: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border-md);
  width: 100%;
}

.btn--reset:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: var(--color-text-dim);
  color: var(--color-text-strong);
}

/* Back button — subtle, text-like */
.btn--back {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
  padding-left: 6px;
}

.btn--back:hover:not(:disabled) {
  color: var(--color-text-base);
  background: var(--color-bg);
  border-color: var(--color-border);
}

/* Disabled state */
.btn:disabled,
.btn.disabled {
  pointer-events: none;
  opacity: 0.45;
}

/* ==========================================================================
   18. Navigation Row   (shared across steps)
   ========================================================================== */

/* Step nav: back on left, forward on right */
.step-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  gap: 8px;
}

/* Action group: stacked buttons in Step 4 */
.action-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

/* ==========================================================================
   19. Step Indicator   (rendered by renderStepIndicator — task 10.2)
   Included here so the HTML shell renders correctly even before task 10.2.
   ========================================================================== */

.step-indicator {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 24px;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.step-item--active .step-label {
  font-weight: 600;
  color: var(--color-accent);
}

.step-connector {
  flex-grow: 1;
  flex-shrink: 1;
  height: 2px;
  background: var(--color-border);
  min-width: 16px;
  max-width: 48px;
  margin-bottom: 22px; /* kompensasi tinggi label agar connector sejajar lingkaran */
}

.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
  transition:
    background    0.2s ease,
    border-color  0.2s ease,
    box-shadow    0.2s ease;
}

.step-dot--active {
  background: var(--color-accent);
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.step-dot--done {
  background: var(--color-accent-hover);
  color: #ffffff;
}

.step-dot--inactive {
  background: transparent;
  border: 2px solid var(--color-border);
  color: var(--color-text-dim);
  opacity: 0.7;
}

.step-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-align: center;
  white-space: nowrap;
}

/* ==========================================================================
   20. Error Message
   ========================================================================== */

.error-msg {
  display: block;
  color: var(--color-error);
  font-size: 0.8rem;
  margin-top: 6px;
}

/* ==========================================================================
   21. Responsive Media Queries   (Task 11.1 — Req 13.1)
   ========================================================================== */

/* <480px: grid 2 kolom, padding dikurangi */
@media (max-width: 479px) {
  #app {
    padding: 12px;
  }

  .produk-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .card {
    padding: 10px 8px;
  }

  .result-harga {
    font-size: 1.4rem;
  }

  .step-label {
    display: none; /* Sembunyikan label step pada layar sangat kecil */
  }
}

/* 480–767px: grid 3–4 kolom */
@media (min-width: 480px) and (max-width: 767px) {
  .produk-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }
}

/* ≥768px: max-width 800px, centered (sudah ada di #app) */
@media (min-width: 768px) {
  #app {
    padding: 24px 16px;
  }

  .result-harga {
    font-size: 2rem;
  }

  .action-group {
    flex-direction: row;
    gap: 12px;
  }

  .btn--wa,
  .btn--reset {
    width: auto;
    flex: 1;
  }
}
