/* ============================================================
   Tool Styles — Payment Calculator v2.1
   File: /assets/css/modules/calculators/financialcalculators/payment-calculator.v2.1.css
   Purpose:
   - Tool-only layout and visuals for Payment Calculator
   - No changes to ub-toolkit.v2.1.css
   - Mobile-first, accessible, UB-CERT aligned
   ============================================================ */

/* Local tool tokens */
:root{
  --pay-radius: 16px;
  --pay-gap: 14px;
  --pay-soft: rgba(0,0,0,.06);
  --pay-principal: linear-gradient(135deg, #ff7426, #f93a13);
  --pay-interest: linear-gradient(135deg, #f59e0b, #d97706);
  --pay-tax: linear-gradient(135deg, #38bdf8, #0284c7);
  --pay-fees: linear-gradient(135deg, #8b5cf6, #6d28d9);
}

/* Tool hero layout */
.ub-hero{
  display:grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: var(--pay-gap);
}

/* Stack on tablet/mobile */
@media (max-width: 980px){
  .ub-hero{
    grid-template-columns: 1fr;
  }
}

/* Summary / visual panel */
.ub-lab{
  background: var(--ub-surface-2);
  border: 1px solid var(--ub-border);
  border-radius: var(--pay-radius);
  padding: 12px;
}

.ub-lab-top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
  flex-wrap:wrap;
  margin-bottom:8px;
}

.ub-lab-title{
  font-size: clamp(13px, 1.2vw, 14px);
  font-weight:950;
  letter-spacing:.01em;
}

.ub-lab-sub{
  font-size:12px;
  color: var(--ub-muted);
  margin-top:2px;
}

/* KPI tiles */
.ub-kpis{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  justify-content:flex-end;
}

.ub-kpi{
  min-width: 120px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid var(--ub-border);
  background: var(--ub-card-bg);
}

.ub-kpi .k{
  font-size:11px;
  font-weight:900;
  text-transform:uppercase;
  letter-spacing:.04em;
  color: var(--ub-muted);
}

.ub-kpi .v{
  font-family: var(--ub-mono);
  font-weight:950;
  font-size:14px;
  margin-top:2px;
}

/* Cost pill */
.ub-risk{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius:999px;
  border:1px solid var(--ub-border);
  background: var(--ub-card-bg);
  font-size:12px;
  font-weight:950;
  min-height:44px;
}

.ub-dot{
  width:10px;
  height:10px;
  border-radius:50%;
  background: var(--ub-muted);
  flex:0 0 auto;
}

/* Solve mode chips */
.ub-wheel{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap:10px;
  margin-top:10px;
}

.ub-wheel .ub-chip{
  min-height:44px;
  padding:10px 12px;
  border-radius:999px;
  border:1px solid var(--ub-border);
  background: var(--ub-chip-bg);
  color: var(--ub-chip-text);
  font-weight:900;
  cursor:pointer;
  user-select:none;
}

.ub-wheel .ub-chip:hover{
  background: var(--ub-chip-hover);
}

.ub-wheel .ub-chip[aria-pressed="true"]{
  border-color: rgba(249,58,19,.55);
  box-shadow: 0 0 0 4px rgba(249,58,19,.12);
}

/* Breakdown chart area */
.ub-chart-wrap{
  margin-top: 12px;
}

.ub-chart-card{
  border:1px solid var(--ub-border);
  border-radius: 16px;
  background: var(--ub-card-bg);
  padding: 12px;
}

.ub-chart-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  margin-bottom: 10px;
  font-size: 13px;
}

.ub-chart-head strong{
  font-size: 13px;
  font-weight: 950;
}

.ub-chart-head span{
  color: var(--ub-muted);
  font-size: 12px;
}

/* Breakdown bar */
.ub-breakdown{
  width:100%;
}

.ub-breakdown-bar{
  display:flex;
  width:100%;
  min-height: 24px;
  border-radius: 999px;
  overflow:hidden;
  background: var(--ub-surface-3);
  border:1px solid var(--ub-border);
}

.ub-breakdown-bar .seg{
  display:block;
  min-width: 0;
  transition: width 160ms ease;
}

.ub-breakdown-bar .seg:first-child{
  border-top-left-radius: 999px;
  border-bottom-left-radius: 999px;
}

.ub-breakdown-bar .seg:last-child{
  border-top-right-radius: 999px;
  border-bottom-right-radius: 999px;
}

.seg-principal{ background: var(--pay-principal); }
.seg-interest{ background: var(--pay-interest); }
.seg-tax{ background: var(--pay-tax); }
.seg-fees{ background: var(--pay-fees); }

/* Legend */
.ub-legend{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap:10px;
  margin-top: 12px;
}

.ub-legend-item{
  display:grid;
  grid-template-columns: auto 1fr auto;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius: 14px;
  border:1px solid var(--ub-border);
  background: var(--ub-surface-2);
  min-height:44px;
  font-size:13px;
}

.ub-legend-item strong{
  font-family: var(--ub-mono);
  font-size:12px;
  font-weight:950;
}

.swatch{
  width:12px;
  height:12px;
  border-radius:999px;
  display:inline-block;
  flex:0 0 auto;
}

.swatch-principal{ background: linear-gradient(135deg, #ff7426, #f93a13); }
.swatch-interest{ background: linear-gradient(135deg, #f59e0b, #d97706); }
.swatch-tax{ background: linear-gradient(135deg, #38bdf8, #0284c7); }
.swatch-fees{ background: linear-gradient(135deg, #8b5cf6, #6d28d9); }

/* Presets row */
.ub-preset-row{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:10px;
}

.ub-preset-row .ub-chip{
  min-height:44px;
  padding:10px 12px;
}

/* Slider helpers */
.ub-slider-row{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

.ub-range{
  width: min(420px, 100%);
  height: 44px;
  accent-color: var(--ub-btn-grad-b);
}

/* Work box */
.ub-work{
  font-family: var(--ub-mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap:anywhere;
}

/* Collapsible enhancement */
.ub-collapsible summary{
  cursor:pointer;
  font-weight:950;
  min-height:44px;
  display:flex;
  align-items:center;
}

.ub-collapsible summary:focus{
  outline:none;
  box-shadow: 0 0 0 4px var(--ub-focus);
  border-radius:12px;
}

/* Block buttons for rail */
.ub-btn--block{
  width:100%;
}

/* Input hint spacing and inline errors */
.hint{
  margin-top:6px;
  font-size:12px;
  color: var(--ub-muted);
}

.ub-inline-error{
  margin-top:6px;
  font-size:12px;
  color: var(--ub-danger);
  font-weight:800;
  min-height:16px;
}

/* Payment detail polish */
#detailNote,
#outNote{
  overflow-wrap:anywhere;
}

/* Improve chip wrapping in tight spaces */
@media (max-width: 640px){
  .ub-wheel{
    grid-template-columns: 1fr;
  }

  .ub-kpi{
    min-width: 102px;
  }

  .ub-legend{
    grid-template-columns: 1fr;
  }

  .ub-legend-item{
    grid-template-columns: auto 1fr;
  }

  .ub-legend-item strong{
    grid-column: 1 / -1;
    padding-left: 22px;
  }
}

/* Very small screen polish */
@media (max-width: 520px){
  .ub-lab-top{
    align-items:stretch;
  }

  .ub-kpis{
    justify-content:flex-start;
  }

  .ub-kpi{
    min-width: 96px;
  }

  .ub-chart-head{
    align-items:flex-start;
  }
}

/* Dark mode slight emphasis for panels */
html.ub-theme-dark .ub-chart-card,
html.ub-theme-dark .ub-kpi,
html.ub-theme-dark .ub-legend-item,
html.ub-theme-dark .ub-risk{
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}

/* Reduced motion respect */
@media (prefers-reduced-motion: reduce){
  .ub-breakdown-bar .seg{
    transition: none;
  }
}