/* ========================================================
 * 모바일 반응형 스타일 (head_style_0018.css에서 이동, 2025-10-02)
 * Phase 2.2e: 모바일 미디어 쿼리 통합 관리
 * ======================================================== */


/* 원본 라인 83-92 (10 라인) */
    @media (min-width: 1920px) {
      .welcome-content {
        max-width: 1800px;  /* ★ 수정: 더 넓게 */
        gap: 20px;
      }
      
      .feature-notice, .trending-widget, .exchange-widget, .stock-widget, .crypto-widget {
        max-width: 950px;  /* ★ 수정: 대형 화면에서 더 넓게 (700px → 950px) */
      }
    }

/* 원본 라인 95-111 (17 라인) */
    @media (min-width: 2560px) {
      .welcome-content {
        max-width: 2200px;
        gap: 24px;
      }
      
      .trending-widget {
        max-width: 850px;
      }
      
      .feature-notice,
      .exchange-widget,
      .stock-widget,
      .crypto-widget {
        max-width: 750px;
      }
    }

/* 원본 라인 114-130 (17 라인) */
    @media (min-width: 3840px) {
      .welcome-content {
        max-width: 3200px;
        gap: 30px;
      }
      
      .trending-widget {
        max-width: 1000px;
      }
      
      .feature-notice,
      .exchange-widget,
      .stock-widget,
      .crypto-widget {
        max-width: 900px;
      }
    }

/* 원본 라인 133-142 (10 라인) */
    @media (max-width: 1600px) {
      .welcome-content {
        flex-direction: column;
        align-items: center;
      }
      
      .feature-notice, .trending-widget, .exchange-widget {
        max-width: 800px;
      }
    }

/* 원본 라인 756-830 (75 라인) */
    @media (max-width: 768px) {
      /* 사이드바는 layout.css에서 transform으로 관리 */

      .main-content {
        width: 100%;
        margin-left: 0 !important;
        --content-offset: 0 !important;
      }
      
      .auth-modal {
        padding: 24px;
        margin: 20px;
      }
      
      .message-content {
        max-width: 90%;
        min-width: 150px;
      }
      
      /* 모바일에서 메시지 액션 버튼 표시 */
      .message-actions {
        display: flex !important;
        opacity: 1 !important;
        gap: 6px;
        margin-top: 6px;
        padding-top: 6px;
      }
      
      .action-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
      }
      
      .response-time {
        font-size: 10px;
        padding: 2px 6px;
      }
      
      /* 입력창 위치는 layout.css에서 제어 */
      
      /* 모바일에서 파일 첨부, 웹검색 버튼 개선 */
/* ========================================================
 * 모바일 파일 업로드 → css/components/input.css로 이동 (2025-10-02)
 * 원본 위치: 라인 970-980 (11 라인)
 * ======================================================== */
      
      .chat-input {
        font-size: 16px; /* iOS 자동 줌 방지 */
        padding: 8px;
      }
      
      .send-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
      }
    }

/* 원본 라인 1083-1109 (27 라인) */
  @media (max-width: 768px) {
    .multi-assistant-page {
      padding: 20px 16px;
    }
    
    .page-title {
      font-size: 24px;
    }
    
    /* 모바일: 1열 그리드 */
    .assistant-grid {
      grid-template-columns: 1fr;
      gap: 16px;
    }
    
    .assistant-card {
      padding: 20px;
    }
    
    .assistant-card .card-icon {
      font-size: 40px;
      margin-bottom: 12px;
    }
    
    .assistant-card .card-title {
      font-size: 18px;
    }
  }

  @media (max-width: 768px) {
    body.multi-assistant-active #header-dropdown,
    body.assistant-active #header-dropdown,
    body.multi-assistant-active #model-selector-btn,
    body.assistant-active #model-selector-btn,
    body.multi-assistant-active #top-left-dropdown,
    body.assistant-active #top-left-dropdown {
      display: none !important;
    }
  }

