/* 픽메타 - PC 스타일 유지 완벽한 반응형 CSS */

/* ========== 태블릿 (768px - 1024px) ========== */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  .app-container {
    padding: 20px;
  }
  
  .music-grid,
  .games-grid,
  .feed-grid,
  .tools-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
}

/* ========== 모바일 (768px 이하) ========== */
@media screen and (max-width: 768px) {
  
  /* 기본 설정 */
  html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
  }
  
  body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', Roboto, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    padding-top: 60px;
    overflow-x: hidden;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  
  /* 헤더 - PC 스타일 유지 */
  .app-header {
    background: white;
    border-bottom: 1px solid #e9ecef;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    padding: 0 16px;
  }
  
  .header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
  }
  
  /* 로고 섹션 */
  .logo-section {
    display: flex;
    align-items: center;
    min-width: auto;
  }
  
  .logo-section h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #667eea;
    margin: 0;
  }
  
  .tagline {
    display: none;
  }
  
  /* 검색 섹션 - 모바일 숨김 */
  .search-section {
    display: none;
  }
  
  /* 사용자 섹션 */
  .user-section {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  
  .user-avatar {
    width: 32px;
    height: 32px;
  }
  
  /* 메인 컨테이너 */
  .app-container {
    width: 100%;
    padding: 16px;
    max-width: 100%;
    margin: 0 auto;
  }
  
  /* AI 검색 섹션 - PC 디자인 유지 */
  #aiSearchSection {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 24px 20px;
    margin-bottom: 24px;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
    animation: fadeIn 0.5s ease;
  }
  
  #aiSearchSection h2 {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }
  
  #aiSearchSection .search-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  
  #aiSearchSection input {
    width: 100%;
    height: 48px;
    padding: 0 20px;
    font-size: 16px;
    border: none;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
  }
  
  #aiSearchSection input:focus {
    outline: none;
    background: white;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  }
  
  #aiSearchSection button {
    width: 100%;
    height: 48px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    border: none;
    border-radius: 24px;
    box-shadow: 0 4px 15px rgba(238, 90, 111, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
  }
  
  #aiSearchSection button:active {
    transform: scale(0.98);
  }
  
  /* 탭 네비게이션 - PC 스타일 */
  .tab-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 5px;
    scrollbar-width: thin;
  }
  
  .tab-nav::-webkit-scrollbar {
    height: 4px;
  }
  
  .tab-nav::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
  }
  
  .tab-nav::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 2px;
  }
  
  .tab-btn {
    flex-shrink: 0;
    padding: 10px 20px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
  }
  
  .tab-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  }
  
  /* 그리드 레이아웃 - 모바일 최적화 */
  .music-grid,
  .games-grid,
  .feed-grid,
  .tools-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 0;
  }
  
  /* 카드 스타일 - PC 디자인 유지 */
  .card,
  .music-card,
  .game-card,
  .feed-card,
  .ai-tool-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    animation: slideUp 0.4s ease;
  }
  
  .card:active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  }
  
  /* 카드 내용 */
  .card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
  }
  
  .card p {
    font-size: 14px;
    line-height: 1.6;
    color: #666;
    margin-bottom: 16px;
  }
  
  /* 카드 이미지 */
  .card img,
  .card-image {
    width: 100%;
    height: auto;
    border-radius: 10px;
    margin-bottom: 16px;
    object-fit: cover;
  }
  
  /* 버튼 스타일 */
  .card button,
  .btn,
  .button {
    display: inline-block;
    padding: 10px 20px;
    margin: 4px 4px 4px 0;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
  }
  
  .card button:active {
    transform: scale(0.95);
  }
  
  /* 특별 카드 스타일 */
  .music-card {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
  }
  
  .music-card h3,
  .music-card p {
    color: white;
  }
  
  .music-controls {
    display: flex;
    justify-content: space-around;
    margin-top: 16px;
  }
  
  .music-controls button {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
  }
  
  /* 게임 카드 */
  .game-card {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
  }
  
  .game-card h3,
  .game-card p {
    color: white;
  }
  
  /* 피드 카드 */
  .feed-card {
    border-left: 4px solid #667eea;
  }
  
  .feed-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #999;
    margin-top: 12px;
  }
  
  /* AI 도구 카드 */
  .ai-tool-card {
    background: linear-gradient(135deg, #fa709a, #fee140);
  }
  
  .ai-tool-card h3 {
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  }
  
  /* 플로팅 버튼 */
  .fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    font-size: 24px;
    cursor: pointer;
    z-index: 999;
    transition: all 0.3s ease;
  }
  
  .fab:active {
    transform: scale(0.9);
  }
  
  /* 모달 */
  .modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    backdrop-filter: blur(5px);
  }
  
  .modal-content {
    background: white;
    border-radius: 20px;
    padding: 24px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
  }
  
  /* 폼 요소 */
  input,
  textarea,
  select {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    transition: border-color 0.3s ease;
    margin-bottom: 16px;
  }
  
  input:focus,
  textarea:focus,
  select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  }
  
  /* 로딩 상태 */
  .loading {
    text-align: center;
    padding: 40px;
  }
  
  .loading::after {
    content: '';
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid #667eea;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
  }
  
  /* 토스트 메시지 */
  .toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    z-index: 9999;
    animation: slideUp 0.3s ease;
  }
  
  /* 반응형 텍스트 */
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.1rem; }
  p { font-size: 14px; }
  
  /* 숨김 요소 */
  .desktop-only,
  .hide-mobile {
    display: none !important;
  }
  
  .mobile-only {
    display: block !important;
  }
}

