/**
 * 响应式设计样式
 * 支持桌面、平板、手机等不同设备
 */

/* ========================================
   断点定义
   ======================================== */
/* 
  - 手机: < 768px
  - 平板: 768px - 1024px
  - 桌面: > 1024px
*/

/* ========================================
   通用响应式优化
   ======================================== */

/* 确保所有图片和媒体自适应 */
img, video, canvas {
  max-width: 100%;
  height: auto;
}

/* 防止长文本溢出 */
* {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ========================================
   平板设备 (768px - 1024px)
   ======================================== */
@media (max-width: 1024px) {
  /* 侧边栏宽度调整 */
  .sidebar {
    width: 240px;
  }

  /* 主内容区域调整 */
  .main-content {
    padding: 20px;
  }

  /* 视图头部 */
  .view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .view-header h2 {
    font-size: 24px;
  }

  /* 群组网格 */
  .groups-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
  }

  /* 文档网格 */
  .documents-list {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }

  /* 知识库网格 */
  .knowledge-list {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
  }

  /* 备份统计卡片 */
  .backup-stats {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
  }

  /* 设置卡片网格 */
  .settings-cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }

  /* 协作工具标签 */
  .collab-tools-tabs-modern {
    gap: 8px;
  }

  .collab-tab-btn {
    min-width: 100px;
    padding: 12px 16px;
    font-size: 13px;
  }

  /* 模态框 */
  .modal-content {
    width: 85%;
    max-width: 700px;
    padding: 24px;
  }

  /* 任务详情信息网格 */
  .task-detail-info {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* 统计卡片 */
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
  }
}

/* ========================================
   手机设备 (< 768px)
   ======================================== */
