/**
 * Popup Modal (Unified)
 * Single responsibility: Shared popup modal shell (overlay + container + header/body/footer).
 *
 * Usage:
 * - Overlay: .popup-modal-overlay (add .is-open to show)
 * - Container: .popup-modal
 * - Header: .popup-modal-header
 * - Title: .popup-modal-title (+ optional icon .popup-modal-icon)
 * - Body: .popup-modal-body
 * - Footer: .popup-modal-footer
 * - Close button: .modal-close-btn (shared)
 */

/* ===== OVERLAY ===== */
.popup-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.popup-modal-overlay.is-open {
    display: flex;
}

/* ===== CONTAINER ===== */
.popup-modal {
    background: #ffffff;
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    margin: 20px;
}

/* ===== HEADER ===== */
.popup-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    background: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-primary-light) 100%);
    color: #ffffff;
    flex-shrink: 0;
}

.popup-modal-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #ffffff;
}

.popup-modal-icon {
    width: 24px;
    height: 24px;
    color: #ffffff;
    stroke: #ffffff;
    fill: none;
    flex-shrink: 0;
}

/* Close button (shared selector) */
.popup-modal-header .modal-close-btn {
    color: #ffffff;
}

.popup-modal-header .modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* ===== BODY ===== */
.popup-modal-body {
    position: relative;
    padding: 24px;
    overflow-y: auto;
    background: #FCFDFA;
    flex: 1;
}

/* ===== COMMON CONTENT (used by many modals) ===== */
.popup-modal-section {
    margin-bottom: 24px;
}

.popup-modal-section:last-child {
    margin-bottom: 0;
}

.popup-modal-label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.popup-modal-hint {
    margin: 12px 0 0 0;
    color: #6c757d;
    font-size: 12px;
    line-height: 1.5;
}

/* ===== FOOTER ===== */
.popup-modal-footer {
    padding: 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: #ffffff;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
}

/* ===== CLOSE BUTTON (shared across all modals) ===== */
.modal-close-btn {
    position: relative;
    top: auto;
    right: auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 15px;
}

.modal-close-btn:hover {
    background: rgba(0,0,0,0.05);
    color: #333;
    transform: rotate(90deg);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .popup-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .popup-modal {
        max-width: 100%;
        width: 100%;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        margin: 0;
    }

    .popup-modal-header {
        padding: 16px;
    }

    .popup-modal-title {
        font-size: 18px;
    }

    .popup-modal-header .modal-close-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        touch-action: manipulation;
    }

    .popup-modal-body {
        padding: 16px;
        max-height: calc(90vh - 140px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .popup-modal-footer {
        padding: 16px;
        flex-direction: column;
        gap: 12px;
    }

    .popup-modal-section {
        margin-bottom: 20px;
    }

    .popup-modal-label {
        font-size: 14px;
        margin-bottom: 12px;
    }
}

