/* ========================================
   Modal Backdrop
======================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: var(--space-6);

    background: rgba(21, 21, 21, 0.6);

    opacity: 0;
    visibility: hidden;

    transition:
        opacity 0.25s ease,
        visibility 0.25s ease;
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}


/* ========================================
   Modal Card
======================================== */

.modal-card {
    position: relative;

    width: min(100%, 672px);
    max-height: 90vh;

    display: flex;
    flex-direction: column;

    background: var(--color-white);

    border-radius: 16px;

    overflow-y: auto;
    overflow-x: hidden;

    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.2);

    transform: translateY(16px);

    transition:
        transform 0.25s ease;
}

.modal-backdrop.active .modal-card {
    transform: translateY(0);
}


/* ========================================
   Sticky Header
======================================== */

.modal-header {
    position: sticky;
    top: 0;
    z-index: 10;

    flex-shrink: 0;

    padding: var(--space-8);

    background: var(--pink-500);
    color: var(--color-white);
}

.modal-header h2 {
    margin: 0;

    font-family: var(--font-family-primary);
    font-size: 32px;
    line-height: 40px;
    font-weight: var(--font-bold);
}

.modal-header p {
    margin: var(--space-2) 0 0;

    font-family: var(--font-family-primary);
    font-size: var(--text-body);
    line-height: var(--leading-body);
    font-weight: var(--font-regular);
}


/* ========================================
   Close Button
======================================== */

.close-btn {
    position: absolute;

    top: var(--space-5);
    right: var(--space-5);

    width: 40px;
    height: 40px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border: 0;
    outline: none;

    background: transparent;
    color: var(--color-white);

    font-size: 32px;
    line-height: 1;

    cursor: pointer;

    appearance: none;
    -webkit-appearance: none;
}

.close-btn:focus-visible {
    outline: 2px solid var(--color-white);
    outline-offset: 2px;
}


/* ========================================
   Form
======================================== */

.modal-body {
    padding: var(--space-8);

    display: flex;
    flex-direction: column;

    gap: var(--space-6);
}

.form-group {
    display: flex;
    flex-direction: column;

    gap: var(--space-2);
}


/* ========================================
   Labels
======================================== */

.form-group label {
    color: var(--grey-950);

    font-family: var(--font-family-primary);
    font-size: var(--text-body-sm);
    line-height: var(--leading-body-sm);
    font-weight: var(--font-semibold);
}

.required-asterisk {
    color: var(--pink-500);
}


/* ========================================
   Inputs / Select / Textarea
======================================== */

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    min-height: 52px;

    padding: 14px 16px;

    box-sizing: border-box;

    border: 1px solid var(--grey-400);
    border-radius: 8px;

    background: var(--color-white);
    color: var(--grey-950);

    font-family: var(--font-family-primary);
    font-size: var(--text-body);
    font-weight: var(--font-regular);
    line-height: var(--leading-body);

    outline: none;

    appearance: none;
    -webkit-appearance: none;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--pink-500);

    box-shadow:
        0 0 0 2px var(--pink-100);
}


/* ========================================
   Program Select
======================================== */

.form-group select {
    padding-right: 48px;

    cursor: pointer;

    background-image:
        linear-gradient(
            45deg,
            transparent 50%,
            var(--grey-800) 50%
        ),
        linear-gradient(
            135deg,
            var(--grey-800) 50%,
            transparent 50%
        );

    background-position:
        calc(100% - 21px) 22px,
        calc(100% - 15px) 22px;

    background-size:
        6px 6px,
        6px 6px;

    background-repeat: no-repeat;
}

.form-group select:hover {
    border-color: var(--grey-600);
}

.form-group select:invalid {
    color: var(--grey-700);
}

.form-group select option {
    color: var(--grey-950);
    background: var(--color-white);
}

.form-group select option:disabled {
    color: var(--grey-700);
}


/* ========================================
   Textarea
======================================== */

.form-group textarea {
    min-height: 140px;

    resize: vertical;
}


/* ========================================
   Submit Button
======================================== */

.submit-btn {
    width: 100%;

    padding:
        var(--space-3)
        var(--space-5);

    box-sizing: border-box;

    border: 0;
    border-radius: 12px;

    background: var(--pink-500);
    color: var(--color-white);

    font-family: var(--font-family-primary);
    font-size: var(--text-body-lg);
    font-weight: var(--font-semibold);
    line-height: var(--leading-body-lg);

    text-decoration: none;

    display: inline-flex;
    justify-content: center;
    align-items: center;

    cursor: pointer;

    appearance: none;
    -webkit-appearance: none;

    transition:
        transform 0.2s ease,
        opacity 0.2s ease;
}

.submit-btn:hover {
    transform: translateY(-1px);
    opacity: 0.9;
}

.submit-btn:focus-visible {
    outline: 2px solid var(--pink-500);
    outline-offset: 3px;
}

.submit-btn:disabled {
    cursor: not-allowed;
    opacity: 0.75;
    transform: none;
}

.submit-btn .btn-spinner {
    width: 18px;
    height: 18px;

    margin-right: var(--space-2);

    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: var(--color-white);
    border-radius: 50%;

    display: inline-block;

    animation: apply-popup-spin 0.7s linear infinite;
}

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


/* ========================================
   Mobile
======================================== */

@media (max-width: 640px) {

    .modal-backdrop {
        padding: 0;

        align-items: flex-end;
    }

    .modal-card {
        width: 100%;
        max-height: 94vh;

        border-radius: 20px 20px 0 0;
    }

    .modal-header {
        padding: var(--space-6);
    }

    .modal-header h2 {
        font-size: 28px;
        line-height: 36px;
    }

    .modal-header p {
        font-size: var(--text-body-sm);
        line-height: var(--leading-body-sm);
    }

    .modal-body {
        padding: var(--space-6);

        gap: var(--space-5);
    }

    .close-btn {
        top: var(--space-4);
        right: var(--space-4);
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        min-height: 50px;
    }
}