/* ============================================================
   THRIFTRUPEE — EMI Calculator
   assets/css/emi-calculator.css
   ============================================================ */

.tr-emi-wrap {
  background: var(--tr-white);
  border: 1px solid var(--tr-sand);
  border-radius: var(--radius-xl);
  overflow: hidden;
  max-width: 960px;
  margin: var(--sp-6) auto;
  box-shadow: var(--shadow-md);
}

/* ── Header ── */
.tr-emi-header {
  background: linear-gradient(135deg, var(--tr-ink) 0%, var(--tr-forest) 60%, var(--tr-pine) 100%);
  color: var(--tr-white);
  padding: var(--sp-10) var(--sp-8);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.tr-emi-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.022) 1px, transparent 1px);
  background-size: 24px 24px;
}
.tr-emi-header-icon {
  width: 56px; height: 56px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto var(--sp-4);
  font-size: 24px;
  position: relative;
  z-index: 1;
}
.tr-emi-header h2 {
  font-family: var(--font-display);
  font-size: clamp(22px, 3vw, 30px);
  color: var(--tr-white);
  margin-bottom: var(--sp-2);
  font-weight: 400;
  position: relative;
  z-index: 1;
}
.tr-emi-header p {
  font-size: 15px;
  color: rgba(255,255,255,0.6);
  margin: 0;
  position: relative;
  z-index: 1;
}

/* ── Tab switcher (loan type) ── */
.tr-emi-tabs {
  display: flex;
  border-bottom: 1px solid var(--tr-sand);
  background: var(--tr-warm);
  overflow-x: auto;
  scrollbar-width: none;
}
.tr-emi-tabs::-webkit-scrollbar { display: none; }
.tr-emi-tab {
  flex: 1;
  min-width: 120px;
  padding: var(--sp-4) var(--sp-5);
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--tr-muted);
  text-align: center;
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2.5px solid transparent;
  transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
  white-space: nowrap;
}
.tr-emi-tab:hover { color: var(--tr-green); background: rgba(34,165,84,0.04); }
.tr-emi-tab.is-active {
  color: var(--tr-green);
  border-bottom-color: var(--tr-green);
  background: var(--tr-white);
}

/* ── Body ── */
.tr-emi-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

/* ── Inputs column ── */
.tr-emi-inputs {
  padding: var(--sp-8);
  border-right: 1px solid var(--tr-sand);
}
.tr-emi-field {
  margin-bottom: var(--sp-7);
}
.tr-emi-field:last-child { margin-bottom: 0; }

.tr-emi-field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-3);
}
.tr-emi-field-label {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--tr-heading);
}
.tr-emi-field-value {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  color: var(--tr-emerald);
  background: var(--tr-pale);
  border: 1px solid rgba(34,165,84,0.2);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  min-width: 80px;
  text-align: center;
}

/* Direct input field (editable amount) */
.tr-emi-field-input-wrap {
  position: relative;
  margin-bottom: var(--sp-3);
}
.tr-emi-currency {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  color: var(--tr-muted);
  pointer-events: none;
}
.tr-emi-field input[type="number"] {
  width: 100%;
  border: 1.5px solid var(--tr-sand);
  border-radius: var(--radius);
  padding: 10px 12px 10px 28px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  color: var(--tr-heading);
  background: var(--tr-white);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  -moz-appearance: textfield;
}
.tr-emi-field input[type="number"]::-webkit-inner-spin-button,
.tr-emi-field input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
.tr-emi-field input[type="number"]:focus {
  outline: none;
  border-color: var(--tr-green);
  box-shadow: 0 0 0 3px rgba(34,165,84,0.1);
}

/* Range slider */
.tr-emi-field input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--tr-green) 0%, var(--tr-green) var(--pct, 35%), var(--tr-sand) var(--pct, 35%), var(--tr-sand) 100%);
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.tr-emi-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--tr-white);
  border: 2.5px solid var(--tr-green);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(34,165,84,0.25);
  transition: transform var(--dur-fast), box-shadow var(--dur-fast);
}
.tr-emi-field input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 14px rgba(34,165,84,0.35);
}
.tr-emi-field input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--tr-white);
  border: 2.5px solid var(--tr-green);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(34,165,84,0.25);
}
.tr-emi-field-range {
  display: flex;
  justify-content: space-between;
  margin-top: var(--sp-2);
  font-size: 11px;
  color: var(--tr-stone);
  font-weight: 500;
}

