/* 팝업 모달 전용 CSS - 고객 영역에서 Bootstrap 모달이 제대로 표시되도록 */
.modal {
    z-index: 99999 !important;
    background: transparent !important;
    pointer-events: none !important; /* 모달 배경 클릭 비활성화 */
}

.modal-backdrop {
    z-index: 99998 !important;
    background-color: transparent !important;
    opacity: 0 !important;
    pointer-events: none !important; /* 백드롭 클릭 비활성화 */
}

.modal-dialog {
    z-index: 100000 !important;
    margin: 30px auto;
    pointer-events: auto !important; /* 모달 다이얼로그만 클릭 활성화 */
}

.modal-content {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

.modal-body {
    background: transparent !important;
    padding: 0 !important;
}

.modal-footer {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 5px 0 0 0 !important;
    justify-content: center !important;
}

.modal-body img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* 기존 고객 영역 CSS와 충돌 방지 */
.modal * {
    box-sizing: border-box;
}

/* 모달 닫기 상태 표시 */
.modal.hiding {
    pointer-events: none !important;
    opacity: 0.5 !important;
    transition: opacity 0.2s ease !important;
}

/* 탭 팝업 전용 스타일 */
.tab-popup-modal {
    z-index: 999999 !important;
}

.tab-popup-modal .modal-dialog {
    width: 1000px;
    height: 540px;
    max-width: 1000px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    overflow: hidden;
}

.tab-popup-modal .modal-content {
    width: 100%;
    height: 540px;
    border: none;
    background: transparent;
    box-shadow: none;
    position: relative;
    overflow: hidden;
}

.tab-popup-modal .modal-body {
    padding: 0;
    margin: 0;
    height: 470px;
    position: relative;
    overflow: hidden;
}

.tab-popup-modal .tab-content {
    width: 100%;
    height: 470px;
    position: relative;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.tab-popup-modal .tab-slides-container {
    display: flex;
    height: 470px;
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
    /* 너비는 JavaScript에서 동적으로 설정 */
    /* 스와이프 제스처 지원 */
    touch-action: pan-x;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    cursor: grab;
}

.tab-popup-modal .tab-slides-container:active,
.tab-popup-modal .tab-slides-container.dragging {
    cursor: grabbing !important;
}

.tab-popup-modal .tab-slides-container.dragging {
    transition: none !important; /* 드래그 중에는 트랜지션 비활성화 */
}

.tab-popup-modal .tab-pane {
    flex: 0 0 1000px; /* 고정 너비로 설정 */
    width: 1000px;
    height: 470px;
    margin: 0;
    padding: 0;
    position: relative;
}

.tab-popup-modal .tab-pane.active {
    /* 활성 상태는 JavaScript로 관리됨 */
}

.tab-popup-modal .tab-pane img {
    width: 1000px;
    height: 470px;
    object-fit: contain;
    display: block;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    pointer-events: none; /* 이미지 드래그 방지 */
}

/* 클릭 가능한 이미지는 클릭 허용하되 드래그 방지 */
.tab-popup-modal .tab-pane img.popup-image-clickable {
    pointer-events: auto !important; /* 클릭 허용 */
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

.tab-popup-modal .tab-pane .text-content {
    width: 1000px;
    height: 470px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    box-sizing: border-box;
    margin: 0;
}

.tab-popup-modal .tab-pane .text-content-inner {
    text-align: center;
    color: #333;
    max-width: 800px;
}

.tab-popup-modal .tab-pane .text-content h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 24px;
}

.tab-popup-modal .tab-pane .text-content div {
    line-height: 1.8;
    font-size: 16px;
}

/* 탭 네비게이션 스타일 */
.tab-popup-modal .modal-footer {
    background: rgba(255,255,255,0.95);
    border: none;
    padding: 0;
    margin: 0;
    height: 35px;
    display: flex;
    flex-direction: row;
    position: absolute;
    bottom: 35px;
    left: 0;
    right: 0;
    backdrop-filter: blur(5px);
}

.tab-popup-modal .tab-navigation {
    display: flex;
    width: 100%;
    height: 35px;
    margin: 0;
    padding: 0;
}

.tab-popup-modal .tab-btn {
    height: 35px;
    border: none;
    margin: 0;
    padding: 6px 8px;
    border-radius: 0;
    transition: all 0.2s ease;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-popup-modal .tab-btn:not(:last-child) {
    border-right: 1px solid #e0e0e0;
}

.tab-popup-modal .tab-btn:not(.active) {
    background: rgba(255,255,255,0.8);
    color: #666666;
}

.tab-popup-modal .tab-btn.active {
    background: #333333;
    color: #ffffff;
}

.tab-popup-modal .tab-btn:not(.active):hover {
    background: rgba(51,51,51,0.1);
    color: #333333;
}

.tab-popup-modal .tab-btn:first-child {
    border-radius: 0 !important;
}

.tab-popup-modal .tab-btn:last-child {
    border-radius: 0 !important;
}

/* 네비게이션 동그라미 버튼 스타일 */
.tab-popup-modal .dot-navigation {
    display: none;
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    gap: 8px;
    z-index: 1000003;
}

.tab-popup-modal .dot-btn {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
    margin: 0;
}

.tab-popup-modal .dot-btn.active {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.2);
}

.tab-popup-modal .dot-btn:hover {
    background: rgba(255, 255, 255, 0.8);
}

/* 버튼 영역 스타일 */
.tab-popup-modal .popup-buttons {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(2, 2, 2, 0.95);
}

.tab-popup-modal .popup-buttons .btn {
    font-size: 11px;
    padding: 4px 10px; 
    height: 24px;
    line-height: 1;
}

.tab-popup-modal .btn-close {
    top: 15px;
    right: 15px;
    z-index: 1000002;
    background: rgba(0,0,0,0.6);
    border-radius: 50%;
    padding: 8px;
    filter: invert(1);
    width: 32px;
    height: 32px;
    font-size: 12px;
}

.modal-footer > * {
  /* margin: calc(var(--bs-modal-footer-gap) * 0.5) !important; */
  margin: 0 !important;
}

/* 모바일 팝업 전용 스타일 */
@media (max-width: 768px) {
    /* 탭 팝업 모달 크기 조정 - 모바일 비율에 맞게 축소 */
    .tab-popup-modal .modal-dialog {
        width: 90vw !important;
        height: calc(90vw * 1.31) !important; /* 480:630 비율 유지 (1.31:1) */
        max-width: 90vw !important;
        max-height: calc(90vh - 40px) !important; /* 상하 여백 고려 */
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        margin: 0 !important;
        overflow: hidden !important;
    }
    
    .tab-popup-modal .modal-content {
        width: 100% !important;
        height: 100% !important;
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        position: relative !important;
        overflow: hidden !important;
    }
    
    .tab-popup-modal .modal-body {
        padding: 0 !important;
        margin: 0 !important;
        height: calc(100% - 70px) !important; /* 하단 네비게이션/버튼 영역 제외 */
        position: relative !important;
        overflow: hidden !important;
    }
    
    .tab-popup-modal .tab-content {
        width: 100% !important;
        height: 100% !important;
        position: relative !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
    }
    
    .tab-popup-modal .tab-slides-container {
        display: flex !important;
        height: 100% !important;
        transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
        will-change: transform !important;
        /* 모바일 스와이프 제스처 지원 */
        touch-action: pan-x !important;
        user-select: none !important;
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        cursor: grab !important;
    }
    
    .tab-popup-modal .tab-slides-container.dragging {
        transition: none !important;
        cursor: grabbing !important;
    }
    
    .tab-popup-modal .tab-pane {
        flex: 0 0 90vw !important;
        width: 90vw !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        position: relative !important;
    }
    
    .tab-popup-modal .tab-pane img {
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        user-select: none !important;
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        pointer-events: none !important; /* 모바일에서 이미지 드래그 방지 */
    }
    
    /* 모바일에서도 클릭 가능한 이미지는 클릭 허용 */
    .tab-popup-modal .tab-pane img.popup-image-clickable {
        pointer-events: auto !important; /* 모바일에서도 클릭 허용 */
        -webkit-user-drag: none !important;
        -khtml-user-drag: none !important;
        -moz-user-drag: none !important;
        -o-user-drag: none !important;
        user-drag: none !important;
        /* 모바일에서 터치 영역 확대 */
        position: relative;
        z-index: 10;
    }
    
    /* 모바일에서 탭 네비게이션 숨기고 동그라미 네비게이션 표시 */
    .tab-popup-modal .tab-navigation {
        display: none !important;
    }
    
    .tab-popup-modal .dot-navigation {
        display: flex !important;
    }
    
    .tab-popup-modal .modal-footer {
        background: transparent !important;
        backdrop-filter: none !important;
        height: auto !important;
    }
    
    /* 모든 모바일 모달은 화면 경계 내에 유지 */
    .modal-dialog:not(.tab-popup-modal .modal-dialog) {
        max-width: calc(100vw - 40px) !important;
        max-height: calc(100vh - 40px) !important;
        left: clamp(20px, var(--modal-left, 20px), calc(100vw - 120px)) !important;
        top: clamp(20px, var(--modal-top, 20px), calc(100vh - 120px)) !important;
    }
    
    /* 작은 화면 전체 크기 모달 - 마진 적용 */
    .modal-dialog[style*="calc(100vw - 10px)"] {
        margin: 0 !important;
        max-width: calc(100vw - 10px) !important;
        width: calc(100vw - 10px) !important;
        height: calc(100vh - 90px) !important;
        top: 60px !important;
        left: 5px !important;
    }
    
    .modal-dialog[style*="calc(100vw - 10px)"] .modal-content {
        min-height: calc(100vh - 90px) !important;
        width: 100% !important;
        height: 100% !important;
    }
    
    .modal-dialog[style*="calc(100vw - 10px)"] .modal-body {
        flex: 1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .modal-dialog[style*="calc(100vw - 10px)"] .modal-body img {
        max-width: calc(100vw - 20px) !important;
        max-height: calc(100vh - 160px) !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
        background-color: rgba(0,0,0,0.05);
    }
    
    .modal-dialog[style*="calc(100vw - 10px)"] .modal-footer {
        position: absolute !important;
        bottom: 10px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        background: rgba(0,0,0,0.7) !important;
        border-radius: 0 !important;
        padding: 8px 16px !important;
        margin: 0 !important;
        display: flex !important;
        gap: 10px !important;
        flex-wrap: nowrap !important;
        white-space: nowrap !important;
    }
    
    .modal-dialog[style*="calc(100vw - 10px)"] .btn-close {
        width: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
        padding: 10px !important;
        top: 15px !important;
        right: 15px !important;
    }
    
    /* 작은 크기 모달 (미니 모드) - 화면 경계 제한 */
    .modal-dialog[style*="width:100px"] {
        margin: 0 !important;
        max-width: 100px !important;
        width: 100px !important;
        max-height: calc(100vh - 40px) !important;
        overflow: hidden !important;
    }
    
    .modal-dialog[style*="width:100px"] .modal-content {
        min-height: 120px !important;
    }
    
    .modal-dialog[style*="width:100px"] .modal-body img {
        max-width: 100px !important;
        height: auto !important;
        border-radius: 2px !important;
    }
    
    .modal-dialog[style*="width:100px"] .modal-footer {
        font-size: 10px !important;
        margin: 1px 0 0 0 !important;
        display: flex !important;
        gap: 2px !important;
        flex-wrap: nowrap !important;
        justify-content: center !important;
    }
    
    .modal-dialog[style*="width:100px"] .modal-footer .btn {
        font-size: 6px !important;
        padding: 1px 2px !important;
        margin: 0 !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }
    
    .modal-dialog[style*="width:100px"] .btn-close {
        width: 20px !important;
        height: 20px !important;
        font-size: 10px !important;
        padding: 4px !important;
    }
}