/* 원본 라인 1122-1132 (11 라인) */
    @media (hover: none) and (pointer: coarse) {
      * {
        -webkit-tap-highlight-color: transparent;
      }
      
      button, .auth-btn, .new-chat-btn, .send-btn {
        -webkit-appearance: none;
        appearance: none;
        touch-action: manipulation;
      }
    }

/* 원본 라인 1236-1800 (565 라인) */
    @media (max-width: 768px) {
      /* 기본 레이아웃 설정 */
      body {
        font-size: var(--mobile-font-base);
        overflow-x: hidden;
        -webkit-text-size-adjust: 100%;
      }
      
      /* 햄버거 메뉴 버튼 표시 */
      .mobile-menu-btn {
        display: flex !important;
        position: fixed !important;
        top: 10px !important;
        left: 10px !important;
        width: 36px !important;
        height: 36px !important;
        font-size: 16px !important;
        z-index: 1000 !important;
      }
      
      /* X 버튼들 숨기기 */
      .modal-close,
      .notification-close {
        display: none !important;
      }
      
      /* 메인 컨테이너 */
      .app-container {
        min-height: 100vh;
        min-height: 100dvh; /* 동적 뷰포트 높이 */
      }
      
      /* 사이드바 최적화 - transform은 layout.css에서 관리 */
      .sidebar {
        width: var(--sidebar-width-desktop) !important;
        padding: 0 !important;
      }
      
      .sidebar-header {
        padding: 8px;
      }
      
      .logo {
        font-size: 14px;
        margin-bottom: 6px;
      }
      
      .user-info {
        padding: 4px 6px;
        margin-bottom: 6px;
        font-size: 11px;
      }
      
      .user-name {
        font-size: 10px;
      }
      
      .user-role {
        font-size: 9px;
      }
      
      .guest-auth-buttons {
        gap: 4px;
        padding: 0 6px;
      }
      
      .auth-btn {
        padding: 6px 12px;
        font-size: 10px;
        min-height: 28px;
        white-space: nowrap;
      }
      
      .new-chat-btn {
        padding: 6px 10px;
        font-size: 11px;
        min-height: 32px;
        margin: 0 6px;
      }
      
      .chat-history {
        display: block; /* 모바일에서도 히스토리 표시 */
        padding: 0 8px; /* 좌우 패딩만 */
        max-height: 200px; /* 최대 높이 제한 */
        overflow-y: auto; /* 스크롤 가능 */
      }
      
      /* 채팅 히스토리 아이템들 컴팩트하게 */
      .chat-history .history-item {
        padding: 6px 8px; /* 패딩 줄임 */
        margin-bottom: 2px; /* 간격 줄임 */
        font-size: 11px; /* 폰트 크기 축소 */
        border-radius: 4px; /* 둥근 모서리 축소 */
      }
      
      .chat-history .history-item:hover {
        background: var(--bg-chat);
      }
      
      .sidebar-footer {
        padding: 8px 12px; /* 패딩 줄임 */
        border-top: 1px solid var(--border-color);
      }
      
      .model-info {
        text-align: center;
        margin-bottom: 6px;
        font-size: 10px; /* 폰트 크기 축소 */
      }
      
      .theme-toggle {
        justify-content: center;
        font-size: 11px; /* 폰트 크기 축소 */
      }
      
      .theme-switch {
        transform: scale(0.8); /* 스위치 크기 축소 */
      }
      
      /* 메인 콘텐츠 컴팩트 최적화 */
      .main-content {
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        padding: 0;
        display: flex;
        flex-direction: column;
      }

      /* 헤더는 layout.css에서 제어 */

      /* 드롭다운 스타일은 layout.css와 dropdown.css에서 제어 */

      /* ★ 수정: 명시도를 높여 input.css 덮어쓰기 */
      .main-content .unified-dropdown-menu {
        position: fixed !important;
        top: 50px !important; /* chat-header 아래 */
        left: 8px !important;
        right: auto !important; /* 왼쪽 정렬 */
        bottom: auto !important;
        min-width: 280px !important;
        max-width: calc(100vw - 16px) !important;
        max-height: calc(100vh - 60px) !important;
      }
      
      .chat-messages {
        flex: 1;
        padding: 64px 12px 12px 12px; /* 상단 헤더 여백 + 좌우 완충 */
        overflow-y: visible !important; /* body 스크롤 사용 (중복 스크롤바 제거) */
        padding-bottom: 120px !important; /* 입력창 공간 확보 */
        -webkit-overflow-scrolling: touch;
        margin-top: 0 !important;
        align-items: stretch !important;
        gap: 12px !important;
      }

      .chat-messages .message {
        width: 100% !important;
        margin: 0 auto 8px auto !important;
        padding: 0 !important;
      }

      .chat-messages .message-content,
      .chat-messages .message-bubble {
        width: 100% !important;
        max-width: 100% !important;
      }

      .message {
        margin-bottom: 8px;
      }

      .message-avatar {
        width: 24px;
        height: 24px;
        font-size: 10px;
      }
      
      .message-bubble {
        padding: 8px 14px;
        font-size: 13px;
        border-radius: 12px;
      }

      .message-text {
        font-size: 13px;
        line-height: 1.4;
      }

      .chat-input-wrapper {
        position: fixed !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        bottom: 12px !important;
        width: calc(100% - 24px) !important;
        max-width: calc(100% - 24px) !important;
        padding: 6px 12px !important;
        gap: 6px !important;
        border-radius: 18px !important;
      }

      .chat-input-wrapper .chat-input {
        min-height: 32px !important;
        max-height: 140px !important;
        padding: 4px 0 !important;
        font-size: 14px !important;
        line-height: 1.45 !important;
      }

      .chat-input-wrapper .file-attach-button,
      .chat-input-wrapper .send-button {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
      }

      /* 입력창 컨테이너는 layout.css에서 제어 */
     
     /* (★중요) 모바일 전용 드롭다운 메뉴 스타일 */
     .mobile-actions-dropdown {
       position: relative;
       display: block !important;
     }
     
     .mobile-dropdown-btn {
       width: 40px !important;
       height: 40px !important;
       border: none;
       background: var(--bg-secondary) !important;
       border-radius: 20px;
       color: var(--text-secondary);
       font-size: 16px;
       display: flex !important;
       align-items: center;
       justify-content: center;
       cursor: pointer;
       border: 1px solid var(--border-color);
     }
     
     .mobile-dropdown-btn:hover {
       background: var(--primary-color) !important;
       color: white;
     }
     
     .mobile-dropdown-menu {
       position: absolute;
       bottom: 50px;
       left: 0;
       background: var(--bg-primary);
       border: 1px solid var(--border-color);
       border-radius: 12px;
       box-shadow: 0 4px 12px rgba(0,0,0,0.15);
       display: none;
       flex-direction: column;
       min-width: 120px;
       z-index: 1001;
       overflow: hidden;
     }
     
     .mobile-dropdown-menu.show {
       display: flex;
     }
     
     .mobile-action-item {
       display: flex;
       align-items: center;
       gap: 8px;
       padding: 12px 16px;
       border: none;
       background: transparent;
       color: var(--text-primary);
       font-size: 14px;
       cursor: pointer;
       text-align: left;
       white-space: nowrap;
     }
     
     .mobile-action-item:hover {
       background: var(--bg-secondary);
     }
     
     .mobile-action-item i {
       width: 16px;
       font-size: 14px;
       color: var(--text-secondary);
     }
     
     /* 모바일 드롭다운 구분선 */
     .mobile-divider {
       height: 1px;
       background: var(--border-color);
       margin: 8px 0;
     }
     
     /* 모바일에서 데스크톱 전용 버튼 숨김 (간소화) */
     .model-selector-container,
     .model-selector-btn,
     #model-selector-btn,
    .chat-input-wrapper .latest-info-btn,
    .chat-input-wrapper .file-upload-btn {
      display: none !important;
    }
      
      
      .send-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        font-size: 18px !important;
        border-radius: 16px;
      }
     
     /* (★중요) 모델 선택 버튼 모바일 최적화 */
     .model-selector-btn {
       padding: 8px 12px !important;
       font-size: 14px !important;
       min-height: 36px !important;
       border-radius: 20px !important;
     }
     
     .model-selector-btn #model-selector-icon {
       font-size: 16px !important;
     }

      /* 패딩은 위에서 이미 표준화됨 (150px) */
      
      /* 파일 미리보기 컴팩트화 */
      .file-preview {
        padding: 4px;
        margin-bottom: 4px;
      }
      
      .file-preview-item {
        padding: 4px;
        font-size: 11px;
      }
      
      .file-preview-item img {
        max-width: 60px;
        max-height: 60px;
      }
      
      /* 모달 모바일 최적화 (2025-10-14 개선) */
      .modal-overlay {
        padding: 16px !important;
        align-items: center !important;
        justify-content: center !important;
      }

      .auth-modal {
        width: 100% !important;
        max-width: 400px !important;
        margin: 0 auto !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
      }
      
      .auth-header {
        padding: 16px 20px 12px;
      }

      .auth-logo {
        font-size: 20px;
        margin-bottom: 6px;
      }

      .auth-title {
        font-size: 18px;
        margin-bottom: 4px;
      }

      .auth-subtitle {
        font-size: 12px;
      }
      
      .auth-form {
        padding: 0 24px 24px;
      }
      
      .form-group {
        margin-bottom: 16px;
      }
      
      .form-label {
        font-size: 14px;
        margin-bottom: 6px;
      }
      
      .form-input {
        padding: 12px 16px;
        font-size: 16px; /* iOS에서 줌 방지 */
      }
      
      .auth-button {
        padding: 14px 24px;
        font-size: 16px;
        min-height: 48px;
      }
      
      /* 알림 시스템 모바일 최적화 */
      .notification {
        top: 72px; /* 햄버거 버튼 아래로 이동 */
        right: -100%;
        left: 16px;
        max-width: none;
        width: calc(100% - 32px);
        display: none; /* 모바일에서는 기본적으로 숨김 */
      }
      
      .notification.show {
        display: block;
        right: 0;
        left: 16px;
      }
      
      /* 모바일에서 알림 닫기 버튼 숨김 */
      .notification-close {
        display: none;
      }
      
      /* 환영 화면 모바일 최적화 */
      .welcome-screen {
        padding: 76px 16px 40px; /* 상단: chat-header(52px) + 여백(24px) */
        text-align: center !important; /* 중앙 정렬 강제 */
        min-height: auto; /* 최소 높이 제거 */
        gap: 12px;
        margin-top: 0 !important;
        display: flex;
        flex-direction: column;
        align-items: center; /* 중앙 정렬 */
        justify-content: flex-start; /* 상단 시작 */
      }

      /* 환영 텍스트 중앙 정렬 */
      .welcome-hero,
      .welcome-greeting {
        text-align: center !important;
        width: 100%;
      }

      .welcome-logo {
        font-size: 42px;
        margin-bottom: 8px;
      }
      
      .welcome-title {
        font-size: 18px;
        margin-bottom: 8px;
      }
      
      .welcome-subtitle {
        font-size: 13px;
        line-height: 1.4;
      }
      
      /* 기능 안내 모바일 최적화 */
      .feature-notice {
        margin: 12px 16px 20px;
        max-width: calc(100% - 32px);
      }
      
      .notice-content {
        padding: 0 16px 16px;
      }
      
      .notice-content p {
        font-size: 13px;
        margin: 6px 0;
      }
      
      .notice-examples {
        padding: 10px;
        margin: 10px 0;
      }
      
      .example-item {
        padding: 5px 8px;
        margin: 3px 0;
        font-size: 12px;
      }
      
      .notice-tip {
        padding: 8px;
        margin-top: 10px !important;
        font-size: 12px;
      }
      
      .trending-widget {
        margin-top: 12px;
        padding: 12px;
        max-width: calc(100% - 32px);
      }
      
      /* 음악 플레이어 모바일 최적화 (★중요) */
