/**
 * 하룹팩 전후사진 프론트엔드 스타일
 * 반응형 디자인 + 최고 품질 UI/UX
 */

/* 컨테이너 */
.haroop-ba-gallery-container {
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0 auto;
}

/* 카테고리 필터 */
.ba-category-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
    justify-content: flex-start;
}

.ba-cat-btn {
    padding: 12px 28px;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.ba-cat-btn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.ba-cat-btn.active {
    background: #333333;
    color: white;
    border-color: #333333;
    box-shadow: 0 4px 16px rgba(51, 51, 51, 0.25);
}

/* 2차 카테고리 필터 */
.ba-subcategory-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 28px;
    justify-content: flex-start;
    padding: 16px 20px;
    background: #f9fafb;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

/* 3차 카테고리 필터 (더 작고 어두운 배경) */
.ba-third-level-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 24px;
    justify-content: flex-start;
    padding: 12px 16px;
    background: #f1f5f9;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    margin-left: 20px; /* 들여쓰기로 계층 표현 */
}

/* 4차 카테고리 필터 (가장 작고 가장 어두운 배경) */
.ba-fourth-level-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
    justify-content: flex-start;
    padding: 10px 14px;
    background: #e2e8f0;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    margin-left: 40px; /* 더 깊은 들여쓰기 */
}

/* 3차 카테고리 버튼 (2차보다 작음) */
.ba-third-btn {
    padding: 6px 14px;
    background: white;
    border: 1.5px solid #cbd5e1;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ba-third-btn:hover {
    border-color: #94a3b8;
    color: #334155;
    background: #f8fafc;
}

.ba-third-btn.active {
    background: #475569;
    color: white;
    border-color: #475569;
    box-shadow: 0 2px 8px rgba(71, 85, 105, 0.2);
}

/* 4차 카테고리 버튼 (가장 작음) */
.ba-fourth-btn {
    padding: 5px 12px;
    background: white;
    border: 1.5px solid #cbd5e1;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ba-fourth-btn:hover {
    border-color: #94a3b8;
    color: #334155;
    background: #f8fafc;
}

.ba-fourth-btn.active {
    background: #64748b;
    color: white;
    border-color: #64748b;
    box-shadow: 0 2px 6px rgba(100, 116, 139, 0.2);
}

.ba-subcat-btn {
    padding: 8px 18px;
    background: white;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ba-subcat-btn:hover {
    border-color: #9ca3af;
    color: #374151;
    background: #f3f4f6;
}

.ba-subcat-btn.active {
    background: #4b5563;
    color: white;
    border-color: #4b5563;
    box-shadow: 0 2px 8px rgba(75, 85, 99, 0.2);
}

/* 갤러리 그리드 */
.ba-gallery-grid {
    display: grid;
    gap: 24px;
    margin-bottom: 40px;
}

/* 그리드 레이아웃 (PC) */
.ba-gallery-grid.cols-1 { grid-template-columns: 1fr; }
.ba-gallery-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.ba-gallery-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

/* 갤러리 아이템 */
.ba-gallery-item {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.06);
}

.ba-gallery-item:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.12), 0 6px 12px rgba(0,0,0,0.08);
    border-color: #d1d5db;
}

/* 이미지 래퍼 */
.ba-image-wrapper {
    position: relative;
}

/* 방향 선택 탭 (이미지 하단 중앙에 표시 - 다중 이미지만) */
.ba-direction-tabs {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 24px;
    padding: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
    backdrop-filter: blur(8px);
}

.ba-dir-tab {
    padding: 8px 20px;
    background: transparent;
    border: none;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    white-space: nowrap;
}

.ba-dir-tab:hover {
    background: rgba(241, 245, 249, 0.8);
    color: #334155;
}

.ba-dir-tab.active {
    background: #1e293b;
    color: #ffffff;
}

/* 이미지 컨테이너 */
.ba-images {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
    position: relative; /* 방향 버튼의 기준점 */
}

/* 개별 이미지 */
.ba-image {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    background: #f8fafc;
}

.ba-image.ba-before {
    border-right: 2px solid #f1f5f9;
}

.ba-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.ba-gallery-item:hover .ba-img {
    transform: scale(1.05);
}

