/* ─── Loan Form Plugin ──────────────────────────────────────────────────────── */

/*
 * Brand tokens. These match the Loan Consolidation design system, but the
 * plugin defines them itself rather than reading the theme's, so the form still
 * looks right if it is dropped on a site that does not set them.
 */
:root {
    --lf-navy:        #111d4a;
    --lf-navy-800:    #1a2a66;
    --lf-accent:      #f4502c;
    --lf-accent-dark: #d63e1c;
    --lf-accent-soft: #fdeee8;
    --lf-text:        #333333;
    --lf-text-muted:  #444444;
    --lf-text-faint:  #9a9a9a;
    --lf-border:      #e2e2e2;
    --lf-bg:          #ffffff;
    --lf-bg-soft:     #f7f8fa;
    --lf-error:       #f2322b;
    --lf-error-bg:    #fef2f2;
    --lf-success:     #16a34a;
    --lf-radius:      16px;
    --lf-radius-sm:   10px;
    --lf-shadow:      0 4px 24px rgba(17, 29, 74, .08);
    --lf-shadow-lg:   0 12px 40px rgba(17, 29, 74, .14);
    --lf-font:        "Montserrat", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

.lf-form-wrap {
    font-family: var(--lf-font);
    color: var(--lf-text);
    max-width: 820px;
    margin: 0 auto;
}

/* ── Progress bar ────────────────────────────────────────────────────────── */

/*
 * The numbers sit on the bar rather than under it: one row instead of two, and
 * the dot for each step lands on the point of the bar it represents.
 */
.lf-progress-wrap {
    position: relative;
    margin-bottom: 32px;
}

.lf-progress-bar {
    position: absolute;
    top: 13px;               /* half the dot height, so the bar runs through it */
    left: 0;
    right: 0;
    height: 6px;
    background: #e5e7eb;
    border-radius: 99px;
    overflow: hidden;
}

.lf-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--lf-accent), var(--lf-accent-dark));
    border-radius: 99px;
    transition: width 0.4s ease;
}

.lf-progress-steps {
    position: relative;      /* above the bar */
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 4px;
}

.lf-progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: default;
}

.lf-progress-step-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--lf-border);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--lf-text-muted);
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.lf-progress-step.is-active .lf-progress-step-dot,
.lf-progress-step.is-complete .lf-progress-step-dot {
    background: var(--lf-accent);
    border-color: var(--lf-accent);
    color: #fff;
}

.lf-progress-step-label {
    font-size: 11px;
    color: var(--lf-text-muted);
    text-align: center;
    line-height: 1.2;
    max-width: 84px;
}

/* On a phone the labels do not fit under six dots; the step header names the
   step anyway, so only the numbers remain. */
@media (max-width: 640px) {
    .lf-progress-step-label { display: none; }

    .lf-progress-step-dot {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }

    .lf-progress-bar { top: 10px; }
}

.lf-progress-step.is-active .lf-progress-step-label {
    color: var(--lf-accent);
    font-weight: 600;
}

/* ── Step header ─────────────────────────────────────────────────────────── */

.lf-step-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--lf-border);
}

.lf-step-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--lf-accent-soft);
    color: var(--lf-accent);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.lf-step-titles h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 6px;
    color: var(--lf-text);
}

.lf-step-titles p {
    font-size: 14px;
    color: var(--lf-text-muted);
    margin: 0;
    line-height: 1.5;
}

/* ── Fields container ────────────────────────────────────────────────────── */

.lf-fields {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ── Labels ──────────────────────────────────────────────────────────────── */

.lf-label {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--lf-navy);
    margin-bottom: 10px;
    line-height: 1.4;
}

.lf-required {
    color: var(--lf-accent);
    margin-left: 2px;
}

/* ── Text inputs ─────────────────────────────────────────────────────────── */

.lf-input,
.lf-select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--lf-border);
    border-radius: var(--lf-radius-sm);
    font-size: 15px;
    color: var(--lf-text);
    background: var(--lf-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    appearance: none;
}

.lf-input:focus,
.lf-select:focus {
    border-color: var(--lf-accent);
    box-shadow: 0 0 0 3px rgba(244, 80, 44, .15);
}

.lf-input.lf-uppercase {
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.lf-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23444' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
    cursor: pointer;
}

/* ── Date inputs ─────────────────────────────────────────────────────────── */

.lf-date-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr 1.5fr;
    gap: 10px;
}

/* ── Error messages ──────────────────────────────────────────────────────── */

.lf-error-msg {
    margin-top: 6px;
    font-size: 13px;
    color: var(--lf-error);
    display: flex;
    align-items: center;
    gap: 4px;
}

.lf-error-msg::before {
    content: '⚠';
    font-size: 12px;
}

.lf-input.lf-has-error,
.lf-select.lf-has-error {
    border-color: var(--lf-error);
}

/* ── Radio cards (large image-style, e.g. loan purpose) ─────────────────── */

.lf-radio-cards legend.lf-label { margin-bottom: 14px; }

.lf-radio-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.lf-radio-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px 16px;
    border: 2px solid var(--lf-border);
    border-radius: var(--lf-radius);
    background: var(--lf-bg);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    text-align: center;
}