@media (max-width: 768px) {
  /* ===== 布局调整 ===== */
  
  /* Dashboard布局改为垂直 */
  .dashboard {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  /* 侧边栏改为顶部导航 */
  .sidebar {
    width: 100%;
    height: auto;
    max-height: none;
    border-right: none;
    border-bottom: 2px solid var(--border);
    padding: 12px;
    overflow-y: visible;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-card);
  }

  /* 侧边栏头部 */
  .sidebar-header {
    margin-bottom: 12px;
  }

  .sidebar-header h2 {
    font-size: 18px;
  }

  /* 用户信息 */
  .user-info {
    padding: 10px;
    margin-bottom: 12px;
  }

  .avatar {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .username {
    font-size: 14px;
  }

  .user-role {
    font-size: 12px;
  }

  /* 导航菜单改为横向滚动 */
  .nav-menu {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .nav-menu::-webkit-scrollbar {
    height: 4px;
  }

  .nav-menu::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-radius: 2px;
  }

  .nav-menu::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 2px;
  }

  .nav-item {
    flex-shrink: 0;
    padding: 10px 14px;
    font-size: 13px;
    white-space: nowrap;
  }

  .nav-item .icon {
    font-size: 16px;
  }

  /* 侧边栏底部 */
  .sidebar-footer {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin-top: 12px;
  }

  .sidebar-footer .nav-item {
    flex: 1;
  }

  /* 退出登录按钮 */
  .btn-logout {
    padding: 10px;
    font-size: 13px;
    margin-top: 8px;
  }

  /* 主内容区域 */
  .main-content {
    padding: 16px;
    height: auto;
    max-height: none;
  }

  /* ===== 视图头部 ===== */
  .view-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 20px;
  }

  .view-header h2 {
    font-size: 22px;
  }

  .view-header button {
    width: 100%;
  }

  /* ===== 网格布局 ===== */
  .groups-grid,
  .documents-list,
  .knowledge-list,
  .files-list {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* ===== 卡片样式 ===== */
  .group-card,
  .document-card,
  .knowledge-card,
  .file-card {
    padding: 16px;
  }

  .group-card h3,
  .document-card h3,
  .knowledge-card h3 {
    font-size: 16px;
  }

  /* ===== 任务列表 ===== */
  .tasks-list {
    gap: 12px;
  }

  .task-card {
    padding: 16px;
  }

  .task-card h3 {
    font-size: 16px;
  }

  .task-meta {
    flex-direction: column;
    gap: 8px;
  }

  .task-actions {
    flex-direction: column;
    gap: 8px;
  }

  .task-actions button {
    width: 100%;
  }

  /* ===== 模态框 ===== */
  .modal {
    padding: 10px;
  }

  .modal-content {
    width: 95%;
    max-width: none;
    padding: 20px;
    max-height: 90vh;
    overflow-y: auto;
  }

  .modal-header h3 {
    font-size: 20px;
  }

  /* ===== 表单 ===== */
  .form-group {
    margin-bottom: 16px;
  }

  .form-group label {
    font-size: 13px;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 10px 12px;
    font-size: 14px;
  }

  /* ===== 按钮 ===== */
  .btn-primary,
  .btn-secondary,
  .btn-danger,
  .btn-success,
  .btn-warning {
    padding: 12px 16px;
    font-size: 14px;
    width: 100%;
  }

  .btn-sm {
    padding: 8px 12px;
    font-size: 12px;
  }

  /* ===== 聊天界面 ===== */
  .chat-container {
    height: calc(100vh - 200px);
    min-height: 400px;
  }

  .messages {
    padding: 12px;
    gap: 12px;
  }

  .message {
    max-width: 85%;
  }

  .message-content {
    padding: 10px 12px;
    font-size: 14px;
  }

  .chat-input {
    padding: 12px;
    gap: 8px;
  }

  .chat-input input {
    padding: 10px 12px;
    font-size: 14px;
  }

  /* ===== 编辑器 ===== */
  .editor-container {
    height: calc(100vh - 250px);
    min-height: 300px;
    padding: 12px;
  }

  .editor-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  #editor {
    padding: 12px;
    font-size: 14px;
  }

  /* ===== 搜索 ===== */
  .search-box {
    flex-direction: column;
    gap: 8px;
  }

  .search-box input,
  .search-box button {
    width: 100%;
  }

  .search-filters {
    flex-direction: column;
    gap: 12px;
  }

  /* ===== 审计日志 ===== */
  .audit-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-number {
    font-size: 24px;
  }

  .audit-header {
    display: none;
  }

  .audit-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
  }

  .audit-row > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
  }

  .audit-row > div::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
  }

  /* ===== 备份管理 ===== */
  .backup-stats {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .backup-header {
    display: none;
  }

  .backup-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
  }

  .backup-row > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .backup-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  /* ===== 设置页面 ===== */
  .settings-cards-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .setting-card {
    padding: 20px;
  }

  .setting-icon {
    font-size: 40px;
  }

  .settings-detail-modern {
    padding: 16px;
  }

  .settings-header-modern {
    padding: 24px 16px;
  }

  .settings-icon-large {
    font-size: 48px;
  }

  .settings-header-modern h2 {
    font-size: 24px;
  }

  .setting-card-detail {
    flex-direction: column;
    text-align: center;
    padding: 16px;
  }

  .setting-card-header {
    flex-direction: column;
    gap: 12px;
  }

  .settings-actions {
    flex-direction: column;
  }

  .btn-primary-large,
  .btn-secondary-large {
    width: 100%;
    justify-content: center;
    padding: 14px 24px;
    font-size: 15px;
  }

  /* ===== 语言选择器 ===== */
  .language-selector-modern {
    grid-template-columns: 1fr;
  }

  .language-card {
    padding: 16px;
  }

  /* ===== 数据统计 ===== */
  .data-stats-cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* ===== AI功能展示 ===== */
  .features-grid {
    grid-template-columns: 1fr;
  }

  /* ===== 帮助中心 ===== */
  .help-sections {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .help-footer {
    flex-direction: column;
    text-align: center;
  }

  .help-footer button {
    width: 100%;
  }

  /* ===== 任务详情 ===== */
  .task-detail-view {
    padding: 20px;
  }

  .task-detail-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .task-detail-header h2 {
    font-size: 20px;
  }

  .task-detail-info {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-value {
    font-size: 24px;
  }

  .members-table-header,
  .members-table-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
  }

  .members-table-header {
    display: none;
  }

  .members-table-row > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  /* ===== 协作工具 ===== */
  .collab-tools-tabs-modern {
    flex-direction: column;
    gap: 8px;
  }

  .collab-tab-btn {
    width: 100%;
    flex-direction: row;
    justify-content: center;
    padding: 12px 16px;
  }

  .tab-icon {
    font-size: 20px;
  }

  .tab-text {
    font-size: 13px;
  }

  /* 白板 */
  .whiteboard-container {
    min-height: 400px;
  }

  .whiteboard-toolbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
  }

  .tool-btn {
    font-size: 12px;
    padding: 8px 12px;
  }

  #whiteboard {
    margin: 12px;
    max-height: 400px;
  }

  #brushSize {
    width: 100%;
  }

  .whiteboard-footer {
    flex-direction: column;
    gap: 12px;
    padding: 12px;
  }

  /* 投票创建器 */
  .poll-creator {
    padding: 16px;
    max-height: calc(100vh - 200px);
  }

  .poll-creator h3 {
    font-size: 20px;
  }

  /* 代码编辑器 */
  .code-editor {
    min-height: 400px;
  }

  .editor-toolbar {
    flex-wrap: wrap;
    padding: 12px;
  }

  #codeEditor {
    padding: 12px;
    font-size: 13px;
  }

  .code-output {
    max-height: 150px;
  }

  /* 思维导图 */
  .mindmap-container {
    min-height: 400px;
  }

  .mindmap-toolbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
  }

  .mindmap-toolbar button {
    font-size: 12px;
    padding: 8px 12px;
  }

  .mindmap-canvas {
    min-height: 300px;
  }

  .mindmap-node {
    min-width: 100px;
    padding: 10px 12px;
    font-size: 13px;
  }

  .mindmap-node.root {
    min-width: 140px;
    padding: 12px 16px;
    font-size: 16px;
  }

  .mindmap-legend {
    font-size: 11px;
    padding: 10px;
  }

  .legend-color {
    width: 16px;
    height: 16px;
  }

  /* ===== 登录页面 ===== */
  .login-container {
    padding: 16px;
  }

  .login-card {
    padding: 24px;
    max-width: 100%;
  }

  .logo {
    font-size: 28px;
  }

  .auth-form {
    gap: 16px;
  }

  /* ===== 随机点名 ===== */
  .call-panel {
    padding: 20px;
  }

  .call-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .call-controls input {
    width: 100%;
  }

  .called-members {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  /* ===== 导出管理 ===== */
  .export-container {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .export-section {
    padding: 14px;
  }

  .export-actions {
    flex-direction: column;
  }

  .export-actions button {
    width: 100%;
  }

  /* ===== 知识库过滤器 ===== */
  .knowledge-filters {
    flex-direction: column;
    gap: 10px;
  }

  .knowledge-filters input,
  .knowledge-filters select {
    width: 100%;
    min-width: auto;
  }

  /* ===== 投票结果 ===== */
  .poll-options-results {
    gap: 10px;
  }

  .poll-option-result {
    padding: 12px;
  }

  .poll-option-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ========================================
   小屏手机 (< 480px)
   ======================================== */
@media (max-width: 480px) {
  /* 进一步优化小屏幕 */
  .main-content {
    padding: 12px;
  }

  .view-header h2 {
    font-size: 20px;
  }

  .modal-content {
    padding: 16px;
  }

  .btn-primary,
  .btn-secondary {
    padding: 10px 12px;
    font-size: 13px;
  }

  .audit-stats,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .called-members {
    grid-template-columns: 1fr;
  }

  .setting-icon {
    font-size: 36px;
  }

  .settings-icon-large {
    font-size: 40px;
  }

  .task-detail-header h2 {
    font-size: 18px;
  }

  .stat-value {
    font-size: 20px;
  }
}

/* ========================================
   横屏模式优化
   ======================================== */
@media (max-width: 768px) and (orientation: landscape) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    max-height: 60px;
    overflow: hidden;
  }

  .sidebar-header,
  .user-info,
  .sidebar-footer {
    display: none;
  }

  .nav-menu {
    margin: 0;
    padding: 8px;
  }

  .main-content {
    margin-top: 60px;
  }

  .chat-container,
  .editor-container {
    height: calc(100vh - 120px);
  }
}