/* ========================================================
 * 음악 플레이어 모바일 → css/components/cards.css로 이동 (2025-10-02)
 * 원본 위치: 라인 1917-1972 (56 라인)
 * 메인 스타일: css/music-player.css
 * ======================================================== */
      /* 사용자 드롭다운 모바일 최적화 */
      .user-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 16px 16px 0 0;
        max-height: 50vh;
        overflow-y: auto;
      }
      
      .dropdown-item {
        padding: 16px 20px;
        font-size: 16px;
        min-height: 48px;
        display: flex;
        align-items: center;
        border-bottom: 1px solid var(--border-color);
      }
      
      .dropdown-item:last-child {
        border-bottom: none;
        border-radius: 0 0 16px 16px;
      }
      
      /* 타이핑 인디케이터 모바일 최적화 */
      .typing-indicator {
        margin-bottom: 16px;
      }
      
      .typing-dots {
        padding: 12px 16px;
      }
      
      .dot {
        width: 6px;
        height: 6px;
      }

    }

/* 원본 라인 1802-1862 (61 라인) */
    @media (max-width: 480px) {
      /* 초소형 모바일 기기 */
      .main-content {
        min-height: calc(100vh - 150px);
      }
      
      .sidebar {
        height: 100vh; /* 전체 높이로 복원 */
        max-height: none; /* 최대 높이 제한 제거 */
      }
      
      .sidebar-header {
        padding: 12px;
      }
      
      .logo {
        font-size: 18px;
        margin-bottom: 8px;
      }
      
      .auth-modal {
        max-height: 85vh !important;
        max-width: 360px !important;
      }

      .modal-overlay {
        padding: 12px !important;
        align-items: center !important;
      }
      
      .auth-header {
        padding: 16px 20px 12px;
      }
      
      .auth-form {
        padding: 0 20px 20px;
      }
      
      .form-input {
        padding: 10px 14px;
      }
      
      .auth-button {
        padding: 10px 20px;
        font-size: 15px;
      }
      
      .chat-messages {
        padding: 12px;
      }
      
      .chat-input-container {
        padding: 8px 12px;
      }
      
      .notification {
        top: 12px;
        right: 12px;
        left: 12px;
        padding: 12px;
      }
    }