.lf-radio-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.lf-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--lf-accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.lf-card-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--lf-text);
}

.lf-radio-card:has(input:checked) {
    border-color: var(--lf-accent);
    background: var(--lf-accent-soft);
    box-shadow: 0 0 0 3px rgba(244, 80, 44, .12);
}

.lf-radio-card:hover {
    border-color: var(--lf-accent);
    box-shadow: var(--lf-shadow);
}

/* ── Radio tiles (compact grid, e.g. amounts, years) ────────────────────── */

.lf-radio-tiles legend.lf-label { margin-bottom: 14px; }

.lf-radio-tiles-grid {
    display: grid;
    gap: 10px;
}

.lf-cols-2 .lf-radio-tiles-grid { grid-template-columns: 1fr 1fr; }
.lf-cols-3 .lf-radio-tiles-grid { grid-template-columns: 1fr 1fr 1fr; }
.lf-cols-4 .lf-radio-tiles-grid { grid-template-columns: 1fr 1fr 1fr 1fr; }

.lf-radio-tile {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1.5px solid var(--lf-border);
    border-radius: var(--lf-radius-sm);
    background: var(--lf-bg);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.lf-radio-tile input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.lf-tile-check {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--lf-border);
    flex-shrink: 0;
    position: relative;
    transition: border-color 0.2s;
}

.lf-tile-check::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--lf-accent);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%) scale(0);
    transition: transform 0.15s;
}

.lf-radio-tile:has(input:checked) {
    border-color: var(--lf-accent);
    background: var(--lf-accent-soft);
}

.lf-radio-tile:has(input:checked) .lf-tile-check {
    border-color: var(--lf-accent);
}

.lf-radio-tile:has(input:checked) .lf-tile-check::after {
    transform: translate(-50%,-50%) scale(1);
}

.lf-radio-tile:hover { border-color: var(--lf-accent); }

.lf-tile-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--lf-text);
    line-height: 1.3;
}

@media (max-width: 480px) {
    .lf-cols-3 .lf-radio-tiles-grid,
    .lf-cols-4 .lf-radio-tiles-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Checkboxes ──────────────────────────────────────────────────────────── */

.lf-field-checkbox { margin: 2px 0; }

.lf-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
}

.lf-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.lf-checkbox-box {
    width: 20px;
    height: 20px;
    border: 2px solid var(--lf-border);
    border-radius: 4px;
    background: #fff;
    flex-shrink: 0;
    margin-top: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, background 0.2s;
}

.lf-checkbox-box::after {
    content: '';
    width: 10px;
    height: 6px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translateY(-1px) scale(0);
    transition: transform 0.15s;
}

.lf-checkbox:checked + .lf-checkbox-box {
    background: var(--lf-accent);
    border-color: var(--lf-accent);
}

.lf-checkbox:checked + .lf-checkbox-box::after {
    transform: rotate(-45deg) translateY(-1px) scale(1);
}

.lf-checkbox-text {
    font-size: 14px;
    color: var(--lf-text);
    line-height: 1.5;
}

/* ── Group headings ──────────────────────────────────────────────────────── */

.lf-group-heading {
    font-size: 16px;
    font-weight: 700;
    color: var(--lf-text);
    margin: 8px 0 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--lf-accent-soft);
}

/* ── Navigation buttons ──────────────────────────────────────────────────── */

.lf-step-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 32px;
    gap: 12px;
}

.lf-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: var(--lf-radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
    line-height: 1;
}

.lf-btn:active { transform: scale(0.98); }

.lf-btn-next,
.lf-btn-submit {
    background: var(--lf-accent);
    color: #fff;
    margin-left: auto;
}

.lf-btn-next:hover,
.lf-btn-submit:hover {
    background: var(--lf-accent-dark);
}

.lf-btn-back {
    background: var(--lf-bg-soft);
    color: var(--lf-text-muted);
    border: 1.5px solid var(--lf-border);
}

.lf-btn-back:hover {
    background: var(--lf-border);
    color: var(--lf-text);
}

/* ── Loader ──────────────────────────────────────────────────────────────── */

.lf-loader {
    padding: 48px 24px;
    text-align: center;
}

.lf-loader-inner {
    max-width: 480px;
    margin: 0 auto;
}

.lf-loader h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--lf-text);
    margin: 0 0 8px;
}

.lf-loader > .lf-loader-inner > p:first-of-type {
    font-size: 16px;
    color: var(--lf-text-muted);
    margin: 0 0 32px;
}

.lf-spinner {
    width: 120px;
    height: 120px;
    margin: 0 auto 32px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lf-spinner-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 6px solid var(--lf-accent-soft);
    border-top-color: var(--lf-accent);
    animation: lf-spin 1s linear infinite;
}

.lf-spinner-symbol {
    font-size: 36px;
    font-weight: 700;
    color: var(--lf-accent);
    line-height: 1;
}

@keyframes lf-spin {
    to { transform: rotate(360deg); }
}

.lf-loader-warning {
    font-size: 13px;
    color: var(--lf-accent);
    font-weight: 600;
    margin: 0 0 8px;
}

