/* ==========================================================================
   I HATE CALCULATOR CALCULATOR CONTROLS & VISUALIZERS — TACTILE & EDITORIAL
   Physical inputs, precision sliders, proportional financial bars & ledger rows
   ========================================================================== */

/* Calculator Grid (2-Column Split) */
.calc-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 0;
  min-height: 520px;
}

@media (max-width: 900px) {
  .calc-grid {
    grid-template-columns: 1fr;
  }
}

/* Form Panel (Left) */
.calc-form-panel {
  padding: 2rem;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: var(--bg-surface);
}

@media (max-width: 900px) {
  .calc-form-panel {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    padding: 1.25rem;
  }
}

.calc-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.calc-panel-title {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Quick Market Presets */
.calc-presets {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.preset-btn {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.preset-btn:hover {
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* Form Input Groups (Tactile & Solid) */
.calc-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.calc-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.calc-input-box {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  transition: all 0.15s ease;
  overflow: hidden;
}

.calc-input-box:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px var(--brand-primary-subtle);
}

.calc-input-prefix {
  padding: 0.45rem 0.65rem;
  background: var(--bg-surface-elevated);
  border-right: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.88rem;
  user-select: none;
}

.calc-input-box input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  padding: 0.45rem 0.75rem;
  width: 100%;
}

.calc-input-suffix {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.45rem 0.65rem;
}

/* Custom Fluid Slider (Physical Dial Aesthetic) */
.calc-slider-wrap {
  position: relative;
  width: 100%;
  padding-top: 0.25rem;
}

.calc-range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--border-subtle);
  outline: none;
  cursor: pointer;
}

.calc-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brand-primary);
  border: 2px solid var(--bg-surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.calc-range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* Result Panel (Right) - Financial Statement Layout */
.calc-result-panel {
  background: var(--bg-surface-alt);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.5rem;
  border-left: 1px solid var(--border-subtle);
}

@media (max-width: 900px) {
  .calc-result-panel {
    padding: 1.25rem;
    border-left: none;
  }
}

.calc-result-hero {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-xs);
  position: relative;
}

.calc-result-kicker {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.calc-result-value {
  font-size: clamp(2rem, 3.2vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.35rem;
}

.calc-result-subtext {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Editorial Guidance Callout */
.calc-editorial-callout {
  padding: 0.75rem 0.95rem;
  background: var(--brand-primary-subtle);
  border-left: 3px solid var(--brand-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.calc-editorial-callout strong {
  color: var(--text-primary);
}

/* Breakdown Rows */
.calc-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.calc-breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-size: 0.86rem;
}

.breakdown-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.breakdown-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
}

.breakdown-val {
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Proportional Split Bar Visualizer */
.loan-split-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.loan-split-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.loan-split-bar {
  display: flex;
  height: 10px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--border-subtle);
}

.bar-fill {
  height: 100%;
  transition: width 0.3s ease;
}

.bar-principal {
  background: var(--brand-primary);
}

.bar-interest {
  background: var(--brand-accent);
}

/* BMI Gauge Needle */
.bmi-meter-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.25rem;
}

.bmi-meter-track {
  position: relative;
  height: 10px;
  border-radius: var(--radius-full);
  background: linear-gradient(to right, #0284c7 0%, #16a34a 25%, #d97706 60%, #dc2626 100%);
}

.bmi-meter-needle {
  position: absolute;
  top: -5px;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 2.5px solid var(--bg-surface);
  box-shadow: var(--shadow-sm);
  transition: left 0.25s ease;
}

.bmi-meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Tip Splitter Specific */
.tip-chips-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tip-chip {
  flex: 1;
  min-width: 48px;
  padding: 0.45rem 0.4rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.86rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.12s ease;
}

.tip-chip:hover {
  border-color: var(--border-hover);
  background: var(--bg-surface-elevated);
}

.tip-chip.active {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  border-color: var(--btn-primary-bg);
  font-weight: 700;
}

.people-counter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.counter-btn {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: all 0.12s ease;
}

.counter-btn:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-hover);
}

/* Actions Footer */
.calc-result-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

/* ── Hàng nút chọn mức tiền boa trên màn hẹp (thêm 20/09/2026) ──
   `flex:1` + `min-width:48px` cho nút co xuống 59px, nhưng nhãn dài nhất
   ("25% (Exceptional)") cần 94px và từ "Exceptional" không cắt được
   → chữ tràn ra ngoài nút, kéo cả trang lệch 6px.
   min-width:48px đã VÔ HIỆU HOÁ sàn min-content mặc định — đó là gốc lỗi.
   Cách chữa: dưới 420px xếp 2 nút mỗi hàng, đủ rộng cho từ dài nhất. */
@media (max-width: 420px) {
  .tip-chip {
    flex: 1 1 calc(50% - 0.2rem);
    min-width: 0;
    font-size: 0.78rem;
    overflow-wrap: anywhere;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   LỚP THIẾU LUẬT — ĐỢT 2, 20/09/2026 (tìm ra bằng cách NHÌN ảnh chụp)
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Thước BMI: KIM CHỈ không có luật nên vô hình ──
   `#bmi-needle` được JS đặt `left: 47%` nhưng không có kích thước, màu, hay
   `position:absolute` → khách không biết chỉ số của mình rơi vào đâu trên thước. */
.bmi-gauge-container { position: relative; }

/* HTML viết `bmi-indicator-needle`, còn CSS gốc định nghĩa `bmi-meter-needle`
   — hai cái tên KHÁC NHAU nên kim chỉ chưa bao giờ hiện. Dùng đúng kiểu kim
   tròn mà thiết kế gốc đã định, chứ không bịa kiểu mới. */
.bmi-indicator-needle {
  position: absolute;
  top: -5px;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 2.5px solid var(--bg-surface);
  box-shadow: var(--shadow-sm);
  transition: left 0.25s ease;
  z-index: 2;
}
.bmi-gauge-container .bmi-meter-track { position: relative; }

/* Nhãn 4 mốc trên thước dính liền nhau thành một khối chữ không đọc được:
   "Under (<18.5)Normal (18.5–24.9)Over (25–29.9)Obese (30+)" */
.bmi-gauge-container .bmi-meter-labels {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  margin-top: 0.4rem;
  font-size: 0.66rem;
  line-height: 1.25;
  color: var(--text-muted);
}
.bmi-gauge-container .bmi-meter-labels > span {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
}
.bmi-gauge-container .bmi-meter-labels > span:first-child { text-align: left; }
.bmi-gauge-container .bmi-meter-labels > span:last-child  { text-align: right; }

/* ── Thanh chia tỉ lệ (lương ròng ↔ thuế) ── */
.calc-split-bar {
  display: flex;
  width: 100%;
  height: 12px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
}
.calc-split-segment { height: 100%; transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1); }

/* ── Hộp "giới hạn của công cụ" + các bước hướng dẫn ── */
.limitations-box-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}
.limitations-list {
  margin: 0;
  padding-left: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.87rem;
  line-height: 1.6;
  color: var(--text-secondary);
}
.step-title { font-weight: 700; font-size: 0.95rem; color: var(--text-primary); margin-bottom: 0.25rem; }
.step-desc  { font-size: 0.86rem; line-height: 1.6; color: var(--text-secondary); }

/* ── Khung xem thử widget ở trang /embed ── */
.embed-preview-frame {
  width: 100%;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--bg-app);
  display: block;
}

/* ── Nút chép mã + khung xem nhanh ở trang chủ ── */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}
.copy-btn:hover { color: var(--text-primary); border-color: var(--border-hover); }
.studio-calc-view { min-width: 0; }
