/* ATI Package Modal - 모달 전용 CSS - 완전 수정된 버전 */

/* ===== 모달 기본 구조 ===== */
.ati-package-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000000;
    display: none;
    opacity: 1;
    transition: opacity 0.3s ease;
    pointer-events: all;
}

.ati-package-modal.show {
    opacity: 1;
    pointer-events: all;
}

.ati-package-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    cursor: pointer;
    z-index: 1000000;
}

.ati-package-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 90vh;
    width: 1000px;
    height: 600px;
    display: flex;
    flex-direction: column;
    z-index: 1000001;
    pointer-events: all;
}

/* ===== 모달 헤더 (선택 버튼 포함) ===== */
.ati-package-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    gap: 8px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    position: relative;
    z-index: 1000001;
    flex-shrink: 0;
}

.ati-package-modal-header h3 {
    margin: 0;
    font-size: 15px;
    line-height: 1.2;
    font-weight: 600;
    color: #333;
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ati-package-modal-header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.ati-package-modal-select {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ati-package-modal-select input {
    transform: scale(1.3);
    accent-color: #007cba;
    margin: 0;
    cursor: pointer;
}

.ati-package-modal-select label {
    font-size: 14px;
    color: #007cba;
    font-weight: 600;
    cursor: pointer;
    margin: 0;
    white-space: nowrap;
}

.ati-package-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #666;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000002;
}

.ati-package-modal-close:hover {
    background: #e9ecef;
    color: #dc3545;
    transform: scale(1.1);
}

/* ===== 통합 모달 컨텐츠 ===== */
.ati-package-modal-unified-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ===== 왼쪽 섹션 - 비디오 영역 ===== */
.ati-package-modal-left-section {
    flex: 0 0 320px;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
}

.ati-package-modal-video {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    margin: 0 !important;
    padding: 0 !important;
    border: none;
    overflow: hidden;
    aspect-ratio: 9/16;
    max-height: 70vh;
}

.ati-package-modal-video video {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: contain;
    display: block;
    margin: 0;
    padding: 0;
    border: none;
}

.ati-package-modal-video-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

.ati-package-modal-video-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    color: #666;
    font-size: 14px;
    text-align: center;
}

.ati-package-modal-video-placeholder .video-icon {
    font-size: 48px;
    margin-bottom: 10px;
    color: #ccc;
}

/* ===== 패키지 정보 ===== */
.ati-package-modal-info {
    flex-shrink: 0;
    padding: 15px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.ati-package-modal-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.ati-package-modal-meta-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 12px;
}

.ati-package-modal-meta-item span:first-child {
    color: #666;
    font-weight: 500;
}

.ati-package-modal-meta-item span:last-child {
    color: #333;
    font-weight: 600;
}

.ati-package-modal-description {
    font-size: 11px;
    color: #007cba;
    line-height: 1.4;
    text-align: center;
}

/* ===== 오른쪽 섹션 - 이미지 영역 ===== */
.ati-package-modal-right-section {
    flex: 1.5;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

.ati-package-modal-right-section h4 {
    padding: 15px 20px 10px 20px;
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    flex-shrink: 0;
}

.ati-package-modal-images-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px 20px;
}

/* ===== 이미지 그리드 개선 - 공간 활용 최적화 ===== */
.ati-package-modal-images-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)) !important;
    gap: 10px;
    padding: 5px 0;
    width: 100%;
}

/* 추가 (기존 블록 유지) */
.ati-package-modal-right-section,
.ati-package-modal-images-container {
    min-width: 0;
}

.ati-package-modal-image-item {
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    aspect-ratio: 9/16;
    border: 2px solid #e9ecef;
    background: #f8f9fa;
    position: relative;
}

.ati-package-modal-image-item:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    border-color: #007cba;
}

.ati-package-modal-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    display: block;
}

.ati-package-modal-image-item:hover img {
    transform: scale(1.05);
}

