/* Mobile-first application form: one column, large touch targets, nothing wider than the phone.
   Colours and fonts come from the tokens in site.css. */

.apply {
    max-width: 34rem;
    margin: 0 auto;
    padding-bottom: 6rem; /* room above the sticky buttons */
}

.apply h1 {
    margin-bottom: 0.75rem;
    font-size: clamp(1.75rem, 6vw, 2.125rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.apply h2 {
    font-size: 1.125rem;
}

.apply .form-label {
    margin-top: 1rem;
    font-weight: 600;
}

.apply .form-control:not([type="file"]),
.apply .form-select {
    min-height: 3.5rem;
    padding-inline: 1rem;
    border-radius: var(--radius-control);
    font-size: 1.0625rem;
}

/* Digits and references read best in mono with a little air between them. */
.apply #nin,
.apply #accountNumber,
.apply #amount,
.apply #statusReference,
.apply #reference {
    font-family: var(--font-mono);
    font-size: 1.1875rem;
    letter-spacing: 0.08em;
}

.apply .form-control[type="file"] {
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-control);
}

.apply .form-check {
    margin-top: 1rem;
    padding: 1rem 1rem 1rem 2.75rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
}

.apply .form-check .form-check-input {
    margin-left: -1.75rem;
}

.apply details summary {
    color: var(--blue-700);
    font-weight: 600;
    cursor: pointer;
}

/* ---------- progress ---------- */

.apply-progress {
    margin: 0 0 0.5rem;
    color: var(--blue-700);
    font-size: 0.875rem;
    font-weight: 700;
}

/* One segment per step (--steps), filled up to the step on screen (--progress); apply.js sets both on #apply. */
.apply-bar {
    --segment: calc(100% / var(--steps, 4));
    position: relative;
    height: 6px;
    margin-bottom: 1.75rem;
    border-radius: 999px;
    background: repeating-linear-gradient(90deg, var(--line) 0 calc(var(--segment) - 4px), transparent calc(var(--segment) - 4px) var(--segment));
}

.apply-bar::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: repeating-linear-gradient(90deg, var(--blue-700) 0 calc(var(--segment) - 4px), transparent calc(var(--segment) - 4px) var(--segment));
    clip-path: inset(0 calc(100% - var(--progress, 1) * var(--segment)) 0 0);
    transition: clip-path 0.3s ease;
}

.apply:has(> [data-step="done"]:not([hidden])) .apply-bar { display: none; }

@media (prefers-reduced-motion: reduce) {
    .apply-bar::before {
        transition: none;
    }
}

/* ---------- messages ---------- */

.apply-notice {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-control);
    background: var(--saffron-100);
    color: #5C3B00;
}

.apply-error {
    min-height: 1.25rem;
    margin: 0.35rem 0 0;
    color: var(--red-700);
    font-size: 0.9375rem;
    font-weight: 600;
}

.apply-error:empty {
    min-height: 0;
}

/* ---------- key facts ---------- */

.apply-facts {
    display: grid;
    grid-template-columns: minmax(7rem, auto) 1fr;
    margin: 0;
    padding: 0.25rem 1rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
}

.apply-facts dt,
.apply-facts dd {
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--blue-100);
}

.apply-facts dt {
    padding-right: 1rem;
    color: var(--slate-600);
    font-weight: 500;
}

