
/**
 * Layer Popup System CSS (Refactored)
 * 레이어 팝업 시스템 스타일 (리팩토링)
 */

/* CSS 변수 정의 */
:root {
    --popup-overlay-bg: rgba(0, 0, 0, 0.5);
    --popup-bg: #ffffff;
    --popup-border-radius: 12px;
    --popup-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    --popup-z-index-base: 1000;
    --popup-animation-duration: 0.3s;
    --mobile-breakpoint: 768px;
}

/* 팝업 오버레이 컨테이너 */
.layer-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5); /* 반투명 검정 배경 */
    z-index: var(--popup-z-index-base);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--popup-animation-duration) ease;
}

.layer-popup-overlay.visible {
    pointer-events: auto;
    opacity: 1;
}

/* 개별 레이어 팝업 */
.layer-popup {
    position: fixed;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: var(--popup-bg);
    border-radius: var(--popup-border-radius);
    box-shadow: var(--popup-shadow);
    overflow: hidden;
    opacity: 1;
    transition: none;
    pointer-events: auto;
    width: auto; /* 이미지 크기에 따라 자동 */
    height: auto; /* 높이: 이미지 비율에 따라 자동 */
    max-width: min(28vw, 320px); /* PC: 화면의 28% (최대 320px), 반응형 */
    max-height: calc(100vh - 200px); /* 상하 여백 100px씩 확보 */
    display: flex;
    flex-direction: column;
}

.layer-popup.visible {
    opacity: 1 !important;
    transform: translate(-50%, -50%) !important;
}

.layer-popup.closing {
    opacity: 0 !important;
    transform: translate(-50%, -50%) !important;
}

/* 팝업 내용 영역 */
.layer-popup-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    max-height: inherit;
    overflow: hidden;
}

/* 팝업 헤더 (사용하지 않음) */
.layer-popup-header {
    display: none;
}

/* 팝업 이미지 영역 */
.layer-popup-image {
    width: 100%;
    flex: 1 1 auto;
    overflow: hidden; /* 스크롤 제거 */
    background: #f5f5f5; /* 여백 배경색 */
    min-height: 0;
}

.layer-popup-image img {
    width: 100%;
    height: 100%;
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* 비율 유지하며 영역 내 맞춤 */
}

.layer-popup-image a {
    display: block;
    width: 100%;
    text-decoration: none;
}

/* 팝업 푸터 */
.layer-popup-footer {
    padding: 10px 16px;
    height: 45px;
    background: rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.layer-popup-never-show {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
}

.layer-popup-never-show input[type="checkbox"] {
    margin: 0;
}

.layer-popup-actions {
    display: flex;
    gap: 8px;
}

.layer-popup-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.layer-popup-btn:hover {
    background: #f5f5f5;
}

/* 팝업 네비게이션 (양옆 배치) */
.popup-navigation {
    display: none; /* 기본 숨김 */
}

.popup-navigation.visible {
    display: block !important; /* 보일 때 */
}

/* 좌/우 화살표 버튼 */
.popup-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #333;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.popup-nav-btn[data-action="prev"] {
    left: 10px;
}

.popup-nav-btn[data-action="next"] {
    right: 10px;
}

.popup-nav-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-50%) scale(1.1);
}

.popup-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.popup-nav-btn:disabled:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-50%);
}

/* 페이지 카운터 (하단 중앙) */
.popup-counter {
    position: absolute;
    bottom: 55px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    white-space: nowrap;
    z-index: 10;
}

/* 대형 화면 (1280px 이상) */
@media screen and (min-width: 1280px) {
    .layer-popup {
        max-width: min(30vw, 380px); /* 대형 화면: 30% (최대 380px) */
    }
}

/* 모바일 반응형 스타일 */
@media screen and (max-width: 768px) {
    .layer-popup {
        max-width: calc(100vw - 32px); /* 좌우 여백 16px씩 */
        max-height: calc(100vh - 80px); /* 상하 여백 확보 */
        border-radius: 8px;
    }

    .layer-popup-footer {
        padding: 8px 12px;
        height: auto;
        min-height: 40px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .layer-popup-never-show {
        font-size: 12px;
        flex: 1 1 auto;
    }

    .layer-popup-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .popup-nav-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .popup-nav-btn[data-action="prev"] {
        left: 5px;
    }

    .popup-nav-btn[data-action="next"] {
        right: 5px;
    }

    .popup-counter {
        bottom: 50px;
        font-size: 12px;
        padding: 3px 10px;
    }
}

/* 매우 작은 화면 (360px 이하) */
@media screen and (max-width: 360px) {
    .layer-popup {
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 60px);
    }

    .layer-popup-footer {
        padding: 6px 10px;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .layer-popup-never-show {
        justify-content: center;
    }

    .layer-popup-actions {
        justify-content: center;
    }
}
