/**
 * Expo Registration Form - Unified Styles
 *
 * Supports two modes: kiosk (fullscreen) and site (embedded in page).
 * Brand colors: #22424f (dark blue), #f8f9fa (light bg)
 */

/* ── Reset & base ── */
html.expo-kiosk,
html.expo-kiosk body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100%;
    background: #f8f9fa;
}

/* Hide WP admin bar if logged in */
html.expo-kiosk #wpadminbar {
    display: none !important;
}
html.expo-kiosk,
html.expo-kiosk body {
    margin-top: 0 !important;
}

/* ── App container ── */
.expo-app {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    color: #22424f;
    overflow: hidden;
}

/* ── Top controls bar ── */
.expo-top-controls {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Offline queue toggle ── */
.expo-offline-toggle {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.expo-offline-toggle.has-pending {
    background: #f59e0b;
}

.expo-offline-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #22424f;
}

.expo-offline-toggle.has-pending .expo-offline-icon {
    color: #fff;
}

.expo-pending-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    border-radius: 9px;
    background: #22424f;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    padding: 0 4px;
    display: none;
}

.expo-offline-toggle.has-pending .expo-pending-count {
    display: block;
}

/* ── Offline popover ── */
.expo-offline-popover {
    position: absolute;
    top: 48px;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    color: #22424f;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.expo-offline-popover[hidden] {
    display: none;
}

/* ── Language toggle ── */
.expo-lang-toggle {
    display: flex;
    gap: 0;
    border-radius: 24px;
    overflow: hidden;
    border: 2px solid #22424f;
}

.expo-lang-btn {
    padding: 8px 18px;
    border: none;
    background: #fff;
    color: #22424f;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.expo-lang-btn.active {
    background: #22424f;
    color: #fff;
}

/* ── Screen container (shared) ── */
.expo-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.expo-screen[hidden] {
    display: none;
}

/* ── Header ── */
.expo-header {
    flex-shrink: 0;
}

.expo-banner {
    width: 100%;
    height: auto;
    display: block;
}

.expo-logo-row {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 24px 10px;
}

.expo-logo {
    height: 56px;
    width: auto;
}

/* When no banner, the form is the first child of the screen and the title row
   needs to clear the absolutely-positioned top controls (~40px at top:16px). */
#expo-screen-form > #expo-form:first-child .expo-title-row {
    padding-top: 64px;
}

.expo-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px 14px;
    gap: 24px;
}

.expo-title-row h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    color: #22424f;
    white-space: nowrap;
}

.expo-salesman-field {
    min-width: 220px;
    max-width: 300px;
    margin-bottom: 0 !important;
}

/* ── AFM inline (inside grid) ── */
.expo-afm-inline {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
    grid-column: 1 / -1;
}

.expo-form-grid .expo-checkbox-row {
    grid-column: 1 / -1;
}

.expo-afm-inline .expo-afm-field {
    flex: 1;
    margin-bottom: 0;
}

.expo-afm-lookup-btn {
    height: 54px;
    padding: 0 28px;
    background: #22424f;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.expo-afm-lookup-btn:hover:not(:disabled) {
    background: #1a3440;
}

.expo-afm-lookup-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.expo-afm-status {
    align-self: center;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 4px;
}

.expo-afm-status[hidden] {
    display: none;
}

.expo-afm-status--success {
    color: #166534;
    background: #dcfce7;
}

.expo-afm-status--error {
    color: #991b1b;
    background: #fef2f2;
}

/* ── Form layout ── */
#expo-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 24px 24px;
}

.expo-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 28px;
}

/* ── Fieldset / section ── */
.expo-fieldset {
    border: none;
    margin: 0 0 10px;
    padding: 0;
}

.expo-section-title {
    display: block;
    width: 100%;
    background: #22424f;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
}

/* ── Floating-label fields ── */
.expo-field {
    position: relative;
    margin-bottom: 14px;
}

.expo-field input {
    width: 100%;
    height: 54px;
    padding: 22px 12px 6px;
    border: 1.5px solid #cfd4da;
    border-radius: 6px;
    font-size: 16px;
    background: #fff;
    color: #22424f;
    transition: border-color 0.2s, background-color 0.5s;
    box-sizing: border-box;
    -webkit-appearance: none;
}

.expo-field input:focus {
    outline: none;
    border-color: #22424f;
}

.expo-field label {
    position: absolute;
    left: 12px;
    top: 17px;
    font-size: 15px;
    color: #89919d;
    pointer-events: none;
    transition: all 0.2s ease;
}

