/* ==========================================================================
   TIMBER ESTIMATION & QUOTATION CALCULATOR — STYLESHEET
   ==========================================================================
   This file is intentionally separate from assets/css/style.css so the
   existing site is never touched. It reuses the same design tokens
   (colours, fonts, radius, shadow, transition) defined in :root inside
   style.css — load style.css BEFORE this file on any page that uses it.

   Structure:
   1. Layout shell + step indicator
   2. Step 1 — Customer details form
   3. Step 2 — Category picker cards
   4. Step 3 — Estimation table (editable, Excel-like)
   5. Step 4 — Final summary / quotation preview
   6. Shared bits (success toast, empty states)
   7. Responsive breakpoints
   ========================================================================== */

/* -------------------------------------------------------------------------
   1. LAYOUT SHELL + STEP INDICATOR
------------------------------------------------------------------------- */
.calc-app {
  max-width: 980px;
  margin: 0 auto;
}

.calc-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 56px;
  flex-wrap: wrap;
}
.calc-step-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 8px;
  border-radius: 999px;
  background: var(--color-ivory-soft);
  border: 1px solid var(--color-line);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-charcoal-soft);
  transition: all var(--transition);
}
.calc-step-pill .num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--color-line);
  color: var(--color-charcoal-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.76rem;
  flex-shrink: 0;
  transition: all var(--transition);
}
.calc-step-pill.active {
  background: var(--color-espresso);
  border-color: var(--color-espresso);
  color: var(--color-ivory);
}
.calc-step-pill.active .num { background: var(--color-teak); color: #fff; }
.calc-step-pill.done { background: var(--color-ivory-soft); border-color: var(--color-teak); color: var(--color-teak-dark); }
.calc-step-pill.done .num { background: var(--color-teak); color: #fff; }
.calc-step-connector { width: 26px; height: 1px; background: var(--color-line); flex-shrink: 0; }

/* Each "panel" is one step of the flow; JS toggles .active */
.calc-panel { display: none; }
.calc-panel.active { display: block; animation: calc-fade-in 0.5s ease; }

@keyframes calc-fade-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.calc-card {
  background: var(--color-ivory-soft);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  padding: 44px;
  box-shadow: var(--shadow-soft);
}

/* -------------------------------------------------------------------------
   2. STEP 1 — CUSTOMER DETAILS FORM
------------------------------------------------------------------------- */
.calc-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-bottom: 6px;
}
.calc-field { display: flex; flex-direction: column; gap: 8px; }
.calc-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-espresso);
}
.calc-field label .req { color: var(--color-teak-dark); }
.calc-field input,
.calc-field select {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-line);
  background: #fff;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--color-charcoal);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.calc-field input:focus,
.calc-field select:focus {
  border-color: var(--color-teak);
  box-shadow: 0 0 0 3px rgba(168, 92, 42, 0.12);
  outline: none;
}
.calc-field input.invalid,
.calc-field select.invalid { border-color: #b3402f; }
.calc-field .error-msg {
  font-size: 0.78rem;
  color: #b3402f;
  min-height: 16px;
  display: none;
}
.calc-field.has-error .error-msg { display: block; }

.calc-form-actions {
  margin-top: 32px;
  display: flex;
  justify-content: flex-end;
}
.calc-form-actions .btn:disabled,
.calc-form-actions .btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

/* Applies to any calculator button while a request is in flight (e.g. Get Quotation) */
.calc-app .btn:disabled {
  opacity: 0.6;
  cursor: wait;
  pointer-events: none;
}

/* -------------------------------------------------------------------------
   3. STEP 2 — CATEGORY PICKER CARDS
------------------------------------------------------------------------- */
.calc-category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 26px;
}
.calc-category-card {
  position: relative;
  background: var(--color-ivory-soft);
  border: 1.5px solid var(--color-line);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  text-align: left;
  transition: all var(--transition);
  cursor: pointer;
}
.calc-category-card:hover:not(.is-done) {
  border-color: var(--color-teak);
  transform: translateY(-6px);
  box-shadow: var(--shadow-soft);
}
.calc-category-card .icon-badge {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--color-teak);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
}
.calc-category-card .icon-badge svg { width: 24px; height: 24px; }
.calc-category-card h3 { font-size: 1.25rem; margin-bottom: 8px; }
.calc-category-card p { color: var(--color-charcoal-soft); font-size: 0.9rem; margin-bottom: 18px; }
.calc-category-card .cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--color-teak-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.calc-category-card .cta svg { width: 15px; height: 15px; transition: transform var(--transition); }
.calc-category-card:hover:not(.is-done) .cta svg { transform: translateX(5px); }

