/**
 * Auto Finance Online Calculator Widget — Redesigned UI
 * Two-panel layout: light left controls, bold right results panel.
 * All colours driven by CSS variables for admin override.
 *
 * Variable reference (set via :root in enqueue_scripts):
 *   --afo-primary        Accent / slider thumb
 *   --afo-left-bg        Left panel background
 *   --afo-left-heading   Left panel heading text
 *   --afo-left-label     Left panel slider label text
 *   --afo-left-sublabel  Left panel sub-label / hint text
 *   --afo-left-muted     Left panel secondary text (price header, range labels)
 *   --afo-slider-track   Unfilled slider track colour
 *   --afo-bubble-bg      Floating bubble background
 *   --afo-bubble-text    Floating bubble text
 *   --afo-arrow-bg       Arrow step-button background
 *   --afo-arrow-text     Arrow step-button icon colour
 *   --afo-right-bg       Right panel background
 *   --afo-right-text     Right panel primary text
 *   --afo-right-muted    Right panel secondary / muted text
 *   --afo-circle-bg      Monthly payment circle background
 *   --afo-btn-bg         Quote button background
 *   --afo-btn-text       Quote button label colour
 *   --afo-rep-bg         Representative example box background
 *   --afo-rep-text       Representative example primary text
 *   --afo-rep-muted      Representative example muted / label text
 *   --afo-rep-border     Representative example row divider colour
 */

/* ─────────────────────────────────────────────
   CONTAINER
───────────────────────────────────────────── */
.afo-calculator-container {
    display: flex;
    gap: 0;
    font-family: inherit;
    margin: 0 auto;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.14);
}