/* 이미지 라벨 */
.ba-image-label {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.45);
    color: white;
    padding: 6px 12px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    z-index: 10;
    backdrop-filter: blur(4px);
}

.ba-image-label.after {
    background: rgba(51, 51, 51, 0.9);
}

/* 로그인 오버레이 */
.ba-before.locked {
    position: relative;
}

.ba-login-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.ba-login-content {
    text-align: center;
    color: white;
    padding: 20px;
}

.ba-lock-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.ba-login-content p {
    margin: 0 0 20px;
    font-size: 15px;
    font-weight: 500;
}

.ba-login-btn {
    display: inline-block;
    padding: 12px 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 100px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ba-login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

/* 제목 */
.ba-item-title {
    padding: 18px 24px;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    text-align: left;
    border-top: 1px solid #e5e7eb;
    background: #333333;
    letter-spacing: -0.01em;
    line-height: 1.5;
}

/* 이전 방향 스위처 스타일 제거됨 - 새로운 탭 스타일 사용 */

/* 빈 메시지 */
.ba-empty-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: #94a3b8;
}

.ba-empty-message p {
    margin: 0;
    font-size: 16px;
}

/* 페이지네이션 */
.ba-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 48px;
}

.ba-pagination ul,
.ba-pagination .page-numbers {
    display: inline-flex;
    gap: 6px;
    list-style: none;
    padding: 0;
    margin: 0;
    align-items: center;
}

.ba-pagination ul li,
.ba-pagination .page-numbers li {
    display: inline-block;
    list-style: none;
}

.ba-pagination a,
.ba-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 5px 10px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    color: #64748b;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ba-pagination a:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #1e293b;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ba-pagination .current {
    background: #1e293b;
    color: white;
    border-color: #1e293b;
    box-shadow: 0 2px 8px rgba(30, 41, 59, 0.3);
}

.ba-pagination .dots {
    border: none;
    background: transparent;
    box-shadow: none;
    color: #94a3b8;
}

.ba-pagination .prev,
.ba-pagination .next {
    font-weight: 600;
    padding: 0 16px;
}

/* 태블릿 (768px - 1024px) */
@media (max-width: 1024px) {
    /* 3열은 태블릿에서 2열로 */
    .ba-gallery-grid.cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .ba-category-filter {
        gap: 8px;
    }

    .ba-cat-btn {
        padding: 8px 16px;
        font-size: 14px;
    }
}

