/* ─────────────────────────────────────────
   PRIMA LIVING — Modals
   File: ~/Files/templates/main/css/modals.css
   ───────────────────────────────────────── */

/* ══════════════════════════════════════════
   OVERLAY
══════════════════════════════════════════ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 20, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 500;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 24px;
}

    .modal-overlay.open {
        display: block;
    }

/* ══════════════════════════════════════════
   MODAL PANEL
══════════════════════════════════════════ */
.modal {
    background: #EEF0EE;
    border-radius: 10px;
    padding: 40px;
    width: 100%;
    max-width: 630px;
    margin: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Close button ── */
.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 12px;
    transition: background 0.15s;
}

    .modal-close:hover {
        background: rgba(9, 46, 29, 0.08);
    }

    .modal-close svg {
        width: 32px;
        height: 32px;
        stroke: var(--dark, #141414);
        stroke-width: 2;
        fill: none;
    }

/* ── Heading ── */
.modal-heading {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.modal-title {
    font-family: 'STIX Two Text', serif;
    font-size: 48px;
    font-weight: 500;
    color: var(--dark, #141414);
    line-height: 1.2;
    margin: 0;
}

.modal-divider {
    width: 80px;
    height: 4px;
    background: var(--sage, #9EA274);
    border-radius: 2px;
    flex-shrink: 0;
}

.modal-subtitle {
    font-family: 'Nunito Sans', sans-serif;
    font-size: 18px;
    font-weight: 500;
    color: var(--dark, #141414);
    line-height: 1.5;
    margin: 0;
}

/* ══════════════════════════════════════════
   FORM FIELDS
══════════════════════════════════════════ */
.modal-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-row {
    display: flex;
    gap: 10px;
}

    .modal-row .modal-field {
        flex: 1;
        min-width: 0;
    }

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

    .modal-field label {
        font-family: 'Nunito Sans', sans-serif;
        font-size: 16px;
        font-weight: 500;
        color: var(--dark, #141414);
        line-height: 1.5;
    }

    .modal-field input,
    .modal-field select,
    .modal-field textarea {
        background: var(--white, #FAFAFA);
        border: 1px solid var(--cool-grey, #C2CDC5);
        border-radius: 4px;
        font-family: 'Nunito Sans', sans-serif;
        font-size: 16px;
        font-weight: 400;
        color: var(--dark, #141414);
        line-height: 1.5;
        padding: 10px 12px;
        width: 100%;
        outline: none;
        transition: border-color 0.15s;
        box-sizing: border-box;
        appearance: none;
        -webkit-appearance: none;
    }

        .modal-field input::placeholder,
        .modal-field textarea::placeholder {
            color: var(--grey, #6C757D);
            font-style: italic;
            opacity: 1;
        }

        .modal-field input:focus,
        .modal-field select:focus,
        .modal-field textarea:focus {
            border-color: var(--forest, #092E1D);
        }

    .modal-field input {
        height: 48px;
    }

    .modal-field textarea {
        height: 120px;
        resize: vertical;
        border-radius: 3.5px;
    }

/* Select with chevron */
.modal-select-wrap {
    position: relative;
}

    .modal-select-wrap select {
        padding-right: 32px;
        cursor: pointer;
        color: var(--grey, #6C757D);
        font-style: italic;
    }

        .modal-select-wrap select.has-value {
            color: var(--dark, #141414);
            font-style: normal;
        }

    .modal-select-wrap::after {
        content: '';
        position: absolute;
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
        width: 0;
        height: 0;
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-top: 6px solid var(--grey, #6C757D);
        pointer-events: none;
    }

/* Checkbox row */
.modal-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

    .modal-checkbox-row input[type="checkbox"] {
        width: 24px;
        height: 24px;
        border: 1px solid var(--cool-grey, #C2CDC5);
        border-radius: 2px;
        background: var(--white, #FAFAFA);
        appearance: none;
        -webkit-appearance: none;
        cursor: pointer;
        flex-shrink: 0;
        margin: 0;
        transition: background 0.15s, border-color 0.15s;
    }

        .modal-checkbox-row input[type="checkbox"]:checked {
            background: var(--forest, #092E1D);
            border-color: var(--forest, #092E1D);
        }

    .modal-checkbox-row label {
        font-family: 'Nunito Sans', sans-serif;
        font-size: 16px;
        font-weight: 500;
        color: var(--dark, #141414);
        line-height: 1.5;
        cursor: pointer;
        user-select: none;
    }

/* ── Submit button ── */
.modal-submit {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--forest, #092E1D);
    border: 1px solid var(--forest, #092E1D);
    border-radius: 2px;
    color: var(--cool-grey, #C2CDC5);
    font-family: 'Nunito Sans', sans-serif;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.5;
    height: 48px;
    padding: 4px 20px;
    width: 200px;
    cursor: pointer;
    margin-top: 10px;
    transition: opacity 0.2s;
    white-space: nowrap;
}

    .modal-submit:hover {
        color: var(--PL-White-Base, #FAFAFA);
        box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.05);
        background: var(--PL-Dark, #141414);
    }

    .modal-submit svg {
        width: 20px;
        height: 20px;
        stroke: var(--cool-grey, #C2CDC5);
        stroke-width: 2;
        fill: none;
        flex-shrink: 0;
    }

.modal-error {
    display: none;
    color: #c63a3a;
    font-size: 13px;
    margin-top: 4px;
}

.modal-field input.error,
.modal-field textarea.error,
.modal-field select.error {
    border-color: #c63a3a;
}

/* ── Success state ── */
.modal-success {
    display: none;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    padding: 40px 0 20px;
}

    .modal-success.visible {
        display: flex;
    }

.modal-success-icon {
    width: 56px;
    height: 56px;
    background: var(--forest, #092E1D);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .modal-success-icon svg {
        width: 28px;
        height: 28px;
        stroke: #FAFAFA;
        stroke-width: 2.5;
        fill: none;
    }

.modal-success h3 {
    font-family: 'STIX Two Text', serif;
    font-size: 28px;
    font-weight: 500;
    color: var(--dark, #141414);
    margin: 0;
}

.modal-success p {
    font-family: 'Nunito Sans', sans-serif;
    font-size: 16px;
    color: var(--grey, #6C757D);
    line-height: 1.6;
    margin: 0;
    max-width: 420px;
}

/* ══════════════════════════════════════════
   RESPONSIVE — MOBILE (≤540px)
══════════════════════════════════════════ */
@media (max-width: 540px) {
    .modal-overlay {
        padding: 0;
    }

    .modal {
        max-width: 100%;
        min-height: 100%;
        border-radius: 0;
        padding: 32px 24px;
        animation: modalInMobile 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes modalInMobile {
        from {
            opacity: 0;
            transform: translateY(40px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .modal-title {
        font-size: 32px;
    }

    .modal-row {
        flex-direction: column;
        gap: 10px;
    }

    .modal-submit {
        width: 100%;
    }
}

/* ══════════════════════════════════════════
   CROSS-BROWSER COMPATIBILITY
══════════════════════════════════════════ */

/* Firefox < 80 fallback: -moz-appearance (appearance: none 단독으로 안 먹히는 구버전용) */
.modal-field input,
.modal-field select,
.modal-field textarea,
.modal-checkbox-row input[type="checkbox"] {
    -moz-appearance: none;
}

/* Firefox < 103: backdrop-filter 미지원 시 overlay를 더 불투명하게 */
@supports not (backdrop-filter: blur(1px)) {
    .modal-overlay {
        background: rgba(20, 20, 20, 0.82);
    }
}