/* ========== 가로 모드 최적화 ========== */
@media screen and (max-width: 768px) and (orientation: landscape) {
  
  body {
    padding-top: 50px;
  }
  
  .app-header {
    height: 100px;
  }
  
  .logo-section h1 {
    font-size: 1.1rem;
  }
  
  /* 2열 그리드 */
  .music-grid,
  .games-grid,
  .feed-grid,
  .tools-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  /* AI 검색 섹션 가로 배치 */
  #aiSearchSection {
    padding: 20px;
  }
  
  #aiSearchSection h2 {
    font-size: 1.3rem;
    margin-bottom: 16px;
  }
  
  #aiSearchSection .search-wrapper {
    flex-direction: row;
  }
  
  #aiSearchSection input {
    flex: 1;
  }
  
  #aiSearchSection button {
    width: auto;
    padding: 0 32px;
  }
}

/* ========== 작은 화면 (iPhone SE 등) ========== */
@media screen and (max-width: 375px) {
  
  .app-container {
    padding: 12px;
  }
  
  #aiSearchSection {
    padding: 20px 16px;
  }
  
  #aiSearchSection h2 {
    font-size: 1.3rem;
  }
  
  .card {
    padding: 16px;
  }
  
  .tab-btn {
    padding: 8px 16px;
    font-size: 13px;
  }
  
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.2rem; }
  h3 { font-size: 1rem; }
}

/* ========== 애니메이션 ========== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ========== 터치 최적화 ========== */
@media (hover: none) and (pointer: coarse) {
  
  /* 터치 타겟 크기 */
  button,
  .btn,
  .tab-btn,
  a {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* 호버 효과 제거 */
  .card:hover,
  button:hover,
  .tab-btn:hover {
    transform: none;
  }
  
  /* 터치 피드백 */
  .card:active,
  button:active,
  .tab-btn:active {
    opacity: 0.9;
  }
}

/* ========== 스크롤 보장 ========== */
@media screen and (max-width: 768px) {
  html,
  body {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  .app-container,
  .tab-content,
  .tab-pane {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
}

/* 사이드바 기본 스타일 */
.category-sidebar {
  width: 280px;
  height: 100%;
  position: fixed;
  top: 60px;
  left: 0;
  background: white;
  border-right: 1px solid #e5e8eb;
  overflow-y: auto;
  z-index: 99;
}

.category-sidebar.active {
  transform: translateX(0);
}

/* 모바일 오버레이 */
.mobile-sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 98;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-sidebar-overlay.active {
  display: block;
  opacity: 1;
}

@media (min-width: 769px) {
  .app-container {
    padding-left: 0;
  }
  
  .category-sidebar {
    left: 0;
    transform: none;
  }
  
  .mobile-menu-btn {
    display: none;
  }
}