/* 
VIKO Academy TOPIK Platform - Mobile Stylesheet
Version: 4.0.0
Description: 모바일 특화 반응형 스타일
*/

/* ========================================
   📱 모바일 특화 변수
   ======================================== */
@media (max-width: 768px) {
  :root {
    /* 모바일 헤더 높이 조정 */
    --header-height: 60px;
    
    /* 모바일 터치 타겟 크기 */
    --touch-target: 44px;
    
    /* 모바일 간격 조정 */
    --mobile-padding: 1rem;
    --mobile-margin: 0.75rem;
    
    /* 모바일 폰트 크기 */
    --mobile-font-base: 14px;
    --mobile-font-large: 16px;
    
    /* 모바일 애니메이션 */
    --mobile-transition: 0.2s ease-out;
  }
}

/* ========================================
   📱 모바일 기본 설정
   ======================================== */
@media (max-width: 768px) {
  html {
    font-size: var(--mobile-font-base);
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
  }
  
  body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  
  /* 모바일 스크롤 개선 */
  * {
    -webkit-overflow-scrolling: touch;
  }
}

/* ========================================
   📱 모바일 네비게이션
   ======================================== */
@media (max-width: 768px) {
  /* 모바일 헤더 */
  .topik-header {
    height: var(--header-height);
    padding: 0;
  }
  
  .header-container {
    padding: 0 1rem;
  }
  
  /* 모바일 로고 */
  .logo {
    font-size: 1.125rem;
  }
  
  .logo-icon {
    width: 36px;
    height: 36px;
    font-size: 1.125rem;
  }
  
  /* 모바일 메뉴 토글 */
  .mobile-menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: var(--touch-target);
    height: var(--touch-target);
    padding: 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    z-index: calc(var(--z-fixed) + 1);
  }
  
  .mobile-menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--gray-700);
    border-radius: 1px;
    transition: var(--mobile-transition);
    transform-origin: center;
  }
  
  /* 햄버거 메뉴 애니메이션 */
  .mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
  }
  
  .mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
  }
  
  .mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
  }
  
  /* 데스크톱 네비게이션 숨김 */
  .nav-menu {
    display: none;
  }
  
  /* 모바일 사이드바 */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: white;
    z-index: var(--z-modal);
    transform: translateX(-100%);
    transition: transform var(--mobile-transition);
    box-shadow: none;
    border-right: none;
  }
  
  .sidebar.show {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }
  
  /* 모바일 사이드바 오버레이 */
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-modal) - 1);
    opacity: 0;
    visibility: hidden;
    transition: var(--mobile-transition);
  }
  
  .sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
  }
  
  /* 모바일 사이드바 헤더 */
  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
    height: var(--header-height);
  }
  
  .sidebar-logo {
    font-weight: 600;
    color: var(--gray-900);
  }
  
  .sidebar-close {
    width: var(--touch-target);
    height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--gray-500);
    font-size: 1.25rem;
    cursor: pointer;
  }
  
  /* 모바일 사이드바 콘텐츠 */
  .sidebar-content {
    padding: 1rem;
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
  }
  
  .sidebar-link {
    padding: 1rem;
    min-height: var(--touch-target);
    font-size: var(--mobile-font-large);
  }
  
  .sidebar-link .icon {
    font-size: 1.25rem;
  }
}

/* ========================================
   📱 모바일 컨테이너 및 레이아웃
   ======================================== */
@media (max-width: 768px) {
  .container {
    padding: 0 var(--mobile-padding);
  }
  
  .container-fluid {
    padding: 0 var(--mobile-padding);
  }
  
  /* 모바일 그리드 시스템 */
  .row {
    margin: 0 -0.5rem;
  }
  
  .col {
    padding: 0 0.5rem;
  }
  
  /* 모바일에서 모든 컬럼을 풀 위드로 */
  .col-1, .col-2, .col-3, .col-4, 
  .col-6, .col-8, .col-9 {
    flex: 0 0 100%;
    max-width: 100%;
    margin-bottom: var(--mobile-margin);
  }
  
  .col-12 {
    margin-bottom: var(--mobile-margin);
  }
}

/* ========================================
   📱 모바일 카드 컴포넌트
   ======================================== */