/* 원본 라인 1865-1882 (18 라인) */
    @media (max-width: 768px) and (orientation: landscape) {
      .main-content {
        min-height: calc(100vh - 120px);
      }
      
      .sidebar {
        height: 100vh; /* 전체 높이로 복원 */
        max-height: none; /* 최대 높이 제한 제거 */
      }
      
      .modal-overlay {
        padding: 16px !important;
        align-items: center !important;
      }

      .auth-modal {
        max-height: 80vh !important;
      }
    }

/* 원본 라인 1896-1915 (20 라인) */
    @media (max-width: 768px) {
      .chat-input:focus {
        /* 키보드 나타날 때 스크롤 */
        position: relative;
      }
      
      /* 키보드 나타날 때 패딩은 표준화된 150px 사용 */
      
      /* 입력창 포커스 시 다른 요소 숨기기 */
      body:has(.chat-input:focus) .chat-header {
        opacity: 0.8;
      }
    }

/* 원본 라인 1918-1942 (25 라인) */
    @media (hover: none) and (pointer: coarse) {
      /* 터치 타겟 최소 크기 */
      button, a, .clickable {
        min-height: 32px;
        min-width: 32px;
      }
      
      /* 호버 효과 제거 */
      *:hover {
        transform: none !important;
      }
      
      /* 터치 피드백 */
      button:active, a:active {
        opacity: 0.8;
        transform: scale(0.96);
      }
      
      /* 스크롤 부드럽게 */
      .chat-messages,
      .sidebar {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
      }
    }

