/**
 * 통합 갤러리 시스템 CSS
 * 모든 제품 페이지에서 재사용 가능한 갤러리 스타일
 * Created: 2025년 12월
 */

/* =================================
   메인 갤러리 컨테이너
   ================================= */
.unified-gallery {
    max-width: 500px;
    margin: 0 auto;
    padding: 1rem;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.gallery-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 1rem;
    text-align: center;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #f8f9fa;
}

/* =================================
   메인 이미지 영역
   ================================= */
.main-image-container {
    margin-bottom: 1rem;
}

.main-image-wrapper {
    position: relative;
    width: 500px;
    height: 400px;
    background: rgba(30, 78, 121, 0.4);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: zoom-in;
    margin: 0 auto; /* 중앙 정렬 */
}

.main-image-wrapper:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.main-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center center;
}

/* 호버 확대 효과 */
.main-image-wrapper.zoom-active .main-image {
    transform: scale(1.35);
}

/* 통합 갤러리 메인 뷰어 호버 확대 효과 */
.main-viewer.zoom-active img {
    transform: scale(1.35);
    transition: transform-origin 0.1s ease, transform 0.3s ease;
}

.main-image-wrapper.loading .main-image {
    opacity: 0.7;
}

.image-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none; /* 마우스 이벤트 차단 방지 */
    z-index: 1;
}

.main-image-wrapper.loading .image-loader {
    opacity: 1;
}

/* =================================
   썸네일 영역
   ================================= */
.thumbnail-container {
    margin-bottom: 1rem;
}

.thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    max-width: 500px;
    margin: 0 auto; /* 중앙 정렬 */
}

.thumbnail-item {
    position: relative;
    width: 100%;
    height: 80px;
    background: #f8f9fa;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.thumbnail-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #007bff;
}

.thumbnail-item.active {
    border-color: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.3);
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.thumbnail-item:hover img {
    transform: scale(1.1);
}

/* =================================
   더보기 버튼
   ================================= */
.more-button-container {
    text-align: center;
    margin-bottom: 0;
    padding-bottom: 0;
}

.btn-more-gallery {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: rgba(30, 78, 121, 0.8);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-more-gallery:hover {
    background: rgba(30, 78, 121, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(30, 78, 121, 0.4);
}

.btn-more-gallery .icon-gallery {
    font-size: 1.1rem;
}

/* =================================
   팝업 갤러리
   ================================= */
.gallery-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-popup.active {
    opacity: 1;
    visibility: visible;
}

.popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.popup-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 1200px;
    height: 90%;
    max-height: 90vh;
    background: white;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 10001;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: #2c3e50;
    border-bottom: 1px solid #34495e;
    border-radius: 12px 12px 0 0;  /* 상단 모서리만 둥글게 */
}

.popup-header h3 {
    margin: 0;
    color: white;
    font-size: 1.3rem;
    font-weight: 600;
}

.popup-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: white;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.popup-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ecf0f1;
    transform: scale(1.1);
}

.popup-body {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    position: relative;
}

.popup-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

.popup-image-item {
    position: relative;
    aspect-ratio: 1;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.popup-image-item:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.popup-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    color: white;
    padding: 1rem 0.75rem 0.75rem;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    backdrop-filter: blur(2px);
}

.popup-image-item:hover .image-overlay {
    transform: translateY(0);
}

.image-title {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.3;
}

.popup-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.popup-loader.active {
    opacity: 1;
}

.popup-footer {
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

/* =================================
   페이지네이션
   ================================= */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.page-btn {
    min-width: 40px;
    height: 40px;
    border: 1px solid #dee2e6;
    background: white;
    color: #495057;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.page-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.page-btn.active {
    background: #007bff;
    border-color: #007bff;
    color: white;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =================================
   라이트박스
   ================================= */
.gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.gallery-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
}

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.lightbox-prev {
    left: 2rem;
}

.lightbox-next {
    right: 2rem;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-image-wrapper {
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-size: 0.9rem;
    backdrop-filter: blur(10px);
}

/* =================================
   로딩 스피너
   ================================= */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =================================
   반응형 디자인
   ================================= */
@media (max-width: 768px) {
    .unified-gallery {
        max-width: 100%;
        margin: 0;
        margin-bottom: 0;
        padding: 0.5rem;
        padding-bottom: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .main-image-wrapper {
        width: 100%; /* 모바일에서는 전체 너비 */
        height: 320px;
    }

    .thumbnail-grid {
        max-width: 100%; /* 모바일에서는 전체 너비 */
    }
    
    .thumbnail-grid {
        gap: 0.25rem;
    }
    
    .thumbnail-item {
        height: 60px;
    }
    
    .popup-content {
        width: 95%;
        height: 95%;
        max-height: 90vh;
        margin: auto;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
    
    .popup-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.75rem;
    }
    
    .lightbox-prev,
    .lightbox-next {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .lightbox-prev {
        left: 1rem;
    }
    
    .lightbox-next {
        right: 1rem;
    }
    
    .lightbox-close {
        top: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .main-image-wrapper {
        width: 100%; /* 작은 화면에서는 전체 너비 */
        height: 270px;
    }
    
    .thumbnail-item {
        height: 50px;
    }
    
    .popup-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 0.5rem;
    }
    
    .btn-more-gallery {
        padding: 0.6rem 1.2rem;
        font-size: 0.85rem;
    }
}