@media (max-width: 768px) {
  .card {
    margin-bottom: var(--mobile-margin);
    border-radius: var(--border-radius);
  }
  
  .card-header {
    padding: var(--mobile-padding);
  }
  
  .card-body {
    padding: var(--mobile-padding);
  }
  
  .card-footer {
    padding: 0.75rem var(--mobile-padding);
  }
  
  .card-title {
    font-size: 1.125rem;
    line-height: 1.3;
  }
  
  /* 모바일 코스 카드 */
  .course-card {
    margin-bottom: 1.5rem;
  }
  
  .course-info {
    padding: var(--mobile-padding);
  }
  
  .course-title {
    font-size: 1rem;
    line-height: 1.4;
  }
  
  .course-description {
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
  }
  
  .course-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.8125rem;
  }
  
  .course-badge {
    top: 0.75rem;
    right: 0.75rem;
    font-size: 0.6875rem;
    padding: 0.25rem 0.5rem;
  }
}

/* ========================================
   📱 모바일 버튼
   ======================================== */
@media (max-width: 768px) {
  .btn {
    min-height: var(--touch-target);
    padding: 0.875rem 1.25rem;
    font-size: var(--mobile-font-large);
    border-radius: var(--border-radius);
  }
  
  .btn-sm {
    min-height: 36px;
    padding: 0.5rem 1rem;
    font-size: var(--mobile-font-base);
  }
  
  .btn-lg {
    min-height: 52px;
    padding: 1rem 2rem;
    font-size: 1.125rem;
  }
  
  .btn-block {
    width: 100%;
    margin-bottom: var(--mobile-margin);
  }
  
  /* 모바일 버튼 그룹 */
  .btn-group-mobile {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .btn-group-mobile .btn {
    width: 100%;
  }
}

/* ========================================
   📱 모바일 폼
   ======================================== */
@media (max-width: 768px) {
  .form-group {
    margin-bottom: 1.25rem;
  }
  
  .form-label {
    font-size: var(--mobile-font-large);
    margin-bottom: 0.5rem;
  }
  
  .form-input,
  .form-select,
  .form-textarea {
    min-height: var(--touch-target);
    padding: 0.875rem;
    font-size: var(--mobile-font-large);
    border-radius: var(--border-radius);
  }
  
  .form-textarea {
    min-height: 120px;
    resize: vertical;
  }
  
  /* 모바일 입력 포커스 개선 */
  .form-input:focus,
  .form-select:focus,
  .form-textarea:focus {
    transform: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
  }
}

/* ========================================
   📱 모바일 모달
   ======================================== */
@media (max-width: 768px) {
  .modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    border-radius: 0;
    transform: translateY(100%);
  }
  
  .modal.show {
    transform: translateY(0);
  }
  
  /* 모바일 모달 헤더 */
  .modal-header {
    padding: var(--mobile-padding);
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
    border-bottom: 1px solid var(--gray-200);
  }
  
  .modal-title {
    font-size: 1.125rem;
  }
  
  .modal-close {
    width: var(--touch-target);
    height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* 모바일 모달 바디 */
  .modal-body {
    padding: var(--mobile-padding);
    overflow-y: auto;
    max-height: none;
    flex: 1;
  }
  
  /* 모바일 모달 푸터 */
  .modal-footer {
    padding: var(--mobile-padding);
    flex-direction: column;
    gap: 0.75rem;
    position: sticky;
    bottom: 0;
    background: white;
    border-top: 1px solid var(--gray-200);
  }
  
  .modal-footer .btn {
    width: 100%;
  }
}

/* ========================================
   📱 모바일 토스트 알림
   ======================================== */
@media (max-width: 768px) {
  .toast-container {
    position: fixed;
    bottom: 1rem;
    left: var(--mobile-padding);
    right: var(--mobile-padding);
    top: auto;
    max-width: none;
  }
  
  .toast {
    margin-bottom: 0.75rem;
    padding: var(--mobile-padding);
    border-radius: var(--border-radius);
    transform: translateY(100%);
  }
  
  .toast.show {
    transform: translateY(0);
  }
  
  .toast-content {
    flex: 1;
  }
  
  .toast-title {
    font-size: var(--mobile-font-large);
  }
  
  .toast-message {
    font-size: var(--mobile-font-base);
  }
  
  .toast-close {
    width: var(--touch-target);
    height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ========================================
   📱 모바일 언어 전환
   ======================================== */
@media (max-width: 768px) {
  .language-switcher {
    width: 100%;
  }
  
  .language-toggle {
    width: 100%;
    padding: 0.875rem;
    justify-content: space-between;
    min-height: var(--touch-target);
    font-size: var(--mobile-font-large);
  }
  
  .language-dropdown {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 300px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
  }
  
  .language-option {
    padding: 1rem;
    min-height: var(--touch-target);
    font-size: var(--mobile-font-large);
  }
  
  .language-flag {
    width: 24px;
    height: 18px;
  }
}

/* ========================================
   📱 모바일 진도 표시
   ======================================== */
@media (max-width: 768px) {
  .progress {
    height: 6px;
    margin-bottom: 0.75rem;
  }
  
  .progress-text {
    font-size: var(--mobile-font-base);
    margin-top: 0.5rem;
  }
  
  /* 모바일 원형 진도 */
  .progress-circle {
    width: 60px;
    height: 60px;
  }
  
  .progress-circle .progress-value {
    font-size: 0.875rem;
  }
}

/* ========================================
   📱 모바일 강의실
   ======================================== */
@media (max-width: 768px) {
  .classroom-container {
    margin-top: var(--header-height);
  }
  
  .classroom-content {
    margin-left: 0;
    padding: var(--mobile-padding);
  }
  
  /* 모바일 비디오 플레이어 */
  .video-container {
    margin-bottom: 1.5rem;
    border-radius: var(--border-radius);
  }
  
  .video-placeholder {
    aspect-ratio: 16/9;
    font-size: 1rem;
    padding: 2rem 1rem;
    text-align: center;
  }
  
  /* 모바일 채팅 */
  .chat-container {
    height: 300px;
    margin-bottom: 1.5rem;
  }
  
  .chat-messages {
    padding: 0.75rem;
  }
  
  .chat-message {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    font-size: var(--mobile-font-base);
    line-height: 1.4;
  }
  
  .chat-message.user {
    margin-left: 1rem;
  }
  
  .chat-input-container {
    padding: 0.75rem;
    gap: 0.5rem;
  }
  
  .chat-input {
    padding: 0.75rem;
    min-height: var(--touch-target);
    font-size: var(--mobile-font-large);
  }
}

/* ========================================
   📱 모바일 테이블
   ======================================== */
@media (max-width: 768px) {
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .table {
    min-width: 600px;
  }
  
  .table th,
  .table td {
    padding: 0.75rem 0.5rem;
    font-size: var(--mobile-font-base);
  }
  
  /* 모바일 카드형 테이블 */
  .table-mobile {
    display: block;
  }
  
  .table-mobile thead {
    display: none;
  }
  
  .table-mobile tbody {
    display: block;
  }
  
  .table-mobile tr {
    display: block;
    background: white;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    padding: var(--mobile-padding);
  }
  
  .table-mobile td {
    display: block;
    text-align: left;
    padding: 0.5rem 0;
    border: none;
  }
  
  .table-mobile td:before {
    content: attr(data-label) ": ";
    font-weight: 600;
    color: var(--gray-600);
  }
}

/* ========================================
   📱 모바일 아코디언
   ======================================== */
@media (max-width: 768px) {
  .accordion-item {
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    overflow: hidden;
  }
  
  .accordion-header {
    padding: var(--mobile-padding);
    background: var(--gray-50);
    cursor: pointer;
    user-select: none;
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  
  .accordion-title {
    font-weight: 500;
    font-size: var(--mobile-font-large);
  }
  
  .accordion-icon {
    transition: transform var(--mobile-transition);
  }
  
  .accordion-item.active .accordion-icon {
    transform: rotate(180deg);
  }
  
  .accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--mobile-transition);
  }
  
  .accordion-item.active .accordion-content {
    max-height: 500px;
  }
  
  .accordion-body {
    padding: var(--mobile-padding);
  }
}

/* ========================================
   📱 모바일 탭
   ======================================== */
@media (max-width: 768px) {
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .tab-nav {
    display: flex;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
    min-width: max-content;
  }
  
  .tab-nav-item {
    padding: 1rem 1.5rem;
    color: var(--gray-600);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: var(--mobile-transition);
    font-size: var(--mobile-font-large);
    min-width: 120px;
    text-align: center;
  }
  
  .tab-nav-item.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
  }
  
  .tab-content {
    padding: var(--mobile-padding);
  }
}

/* ========================================
   📱 모바일 스와이프 제스처
   ======================================== */
@media (max-width: 768px) {
  .swipe-container {
    overflow: hidden;
    touch-action: pan-y;
  }
  
  .swipe-wrapper {
    display: flex;
    transition: transform var(--mobile-transition);
  }
  
  .swipe-slide {
    flex-shrink: 0;
    width: 100%;
  }
  
  /* 스와이프 인디케이터 */
  .swipe-pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
  }
  
  .swipe-bullet {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray-300);
    cursor: pointer;
    transition: var(--mobile-transition);
  }
  
  .swipe-bullet.active {
    background: var(--primary-color);
  }
}