.calc-category-card.is-done {
  cursor: default;
  border-color: var(--color-teak);
  background: rgba(168, 92, 42, 0.06);
}
.calc-category-card .done-badge {
  position: absolute;
  top: 20px; right: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--color-forest);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  letter-spacing: 0.03em;
}
.calc-category-card .done-badge svg { width: 12px; height: 12px; }
.calc-category-card .done-summary {
  font-size: 0.84rem;
  color: var(--color-charcoal-soft);
  border-top: 1px dashed var(--color-line);
  padding-top: 12px;
  margin-top: 4px;
}
.calc-category-card .done-summary strong { color: var(--color-espresso); }

.calc-picker-actions {
  text-align: center;
  margin-top: 40px;
}

/* -------------------------------------------------------------------------
   4. STEP 3 — ESTIMATION TABLE (Excel-like, editable)
------------------------------------------------------------------------- */
.calc-table-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}
.calc-table-head-row h3 { font-size: 1.5rem; margin-bottom: 6px; }
.calc-table-head-row p { color: var(--color-charcoal-soft); font-size: 0.9rem; }

.calc-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: #fff;
}
.calc-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}
.calc-table th {
  background: var(--color-espresso);
  color: var(--color-ivory);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  text-align: left;
  padding: 14px 12px;
  white-space: nowrap;
}
.calc-table td {
  padding: 8px;
  border-bottom: 1px solid var(--color-line);
  vertical-align: middle;
}
.calc-table tbody tr:last-child td { border-bottom: none; }
.calc-table tbody tr:hover { background: rgba(168, 92, 42, 0.04); }

.calc-table .sno-cell {
  text-align: center;
  font-weight: 600;
  color: var(--color-charcoal-soft);
  width: 46px;
}
.calc-table input.cell-input {
  width: 100%;
  min-width: 78px;
  padding: 10px 10px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--color-ivory-soft);
  font-family: var(--font-body);
  font-size: 0.92rem;
  text-align: center;
  transition: border-color var(--transition), background var(--transition);
  -moz-appearance: textfield;
}
.calc-table input.cell-input::-webkit-outer-spin-button,
.calc-table input.cell-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.calc-table input.cell-input:focus {
  border-color: var(--color-teak);
  background: #fff;
  outline: none;
}
.calc-table .cft-cell {
  text-align: center;
  font-weight: 700;
  color: var(--color-teak-dark);
  font-variant-numeric: tabular-nums;
  min-width: 90px;
}
.calc-table .row-delete-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #b3402f;
  transition: all var(--transition);
  margin: 0 auto;
}
.calc-table .row-delete-btn:hover { background: rgba(179, 64, 47, 0.12); }
.calc-table .row-delete-btn svg { width: 16px; height: 16px; }

.calc-table tfoot td {
  background: var(--color-ivory-soft);
  font-weight: 700;
  padding: 14px 12px;
  border-top: 2px solid var(--color-line);
  color: var(--color-espresso);
}
.calc-table tfoot .totals-label { text-align: right; }
.calc-table tfoot .totals-value { text-align: center; color: var(--color-teak-dark); }

.calc-table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 20px;
}
.calc-add-row-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--color-teak);
  color: var(--color-teak-dark);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition);
}
.calc-add-row-btn:hover { background: rgba(168, 92, 42, 0.08); }
.calc-add-row-btn svg { width: 16px; height: 16px; }

.calc-live-totals {
  display: flex;
  gap: 24px;
  font-size: 0.86rem;
  color: var(--color-charcoal-soft);
}
.calc-live-totals strong { color: var(--color-espresso); font-size: 1rem; }

.calc-table-actions {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 40px;
}

