/* Professional EMI Calculator - advanced, precise, easy to use */

/* Outer layout: left ad rail | calculator | right ad rail */
.page-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr) 280px; gap: 32px; align-items: start; }

.calc-pro-wrap { width: 100%; max-width: 1200px; margin: 0; padding: 10px 0 20px; min-width: 0; justify-self: center; }

.calc-pro-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 24px; align-items: start; min-width: 0; }
.calc-pro-grid > * { min-width: 0; }

.calc-pro-form-card, .calc-pro-result-card, .calc-pro-schedule-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 14px;
    padding: 26px 28px;
    box-shadow: 0 2px 10px rgba(35, 39, 47, .06);
}

.calc-pro-form-card h2, .calc-pro-result-card h2, .calc-pro-schedule-card h2 {
    font-size: 1.25em;
    font-weight: 700;
    margin: 0 0 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #23272f;
}
.calc-pro-form-card h2 i, .calc-pro-result-card h2 i, .calc-pro-schedule-card h2 i { color: #923239; }

/* ===== Basic / Advanced mode toggle ===== */
.calc-pro-card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.calc-pro-card-head h2 { margin-bottom: 0; }
.calc-mode-toggle { display: flex; background: #f2eeee; border-radius: 30px; padding: 4px; }
.calc-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; }
.calc-mode-btn.is-active { background: #923239; color: #fff; box-shadow: 0 3px 8px rgba(146,50,57,.3); }

/* Basic mode is the default state: advanced-only elements start hidden */
.advanced-only { display: none; }
.calc-pro-wrap.mode-advanced .advanced-only { display: block; }
.calc-pro-wrap.mode-advanced .calc-pro-tiles .advanced-only { display: block; }

/* ===== Fields ===== */
.calc-pro-field { margin-bottom: 22px; }
.calc-pro-field-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.calc-pro-field-head label { font-weight: 600; font-size: .92em; color: #3d4148; }
.calc-pro-input-box { display: flex; align-items: center; border: 1.5px solid #e2e4e8; border-radius: 8px; overflow: hidden; transition: border-color .2s ease; background: #fbfbfc; }
.calc-pro-input-box:focus-within { border-color: #923239; background: #fff; }
.calc-pro-input-box .unit { padding: 0 12px; color: #923239; font-weight: 700; font-size: .95em; background: #f7f4f4; align-self: stretch; display: flex; align-items: center; }
.calc-pro-input-box input[type="number"] {
    flex: 1; border: none; outline: none; background: transparent; padding: 10px 12px; font-size: 1.05em; font-weight: 600; color: #23272f; width: 100%;
    -moz-appearance: textfield;
}
.calc-pro-input-box input[type="number"]::-webkit-outer-spin-button,
.calc-pro-input-box input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.calc-pro-field input[type="range"] {
    width: 100%; margin-top: 12px; -webkit-appearance: none; appearance: none;
    height: 6px; border-radius: 4px; background: #eee; outline: none;
}
.calc-pro-field input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%;
    background: #923239; cursor: pointer; border: 3px solid #fff; box-shadow: 0 0 0 1px #923239;
}
.calc-pro-field input[type="range"]::-moz-range-thumb {
    width: 18px; height: 18px; border-radius: 50%; background: #923239; cursor: pointer; border: 3px solid #fff; box-shadow: 0 0 0 1px #923239;
}
.calc-pro-range-labels { display: flex; justify-content: space-between; font-size: .75em; color: #9aa0aa; margin-top: 4px; }

.calc-pro-error { color: #c62828; font-size: .8em; margin-top: 6px; display: none; }
.calc-pro-error.show { display: block; }
.calc-pro-field.has-error .calc-pro-input-box { border-color: #c62828; }

.calc-pro-submit {
    width: 100%; padding: 14px; background: #923239; 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;
}
.calc-pro-submit:hover { background: #6d2429; transform: translateY(-1px); box-shadow: 0 8px 18px rgba(146,50,57,.25); }

/* ===== Results ===== */
.calc-pro-hero-result { text-align: center; padding: 18px 10px 22px; border-bottom: 1px dashed #eee; margin-bottom: 20px; }
.calc-pro-hero-result .label { font-size: .82em; color: #6b7280; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.calc-pro-hero-result .amount { font-size: 2.4em; font-weight: 800; color: #923239; margin: 6px 0 2px; }
.calc-pro-hero-result .amount sup { font-size: .5em; font-weight: 600; margin-right: 2px; }
.calc-pro-hero-result .sub { font-size: .85em; color: #9aa0aa; }

.calc-pro-chart-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; justify-content: center; margin-bottom: 20px; }
.calc-pro-chart-wrap canvas { max-width: 75px; max-height: 75px; }
.calc-pro-legend { display: flex; flex-direction: column; gap: 10px; }
.calc-pro-legend-item { display: flex; align-items: center; gap: 8px; font-size: .88em; }
.calc-pro-legend-dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

.calc-pro-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; min-width: 0; }
.calc-pro-tiles > * { min-width: 0; }
.calc-pro-tile { background: #f7f4f4; border-radius: 10px; padding: 14px 16px; }
.calc-pro-tile .tile-label { font-size: .76em; color: #6b7280; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.calc-pro-tile .tile-value { font-size: 1.15em; font-weight: 700; color: #23272f; }
.calc-pro-tile .tile-formula { font-size: .7em; color: #b0b4bc; margin-top: 2px; }

/* ===== Schedule ===== */
.calc-pro-schedule-card { margin-top: 24px; }
.calc-pro-schedule-toggle { background: none; border: 1.5px solid #923239; color: #923239; padding: 10px 20px; border-radius: 30px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: all .2s ease; }
.calc-pro-schedule-toggle:hover { background: #923239; color: #fff; }
.calc-pro-schedule-toggle i { transition: transform .25s ease; }
.calc-pro-schedule-toggle.open i { transform: rotate(180deg); }

.calc-pro-schedule-body { max-height: 0; overflow: hidden; transition: max-height .35s ease; }
.calc-pro-schedule-body.open { max-height: 3000px; }
.calc-pro-schedule-table-wrap { overflow-x: auto; margin-top: 18px; max-height: 420px; overflow-y: auto; border: 1px solid #eee; border-radius: 10px; }
table.calc-pro-table { width: 100%; border-collapse: collapse; font-size: .9em; }
table.calc-pro-table thead th { position: sticky; top: 0; background: #923239; color: #fff; text-align: right; padding: 10px 14px; font-weight: 600; }
table.calc-pro-table thead th:first-child { text-align: left; }
table.calc-pro-table td { padding: 9px 14px; text-align: right; border-bottom: 1px solid #f0f0f0; }
table.calc-pro-table td:first-child { text-align: left; font-weight: 600; }
table.calc-pro-table tbody tr:nth-child(even) td { background: #fbfaf9; }
table.calc-pro-table tbody tr:hover td { background: #fdf0ee; }

.calc-pro-note { max-width: 1200px; margin: 22px auto 0; font-size: .85em; color: #9aa0aa; text-align: center; }

/* Narrower rail columns once the viewport can't comfortably fit the full
   280px width alongside the content column, before the rail disappears
   entirely below 1200px (kept in sync with .page-ad-rail's own breakpoint
   in ad-rail.css). */
@media (max-width: 1500px) {
    .page-layout { grid-template-columns: 200px minmax(0, 1fr) 200px; gap: 15px; }
}

/* Laptop / small desktop: ad rails hidden, layout is single flexible column */
@media (max-width: 1200px) {
    .page-layout { grid-template-columns: minmax(0, 1fr); }
}

/* Tablet: stack form/result, keep 2-up tiles, trim card padding */
@media (max-width: 900px) {
    .calc-pro-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    .calc-pro-tiles { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .calc-pro-form-card, .calc-pro-result-card, .calc-pro-schedule-card { padding: 20px; }
}

/* Large phone / small tablet portrait */
@media (max-width: 600px) {
    .calc-pro-form-card h2, .calc-pro-result-card h2, .calc-pro-schedule-card h2 { font-size: 1.1em; }
    .calc-pro-card-head { gap: 8px; }
    .calc-mode-toggle { width: 100%; justify-content: center; }
    .calc-mode-btn { flex: 1; text-align: center; }
    .calc-pro-hero-result .amount { font-size: 2em; word-break: break-word; }
    .calc-pro-chart-wrap { gap: 14px; }
    .calc-pro-chart-wrap canvas { max-width: 75px; max-height: 75px; }
    .calc-pro-schedule-toggle { width: 100%; justify-content: center; }
}

/* Small phone */
@media (max-width: 480px) {
    .calc-pro-tiles { grid-template-columns: 1fr; }
    .calc-pro-hero-result .amount { font-size: 1.75em; }
    .calc-pro-input-box input[type="number"] { font-size: .98em; }
    .calc-pro-form-card, .calc-pro-result-card, .calc-pro-schedule-card { padding: 16px; }
    table.calc-pro-table { font-size: .82em; }
    table.calc-pro-table th, table.calc-pro-table td { padding: 7px 9px; }
}

/* Very small phones (older/compact devices) */
@media (max-width: 360px) {
    .calc-pro-hero-result .amount { font-size: 1.5em; }
    .calc-pro-input-box .unit { padding: 0 8px; font-size: .85em; }
}
