/**
 * Leaf Modal Styles
 *
 * Scoped to .leaf-modal namespace to avoid conflicts
 * Uses existing CSS variables from the design system
 *
 * @version 1.0.0
 */

/* ===========================================
   CSS CUSTOM PROPERTIES (Scoped to modal)
   =========================================== */
.leaf-modal {
    --leaf-modal-header-bg: var(--brand-red, #E25465);
    --leaf-modal-header-color: var(--site-default, #fff);
    --leaf-modal-subheader-bg: var(--golden-yellow, #F2B21A);
    --leaf-modal-subheader-color: var(--dark-gray, #333);
    --leaf-modal-overlay: var(--modal-overlay, rgba(0, 0, 0, 0.6));
    --leaf-modal-bg: var(--site-default, #fff);
    --leaf-modal-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --leaf-modal-radius: var(--modal-border-radius, 1rem);
    --leaf-modal-max-width: 600px;
    --leaf-modal-transition: var(--transition-fast, 0.2s ease);
}

/* ===========================================
   MODAL CONTAINER (Fixed overlay)
   =========================================== */
.leaf-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;

    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.leaf-modal[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
}

/* ===========================================
   OVERLAY (Dark backdrop)
   =========================================== */
.leaf-modal__overlay {
    position: absolute;
    inset: 0;
    background: var(--leaf-modal-overlay);
    cursor: pointer;
}

/* ===========================================
   CONTAINER (Content wrapper)
   =========================================== */
.leaf-modal__container {
    position: relative;
    background: var(--leaf-modal-bg);
    border-radius: var(--leaf-modal-radius);
    box-shadow: var(--leaf-modal-shadow);
    width: 100%;
    min-width: 360px;
    max-width: 400px;
    aspect-ratio: 9 / 16;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;

    /* Entry animation */
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s ease;
}

.leaf-modal[aria-hidden="false"] .leaf-modal__container {
    transform: scale(1) translateY(0);
}

/* ===========================================
   HEADER (Red background)
   =========================================== */
.leaf-modal__header {
    background: var(--leaf-modal-header-bg);
    color: var(--leaf-modal-header-color);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.leaf-modal__title {
    font-size: 1.25rem;
    font-weight: 400;
    font-style: normal;
    margin: 0;
    line-height: 1.3;
}

/* ===========================================
   CLOSE BUTTON
   =========================================== */
.leaf-modal__close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: inherit;
    opacity: 0.8;
    transition: opacity var(--leaf-modal-transition), transform var(--leaf-modal-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    margin: -0.25rem -0.25rem -0.25rem 0.5rem;
}

.leaf-modal__close:hover,
.leaf-modal__close:focus {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.leaf-modal__close:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.leaf-modal__close svg {
    width: 24px;
    height: 24px;
}

/* Text-based close button fallback */
.leaf-modal__close:not(:has(svg)) {
    font-size: 1.75rem;
    line-height: 1;
    font-weight: 300;
}

/* ===========================================
   SUB-HEADER (Yellow background)
   =========================================== */
.leaf-modal__subheader {
    background: var(--leaf-modal-subheader-bg);
    color: var(--leaf-modal-subheader-color);
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    flex-shrink: 0;
}

/* ===========================================
   BODY (Scrollable content area)
   =========================================== */
.leaf-modal__body {
    padding: 0.75rem;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

/* Ensure content doesn't overflow horizontally */
.leaf-modal__body>* {
    max-width: 100%;
}

/* ===========================================
   LOADING SPINNER
   =========================================== */
.leaf-modal__spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    flex-shrink: 0;
}

.leaf-modal__spinner[hidden] {
    display: none;
}

.leaf-modal__spinner-icon {
    width: 40px;
    height: 40px;
    border: 3px solid var(--medium-gray, #ccc);
    border-top-color: var(--brand-red, #E25465);
    border-radius: 50%;
    animation: leaf-modal-spin 0.8s linear infinite;
}

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

/* ===========================================
   LOCKED DATE FIELD
   =========================================== */
.leaf-modal__date-locked {
    background: var(--light-beige, #f5f5f0) !important;
    color: var(--dark-gray, #333) !important;
    cursor: not-allowed !important;
    border-color: var(--medium-gray, #ccc) !important;
    user-select: none;
}

.leaf-modal__date-locked:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* ===========================================
   ERROR STATE
   =========================================== */
.leaf-modal__error {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--form-error-color, #dc2626);
}

.leaf-modal__error p {
    margin: 0 0 0.5rem;
    line-height: 1.5;
}

.leaf-modal__error p:last-child {
    margin-bottom: 0;
}

/* ===========================================
   INLINE FORM STYLES (Compact)
   =========================================== */
.leaf-modal__form {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.leaf-modal__form-intro {
    color: var(--medium-gray, #666);
    font-size: 0.8rem;
    line-height: 1.4;
}

.leaf-modal__form-intro p {
    margin: 0;
}

.leaf-modal__form-group {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.leaf-modal__form-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--dark-gray, #333);
}

.leaf-modal__form-group input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--medium-gray, #ccc);
    border-radius: 4px;
    font-size: 0.875rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.leaf-modal__form-group input:focus {
    outline: none;
    border-color: var(--brand-red, #E25465);
    box-shadow: 0 0 0 2px rgba(226, 84, 101, 0.1);
}

.leaf-modal__form-group input::placeholder {
    color: #999;
}

.leaf-modal__consent {
    font-size: 0.7rem;
    color: var(--dark-gray, #333);
}

.leaf-modal__consent label {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    cursor: pointer;
}

.leaf-modal__consent input[type="checkbox"] {
    margin-top: 0.1rem;
    cursor: pointer;
}

.leaf-modal__consent a {
    color: var(--brand-red, #E25465);
    text-decoration: none;
}

.leaf-modal__consent a:hover {
    text-decoration: underline;
}

.leaf-modal__submit {
    background: var(--earthy-olive, #7D8B4C);
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s ease;
    margin-top: 0.75rem;
}

.leaf-modal__submit:hover {
    opacity: 0.9;
}

.leaf-modal__submit:disabled {
    background: var(--medium-gray, #999);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ===========================================
   FORM STYLES INSIDE MODAL
   Inherit/extend existing form patterns
   =========================================== */

/* Participant fields container */
.leaf-modal__body .participant-fields {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

@media (max-width: 480px) {
    .leaf-modal__body .participant-fields {
        flex-direction: column;
    }
}

/* Participant fields in modal */
.leaf-modal__body .participant-fields input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    min-width: 0;
    background: var(--off-white, #f0f0f0);
    color: var(--dark-gray, #333);
}

.leaf-modal__body .participant-fields input:focus {
    outline: none;
    background: var(--warm-beige, #e8e8e8);
}

.leaf-modal__body .participant-fields input.error {
    background: var(--error-light, #ffe0e0);
}

/* Confirm button in modal */
.leaf-modal__body .confirm-btn {
    background-color: var(--earthy-olive, #7D8B4C);
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}

.leaf-modal__body .confirm-btn:hover:not(:disabled) {
    opacity: 0.9;
}

.leaf-modal__body .confirm-btn:disabled {
    background-color: var(--medium-gray, #666);
    cursor: not-allowed;
    opacity: 0.5;
}

/* Form row layouts */
.leaf-modal__body .form-row {
    margin-bottom: 1rem;
}

.leaf-modal__body .form-row:last-child {
    margin-bottom: 0;
}

/* Session info display */
.leaf-modal__body .session-info {
    background: var(--light-beige, #f5f5f0);
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    border-left: 3px solid var(--brand-red, #E25465);
}

.leaf-modal__body .session-info__date {
    font-weight: 600;
    color: var(--dark-gray, #333);
    margin-bottom: 0.25rem;
}

.leaf-modal__body .session-info__time {
    color: var(--medium-gray, #666);
    font-size: 0.9rem;
}

/* ===========================================
   RESPONSIVE ADJUSTMENTS
   =========================================== */

/* Mobile: Full width modal */
@media (max-width: 480px) {
    .leaf-modal {
        padding: 0.5rem;
    }

    .leaf-modal__container {
        max-height: 95vh;
        border-radius: 0.75rem;
    }

    .leaf-modal__header {
        padding: 1rem 1.25rem;
    }

    .leaf-modal__title {
        font-size: 1.1rem;
    }

    .leaf-modal__subheader {
        padding: 0.625rem 1.25rem;
        font-size: 0.85rem;
    }

    .leaf-modal__body {
        padding: 1.25rem;
    }

    .leaf-modal__spinner {
        padding: 2rem 1rem;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .leaf-modal {
        padding: 0.25rem;
    }

    .leaf-modal__container {
        border-radius: 0.5rem;
    }

    .leaf-modal__header {
        padding: 0.875rem 1rem;
    }

    .leaf-modal__title {
        font-size: 1rem;
    }

    .leaf-modal__body {
        padding: 1rem;
    }
}

/* Tablets and up: Centered modal with max-width */
@media (min-width: 768px) {
    .leaf-modal {
        padding: 2rem;
    }

    .leaf-modal__container {
        max-height: 85vh;
    }

    .leaf-modal__header {
        padding: 1.5rem 2rem;
    }

    .leaf-modal__title {
        font-size: 1.375rem;
    }

    .leaf-modal__subheader {
        padding: 0.875rem 2rem;
    }

    .leaf-modal__body {
        padding: 2rem;
    }
}

/* ===========================================
   REDUCED MOTION SUPPORT
   =========================================== */
@media (prefers-reduced-motion: reduce) {

    .leaf-modal,
    .leaf-modal__container {
        transition: none;
    }

    .leaf-modal__spinner-icon {
        animation: none;
        border-top-color: var(--brand-red, #E25465);
        border-right-color: var(--brand-red, #E25465);
    }
}

/* ===========================================
   PRINT STYLES
   =========================================== */
@media print {
    .leaf-modal {
        display: none !important;
    }
}

/* ===========================================
   CONTENT MATRIX (Text above form)
   =========================================== */
.leaf-modal__seasonal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--brand-red, #E25465);
    margin: 0 0 1rem 0;
    line-height: 1.3;
}

.matrix-content {
    margin-bottom: 1.5rem;
}

.matrix-block {
    margin-bottom: 0.75rem;
}

.matrix-block p {
    font-size: 0.8rem;
    /* Drastic reduction */
    line-height: 1.5;
    color: var(--dark-gray, #333);
    margin: 0;
}

.matrix-block h3 {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
    color: var(--dark-gray, #333);
}

.matrix-block.reassurance p {
    font-size: 0.75rem;
    /* Even smaller for reassurance/legal-like text */
    color: var(--medium-gray, #666);
}

/* ===========================================
   REGISTRATION SUCCESS/ERROR STATES
   =========================================== */
.registration-success {
    text-align: center;
    padding: 1.5rem 1rem;
    background: #f0f9f4;
    border-radius: 8px;
    border: 1px solid #86c5a0;
}

.registration-success p {
    margin: 0;
    font-size: 0.9rem;
    color: #2d6a4f;
}

.registration-success p:first-child {
    font-weight: 600;
    font-size: 1rem;
}

.registration-success .success-subtext {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #52796f;
}

.registration-error {
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border-radius: 4px;
    border: 1px solid #fca5a5;
    margin-bottom: 0.75rem;
}

.registration-error p {
    margin: 0;
    font-size: 0.8rem;
    color: #dc2626;
}