/* 모바일 (< 768px) */
@media (max-width: 767px) {
    .ba-gallery-grid {
        gap: 16px;
    }

    /* 모든 열은 모바일에서 1열로 */
    .ba-gallery-grid.cols-2,
    .ba-gallery-grid.cols-3 {
        grid-template-columns: 1fr;
    }

    .ba-category-filter {
        gap: 6px;
        margin-bottom: 20px;
    }

    .ba-cat-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .ba-subcategory-filter {
        padding: 12px;
        margin-bottom: 16px;
    }

    .ba-subcat-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    /* 3차/4차 카테고리 모바일 반응형 */
    .ba-third-level-filter {
        margin-left: 10px; /* 모바일에서는 들여쓰기 줄임 */
        padding: 10px 12px;
    }

    .ba-fourth-level-filter {
        margin-left: 20px; /* 모바일에서는 들여쓰기 줄임 */
        padding: 8px 10px;
    }

    .ba-third-btn {
        padding: 5px 10px;
        font-size: 12px;
    }

    .ba-fourth-btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    .ba-item-title {
        font-size: 14px;
        padding: 12px 16px;
    }

    .ba-direction-tabs {
        padding: 4px;
        gap: 6px;
        bottom: 12px;
    }

    .ba-dir-tab {
        padding: 6px 16px;
        font-size: 12px;
    }

    .ba-image-label {
        padding: 4px 10px;
        font-size: 11px;
    }

    .ba-login-content {
        padding: 16px;
    }

    .ba-lock-icon {
        font-size: 36px;
        margin-bottom: 12px;
    }

    .ba-login-content p {
        font-size: 14px;
        margin-bottom: 16px;
    }

    .ba-login-btn {
        padding: 10px 24px;
        font-size: 13px;
    }

    .ba-pagination a,
    .ba-pagination span {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* 1열 레이아웃 특별 처리 */
.ba-gallery-grid.cols-1 .ba-images {
    max-width: 100%;
}

.ba-gallery-grid.cols-1 .ba-image {
    aspect-ratio: 16/9;
}

/* 애니메이션 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ba-gallery-item {
    animation: fadeIn 0.4s ease forwards;
}

/* 이미지 로딩 효과 */
.ba-img {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

.ba-img[src] {
    animation: none;
    background: transparent;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ========================================
   Before-After 쇼케이스 슬라이더 스타일
   드래그로 움직이는 비교 슬라이더
   ======================================== */

.ba-showcase {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 12px;
    cursor: ew-resize;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y;
}

.ba-showcase img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
}

/* After 이미지 (아래 레이어) */
.ba-showcase-after {
    position: relative;
    width: 100%;
}

.ba-showcase-after img {
    width: 100%;
}

/* Before 이미지 (위 레이어, clip으로 잘림) */
.ba-showcase-before {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    overflow: hidden;
    border-right: 3px solid #fff;
    box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    transition: none !important;
}

/* 드래그 모드 활성화 시 호버 효과 완전 비활성화 */
.ba-showcase.ba-showcase-drag-enabled:hover .ba-showcase-before,
.ba-showcase.ba-showcase-drag-enabled:hover .ba-showcase-handle,
.ba-showcase.ba-showcase-drag-enabled:active .ba-showcase-before,
.ba-showcase.ba-showcase-drag-enabled:active .ba-showcase-handle,
.ba-showcase.ba-showcase-drag-enabled:focus .ba-showcase-before,
.ba-showcase.ba-showcase-drag-enabled:focus .ba-showcase-handle {
    transition: none !important;
    /* width와 left는 JS에서 inline으로 설정 */
}

/* 호버로 이동하는 CSS 무효화 (사용자 템플릿 오버라이드) */
.ba-showcase.ba-showcase-drag-enabled .ba-showcase-before {
    transition: none !important;
}

/* pointer-events로 호버 효과 차단 */
.ba-showcase.ba-showcase-drag-enabled .ba-showcase-before,
.ba-showcase.ba-showcase-drag-enabled .ba-showcase-after {
    pointer-events: none;
}

.ba-showcase-before img {
    position: absolute;
    top: 0;
    left: 0;
    width: auto;
    height: 100%;
    max-width: none;
}

/* 슬라이더 핸들 */
.ba-showcase-handle {
    position: absolute;
    top: 0;
    left: 50%;
    width: 44px;
    height: 100%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    cursor: ew-resize;
}

.ba-showcase-handle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 3px;
    height: 100%;
    background: #fff;
    transform: translateX(-50%);
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
}

.ba-showcase-handle::after {
    content: '⟨ ⟩';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    font-size: 14px;
    font-weight: bold;
    color: #333;
    letter-spacing: -2px;
    z-index: 11;
}

/* 호버/드래그 시 핸들 강조 */
.ba-showcase:hover .ba-showcase-handle::after,
.ba-showcase.dragging .ba-showcase-handle::after {
    background: #333;
    color: #fff;
    transform: scale(1.1);
}

.ba-showcase.dragging {
    cursor: grabbing;
}

/* Before/After 라벨 */
.ba-showcase-label {
    position: absolute;
    top: 12px;
    padding: 6px 14px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    z-index: 5;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

.ba-showcase-label.before {
    left: 12px;
}

.ba-showcase-label.after {
    right: 12px;
    background: rgba(51,51,51,0.9);
}

/* 반응형 */
@media (max-width: 768px) {
    .ba-showcase-handle {
        width: 36px;
    }

    .ba-showcase-handle::after {
        width: 36px;
        height: 36px;
        font-size: 12px;
    }

    .ba-showcase-label {
        padding: 4px 10px;
        font-size: 11px;
        top: 8px;
    }

    .ba-showcase-label.before {
        left: 8px;
    }

    .ba-showcase-label.after {
        right: 8px;
    }
}

/* ========================================
   .hba-showcase 호버 효과 비활성화
   드래그만 동작하도록 설정
   ======================================== */

/* 드래그 모드 활성화 시 호버 효과 완전 비활성화 */
.hba-showcase.hba-showcase-drag-enabled {
    cursor: ew-resize;
}

.hba-showcase.hba-showcase-drag-enabled .hba-showcase-after {
    transition: none !important;
}

.hba-showcase.hba-showcase-drag-enabled .hba-showcase-divider {
    transition: none !important;
}

.hba-showcase.hba-showcase-drag-enabled .hba-showcase-handle {
    transition: none !important;
}

/* 호버 시 위치 변경 방지 */
.hba-showcase.hba-showcase-drag-enabled:hover .hba-showcase-after {
    /* clip-path는 JS에서 inline으로 설정 */
    transition: none !important;
}

.hba-showcase.hba-showcase-drag-enabled:hover .hba-showcase-divider {
    /* left는 JS에서 inline으로 설정 */
    transition: none !important;
}

.hba-showcase.hba-showcase-drag-enabled:hover .hba-showcase-handle {
    /* transform 변경 방지 */
    transform: translate(-50%, -50%) !important;
    transition: none !important;
}

/* 드래그 중 커서 */
.hba-showcase.hba-dragging {
    cursor: grabbing !important;
}

.hba-showcase.hba-dragging .hba-showcase-handle {
    transform: translate(-50%, -50%) scale(1.1) !important;
}

/* ========================================
   이미지 비공개 보호 스타일
   블러/모자이크 효과 및 로그인 오버레이
   ======================================== */

/* 비공개 보호 이미지 기본 스타일 */
.ba-image.ba-privacy-protected {
    position: relative;
}

/* 블러 효과 */
.ba-image.ba-privacy-protected.ba-blur-effect .ba-img {
    filter: blur(var(--ba-blur-intensity, 15px));
    transform: scale(1.05); /* 블러 엣지 숨기기 */
}

/* 모자이크 효과 (CSS 기반) */
.ba-image.ba-privacy-protected.ba-mosaic-effect .ba-img {
    filter: blur(0.5px);
    image-rendering: pixelated;
}

/* 모자이크 효과 오버레이 */
.ba-image.ba-privacy-protected.ba-mosaic-effect::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent var(--ba-mosaic-size, 10px),
            rgba(128,128,128,0.1) var(--ba-mosaic-size, 10px),
            rgba(128,128,128,0.1) calc(var(--ba-mosaic-size, 10px) * 2)
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent var(--ba-mosaic-size, 10px),
            rgba(128,128,128,0.1) var(--ba-mosaic-size, 10px),
            rgba(128,128,128,0.1) calc(var(--ba-mosaic-size, 10px) * 2)
        );
    z-index: 1;
    pointer-events: none;
}

/* 비공개 보호 오버레이 */
.ba-privacy-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 25;
    text-align: center;
    padding: 20px;
    background: var(--ba-overlay-bg, rgba(0,0,0,0.6));
    backdrop-filter: blur(2px);
}