.lf-loader-time {
    font-size: 13px;
    color: var(--lf-text-muted);
    margin: 0;
}

/* ── Utility ─────────────────────────────────────────────────────────────── */

[hidden] { display: none !important; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 560px) {
    .lf-radio-cards-grid { grid-template-columns: 1fr; }
    .lf-cols-2 .lf-radio-tiles-grid { grid-template-columns: 1fr 1fr; }
    .lf-step-titles h2 { font-size: 18px; }
    .lf-btn { padding: 12px 20px; font-size: 14px; }
}


/* ── Step and choice icons ────────────────────────────────────────────────── */

/*
 * Drawn as CSS masks rather than an icon font or image files, so they take
 * their colour from the element and the plugin stays a single folder with no
 * external requests.
 */
.lf-step-icon::before,
.lf-card-icon::before {
    content: "";
    display: block;
    width: 24px;
    height: 24px;
    background-color: currentColor;
    -webkit-mask: var(--lf-icon) center / contain no-repeat;
    mask: var(--lf-icon) center / contain no-repeat;
}

.lf-card-icon::before { width: 26px; height: 26px; }

.icon-loan::before { --lf-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='2' y='7' width='20' height='14' rx='2'/><path d='M16 3h-8v4h8V3z'/><line x1='12' y1='12' x2='12' y2='16'/><line x1='10' y1='14' x2='14' y2='14'/></svg>"); }
.icon-household::before { --lf-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/><circle cx='12' cy='7' r='4'/></svg>"); }
.icon-address::before { --lf-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/><polyline points='9 22 9 12 15 12 15 22'/></svg>"); }
.icon-employment::before { --lf-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='2' y='7' width='20' height='14' rx='2'/><path d='M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16'/></svg>"); }
.icon-income::before { --lf-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><line x1='12' y1='1' x2='12' y2='23'/><path d='M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6'/></svg>"); }
.icon-personal::before { --lf-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/><circle cx='12' cy='7' r='4'/></svg>"); }
.icon-consolidation::before { --lf-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='4 5 10 5 14 12 20 12'/><polyline points='4 19 10 19 14 12'/><polyline points='17 9 20 12 17 15'/></svg>"); }
.icon-other::before { --lf-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><line x1='12' y1='8' x2='12' y2='16'/><line x1='8' y1='12' x2='16' y2='12'/></svg>"); }

/* ── Choice tiles read as chips, not as a list of radio buttons ──────────── */

.lf-radio-tile input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.lf-radio-tile {
    justify-content: center;
    text-align: center;
}

.lf-tile-check { display: none; }

.lf-radio-tile:has(input:checked) {
    background: var(--lf-accent-soft);
    border-color: var(--lf-accent);
    box-shadow: 0 0 0 3px rgba(244, 80, 44, .12);
}

.lf-radio-tile:has(input:checked) .lf-tile-label {
    color: var(--lf-accent-dark);
    font-weight: 600;
}

.lf-radio-tile:has(input:focus-visible) {
    box-shadow: 0 0 0 4px rgba(244, 80, 44, .25);
}

/* ── Fieldsets ────────────────────────────────────────────────────────────── */

/*
 * Question groups are marked up as fieldsets for screen readers, but a browser's
 * default fieldset border boxes every question in, which the design does not do,
 * and a legend long enough to wrap collides with that border.
 */
.lf-radio-tiles,
.lf-radio-cards {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.lf-radio-tiles > legend.lf-label,
.lf-radio-cards > legend.lf-label {
    display: block;
    width: 100%;
    padding: 0;
}

/* ── Narrow screens ───────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    /* Three and four across is unreadable on a phone. */
    .lf-cols-3 .lf-radio-tiles-grid,
    .lf-cols-4 .lf-radio-tiles-grid { grid-template-columns: 1fr 1fr; }

    .lf-radio-cards-grid { grid-template-columns: 1fr; }

    .lf-step-header { gap: 12px; }
}

/* ── Address lookup ───────────────────────────────────────────────────────── */

/*
 * PlaceAutocompleteElement renders its own input inside a shadow root, so it is
 * styled through the parts Google exposes rather than by selecting into it.
 */
.lf-address-widget {
    display: block;
    width: 100%;
    /* The element follows prefers-color-scheme on its own, so a visitor whose
       OS is in dark mode would get a near-black field in the middle of a light
       form. The rest of the site is light only, so pin it. */
    color-scheme: light;
    background: var(--lf-bg);
    color: var(--lf-text);
    border-radius: var(--lf-radius-sm);
    --gmp-mat-color-primary: var(--lf-accent);
    --gmp-mat-color-on-surface: var(--lf-text);
    --gmp-mat-color-outline: var(--lf-border);
    --gmp-mat-color-surface: var(--lf-bg);
}

/* The element already draws the field's box, so the inner input only needs to
   match the form's type. Bordering it too gives a box inside a box. */
.lf-address-widget::part(input) {
    width: 100%;
    border: 0;
    font-family: var(--lf-font);
    font-size: 15px;
    color: var(--lf-text);
    background: transparent;
}

.lf-address-widget::part(input):focus { outline: none; }
