/**
 * 팝업 스타일
 */

/* 팝업 오버레이 */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 팝업 위치 결정 (위치만 담당) */
.popup-positioner {
    position: fixed;
    pointer-events: none;
}

/* 팝업 컨테이너 (스타일과 애니메이션만 담당) */
.popup-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    pointer-events: all;
}

.popup-overlay.active .popup-container {
    transform: scale(1);
}

/* 팝업 이미지 */
.popup-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

/* 팝업 링크 */
.popup-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: auto;
}

.popup-link:hover .popup-content {
    opacity: 0.95;
}

/* 팝업 내용 */
.popup-content {
    flex: 1;
    padding: 0;
    overflow-y: auto;
    font-family: "Pretendard Variable", Pretendard, -apple-system, sans-serif;
}

.popup-content h1,
.popup-content h2,
.popup-content h3 {
    margin-top: 0;
    margin-bottom: 16px;
}

.popup-content p {
    margin: 0 !important;
    padding: 0 !important;
    line-height: normal !important;
    display: block !important;
    font-size: 0 !important;
    min-height: auto !important;
    height: auto !important;
}

/* 팝업 content 안의 이미지 스타일 */
.popup-content img {
    width: 100% !important;
    min-height: 100px !important;
    height: auto !important;
    display: block !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    object-fit: contain !important;
    vertical-align: top !important;
}

/* 팝업 컨트롤 */
.popup-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: #f5f5f5;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.popup-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    user-select: none;
}

.popup-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.popup-close {
    background: #333;
    color: white;
    border: none;
    padding: 5px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.popup-close:hover {
    background: #555;
}

/* 모바일 반응형 */
@media (max-width: 768px) {
    .popup-positioner {
        left: 50% !important;
        top: 50% !important;
        right: auto !important;
        bottom: auto !important;
        transform: translate(-50%, -50%) !important;
    }

    .popup-container {
        max-width: 90vw !important;
        max-height: 85vh !important;
        width: 90vw !important;
    }

    /* 팝업 이미지 - 모바일에서 제대로 표시되도록 수정 */
    .popup-image {
        width: 100%;
        height: auto;
        max-height: none;
        object-fit: cover;
        display: block;
    }

    .popup-content {
        padding: 0px;
        font-size: 14px;
        max-height: 65vh;
        overflow-y: auto;
    }

    /* 팝업 내부 이미지도 제대로 표시 - 모바일 강제 적용 */
    .popup-content p {
        line-height: normal !important;
        height: auto !important;
        min-height: auto !important;
    }

    .popup-content img {
        width: 100% !important;
        min-height: 100px !important;
        height: auto !important;
        display: block !important;
        max-width: 100% !important;
        object-fit: contain !important;
        margin: 0 !important;
        padding: 0 !important;
        vertical-align: top !important;
    }

    .popup-controls {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .popup-checkbox {
        justify-content: center;
    }

    .popup-close {
        width: 100%;
        padding: 12px;
    }
}

/* 애니메이션 */
@keyframes popupSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.popup-container {
    animation: popupSlideIn 0.4s ease-out;
}