/* ========================================
   📱 모바일 풀업 메뉴
   ======================================== */
@media (max-width: 768px) {
  .pullup-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    box-shadow: var(--shadow-xl);
    z-index: var(--z-modal);
    transform: translateY(100%);
    transition: transform var(--mobile-transition);
    max-height: 80vh;
    overflow: hidden;
  }
  
  .pullup-menu.show {
    transform: translateY(0);
  }
  
  .pullup-handle {
    width: 40px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
    margin: 0.75rem auto;
  }
  
  .pullup-header {
    padding: 0 var(--mobile-padding) var(--mobile-padding);
    border-bottom: 1px solid var(--gray-200);
  }
  
  .pullup-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
  }
  
  .pullup-content {
    padding: var(--mobile-padding);
    overflow-y: auto;
    max-height: calc(80vh - 100px);
  }
}

/* ========================================
   📱 모바일 플로팅 액션 버튼
   ======================================== */
@media (max-width: 768px) {
  .fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: var(--z-fixed);
    transition: var(--mobile-transition);
  }
  
  .fab:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
  }
  
  .fab:active {
    transform: scale(0.95);
  }
}

/* ========================================
   📱 모바일 스크롤 개선
   ======================================== */
@media (max-width: 768px) {
  /* 관성 스크롤 */
  .scroll-smooth {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
  
  /* 수평 스크롤 숨김 */
  .scroll-hide::-webkit-scrollbar {
    display: none;
  }
  
  .scroll-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  
  /* 스크롤 페이드 효과 */
  .scroll-fade {
    mask-image: linear-gradient(to right, transparent, black 20px, black calc(100% - 20px), transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 20px, black calc(100% - 20px), transparent);
  }
}

/* ========================================
   📱 모바일 터치 피드백
   ======================================== */
@media (max-width: 768px) {
  /* 터치 피드백 */
  .touch-feedback {
    position: relative;
    overflow: hidden;
  }
  
  .touch-feedback::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
  }
  
  .touch-feedback:active::before {
    width: 200px;
    height: 200px;
  }
  
  /* 터치 불가능한 요소 */
  .no-touch {
    pointer-events: none;
    user-select: none;
  }
  
  /* 터치 영역 확장 */
  .touch-target {
    position: relative;
  }
  
  .touch-target::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
  }
}

