/* Two-column workspace: Loan Details form (left) + EMI Breakdown result (right) -
   mirrors the original tool's calc-pro-grid, which does NOT stretch both cards to
   equal height (align-items:start), so each card keeps its own natural height. */
.emi-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 24px; align-items: start; min-width: 0; margin-bottom: 24px; }
.emi-grid > * { min-width: 0; }

.emi-form-card, .emi-result-card, .emi-schedule-card { padding: 26px 28px; }

.emi-form-card h2, .emi-result-card h2, .emi-schedule-card h2 {
    font-size: 1.25em;
    font-weight: 700;
    margin: 0 0 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #23272f;
}
.emi-form-card h2 i, .emi-result-card h2 i, .emi-schedule-card h2 i { color: var(--site-dark-2); }

/* ===== Card head + Basic/Advanced mode toggle ===== */
.emi-card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.emi-card-head h2 { margin-bottom: 0; }
.emi-mode-toggle { display: flex; background: #f2eeee; border-radius: 30px; padding: 4px; }
.emi-mode-btn { border: none; background: transparent; padding: 7px 18px; border-radius: 24px; font-size: .85em; font-weight: 600; color: #6b7280; cursor: pointer; transition: all .2s ease; }
.emi-mode-btn.is-active { background: var(--site-dark-2); color: #fff; box-shadow: 0 3px 8px rgba(17,94,89,.3); }

/* Basic mode is the default state: advanced-only elements start hidden */
.emi-advanced-only { display: none; }
.emi-grid.mode-advanced .emi-advanced-only { display: block; }

/* ===== Fields ===== */
.emi-field { margin-bottom: 22px; }
.emi-field:last-of-type { margin-bottom: 0; }
.emi-field-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.emi-field-head label { font-weight: 600; font-size: .92em; color: #3d4148; }
.emi-input-box { display: flex; align-items: center; border: 1.5px solid #e2e4e8; border-radius: 8px; overflow: hidden; transition: border-color .2s ease; background: #fbfbfc; }
.emi-input-box:focus-within { border-color: var(--site-dark-2); background: #fff; }
.emi-input-box .unit { padding: 0 12px; color: var(--site-dark-2); font-weight: 700; font-size: .95em; background: #f7f4f4; align-self: stretch; display: flex; align-items: center; white-space: nowrap; }
.emi-input-box input[type="number"] {
    flex: 1; min-width: 0; border: none; outline: none; background: transparent; padding: 10px 12px; font-size: 1.05em; font-weight: 600; color: #23272f; width: 100%;
    -moz-appearance: textfield;
}
.emi-input-box input[type="number"]::-webkit-outer-spin-button,
.emi-input-box input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.emi-field input[type="range"] {
    width: 100%; margin-top: 12px; -webkit-appearance: none; appearance: none;
    height: 6px; border-radius: 4px; background: #eee; outline: none;
}
.emi-field input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%;
    background: var(--site-dark-2); cursor: pointer; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--site-dark-2);
}
.emi-field input[type="range"]::-moz-range-thumb {
    width: 18px; height: 18px; border-radius: 50%; background: var(--site-dark-2); cursor: pointer; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--site-dark-2);
}
.emi-range-labels { display: flex; justify-content: space-between; font-size: .75em; color: #9aa0aa; margin-top: 4px; }

.emi-error { color: var(--site-danger); font-size: .8em; margin-top: 6px; display: none; }
.emi-error.show { display: block; }
.emi-field.has-error .emi-input-box { border-color: var(--site-danger); }

.emi-submit {
    width: 100%; padding: 14px; background: var(--site-dark-2); color: #fff; border: none; border-radius: 8px;
    font-size: 1.05em; font-weight: 700; cursor: pointer; transition: all .25s ease; display: flex; align-items: center; justify-content: center; gap: 8px;
    margin-top: 4px;
}
.emi-submit:hover { background: var(--site-dark); transform: translateY(-1px); box-shadow: 0 8px 18px rgba(17,94,89,.25); }

/* ===== Results ===== */
.emi-hero-result { text-align: center; padding: 18px 10px 22px; border-bottom: 1px dashed #eee; margin-bottom: 20px; }
.emi-hero-result .label { font-size: .82em; color: #6b7280; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.emi-hero-result .amount { font-size: 2.4em; font-weight: 800; color: var(--site-dark-2); margin: 6px 0 2px; word-break: break-word; }
.emi-hero-result .sub { font-size: .85em; color: #9aa0aa; }

.emi-chart-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; justify-content: center; margin-bottom: 20px; }
.emi-chart-wrap canvas { width: 75px; height: 75px; flex-shrink: 0; aspect-ratio: 1 / 1; }
.emi-legend { display: flex; flex-direction: column; gap: 10px; }
.emi-legend-item { display: flex; align-items: center; gap: 8px; font-size: .88em; }
.emi-legend .dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
/* Chart palette now uses the shared theme tokens (not the original's own maroon/pink/gold),
   per an explicit later request - retheming the site also retheme this chart automatically. */
.emi-dot-principal { background: var(--site-dark); }
.emi-dot-interest { background: var(--site-light); }
.emi-dot-fee { background: var(--site-gold); }

.emi-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; min-width: 0; }
.emi-tiles > * { min-width: 0; }
.emi-tile { background: #f7f4f4; border-radius: 10px; padding: 14px 16px; }
.emi-tile-label { display: block; font-size: .76em; color: #6b7280; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.emi-tile-value { font-size: 1.15em; font-weight: 700; color: #23272f; }
.emi-tile-formula { font-size: .7em; color: #b0b4bc; margin-top: 2px; }

/* ===== Privacy note ===== */
.emi-privacy-note { display: flex; align-items: flex-start; gap: 10px; background: #f0fdfa; border: 1px solid var(--site-success-border); border-radius: 10px; padding: 12px 16px; margin-top: 22px; font-size: .84em; color: #3d4148; }
.emi-privacy-note i { color: var(--site-dark-2); margin-top: 2px; }

/* ===== Amortization schedule card ===== */
.emi-schedule-desc { color: #6b7280; font-size: .9em; margin-top: -10px; }
.emi-schedule-toggle { background: none; border: 1.5px solid var(--site-dark-2); color: var(--site-dark-2); padding: 10px 20px; border-radius: 30px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: all .2s ease; }
.emi-schedule-toggle:hover { background: var(--site-dark-2); color: #fff; }
.emi-schedule-toggle i { transition: transform .25s ease; }
.emi-schedule-toggle.open i { transform: rotate(180deg); }

.emi-schedule-body { max-height: 0; overflow: hidden; transition: max-height .35s ease; }
.emi-schedule-body.open { max-height: 3000px; }
.emi-schedule-card .loan-table-wrap { overflow-x: auto; margin-top: 18px; max-height: 420px; overflow-y: auto; border: 1px solid #eee; border-radius: 10px; }
table.emi-schedule-table { width: 100%; border-collapse: collapse; font-size: .9em; }
table.emi-schedule-table thead th { position: sticky; top: 0; background: var(--site-dark-2); color: #fff; text-align: right; padding: 10px 14px; font-weight: 600; }
table.emi-schedule-table thead th:first-child { text-align: left; }
table.emi-schedule-table td { padding: 9px 14px; text-align: right; border-bottom: 1px solid #f0f0f0; }
table.emi-schedule-table td:first-child { text-align: left; font-weight: 600; }
table.emi-schedule-table tbody tr:nth-child(even) td { background: #fbfaf9; }
table.emi-schedule-table tbody tr:hover td { background: #fdf0ee; }

@media (max-width: 900px) {
    .emi-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    .emi-tiles { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

@media (max-width: 600px) {
    .emi-form-card h2, .emi-result-card h2, .emi-schedule-card h2 { font-size: 1.1em; }
    .emi-card-head { gap: 8px; }
    .emi-mode-toggle { width: 100%; justify-content: center; }
    .emi-mode-btn { flex: 1; text-align: center; }
    .emi-hero-result .amount { font-size: 2em; }
    .emi-chart-wrap { gap: 14px; }
    .emi-schedule-toggle { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
    .emi-tiles { grid-template-columns: 1fr; }
    .emi-hero-result .amount { font-size: 1.75em; }
    .emi-input-box input[type="number"] { font-size: .98em; }
    .emi-form-card, .emi-result-card, .emi-schedule-card { padding: 16px; }
    table.emi-schedule-table { font-size: .82em; }
    table.emi-schedule-table th, table.emi-schedule-table td { padding: 7px 9px; }
}

@media (max-width: 360px) {
    .emi-hero-result .amount { font-size: 1.5em; }
    .emi-input-box .unit { padding: 0 8px; font-size: .85em; }
}