/* 원본 라인 1945-1950 (6 라인) */
    @media (prefers-reduced-motion: reduce) {
      * {
        animation: none !important;
        transition: none !important;
      }
    }

/* 원본 라인 1953-2026 (74 라인) */
    @media (min-width: 769px) {
      /* 사이드바 기본 표시 */
      .sidebar {
        position: relative !important;
        left: 0 !important;
        width: var(--sidebar-width-desktop) !important;
        display: flex !important;
        flex-direction: column !important;
        visibility: visible !important;
        height: 100vh !important;
      }
      
      /* 다크모드 토글 항상 표시 */
      .theme-toggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
      }
      
      /* 파일 첨부 버튼 항상 표시 */
      .file-upload-btn {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
      }
      
      /* 최신 정보 버튼도 표시 */
      .latest-info-btn {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
      }
      
      /* 사이드바 푸터 표시 (★중요) */
      .sidebar-footer {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex-shrink: 0 !important; /* 축소 방지 */
        margin-top: auto !important; /* 하단에 고정 */
        background: var(--bg-primary) !important;
        border-top: 1px solid var(--border-color) !important;
        padding: 16px !important;
      }
      
      /* 채팅 히스토리 높이 제한 */
      .chat-history {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        max-height: calc(100vh - 400px) !important; /* 다른 요소들을 위한 공간 확보 */
      }
      
      /* 입력창 래퍼 정렬 */
      .chat-input-wrapper {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
      }
      
      /* 메인 컨텐츠 조정 */
      .main-content {
        width: calc(100vw - var(--sidebar-current-width)) !important;
      }
      
      /* 채팅 입력창 사이드바 고려 (★중요) */
      .chat-input-container {
        left: var(--sidebar-current-width) !important; /* 사이드바 너비만큼 */
      }
      
      /* 모바일 메뉴 버튼 숨기기 */
      .mobile-menu-btn {
        display: none !important;
      }
    }

