/* ═══════════════════════════════════════ */
/* R7: Toast Notifications                 */
/* ═══════════════════════════════════════ */
#toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-width: 400px;
    width: calc(100% - var(--space-8));
}
.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-elevated);
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font: var(--text-body-sm);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.toast--visible { transform: translateX(0); }
.toast--success { background: #dcfce7; border: 1px solid #86efac; color: #166534; }
.toast--error { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
.toast--warning { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; }
.toast--info { background: #dbeafe; border: 1px solid #93c5fd; color: #1e40af; }
.toast__icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
}
.toast--success .toast__icon { background: #16a34a; color: #fff; }
.toast--error .toast__icon { background: #dc2626; color: #fff; }
.toast--warning .toast__icon { background: #d97706; color: #fff; }
.toast--info .toast__icon { background: #2563eb; color: #fff; }
.toast__msg { flex: 1; }
.toast__close {
    background: none; border: none; cursor: pointer;
    font-size: 1.25rem; color: inherit; opacity: 0.5;
    padding: 0 var(--space-1); line-height: 1;
}
.toast__close:hover { opacity: 1; }

/* ═══════════════════════════════════════ */
/* R1: Step Progress Bar                   */
/* ═══════════════════════════════════════ */
.step-counter {
    text-align: center;
    font: var(--text-caption);
    color: var(--interactive-accent);
    font-weight: 600;
    margin-bottom: var(--space-2);
    letter-spacing: 0.05em;
}
.step-progress-bar {
    height: 4px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: var(--space-4);
}
.step-progress-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--interactive-accent), var(--interactive-cta));
    border-radius: 2px;
    transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    min-width: 2%;
}

/* ═══════════════════════════════════════ */
/* R2: Field Validation States             */
/* ═══════════════════════════════════════ */
.glass-input.field--error,
.glass-select.field--error {
    border-color: var(--interactive-danger) !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1) !important;
}
.glass-input.field--valid,
.glass-select.field--valid {
    border-color: var(--interactive-success) !important;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.08) !important;
}
.form-error {
    font: var(--text-caption);
    color: var(--interactive-danger);
    margin-top: var(--space-1);
    min-height: 0;
    transition: all 0.2s ease;
}
.form-error:not(:empty) {
    min-height: 1.2em;
    animation: shake 0.3s ease;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

/* ═══════════════════════════════════════ */
/* R3: Submit Button Spinner               */
/* ═══════════════════════════════════════ */
.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: -2px;
    margin-right: var(--space-2);
}
.btn--loading {
    position: relative;
    pointer-events: none;
    opacity: 0.85;
}

/* ═══════════════════════════════════════ */
/* R5: Enhanced Status Badges              */
/* ═══════════════════════════════════════ */
.status-badge[title] {
    cursor: help;
}

/* ═══════════════════════════════════════ */
/* R6: Payment Flow Guidance               */
/* ═══════════════════════════════════════ */
.payment-steps {
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin-bottom: var(--space-6);
    padding: var(--space-6);
    background: rgba(220, 38, 38, 0.04);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(220, 38, 38, 0.12);
    overflow-x: auto;
}
.payment-step {
    flex: 1;
    min-width: 100px;
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
}
.payment-step__icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--interactive-accent);
    transition: all var(--transition-normal);
    margin-bottom: var(--space-1);
}
.payment-step__number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--interactive-accent);
    color: #fff;
    font-weight: 700;
    font-size: 0.6875rem;
}
.payment-step__text {
    font: var(--text-caption);
    color: var(--text-secondary);
    line-height: 1.4;
    max-width: 120px;
}
/* Connector between steps */
.payment-step__connector {
    display: flex;
    align-items: center;
    padding-top: 22px;
    flex: 0 0 auto;
    width: 32px;
}
.payment-step__connector-line {
    width: 100%;
    height: 2px;
    background: rgba(220, 38, 38, 0.15);
    border-radius: 1px;
}

/* ═══════════════════════════════════════ */
/* R9: Capacity Urgency                    */
/* ═══════════════════════════════════════ */
.landing-distance-card__bar-fill--low { background: var(--interactive-success); }
.landing-distance-card__bar-fill--medium { background: var(--interactive-accent); }
.landing-distance-card__bar-fill--high { background: var(--interactive-warning); }
.landing-distance-card__bar-fill--critical { background: var(--interactive-danger); }
.slots-urgent {
    color: var(--interactive-danger);
    font-weight: 700;
    animation: pulse-text 2s ease-in-out infinite;
}
@keyframes pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ═══════════════════════════════════════ */
/* R13: Accessibility                      */
/* ═══════════════════════════════════════ */
input[type="checkbox"], input[type="radio"] { min-width: 20px; min-height: 20px; }
.consent-check { min-height: 44px; min-width: 44px; padding: var(--space-2) 0; }
.consent-check input[type="checkbox"] { width: 22px; height: 22px; }
.locale-toggle { min-height: 44px; min-width: 44px; }
.step-indicator__item { min-height: 44px; min-width: 44px; }
*:focus-visible { outline: 2px solid var(--interactive-accent); outline-offset: 2px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
}
.glass-btn:focus-visible { outline: 2px solid var(--interactive-accent); outline-offset: 2px; box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12); }
.distance-option:focus-within { outline: 2px solid var(--interactive-accent); outline-offset: 2px; box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12); }
.consent-check:focus-within { outline: 2px solid var(--interactive-accent); outline-offset: 2px; box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12); }
.skip-link {
    position: absolute; top: -100px; left: 16px; z-index: 10000;
    background: var(--interactive-primary); color: #fff;
    padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
    text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 16px; }