/* ─────────────────────────────────────────────
   LEFT PANEL — CONTROLS
───────────────────────────────────────────── */
.afo-controls {
    background: var(--afo-left-bg, #f0f2f5);
    padding: 2.5rem;
    flex: 1;
}

.afo-controls-heading {
    font-size: 1.9rem;
    font-weight: 600;
    color: var(--afo-left-heading, #111111);
    margin: 0 0 1rem;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.afo-price-header {
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.afo-price-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--afo-left-label, #333333);
    margin: 0 0 0.3rem;
}

.afo-price-header p {
    font-size: 0.88rem;
    color: var(--afo-left-muted, #666666);
    margin: 0;
}

/* ─────────────────────────────────────────────
   SLIDER GROUPS
───────────────────────────────────────────── */
.afo-slider-group {
    margin-bottom: 20px;
}

.afo-slider-label {
    display: block;
    font-weight: 600;
    color: var(--afo-left-label, #222222);
    margin-bottom: 0.2rem;
    font-size: 0.92rem;
    padding-bottom: 1.5rem;
}

.afo-slider-sublabel {
    display: block;
    font-size: 0.78rem;
    color: var(--afo-left-sublabel, #888888);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

/* Arrow + Slider Row */
.afo-slider-track-wrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.afo-arrow-btn.afo-arrow-btn.afo-arrow-btn.afo-arrow-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--afo-arrow-bg, #2a2a2a);
    color: var(--afo-arrow-text, #ffffff);
    font-size: 1.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
    transition: opacity 0.2s, transform 0.1s;
    padding: 0;
    padding-bottom: 2px; /* optical correction for chevron */
}

.afo-arrow-btn.afo-arrow-btn.afo-arrow-btn.afo-arrow-btn:hover {
    opacity: 0.8;
}

.afo-arrow-btn.afo-arrow-btn.afo-arrow-btn.afo-arrow-btn:active {
    transform: scale(0.92);
}

/* Slider inner: floating bubble + track */
.afo-slider-inner {
    flex: 1;
    position: relative;
}

.afo-bubble {
    position: absolute;
    top: -2.5rem;
    transform: translateX(-50%);
    background: var(--afo-bubble-bg, #1a1a1a);
    color: var(--afo-bubble-text, #ffffff);
    padding: 0.2rem 0.6rem;
    border-radius: 5px;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
    transition: left 0.06s ease;
    z-index: 2;
}

.afo-bubble::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--afo-bubble-bg, #1a1a1a);
}

/* Custom range track */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--afo-slider-track, #d0d3d8);
    cursor: pointer;
    outline: none;
    display: block;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--afo-primary, #cc2020);
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--afo-primary, #cc2020);
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.afo-slider-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.76rem;
    color: var(--afo-left-muted, #aaaaaa);
    margin-top: 0.45rem;
    padding: 0 2px;
}

/* ─────────────────────────────────────────────
   RIGHT PANEL — RESULTS
───────────────────────────────────────────── */
.afo-results {
    background: var(--afo-right-bg, #cc2020);
    padding: 2.5rem;
    flex: 1;
    color: var(--afo-right-text, #ffffff);
    display: flex;
    flex-direction: column;
}

.afo-results-heading {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--afo-right-text, #ffffff);
    margin: 0 0 1.5rem;
    letter-spacing: -0.3px;
}

/* Inner card — sits inside the right panel, white bg by default */
.afo-results-card {
    background: var(--afo-card-bg, #ffffff);
    border-radius: 8px;
    padding: 1.25rem 1.25rem 0.25rem;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
}

/* ─────────────────────────────────────────────
   LOADING OVERLAY
───────────────────────────────────────────── */
.afo-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.afo-loading-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

/* Spinner ring */
.afo-spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(0, 0, 0, 0.08);
    border-top-color: var(--afo-primary, #cc2020);
    animation: afo-spin 0.7s linear infinite;
}

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

.afo-loading-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--afo-primary, #cc2020);
    letter-spacing: 0.3px;
}

.afo-results-card .afo-hero-info {
    border-top-color: rgba(0, 0, 0, 0.1);
    color: var(--afo-card-muted, #555555);
}

.afo-results-card .stat-label {
    color: var(--afo-card-muted, #555555) !important;
}

.afo-results-card .stat-value {
    color: var(--afo-card-text, #111111) !important;
}

.afo-results-card .afo-monthly-circle {
    background: var(--afo-card-circle-bg, #1a1a1a);
}

/* Hero block: circle + key stats */
.afo-hero-row {
    display: flex;
    align-items: flex-start;
    gap: 1.4rem;
    margin-bottom: 0.5rem;
}

.afo-monthly-circle {
    width: 118px;
    height: 118px;
    border-radius: 50%;
    background: var(--afo-circle-bg, rgba(0, 0, 0, 0.35));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-align: center;
    padding: 0.5rem;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.afo-monthly-amount {
    font-size: 1.65rem;
    font-weight: 600;
    line-height: 1;
    color: var(--afo-right-text, #ffffff);
    letter-spacing: -1px;
}

.afo-monthly-sublabel {
    font-size: 0.68rem;
    color: var(--afo-right-muted, rgba(255, 255, 255, 0.7));
    margin-top: 0.3rem;
    line-height: 1.2;
}

.afo-hero-stats {
    flex: 1;
}

/* Two-up stat rows */
.afo-hero-stat-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.afo-hero-stat {
    flex: 1;
}

.afo-hero-stat .stat-label {
    display: block;
    font-size: 0.72rem;
    color: var(--afo-right-muted, rgba(255, 255, 255, 0.75));
    margin-bottom: 0.1rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.afo-hero-stat .stat-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--afo-right-text, #ffffff);
    letter-spacing: -0.5px;
}

.afo-hero-info {
    font-size: 0.82rem;
    color: var(--afo-right-muted, rgba(255, 255, 255, 0.85));
    line-height: 1.55;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 0.75rem;
    margin-top: 0.25rem;
}

/* Quote button */
.afo-btn.afo-btn.afo-btn.afo-btn.afo-btn.afo-btn {
    background: var(--afo-btn-bg);
    color: var(--afo-btn-text, #cc2020);
    border: none;
    padding: 0.9rem 2rem;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    margin: 1.1rem 0 0.9rem;
    transition: opacity 0.2s, transform 0.1s;
    letter-spacing: 0.2px;
}

.afo-btn:hover {
    opacity: 0.93;
    transform: translateY(-1px);
}

.afo-btn:active {
    transform: translateY(0);
}

/* ─────────────────────────────────────────────
   REPRESENTATIVE EXAMPLE
───────────────────────────────────────────── */
.afo-rep-example {
    background: transparent;
    padding: 0 0 0.75rem;
    margin-top: auto;
}

.afo-rep-heading {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--afo-rep-text, #ffffff);
    margin-bottom: 0.7rem;
    letter-spacing: 0;
}

.afo-rep-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 1.25rem;
    border-top: 1px solid var(--afo-rep-border, rgba(255, 255, 255, 0.12));

}

.afo-rep-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.74rem;
    border-bottom: 1px solid var(--afo-rep-border, rgba(255, 255, 255, 0.12));
    padding: 0.3rem 0;
}

.afo-rep-row:last-child {
    border-bottom: none;
}

.afo-rep-label {
    color: var(--afo-rep-muted, rgba(255, 255, 255, 0.75));
    flex-shrink: 0;
}

.afo-rep-value {
    font-weight: 600;
    color: var(--afo-rep-text, #ffffff);
    text-align: right;
}

.afo-rep-footer {
    font-size: 0.69rem;
    color: var(--afo-rep-muted, rgba(255, 255, 255, 0.6));
    margin: 0.65rem 0 0;
    line-height: 1.45;
}

/* ─────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────── */
@media (min-width: 1025px) {
    .afo-controls,
    .afo-results {
        flex: 0 0 50%;
        width: 50%;
    }
}

@media (max-width: 1024px) {
    .afo-calculator-container {
        flex-direction: column;
        border-radius: 8px;
    }
}

@media (max-width: 600px) {

    .afo-controls,
    .afo-results {
        padding: 1.5rem;
    }

    .afo-controls-heading {
        font-size: 1.5rem;
    }

    .afo-hero-row {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .afo-hero-stat-row {
        justify-content: center;
    }

    .afo-hero-info {
        text-align: left;
    }

    .afo-rep-grid {
        grid-template-columns: 1fr;
    }
}

.afo-main-results {
    position: relative;
}