/* ========================================
   触摸设备优化
   ======================================== */
@media (hover: none) and (pointer: coarse) {
  /* 增大可点击区域 */
  .nav-item,
  .btn-primary,
  .btn-secondary,
  button {
    min-height: 44px;
    min-width: 44px;
  }

  /* 移除悬停效果 */
  .nav-item:hover,
  .btn-primary:hover,
  .group-card:hover,
  .document-card:hover {
    transform: none;
  }

  /* 优化滚动 */
  * {
    -webkit-overflow-scrolling: touch;
  }

  /* 禁用双击缩放 */
  * {
    touch-action: manipulation;
  }
}

/* ========================================
   打印样式
   ======================================== */
@media print {
  .sidebar,
  .nav-menu,
  .btn-logout,
  .view-header button,
  .task-actions,
  .modal,
  .whiteboard-toolbar,
  .editor-toolbar,
  .mindmap-toolbar {
    display: none !important;
  }

  .main-content {
    padding: 0;
    max-height: none;
    overflow: visible;
  }

  .dashboard {
    display: block;
  }

  * {
    background: white !important;
    color: black !important;
  }
}

/* ========================================
   高对比度模式
   ======================================== */
@media (prefers-contrast: high) {
  :root {
    --border: #ffffff;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
  }

  .btn-primary,
  .btn-secondary,
  .nav-item {
    border-width: 3px;
  }
}

/* ========================================
   减少动画模式
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