/* Visually hidden but accessible to screen readers */
.visually-hidden, .sr-only {
    position: absolute;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    width: 1px;
    height: 1px;
    overflow: hidden;
    white-space: nowrap;
}

/* ═══════════════════════════════════════ */
/* Enhanced form field labels              */
/* ═══════════════════════════════════════ */
.glass-label {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}
.field-hint {
    display: block;
    font: var(--text-caption);
    color: var(--text-tertiary);
    margin-top: 2px;
    font-weight: 400;
}

/* ═══════════════════════════════════════ */
/* Mobile improvements                     */
/* ═══════════════════════════════════════ */
@media (max-width: 639px) {
    #toast-container {
        top: auto;
        bottom: var(--space-4);
        right: var(--space-2);
        left: var(--space-2);
        max-width: none;
        width: auto;
    }
    .payment-steps {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: var(--space-4);
    }
    .payment-step {
        flex-direction: row;
        text-align: left;
        align-items: center;
        padding: var(--space-2) 0;
        min-width: auto;
    }
    .payment-step__icon-wrap {
        width: 36px;
        height: 36px;
        margin-bottom: 0;
    }
    .payment-step__text {
        max-width: none;
        flex: 1;
    }
    .payment-step__connector {
        padding-top: 0;
        width: auto;
        height: 16px;
        padding-left: 17px;
        align-items: stretch;
    }
    .payment-step__connector-line {
        width: 2px;
        height: 100%;
    }
}

/* ═══════════════════════════════════════ */
/* Mobile Web App Enhancements             */
/* ═══════════════════════════════════════ */

/* Prevent text size adjustment on rotate */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Safe-area insets for notched phones */
.site-header {
    padding-top: max(var(--space-3), env(safe-area-inset-top));
    padding-left: max(var(--space-4), env(safe-area-inset-left));
    padding-right: max(var(--space-4), env(safe-area-inset-right));
}

/* Minimum 44px touch targets on all interactive elements */
@media (max-width: 639px) {
    .glass-btn,
    .glass-input,
    .glass-select,
    select,
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="date"],
    input[type="password"],
    input[type="number"],
    textarea {
        min-height: 44px;
    }

    /* Larger radio/checkbox touch area */
    input[type="radio"],
    input[type="checkbox"] {
        width: 20px;
        height: 20px;
        cursor: pointer;
    }

    /* Distance option cards: bigger on mobile */
    .distance-option {
        padding: var(--space-4) !important;
        min-height: 56px;
    }

    /* Form step padding */
    .registration-step {
        padding: var(--space-4) !important;
    }

    /* Event card: full-width tap target */
    .event-card {
        cursor: pointer;
    }
    .event-card a {
        display: block;
    }

    /* Step indicator: compact on mobile */
    .step-indicator {
        gap: var(--space-1) !important;
        padding: var(--space-2) !important;
    }
    .step-indicator__step {
        width: 28px !important;
        height: 28px !important;
        font-size: 0.75rem !important;
    }
    .step-indicator__label {
        display: none !important;
    }

    /* Sticky CTA button for registration form */
    .form-sticky-cta {
        position: sticky;
        bottom: calc(64px + env(safe-area-inset-bottom, 0px));
        z-index: 10;
        padding: var(--space-3) var(--space-4);
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border-top: 1px solid var(--glass-border);
        margin: 0 calc(-1 * var(--space-4));
    }
    .form-sticky-cta .glass-btn--full {
        width: 100%;
    }

    /* Payment form: larger slip upload area */
    #file-upload-area {
        min-height: 160px !important;
        padding: var(--space-6) var(--space-4) !important;
    }

    /* Lookup form: bigger inputs */
    #lookup-idNumber {
        font-size: 1rem;
        letter-spacing: 0.05em;
    }

    /* My registrations: card-style on mobile */
    .registration-row {
        display: flex;
        flex-direction: column;
        gap: var(--space-1);
        padding: var(--space-4);
        background: var(--bg-card);
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-md);
        margin-bottom: var(--space-3);
    }

    /* Toast: full-width on mobile */
    #toast-container {
        top: auto;
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        right: var(--space-3);
        left: var(--space-3);
        max-width: none;
        width: auto;
    }

    /* Glass card: reduce padding on mobile */
    .glass-card {
        padding: var(--space-5) !important;
    }

    /* Success page: better mobile spacing */
    .success-reg-number {
        font-size: 1.5rem !important;
        word-break: break-all;
    }
}

/* Pull-to-refresh visual hint */
@media (max-width: 639px) {
    body::before {
        content: '';
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 3px;
        background: linear-gradient(90deg, var(--interactive-accent), #0cce6b);
        transform: scaleX(0);
        transform-origin: left;
        transition: transform 0.3s ease;
        z-index: 1000;
    }
    body.page-loading::before {
        transform: scaleX(1);
        animation: loading-bar 1.5s ease-in-out infinite;
    }
    @keyframes loading-bar {
        0% { transform: scaleX(0); transform-origin: left; }
        50% { transform: scaleX(1); transform-origin: left; }
        51% { transform: scaleX(1); transform-origin: right; }
        100% { transform: scaleX(0); transform-origin: right; }
    }
}

/* Standalone PWA mode adjustments */
@media (display-mode: standalone) {
    .site-header {
        padding-top: max(var(--space-3), env(safe-area-inset-top, 20px));
    }
    /* Hide browser-specific UI hints */
    .browser-only { display: none !important; }
}
