/* ===============================================
   모바일 최적화 CSS - 터치 인터페이스 및 반응형 개선
=============================================== */

/* 기본 터치 인터페이스 최적화 */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

button, .clickable, .search-button, .filter-toggle, .sidebar-item {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
    cursor: pointer;
}

/* 스크롤 성능 개선 */
body, .sidebar-navigation, .results-table-container {
    -webkit-overflow-scrolling: touch;
}

/* ===============================================
   모바일 브레이크포인트별 최적화
=============================================== */

/* 태블릿 (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .container {
        padding: 16px;
    }
    
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

/* 데스크톱 (1025px 이상) - 3개씩 */
@media (min-width: 1025px) {
    .results-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 25px;
    }
}

/* 모바일 (최대 768px) */
@media (max-width: 768px) {
    /* 기본 레이아웃 */
    body {
        -webkit-overflow-scrolling: touch;
        font-size: 16px; /* iOS 줌 방지 */
    }
    
    .container {
        padding: 12px;
    }
    
    /* 사이드바 터치 최적화 */
    .sidebar-navigation {
        width: 100%;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar-navigation.open {
        transform: translateX(0);
    }
    
    .sidebar-item {
        min-height: 48px;
        padding: 14px 16px;
        font-size: 16px;
    }
    
    /* 검색 섹션 모바일 최적화 */
    .search-box {
        flex-direction: column;
        gap: 12px;
    }
    
    .search-input {
        width: 100%;
        min-height: 48px;
        font-size: 16px; /* iOS 줌 방지 */
        padding: 12px 16px;
        border-radius: 12px;
    }
    
    .search-button, .filter-toggle {
        width: 100%;
        min-height: 48px;
        font-size: 16px;
        padding: 14px 20px;
        border-radius: 12px;
    }
    
    /* 고급 필터 모바일 최적화 */
    .advanced-filters {
        padding: 20px 16px;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
    }
    
    .filter-row {
        flex-direction: column;
        gap: 16px;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-group input,
    .filter-group select {
        width: 100%;
        min-height: 44px;
        font-size: 16px; /* iOS 줌 방지 */
        padding: 12px 16px;
        border-radius: 8px;
        border: 2px solid #e1e8ed;
        transition: border-color 0.3s ease;
    }
    
    .filter-group input:focus,
    .filter-group select:focus {
        outline: none;
        border-color: #6366f1;
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    }
    
    /* 결과 그리드 모바일 최적화 */
    .results-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .video-card {
        padding: 16px;
        border-radius: 12px;
        background: white;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    /* 테이블 모바일 최적화 */
    .results-table-container {
        position: relative;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
        margin: 16px 0;
    }
    
    .results-table {
        min-width: 800px; /* 최소 너비 보장 */
        white-space: nowrap;
    }
    
    .results-table th,
    .results-table td {
        min-width: 100px;
        padding: 12px 8px;
        font-size: 14px;
    }
    
    /* 테이블 스크롤 힌트 */
    .results-table-container::after {
        content: '← 좌우로 스크롤하세요';
        position: absolute;
        bottom: -25px;
        right: 0;
        font-size: 12px;
        color: #666;
        opacity: 0.8;
        pointer-events: none;
    }
    
    /* 페이지네이션 모바일 최적화 */
    .pagination-controls {
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }
    
    .pagination-btn {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 16px;
        border-radius: 8px;
    }
    
    .pagination-numbers {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .pagination-num {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
    }
    
    /* 모달 모바일 최적화 */
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 20px auto;
        border-radius: 12px;
    }
    
    .modal-header h3 {
        font-size: 18px;
        line-height: 1.4;
    }
    
    .modal-close {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* 작은 모바일 (최대 480px) */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }
    
    /* 더 작은 화면에서 터치 영역 확대 */
    .search-button, .filter-toggle {
        min-height: 52px;
        padding: 16px 24px;
        font-size: 18px;
    }
    
    .sidebar-item {
        min-height: 52px;
        padding: 16px 20px;
        font-size: 18px;
    }
    
    /* 텍스트 크기 조정 */
    .content-title {
        font-size: 24px;
        line-height: 1.2;
    }
    
    .content-subtitle {
        font-size: 16px;
        line-height: 1.4;
    }
    
    /* 비디오 카드 최적화 */
    .video-card {
        padding: 12px;
    }
    
    .video-title {
        font-size: 16px;
        line-height: 1.3;
        margin-bottom: 8px;
    }
    
    /* 통계 그리드 최적화 */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stat-item {
        padding: 16px;
        text-align: center;
    }
}

/* ===============================================
   고대비 모드 및 접근성 개선
=============================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: high) {
    .search-input,
    .filter-group input,
    .filter-group select {
        border-width: 3px;
        border-color: #000;
    }
    
    .search-button,
    .filter-toggle,
    .sidebar-item {
        border: 2px solid #000;
        font-weight: bold;
    }
}

/* ===============================================
   다크모드 터치 최적화 (선택적)
=============================================== */

@media (prefers-color-scheme: dark) {
    .search-input,
    .filter-group input,
    .filter-group select {
        background-color: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    .advanced-filters {
        background: rgba(31, 41, 55, 0.95);
        color: #f9fafb;
    }
    
    .results-table-container::after {
        color: #9ca3af;
    }
}

/* ===============================================
   성능 최적화
=============================================== */

/* 이미지 지연 로딩 스타일 */
.lazy-image {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy-image.loaded {
    opacity: 1;
}

/* 스크롤 성능 최적화 */
.smooth-scroll {
    scroll-behavior: smooth;
}

/* GPU 가속 활성화 */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}