/* ===== 로딩 상태 ===== */
.ati-package-modal-image-loading {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

.ati-package-modal-image-loading p {
    margin: 0;
    font-size: 14px;
}

/* ===== 스크롤바 스타일 ===== */
.ati-package-modal-images-container::-webkit-scrollbar {
    width: 8px;
}

.ati-package-modal-images-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.ati-package-modal-images-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.ati-package-modal-images-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ===== 이미지 라이트박스 ===== */
.ati-package-image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000000;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.ati-package-image-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.ati-package-lightbox-content {
    position: relative;
    width: min(90vw, 56.25vh);
    aspect-ratio: 9 / 16;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ati-package-lightbox-image {
    width: 100%;
    height: 100%;
    object-fit: contain;    /* 비율 유지, 잘림 없음 */
    object-position: center;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.ati-package-lightbox-close {
    position: absolute !important;
    top: -40px !important;
    right: 0 !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border: none !important;
    color: #333 !important;
    font-size: 24px !important;
    cursor: pointer !important;
    padding: 8px !important;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease !important;
    z-index: 2000003 !important;
}

.ati-package-lightbox-close:hover {
    background: white !important;
    transform: scale(1.1) !important;
}

/* ===== 알림 ===== */
.ati-package-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    padding: 15px 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1000000;
    max-width: 400px;
    border-left: 4px solid #007cba;
    transform: translateX(400px);
    transition: transform 0.3s ease;
}

.ati-package-notification.show {
    transform: translateX(0);
}

.ati-package-notification.success {
    border-left-color: #28a745;
}

.ati-package-notification.error {
    border-left-color: #dc3545;
}

.ati-package-notification.warning {
    border-left-color: #ffc107;
}

/* ===== 반응형 디자인 ===== */
@media (max-width: 1200px) {
    .ati-package-modal-content {
        width: 98vw;
        max-width: 1000px;
    }
    
    .ati-package-modal-left-section {
        flex: 0 0 300px;
    }
}

@media (max-width: 992px) {
    .ati-package-modal-unified-content {
        flex-direction: column;
        min-height: 600px;
    }
    
    .ati-package-modal-left-section {
        flex: 0 0 250px;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .ati-package-modal-right-section {
        flex: 1;
    }
    
    .ati-package-modal-images-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
    }
}

@media (max-width: 768px) {
    .ati-package-modal-content {
        flex-direction: column;
        width: 95vw;
        height: 90vh;
        max-width: none;
        max-height: none;
    }
    
    .ati-package-modal-unified-content {
        flex-direction: column;
        flex: 1;
    }
    
    .ati-package-modal-left-section {
        flex: 0 0 auto;
        width: 100%;
        min-height: 450px;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .ati-package-modal-header {
        padding: 6px 10px;
    }
    
    .ati-package-modal-header h3 {
        font-size: 12px;
        line-height: 1.2;
    }
    
    .ati-package-modal-header-actions {
        gap: 10px;
    }
    
    .ati-package-modal-select label {
        font-size: 13px;
    }
    
    .ati-package-modal-right-section {
        flex: 1;
        width: 100%;
        overflow-y: auto;
    }
    
    .ati-package-modal-images-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 6px;
    }
    
    .ati-package-modal-image-item img {
        border-radius: 4px;
        transition: transform 0.2s ease;
    }
    
    .ati-package-modal-image-item img:active {
        transform: scale(0.95);
    }
    
    .ati-package-lightbox-close {
        top: 20px !important;
        right: 20px !important;
        background: rgba(255, 255, 255, 0.9) !important;
        color: #333 !important;
    }
    
    .ati-package-lightbox-content {
        padding: 60px 20px 20px 20px !important;
    }
    
    .ati-package-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .ati-package-modal-content {
        width: 98vw;
        height: 95vh;
        border-radius: 8px;
    }
    
    .ati-package-modal-left-section {
        min-height: 420px;
    }
    
    .ati-package-modal-header {
        padding: 10px 15px;
    }
    
    .ati-package-modal-header h3 {
        font-size: 15px;
    }
    
    .ati-package-modal-header-actions {
        gap: 8px;
    }
    
    .ati-package-modal-select label {
        font-size: 12px;
    }
    
    .ati-package-modal-images-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 6px;
        padding: 10px;
    }
    
    .ati-package-modal-info {
        padding: 12px;
    }
    
    .ati-package-modal-meta-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* ===== 모달 열렸을 때 body 스크롤 방지 ===== */
body.ati-package-modal-open {
    overflow: hidden;
}

/* ===== 터치 디바이스 최적화 ===== */
.ati-package-modal-content {
    touch-action: pan-y pinch-zoom !important;
}

.ati-package-modal-video {
    touch-action: manipulation !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

@media (hover: none) and (pointer: coarse) {
    .ati-package-modal-video video,
    .ati-package-modal-image-item img {
        user-select: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
        -webkit-user-drag: none;
    }
}

/* ===== 접근성 및 사용성 개선 ===== */
.ati-package-modal button:focus,
.ati-package-modal input:focus,
.ati-package-modal select:focus {
    outline: 2px solid #007cba !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1) !important;
}

/* ===== 애니메이션 감소 옵션 ===== */
@media (prefers-reduced-motion: reduce) {
    .ati-package-modal,
    .ati-package-modal-content,
    .ati-package-modal-close,
    .ati-package-modal-image-item,
    .ati-package-image-lightbox,
    .ati-package-lightbox-close,
    .ati-package-notification {
        transition: none !important;
        animation: none !important;
    }
    
    .ati-package-modal-image-item:hover,
    .ati-package-modal-close:hover,
    .ati-package-lightbox-close:hover {
        transform: none !important;
    }
}

@media (max-width: 768px) {
    #ati-package-modal-title {
        font-size: 12px !important;
        line-height: 1.2 !important;
        font-weight: 600 !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}