.expo-field input:focus + label,
.expo-field input:not(:placeholder-shown) + label {
    top: 4px;
    font-size: 11px;
    color: #22424f;
    font-weight: 600;
}

/* Required field asterisk */
.expo-field input[required] + label::after {
    content: ' *';
    color: #dc2626;
}

/* Auto-filled field highlight */
.expo-field--autofilled input {
    border-color: #16a34a !important;
    background-color: #f0fdf4 !important;
}

/* Validation error state */
.expo-field.has-error input {
    border-color: #dc2626;
}

.expo-field.has-error label {
    color: #dc2626;
}

/* ── Checkbox ── */
.expo-checkbox-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    margin-top: 6px;
}

.expo-checkbox-row input[type="checkbox"] {
    width: 32px;
    height: 32px;
    accent-color: #22424f;
    flex-shrink: 0;
    cursor: pointer;
}

.expo-checkbox-row label {
    font-size: 15px;
    cursor: pointer;
    user-select: none;
}

/* ── Form error banner ── */
.expo-form-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 6px;
    margin: 8px 0;
    font-size: 15px;
    text-align: center;
}

/* ── Submit row (sticky) ── */
.expo-submit-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 14px 0 50px 0;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    background: #f8f9fa;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
    z-index: 10;
}

/* ── Reset button ── */
.expo-reset-btn {
    height: 56px;
    padding: 0 32px;
    background: transparent;
    color: #89919d;
    border: 1.5px solid #cfd4da;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.expo-reset-btn:hover {
    border-color: #89919d;
    color: #22424f;
}

.expo-submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 280px;
    height: 56px;
    padding: 0 40px;
    background: #22424f;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

.expo-submit-btn:hover {
    background: #1a3440;
}

.expo-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── Success screen ── */
.expo-success-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}

.expo-success-icon {
    width: 100px;
    height: 100px;
    line-height: 100px;
    border-radius: 50%;
    background: #16a34a;
    color: #fff;
    font-size: 56px;
    margin-bottom: 24px;
}

.expo-success-content h2 {
    font-size: 32px;
    margin: 0 0 12px;
    color: #22424f;
}

.expo-success-content p {
    font-size: 18px;
    color: #555;
    max-width: 480px;
    margin: 0 0 32px;
    line-height: 1.5;
}

.expo-new-btn {
    min-width: 260px;
    height: 56px;
    padding: 0 36px;
    background: #22424f;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.expo-new-btn:hover {
    background: #1a3440;
}

/* ── Single-column breakpoint (phone / narrow) ── */
@media (max-width: 700px) {
    .expo-form-grid {
        grid-template-columns: 1fr;
    }

    #expo-form {
        padding: 0 16px 16px;
    }

    .expo-title-row h1 {
        font-size: 20px;
    }

    .expo-title-row {
        flex-wrap: wrap;
    }

    .expo-salesman-field {
        min-width: 100%;
    }

    .expo-afm-inline {
        flex-wrap: wrap;
    }

    .expo-afm-lookup-btn {
        width: 100%;
    }
}

/* ── Loading spinner ── */
@keyframes expo-spin {
    to { transform: rotate(360deg); }
}

.expo-btn-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: expo-spin 0.6s linear infinite;
    flex-shrink: 0;
}

.expo-submit-btn.loading .expo-btn-spinner,
.expo-afm-lookup-btn.loading .expo-btn-spinner {
    display: inline-block;
}

/* ── Tall tablet / landscape tweaks ── */
@media (min-height: 900px) {
    .expo-field {
        margin-bottom: 18px;
    }
}

/* ================================================================
 *  KIOSK MODE: hide site header, footer, admin bar
 * ================================================================ */
html.expo-kiosk .site-header,
html.expo-kiosk .footer-newsletter,
html.expo-kiosk .footer-main,
html.expo-kiosk .wp-block-template-part {
    display: none !important;
}

/* ================================================================
 *  SITE MODE: embedded in page (not fullscreen)
 * ================================================================ */
.expo-app--site {
    width: 100%;
    height: auto;
    max-width: 900px;
    margin: 0 auto;
    overflow: visible;
}

.expo-app--site .expo-screen {
    overflow: visible;
}

.expo-app--site .expo-submit-row {
    position: static;
    box-shadow: none;
}

/* ================================================================
 *  MODE TOGGLE BUTTON (admin only)
 * ================================================================ */
.expo-mode-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #22424f;
    background: #fff;
    color: #22424f;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    padding: 0;
}

.expo-mode-toggle:hover {
    background: #22424f;
    color: #fff;
}