/* -------------------------------------------------------------------------
   5. STEP 4 — FINAL SUMMARY / QUOTATION PREVIEW
------------------------------------------------------------------------- */
.calc-summary-header {
  text-align: center;
  margin-bottom: 40px;
}
.calc-summary-header .ring-mark {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--color-teak);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
}
.calc-summary-header .ring-mark svg { width: 26px; height: 26px; }

.calc-summary-block {
  margin-bottom: 36px;
}
.calc-summary-block h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-teak-dark);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-line);
}

.calc-customer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
.calc-customer-grid .info-item .label { font-size: 0.76rem; color: var(--color-charcoal-soft); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.calc-customer-grid .info-item .value { font-weight: 600; color: var(--color-espresso); font-size: 0.98rem; }

.calc-category-summary-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 12px;
}
.calc-category-summary-card .name { font-weight: 700; color: var(--color-espresso); }
.calc-category-summary-card .name span { display: block; font-weight: 400; font-size: 0.78rem; color: var(--color-charcoal-soft); margin-top: 2px; }
.calc-category-summary-card .figures { display: flex; gap: 28px; }
.calc-category-summary-card .figures .fig { text-align: center; }
.calc-category-summary-card .figures .fig .num { font-family: var(--font-heading); font-size: 1.3rem; color: var(--color-teak-dark); }
.calc-category-summary-card .figures .fig .lbl { font-size: 0.72rem; color: var(--color-charcoal-soft); text-transform: uppercase; letter-spacing: 0.04em; }

.calc-grand-total {
  display: flex;
  justify-content: center;
  gap: 60px;
  padding: 32px;
  background: linear-gradient(160deg, var(--color-espresso) 0%, var(--color-espresso-2) 100%);
  border-radius: var(--radius-lg);
  margin-top: 10px;
}
.calc-grand-total .fig { text-align: center; }
.calc-grand-total .fig .num { font-family: var(--font-heading); font-size: 2.4rem; color: var(--color-teak-light); }
.calc-grand-total .fig .lbl { font-size: 0.8rem; color: rgba(247,241,230,0.75); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }

.calc-summary-actions {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 44px;
}
.calc-get-quote-btn {
  padding: 19px 48px;
  font-size: 1.05rem;
}

/* -------------------------------------------------------------------------
   6. SHARED BITS — success toast + empty state
------------------------------------------------------------------------- */
.calc-toast {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--color-forest);
  color: #fff;
  padding: 18px 24px;
  border-radius: var(--radius-md);
  margin-top: 26px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all var(--transition);
}
.calc-toast.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.calc-toast .icon { width: 26px; height: 26px; flex-shrink: 0; }
.calc-toast .text strong { display: block; font-size: 0.95rem; margin-bottom: 2px; }
.calc-toast .text span { font-size: 0.84rem; opacity: 0.85; }
.calc-toast.is-success { background: var(--color-forest); }
.calc-toast.is-error { background: #8a2f22; }
.calc-toast-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background var(--transition);
}
.calc-toast-download:hover { background: rgba(255, 255, 255, 0.28); }

.calc-empty-row {
  text-align: center;
  padding: 30px;
  color: var(--color-charcoal-soft);
  font-size: 0.9rem;
}

.calc-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-charcoal-soft);
  margin-bottom: 20px;
  transition: color var(--transition);
}
.calc-back-link:hover { color: var(--color-teak-dark); }
.calc-back-link svg { width: 14px; height: 14px; }

/* -------------------------------------------------------------------------
   7. RESPONSIVE BREAKPOINTS
------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .calc-form-grid { grid-template-columns: 1fr; }
  .calc-category-grid { grid-template-columns: 1fr; }
  .calc-customer-grid { grid-template-columns: 1fr 1fr; }
  .calc-grand-total { gap: 36px; }
}

@media (max-width: 640px) {
  .calc-card { padding: 26px 20px; }
  .calc-steps { gap: 4px; }
  .calc-step-pill span.label { display: none; }
  .calc-step-pill { padding: 8px; }
  .calc-step-connector { width: 14px; }
  .calc-customer-grid { grid-template-columns: 1fr; }
  .calc-category-summary-card { flex-direction: column; align-items: flex-start; }
  .calc-grand-total { flex-direction: column; gap: 20px; }
  .calc-table-actions .btn, .calc-summary-actions .btn { width: 100%; justify-content: center; }
  .calc-get-quote-btn { width: 100%; }
}