.apply-facts dd {
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.apply-facts dt:last-of-type,
.apply-facts dd:last-of-type {
    border-bottom: 0;
}

/* ---------- selfie and files ---------- */

.apply-camera video,
.apply-selfie {
    width: 100%;
    max-height: 60vh;
    object-fit: cover;
    border-radius: 18px;
    background: #000;
    transform: scaleX(-1); /* mirror the live preview, as front cameras do */
}

.apply-selfie {
    transform: none;
    margin-bottom: 0.75rem;
}

.apply-files {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.75rem 0 0;
    padding: 0;
    list-style: none;
}

.apply-files li {
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    overflow-wrap: anywhere;
}

/* ---------- amount ---------- */

.apply .form-range {
    height: 2rem;
}

.apply fieldset .btn-group {
    gap: 4px;
    padding: 4px;
    border-radius: 16px;
    background: var(--blue-100);
}

.apply fieldset .btn-group > .btn {
    --bs-btn-hover-bg: rgba(5, 103, 190, 0.08);
    --bs-btn-hover-color: var(--ink);
    --bs-btn-hover-border-color: transparent;
    flex: 1 1 0;
    min-height: 3rem;
    margin: 0 !important;
    border: 0;
    border-radius: 12px !important;
    background: transparent;
    color: var(--ink);
    font-weight: 600;
}

.apply fieldset .btn-check:checked + .btn {
    background: var(--blue-700);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(5, 42, 79, 0.25);
}

.apply fieldset .btn-check:focus-visible + .btn {
    box-shadow: var(--focus-ring);
}

.apply legend.form-label {
    margin-bottom: 0.5rem;
}

.apply-quote {
    margin-top: 1.25rem;
    padding: 1.1rem 1.25rem;
    border-radius: 20px;
    background: var(--navy-900) var(--pattern-adire);
    color: var(--blue-200);
}

.apply-quote:empty {
    display: none;
}

.apply-quote p {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin: 0;
    padding: 0.45rem 0;
}

.apply-quote p + p {
    border-top: 1px solid #1A4A78;
}

.apply-quote strong {
    color: #fff;
    white-space: nowrap;
}

.apply-quote p:first-child {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    padding-bottom: 0.85rem;
}

.apply-quote p:first-child strong {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.05;
}

.apply-quote p:last-child strong {
    color: var(--lime-400);
}

/* ---------- review and done ---------- */

.apply-pdf {
    max-height: 60vh;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--blue-100);
}

.apply-pdf canvas {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: 0.5rem;
    background: #fff;
}

.apply-reference {
    padding: 1.25rem;
    border: 2px dashed var(--blue-700);
    border-radius: 18px;
    background: var(--surface);
    color: var(--navy-900);
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-align: center;
}

/* ---------- buttons ---------- */

.apply-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--surface);
    box-shadow: 0 -8px 24px -12px rgba(5, 42, 79, 0.2);
    z-index: 10;
}

@media (min-width: 576px) {
    .apply-nav {
        position: static;
        padding: 1.5rem 0 0;
        border-top: 0;
        background: none;
        box-shadow: none;
    }

    .apply {
        padding-bottom: 2rem;
    }
}

/* ---------- current loan and history (apply step 1 and Check my loan) ---------- */

.loan-lookup {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--line);
}

.loan-card {
    padding: 1.25rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: var(--surface);
}

.loan-card .apply-facts,
.loan-repay .apply-facts {
    padding: 0;
    border: 0;
    background: none;
}

.loan-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0 0 0.75rem;
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    background: var(--bs-secondary-bg);
    color: var(--slate-600);
    font-size: 0.8125rem;
    font-weight: 700;
}

.loan-badge::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: currentColor;
}

.loan-badge-submitted { background: var(--saffron-100); color: var(--saffron-800); }
.loan-badge-approved { background: var(--blue-100); color: var(--blue-700); }
.loan-badge-active { background: var(--leaf-100); color: var(--leaf-700); }
.loan-badge-repaid { background: var(--leaf-700); color: #fff; }
.loan-badge-overdue { background: var(--red-700); color: #fff; }

.loan-due {
    margin-bottom: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 18px;
    background: var(--navy-900) var(--pattern-adire);
    color: #fff;
}

.loan-due:empty {
    display: none;
}

.loan-due .text-muted {
    color: var(--blue-300) !important;
}

.loan-due-amount {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1.05;
}

.loan-repay {
    margin: 0;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--blue-50);
}

.loan-repay > p {
    margin-top: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 12px;
    background: var(--saffron-100);
    color: #5C3B00;
}

.loan-history {
    margin: 0;
    padding: 0;
    list-style: none;
}

.loan-history li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--line);
}

.loan-history-meta {
    color: var(--slate-600);
    font-size: 0.875rem;
}
