/* =====================================================================================================================
   PaySalaryLoan - general loan calculator (.psl-calc). Markup: templates/_calculator.php and
   tools/site/partials/calculator.html; behaviour: public/js/psl-calculator.js.

   Uses the psl-site.css tokens (--psl-*) and falls back to the same values, so it also renders on a page that does
   not load psl-site.css. Inputs on the left and the navy results panel on the right from 768px (Principal Amount, Interest Amount, highlighted Total Pay Amount); stacked on phones.
===================================================================================================================== */
.psl-calc { --c-navy: var(--psl-navy-900, #071a45); --c-navy-2: var(--psl-navy-800, #0b2768); --c-blue: var(--psl-blue, #0f62fe);
    --c-blue-50: var(--psl-blue-50, #f3f7ff); --c-blue-100: var(--psl-blue-100, #e6efff); --c-blue-200: var(--psl-blue-200, #c9dbff);
    --c-mint: var(--psl-mint, #12b07a); --c-mint-on-navy: var(--psl-mint-on-navy, #9fe3c8); --c-ink: var(--psl-ink, #0d1b3a);
    --c-ink-2: var(--psl-ink-2, #44506b); --c-ink-3: var(--psl-ink-3, #5f6a84); --c-line: var(--psl-line, #e3e8f2); --c-red: var(--psl-red, #c62828);
    --c-focus: var(--psl-focus, #7aa7ff);
    display: grid; gap: 0; overflow: hidden; border-radius: var(--psl-radius-lg, 18px); background: #fff; border: 1px solid var(--c-line);
    box-shadow: 0 18px 48px -24px rgba(7, 26, 69, .28); font-family: var(--psl-font, "Inter", system-ui, sans-serif); color: var(--c-ink); }
.psl-calc *, .psl-calc *::before, .psl-calc *::after { box-sizing: border-box; }
.psl-calc :focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; }

/* ---------------------------------------------------------------- inputs */
.psl-calc__inputs { display: grid; gap: 22px; padding: 22px 18px; min-width: 0; }
.psl-calc__field { min-width: 0; }
.psl-calc__top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 6px; }
.psl-calc__top > label { font-size: .92rem; font-weight: 700; color: var(--c-ink); }
.psl-calc__pair { display: inline-flex; align-items: stretch; gap: 6px; }
.psl-calc__box { display: inline-flex; align-items: center; gap: 4px; height: 42px; padding: 0 10px; border-radius: 10px; background: var(--c-blue-50);
    border: 1.5px solid var(--c-blue-200); font-weight: 700; color: var(--c-ink-2); transition: border-color .15s, box-shadow .15s; }
.psl-calc__box:focus-within { border-color: var(--c-blue); box-shadow: 0 0 0 4px rgba(15, 98, 254, .15); background: #fff; }
.psl-calc__box input { width: 6.2em; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; background: transparent; font: inherit;
    font-family: var(--psl-font-display, inherit); font-size: 1.05rem; font-weight: 800; text-align: right; color: var(--c-navy);
    font-variant-numeric: tabular-nums; }
.psl-calc__box input[aria-invalid="true"] { color: var(--c-red); }
.psl-calc__box:has(input[aria-invalid="true"]) { border-color: var(--c-red); }
.psl-calc__box input:focus-visible { outline: 0; }   /* the ring is on .psl-calc__box */
.psl-calc__box input:is([id$="-tenure"], [id$="-rate"], [id$="-fee"]) { width: 3.4em; }
.psl-calc__unit { height: 42px; padding: 0 28px 0 10px; border-radius: 10px; border: 1.5px solid var(--c-blue-200); cursor: pointer; font: inherit;
    font-size: .9rem; font-weight: 600; color: var(--c-navy-2); -webkit-appearance: none; appearance: none;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%230b2768' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; }
.psl-calc__unit:focus-visible { border-color: var(--c-blue); }

.psl-calc__range { display: block; width: 100%; height: 8px; margin: 12px 0 6px; border-radius: 8px; cursor: pointer; -webkit-appearance: none; appearance: none;
    background: linear-gradient(90deg, var(--c-blue), var(--c-mint)) 0 / var(--fill, 50%) 100% no-repeat, var(--c-blue-100); }
.psl-calc__range::-webkit-slider-thumb { width: 26px; height: 26px; border-radius: 50%; -webkit-appearance: none; appearance: none; cursor: grab;
    background: #fff; border: 3px solid var(--c-blue); box-shadow: 0 2px 6px rgba(7, 26, 69, .25); }
.psl-calc__range::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; cursor: grab; background: #fff; border: 3px solid var(--c-blue); }
.psl-calc__range:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 6px; }
.psl-calc__lim { display: flex; justify-content: space-between; font-size: .74rem; color: var(--c-ink-3); }
.psl-calc__err { margin: 6px 0 0; font-size: .82rem; font-weight: 600; color: var(--c-red); }
.psl-calc__err[hidden] { display: none; }

/* ---------------------------------------------------------------- results: navy panel */
.psl-calc__results { position: relative; display: flex; flex-direction: column; min-width: 0; padding: 22px 18px; color: #dbe6ff;
    background: radial-gradient(circle at 100% 0%, rgba(18, 176, 122, .25), transparent 45%), linear-gradient(150deg, var(--c-navy), var(--c-navy-2)); }
.psl-calc__res-title { margin: 0 0 14px; font-family: var(--psl-font, inherit); font-size: .76rem; font-weight: 700; letter-spacing: .14em;
    text-transform: uppercase; color: var(--c-mint-on-navy); }
.psl-calc__rows { margin: 0 0 16px; }
.psl-calc__rows > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 0; border-bottom: 1px dashed rgba(255, 255, 255, .16);
    font-size: .98rem; }
.psl-calc__rows dt { min-width: 0; color: #c9d4ee; }
.psl-calc__rows dt small { display: block; margin-top: 1px; font-size: .72rem; color: var(--psl-on-navy-2, #9fb0d6); }
.psl-calc__rows dd { margin: 0; flex: none; font-family: var(--psl-font-display, inherit); font-size: 1.1rem; font-weight: 800; text-align: right; color: #fff;
    font-variant-numeric: tabular-nums; }
/* Total Pay Amount: the one highlighted figure */
.psl-calc__total { display: flex; flex-direction: column; gap: 2px; margin-top: auto; min-width: 0; padding: 16px 18px; border-radius: 14px;
    background: rgba(18, 176, 122, .18); border: 1px solid rgba(159, 227, 200, .45); }
.psl-calc__total span { font-size: .84rem; font-weight: 700; letter-spacing: .02em; color: var(--c-mint-on-navy); }
.psl-calc__total strong { overflow-wrap: anywhere; font-family: var(--psl-font-display, inherit); font-size: 1.9rem; font-weight: 800; line-height: 1.15;
    color: #fff; font-variant-numeric: tabular-nums; }
.psl-calc__total small { font-size: .74rem; color: #b9c8ea; }
.psl-calc__sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.psl-calc__note { grid-column: 1 / -1; margin: 0; padding: 12px 18px; font-size: .8rem; line-height: 1.5; color: var(--c-ink-3); background: var(--c-blue-50);
    border-top: 1px solid var(--c-line); }

/* ---------------------------------------------------------------- layout */
@media (min-width: 768px) {
    .psl-calc { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); }
    .psl-calc__inputs { padding: 28px 28px 26px; }
    .psl-calc__results { padding: 28px 26px; }
    .psl-calc__note { padding: 12px 28px; }
}
@media (min-width: 992px) {
    .psl-calc__total strong { font-size: 2.2rem; }
}
@media (prefers-reduced-motion: reduce) {
    .psl-calc * { transition: none !important; }
}

/* responsive audit: 16 px controls (no iOS zoom on focus); 14 px minimum text on phones */
.psl-calc__unit { font-size: 1rem; }
@media (max-width: 767.98px) {
    .psl-calc__lim, .psl-calc__res-title, .psl-calc__rows dt small, .psl-calc__total span, .psl-calc__total small, .psl-calc__note { font-size: .875rem; }
}