.ba-privacy-overlay .ba-privacy-lock {
    font-size: 40px;
    margin-bottom: 12px;
    animation: privacyPulse 2s ease-in-out infinite;
}

@keyframes privacyPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.ba-privacy-overlay .ba-privacy-message {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
    line-height: 1.5;
    max-width: 200px;
}

.ba-privacy-overlay .ba-privacy-login-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.ba-privacy-overlay .ba-privacy-login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

/* 반응형 비공개 보호 스타일 */
@media (max-width: 768px) {
    .ba-privacy-overlay .ba-privacy-lock {
        font-size: 32px;
        margin-bottom: 8px;
    }

    .ba-privacy-overlay .ba-privacy-message {
        font-size: 12px;
        margin-bottom: 12px;
        max-width: 160px;
    }

    .ba-privacy-overlay .ba-privacy-login-btn {
        padding: 10px 18px;
        font-size: 12px;
    }
}

/* 쇼케이스/커스텀 템플릿 비공개 보호 */
.hba-showcase .ba-privacy-protected,
.ba-showcase .ba-privacy-protected {
    position: relative;
}

.hba-showcase .ba-privacy-protected.ba-blur-effect img,
.ba-showcase .ba-privacy-protected.ba-blur-effect img {
    filter: blur(var(--ba-blur-intensity, 15px)) !important;
}

.hba-showcase .ba-privacy-protected.ba-mosaic-effect img,
.ba-showcase .ba-privacy-protected.ba-mosaic-effect img {
    filter: blur(0.5px) !important;
    image-rendering: pixelated !important;
}