/* 원본 라인 2029-2041 (13 라인) */
    @media (prefers-contrast: high) {
      :root {
        --border-color: #000;
        --text-primary: #000;
        --bg-primary: #fff;
      }
      
      [data-theme="dark"] {
        --border-color: #fff;
        --text-primary: #fff;
        --bg-primary: #000;
      }
    }

/* 원본 라인 2115-2129 (15 라인) */
    @media (max-width: 768px) {
      .assistant-options {
        padding: 8px;
        gap: 6px;
      }
      
      .option-button {
        padding: 10px 12px;
        font-size: 13px;
      }
      
      .option-button .option-emoji {
        font-size: 18px;
      }
    }

/* 원본 라인 2208-2230 (23 라인) */
    @media (max-width: 768px) {
      .compact-options {
        padding: 8px;
        gap: 8px;
      }
      
      .option-group {
        gap: 4px;
      }
      
      .compact-btn {
        padding: 5px 10px !important;
        font-size: 12px !important;
        min-height: 28px;
      }
      
      .option-label {
        font-size: 12px;
        display: block;
        width: 100%;
        margin-bottom: 4px;
      }
    }

/* 원본 라인 2678-2688 (11 라인) */
  @media (max-width: 768px) {
    .image-modal-content {
      width: 95%;
      height: 90vh;
      max-height: none;
    }

    .image-modal-header h2 {
      font-size: 18px;
    }

    /* 모바일에서 사이드바 토글 버튼 숨김 */
    .sidebar-toggle-btn,
    .sidebar-expand-btn {
      display: none !important;
    }

    /* 모바일에서 사이드바 접힌 상태 무효화 */
    .sidebar.collapsed {
      margin-left: 0 !important;
    }
  }
