/**
 * AttenderLever — Registration Form Styles
 *
 * Scoped to .al-registration-form to avoid leaking into other contexts.
 * Inherits colour tokens from event-single.css (--event-*) with sensible
 * fallbacks so the form also works inside shortcode embeds.
 *
 * @package AttenderLever
 */

/* ========================================
   Container
   ======================================== */
.al-registration-form {
    --al-primary:       var(--event-primary, #2563eb);
    --al-primary-hover: var(--event-primary-hover, #1d4ed8);
    --al-primary-light: var(--event-primary-light, #2563eb1a);
    --al-primary-shadow: var(--event-primary-shadow, #2563eb40);
    --al-text:          var(--event-text, #1c1c1c);
    --al-text-muted:    var(--event-text-muted, #666);
    --al-bg:            var(--event-bg, #fff);
    --al-bg-subtle:     var(--event-bg-subtle, #fafafa);
    --al-border:        var(--event-border, #e0e0e0);
    --al-radius:        var(--event-radius, 8px);
    --al-error:         #d63638;
    --al-error-light:   #ffebe9;
    --al-success:       #4CAF50;
}

/* ========================================
   Capacity Indicator
   ======================================== */
.al-capacity-indicator {
    font-size: 13px;
    font-weight: 600;
    color: var(--al-text-muted);
    padding: 8px 14px;
    background: var(--al-bg-subtle);
    border-radius: var(--al-radius);
    margin-bottom: 20px;
    text-align: center;
}

.al-capacity-indicator--low {
    color: #b45309;
    background: #fffbeb;
}

.al-capacity-indicator--sold-out {
    color: var(--al-error);
    background: var(--al-error-light);
}

.al-capacity-indicator--waitlist {
    color: #1d4ed8;
    background: var(--al-primary-light);
}

/* ========================================
   Top-Level Messages
   ======================================== */
.al-form-message--error {
    background: var(--al-error-light);
    border-left: 4px solid var(--al-error);
    color: var(--al-error);
    padding: 12px 16px;
    border-radius: var(--al-radius);
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}

.al-form-closed {
    text-align: center;
    padding: 24px;
    background: var(--al-bg-subtle);
    border-radius: var(--al-radius);
    color: var(--al-text-muted);
    font-size: 15px;
}

/* ========================================
   Form Layout
   ======================================== */
.al-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Side-by-side row (First / Last name) */
.al-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ========================================
   Form Groups
   ======================================== */
.al-form-group {
    display: flex;
    flex-direction: column;
}

/* ========================================
   Labels
   ======================================== */
.al-form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
    color: var(--al-text);
    line-height: 1.3;
}

.al-required {
    color: var(--al-error);
    font-weight: 600;
}

/* ========================================
   Inputs, Selects, Textareas
   ======================================== */
.al-form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--al-border);
    border-radius: var(--al-radius);
    font-size: 15px;
    font-family: inherit;
    color: var(--al-text);
    background: var(--al-bg);
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.al-form-input::placeholder {
    color: var(--al-text-muted);
    opacity: 0.6;
}

.al-form-input:focus {
    outline: none;
    border-color: var(--al-primary);
    box-shadow: 0 0 0 3px var(--al-primary-light);
}

/* Error state */
.al-form-input--error {
    border-color: var(--al-error);
}

.al-form-input--error:focus {
    border-color: var(--al-error);
    box-shadow: 0 0 0 3px rgba(214, 54, 56, 0.12);
}

/* Select arrow */
.al-form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

/* Textarea */
.al-form-textarea {
    resize: vertical;
    min-height: 60px;
    line-height: 1.5;
}

/* ========================================
   Field Errors
   ======================================== */
.al-field-error {
    display: none;
    font-size: 13px;
    color: var(--al-error);
    margin-top: 4px;
    line-height: 1.4;
}

/* ========================================
   Ticket Type Selection
   ======================================== */
.al-form-group--ticket-types {
    margin-bottom: 4px;
}

.al-form-group--ticket-types .al-form-label {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 10px;
}

.al-ticket-types {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.al-ticket-type {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 2px solid var(--al-border);
    border-radius: var(--al-radius);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.al-ticket-type:hover {
    border-color: var(--al-primary);
    background: var(--al-primary-light);
}

.al-ticket-type:has(input:checked) {
    border-color: var(--al-primary);
    background: var(--al-primary-light);
}

.al-ticket-type input[type="radio"] {
    margin-top: 3px;
    flex-shrink: 0;
    accent-color: var(--al-primary);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.al-ticket-type__content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.al-ticket-type__name {
    font-weight: 600;
    font-size: 15px;
    color: var(--al-text);
}

.al-ticket-type__desc {
    font-size: 13px;
    color: var(--al-text-muted);
    line-height: 1.4;
}

.al-ticket-type__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin-top: 4px;
    font-size: 13px;
}

.al-ticket-type__price {
    font-weight: 600;
    color: var(--al-text);
}

.al-ticket-type__deadline {
    color: var(--al-text-muted);
}

.al-ticket-type__availability {
    color: var(--al-text-muted);
}

/* Sold out state */
.al-ticket-type--sold-out {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

/* ========================================
   Consent Checkbox
   ======================================== */
.al-form-group--consent {
    margin-top: 4px;
}

.al-form-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.5;
    color: var(--al-text);
}

.al-form-checkbox input[type="checkbox"] {
    margin-top: 2px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--al-primary);
}

.al-form-checkbox__text {
    flex: 1;
}

/* ========================================
   Submit Button
   ======================================== */
.al-form-group--submit {
    margin-top: 4px;
}

.al-form-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px 24px;
    background: var(--al-primary);
    color: #fff;
    border: none;
    border-radius: var(--al-radius);
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 2px 8px var(--al-primary-shadow);
    transition: background 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.al-form-submit:hover:not(:disabled) {
    background: var(--al-primary-hover);
}

.al-form-submit:focus-visible {
    outline: 2px solid var(--al-primary);
    outline-offset: 2px;
}

.al-form-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Protect primary registration action from theme/Elementor button overrides */
.al-registration-form .al-form-submit,
.event-single .al-registration-form .al-form-submit,
.event-single .al-registration-form button.al-form-submit {
    background: var(--al-primary) !important;
    border: 1px solid var(--al-primary) !important;
    color: #fff !important;
}

.al-registration-form .al-form-submit:hover:not(:disabled),
.event-single .al-registration-form .al-form-submit:hover:not(:disabled),
.event-single .al-registration-form button.al-form-submit:hover:not(:disabled),
.event-single .al-registration-form button.al-form-submit:focus:not(:disabled) {
    background: var(--al-primary-hover) !important;
    border-color: var(--al-primary-hover) !important;
    color: #fff !important;
}

/* Loading spinner */
.al-form-submit__loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.al-spinner {
    animation: al-spin 0.8s linear infinite;
}

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

/* ========================================
   Success State
   ======================================== */
.al-form-success {
    text-align: center;
    padding: 40px 24px;
}

.al-form-success__icon {
    margin-bottom: 16px;
}

.al-form-success__title {
    font-size: 22px;
    font-weight: 700;
    color: var(--al-success);
    margin: 0 0 8px;
}

.al-form-success__message {
    font-size: 15px;
    color: var(--al-text);
    margin: 0 0 12px;
    line-height: 1.5;
}

.al-form-success__confirmation {
    font-size: 14px;
    color: var(--al-text-muted);
    margin: 0;
    font-weight: 500;
}

/* ========================================
   Payment Section (Paid Tickets)
   ======================================== */
.al-form-group--payment {
    border: 1px solid var(--al-border);
    border-radius: var(--al-radius);
    padding: 20px;
    background: var(--al-bg-subtle);
}

.al-payment-summary {
    font-size: 16px;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--al-bg);
    border-radius: var(--al-radius);
    border: 1px solid var(--al-border);
    text-align: center;
}

.al-payment-summary strong {
    color: var(--al-text);
}

.al-contribution-warning {
    background: #fffbeb;
    border: 1px solid #f59e0b;
    border-left-width: 4px;
    border-radius: var(--al-radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.5;
    color: #92400e;
}

.al-contribution-warning strong {
    color: #78350f;
}

.al-contribution-warning ul {
    margin: 4px 0 0 16px;
    padding: 0;
}

.al-contribution-warning li {
    margin-bottom: 2px;
}

/* Blocked state: full-width error box when purchase is not allowed */
.al-contribution-warning--blocked {
    background: var(--al-error-light);
    border-color: var(--al-error);
    color: #7f1d1d;
}

.al-contribution-warning--blocked strong {
    color: #7f1d1d;
}

/* Stripe Card Element container — matches input styling */
#al-card-element {
    padding: 12px;
    border: 1px solid var(--al-border);
    border-radius: var(--al-radius);
    background: var(--al-bg);
    min-height: 44px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#al-card-element:focus-within,
#al-card-element.StripeElement--focus {
    border-color: var(--al-primary);
    box-shadow: 0 0 0 3px var(--al-primary-light);
}

#al-card-element.StripeElement--invalid {
    border-color: var(--al-error);
}

#al-card-errors {
    display: none;
    font-size: 13px;
    color: var(--al-error);
    margin-top: 4px;
    line-height: 1.4;
}

/* ========================================
   Donation Prompt — Limit Awareness
   ======================================== */

/* Remaining limit info line shown below the main subtitle */
.al-donation-prompt__limit-info {
    font-size: 13px;
    color: var(--al-text-muted);
    margin: -4px 0 12px;
    line-height: 1.4;
}

/* Full-width info block shown when the annual limit has been reached */
.al-donation-prompt__limit-reached {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--al-radius);
    padding: 16px 20px;
    text-align: center;
    font-size: 15px;
    color: #1e40af;
    line-height: 1.5;
}

.al-donation-prompt__limit-reached p {
    margin: 0;
}

/* ========================================
   Responsive: Mobile (≤480px)
   ======================================== */
@media (max-width: 480px) {
    .al-form-row {
        grid-template-columns: 1fr;
    }

    .al-form-submit {
        padding: 12px 20px;
        font-size: 15px;
    }

    .al-form-success {
        padding: 32px 16px;
    }

    .al-form-success__title {
        font-size: 20px;
    }

    .al-ticket-type {
        padding: 12px 14px;
    }

    /* Larger touch targets on mobile */
    .al-form-checkbox input[type="checkbox"],
    .al-ticket-type input[type="radio"] {
        width: 22px;
        height: 22px;
    }
}