/* ── Results column ── */
.tr-emi-results {
  padding: var(--sp-8);
  background: var(--tr-warm);
}

/* EMI highlight */
.tr-emi-result-main {
  background: linear-gradient(135deg, var(--tr-forest) 0%, var(--tr-pine) 100%);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  text-align: center;
  color: var(--tr-white);
  margin-bottom: var(--sp-5);
  position: relative;
  overflow: hidden;
}
.tr-emi-result-main::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 20px 20px;
}
.tr-emi-result-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.55);
  margin-bottom: var(--sp-2);
  position: relative;
}
.tr-emi-result-amount {
  font-family: var(--font-display);
  font-size: clamp(36px, 5vw, 48px);
  color: var(--tr-lime);
  line-height: 1;
  position: relative;
}
.tr-emi-result-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  margin-top: var(--sp-2);
  position: relative;
}

/* Doughnut chart */
.tr-emi-chart-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: var(--sp-5);
}
.tr-emi-chart-wrap canvas {
  max-width: 200px;
  max-height: 200px;
}

/* Breakdown rows */
.tr-emi-breakdown {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.tr-emi-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--tr-white);
  padding: var(--sp-4);
  border-radius: var(--radius);
  border: 1px solid var(--tr-sand);
  transition: transform var(--dur-fast), box-shadow var(--dur-fast);
}
.tr-emi-row:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.tr-emi-row--total {
  border-color: rgba(34,165,84,0.3);
  background: var(--tr-pale);
}
.tr-emi-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tr-emi-dot--principal { background: var(--tr-green); }
.tr-emi-dot--interest  { background: #f59e0b; }
.tr-emi-dot--total     { background: var(--tr-emerald); }
.tr-emi-row-label {
  flex: 1;
  font-size: 13px;
  color: var(--tr-muted);
  font-weight: 500;
}
.tr-emi-row-value {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  color: var(--tr-heading);
}
.tr-emi-row--total .tr-emi-row-value { color: var(--tr-emerald); }

/* ── Amortisation table ── */
.tr-emi-table-wrap {
  padding: var(--sp-8);
  border-top: 1px solid var(--tr-sand);
}
.tr-emi-table-title {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--tr-heading);
  margin-bottom: var(--sp-5);
}
.tr-emi-table-scroll {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--tr-sand);
}
.tr-emi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 520px;
}
.tr-emi-table th {
  background: var(--tr-warm);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--tr-muted);
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  border-bottom: 1px solid var(--tr-sand);
  white-space: nowrap;
}
.tr-emi-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid rgba(0,0,0,0.04);
  color: var(--tr-body);
}
.tr-emi-table tr:last-child td { border-bottom: none; }
.tr-emi-table tr:hover td { background: var(--tr-pale); }
.tr-emi-table td:last-child {
  font-weight: 600;
  color: var(--tr-emerald);
}
.tr-emi-table-foot td {
  font-weight: 700;
  color: var(--tr-heading);
  background: var(--tr-warm) !important;
  border-top: 1.5px solid var(--tr-sand);
}
.tr-emi-table-foot td:last-child { color: var(--tr-emerald); }

/* Toggle for table */
.tr-emi-table-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
}
.tr-emi-table-toggle button {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--tr-sand);
  color: var(--tr-muted);
  background: var(--tr-white);
  cursor: pointer;
  transition: all var(--dur-fast);
}
.tr-emi-table-toggle button.is-active {
  background: var(--tr-green);
  color: var(--tr-white);
  border-color: var(--tr-green);
}

/* ── Responsive ── */
@media (max-width: 760px) {
  .tr-emi-body {
    grid-template-columns: 1fr;
  }
  .tr-emi-inputs {
    border-right: none;
    border-bottom: 1px solid var(--tr-sand);
    padding: var(--sp-6);
  }
  .tr-emi-results { padding: var(--sp-6); }
  .tr-emi-table-wrap { padding: var(--sp-6); }
}
@media (max-width: 480px) {
  .tr-emi-header { padding: var(--sp-6); }
  .tr-emi-inputs, .tr-emi-results, .tr-emi-table-wrap { padding: var(--sp-5); }
  .tr-emi-result-amount { font-size: 36px; }
}