/* ========================================
   📱 모바일 성능 최적화
   ======================================== */
@media (max-width: 768px) {
  /* 하드웨어 가속 */
  .gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
  }
  
  /* 애니메이션 최적화 */
  .animate-optimized {
    backface-visibility: hidden;
    perspective: 1000px;
  }
  
  /* 이미지 로딩 최적화 */
  img {
    max-width: 100%;
    height: auto;
  }
  
  .lazy-load {
    opacity: 0;
    transition: opacity 0.3s;
  }
  
  .lazy-load.loaded {
    opacity: 1;
  }
}

/* ========================================
   📱 모바일 접근성 개선
   ======================================== */
@media (max-width: 768px) {
  /* 포커스 표시 개선 */
  *:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
  }
  
  /* 고대비 모드 지원 */
  @media (prefers-contrast: high) {
    .btn {
      border-width: 2px;
    }
    
    .card {
      border: 1px solid var(--gray-400);
    }
  }
  
  /* 모션 감소 설정 */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
  
  /* 화면 판독기 전용 텍스트 */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

/* ========================================
   📱 모바일 디버그 도우미 (개발 중에만 사용)
   ======================================== */
@media (max-width: 768px) {
  .debug-mobile {
    position: fixed;
    top: var(--header-height);
    left: 0;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    padding: 0.5rem;
    font-size: 0.75rem;
    z-index: 9999;
    display: none;
  }
  
  /* 개발 모드에서만 표시 */
  body.debug .debug-mobile {
    display: block;
  }
}

/* ========================================
   📱 다크 모드 모바일 지원
   ======================================== */
@media (max-width: 768px) and (prefers-color-scheme: dark) {
  /* 다크 모드 모바일 스타일 준비 */
  .topik-header {
    background: rgba(17, 24, 39, 0.95);
    border-bottom-color: rgba(75, 85, 99, 0.3);
  }
  
  .sidebar {
    background: var(--gray-900);
    border-right-color: var(--gray-700);
  }
  
  .card {
    background: var(--gray-800);
    color: var(--gray-100);
  }
  
  .modal {
    background: var(--gray-800);
    color: var(--gray-100);
  }
}