/* ═══════════════════════════════════════════════════════════════════════════════
   style.css — R2 云盘 纯原生 CSS 样式表
   亮色主题 | 响应式 | 无任何外部 CDN 依赖
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ─── 1. CSS 自定义属性（主题变量） ───────────────────────────────────────────── */
:root {
  /* 主色 */
  --color-primary: #1a73e8;
  --color-primary-hover: #1557b0;
  --color-primary-light: #e8f0fe;
  --color-primary-text: #ffffff;

  /* 危险色 */
  --color-danger: #d93025;
  --color-danger-hover: #b0261d;
  --color-danger-light: #fce8e6;

  /* 中性色 */
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-border: #e0e0e0;
  --color-border-hover: #c5c5c5;
  --color-text: #202124;
  --color-text-secondary: #5f6368;
  --color-text-hint: #9aa0a6;
  --color-overlay: rgba(0, 0, 0, 0.5);
  --color-drop-overlay: rgba(26, 115, 232, 0.08);

  /* 成功 / 警告 */
  --color-success: #137333;
  --color-success-bg: #e6f4ea;
  --color-warning: #b06000;
  --color-warning-bg: #fef7e0;

  /* 尺寸 */
  --header-height: 56px;
  --sidebar-width: 240px;
  --border-radius: 8px;
  --border-radius-sm: 4px;
  --border-radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.16);

  /* 字体 */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
                 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Cascadia Code', 'JetBrains Mono', 'Fira Code', Consolas,
               'Courier New', monospace;

  /* 过渡 */
  --transition: 0.18s ease;
}

/* ─── 2. Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button { cursor: pointer; font-family: inherit; }
input  { font-family: inherit; }

/* ─── 3. 布局结构 ─────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* 顶部导航栏 */
.header {
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  font-size: 24px;
  line-height: 1;
}

.header-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 主内容区 */
.main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px;
}

/* ─── 4. 面包屑导航 ──────────────────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 16px;
  padding: 8px 0;
}

.breadcrumb-item {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--border-radius-sm);
  border: none;
  background: transparent;
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition);
}

.breadcrumb-item:hover {
  background: var(--color-primary-light);
}

.breadcrumb-item.current {
  color: var(--color-text);
  font-weight: 600;
  pointer-events: none;
}

.breadcrumb-separator {
  color: var(--color-text-hint);
  font-size: 16px;
  user-select: none;
}

/* ─── 5. 工具栏 ──────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-count {
  font-size: 13px;
  color: var(--color-text-secondary);
}

/* ─── 6. 按钮系统 ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--border-radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-text);
  border-color: var(--color-primary);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  box-shadow: 0 2px 6px rgba(26,115,232,0.3);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border-color: var(--color-border);
}
.btn-secondary:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.btn-danger {
  background: var(--color-danger);
  color: #ffffff;
  border-color: var(--color-danger);
}
.btn-danger:hover {
  background: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
  margin-top: 8px;
}

/* 图标按钮 */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-sm);
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  transition: background var(--transition), color var(--transition);
  font-size: 16px;
  position: relative;
}
.btn-icon:hover {
  background: var(--color-bg);
  color: var(--color-text);
}
.btn-icon.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}
.btn-icon-lg {
  width: 40px;
  height: 40px;
  font-size: 18px;
}

/* ─── 7. 表单 / 输入框 ───────────────────────────────────────────────────────── */
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}

.input-group .btn-icon {
  position: absolute;
  right: 6px;
}

.input-group .input {
  padding-right: 44px;
}

.error-text {
  color: var(--color-danger);
  font-size: 12px;
  margin-top: 6px;
}

/* ─── 8. 登录弹窗 ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--color-surface);
  border-radius: var(--border-radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}

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

.login-box {
  text-align: center;
}

.login-icon {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 12px;
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.confirm-message {
  color: var(--color-text-secondary);
  margin-top: 8px;
  line-height: 1.6;
  word-break: break-all;
}

/* spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-left: 6px;
  vertical-align: middle;
}

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

/* ─── 9. 拖拽上传遮罩 ─────────────────────────────────────────────────────────── */
.drop-overlay {
  position: fixed;
  inset: var(--header-height) 0 0 0;
  background: var(--color-drop-overlay);
  border: 3px dashed var(--color-primary);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: fadeIn 0.15s ease;
}

.drop-content {
  text-align: center;
  color: var(--color-primary);
}

.drop-icon {
  font-size: 64px;
  margin-bottom: 12px;
  animation: bounce 0.8s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

.drop-content p {
  font-size: 18px;
  font-weight: 600;
}

/* ─── 10. 上传任务面板 ────────────────────────────────────────────────────────── */
.upload-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.upload-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.upload-panel-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text);
  display: flex;
  align-items: center;
}

.upload-panel-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.upload-list {
  max-height: 220px;
  overflow-y: auto;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  animation: fadeIn 0.15s ease;
}
.upload-item:last-child { border-bottom: none; }

.upload-item-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.upload-item-info {
  flex: 1;
  min-width: 0;
}

.upload-item-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text);
}

.upload-item-meta {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.upload-progress-bar {
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.upload-item-status {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.status-uploading { color: var(--color-primary); }
.status-done      { color: var(--color-success); }
.status-error     { color: var(--color-danger); }
.status-pending   { color: var(--color-text-hint); }

/* ─── 11. 文件列表（表格视图） ──────────────────────────────────────────────── */
.list-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: relative;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
}

.file-table thead tr {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.file-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
}

.file-table th:hover { color: var(--color-text); }
.file-table th.col-actions { cursor: default; }

.sort-icon {
  margin-left: 4px;
  opacity: 0.4;
}

.file-table th.sorted-asc  .sort-icon { opacity: 1; content: '↑'; }
.file-table th.sorted-desc .sort-icon { opacity: 1; content: '↓'; }

.file-table tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition);
}
.file-table tbody tr:last-child { border-bottom: none; }
.file-table tbody tr:hover { background: var(--color-bg); }

.file-table td {
  padding: 10px 16px;
  font-size: 13px;
  vertical-align: middle;
}

.col-name    { width: auto; }
.col-size    { width: 100px; }
.col-date    { width: 160px; }
.col-actions { width: 140px; }

/* 文件名单元格 */
.file-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.file-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.file-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text);
  font-weight: 500;
  max-width: 400px;
}

.file-name-text:hover { color: var(--color-primary); }

.folder-name-text {
  color: var(--color-primary);
  font-weight: 500;
}

.file-size {
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.file-date {
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

/* 操作按钮组 */
.action-group {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}
.file-table tbody tr:hover .action-group { opacity: 1; }

/* ─── 12. 文件列表（网格视图） ──────────────────────────────────────────────── */
.file-grid-view {
  padding: 16px;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 8px 12px;
  border-radius: var(--border-radius);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
              box-shadow var(--transition);
  text-align: center;
  position: relative;
  background: var(--color-surface);
}

.grid-item:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.grid-item-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 8px;
}

.grid-item-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text);
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  max-width: 120px;
}

.grid-item-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition);
}
.grid-item:hover .grid-item-actions { opacity: 1; }

/* ─── 13. 空目录 / 加载中 ─────────────────────────────────────────────────────── */
.empty-hint {
  text-align: center;
  padding: 60px 24px;
}

.empty-icon {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.empty-sub {
  font-size: 13px;
  color: var(--color-text-hint);
}

.loading-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  gap: 16px;
  color: var(--color-text-secondary);
  position: absolute;
  inset: 0;
  background: var(--color-surface);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ─── 14. 文件预览 Modal ──────────────────────────────────────────────────────── */
.preview-container {
  background: var(--color-surface);
  border-radius: var(--border-radius-lg);
  display: flex;
  flex-direction: column;
  width: min(92vw, 960px);
  max-height: 90vh;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUp 0.25s ease;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  gap: 12px;
  flex-wrap: wrap;
}

.preview-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.preview-file-icon { font-size: 28px; flex-shrink: 0; }

.preview-title-wrap { min-width: 0; }

.preview-filename {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.preview-meta {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.preview-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.preview-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a1a;
  min-height: 300px;
}

/* 预览内容样式 */
.preview-body img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  display: block;
}

.preview-body video,
.preview-body audio {
  max-width: 100%;
  max-height: 70vh;
  display: block;
}

.preview-body audio {
  width: min(500px, 90%);
  margin: 40px auto;
}

.preview-text-wrap {
  width: 100%;
  height: 100%;
  background: #1e1e1e;
  overflow: auto;
  text-align: left;
}

.preview-text-wrap pre {
  padding: 24px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: #d4d4d4;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.preview-pdf {
  width: 100%;
  height: 70vh;
  border: none;
}

.preview-unsupported {
  text-align: center;
  padding: 48px 24px;
  color: #9aa0a6;
}

.preview-unsupported .preview-unsupported-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.preview-unsupported p {
  font-size: 15px;
  margin-bottom: 6px;
  color: #9aa0a6;
}

/* ─── 15. Toast 通知 ─────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--border-radius);
  background: var(--color-text);
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.25s ease;
  pointer-events: auto;
  max-width: 320px;
  word-break: break-word;
}

.toast.toast-success { background: #1e7e34; }
.toast.toast-error   { background: #c82333; }
.toast.toast-warning { background: #d39e00; color: #212529; }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}

.toast.removing {
  animation: toastOut 0.2s ease forwards;
}

/* ─── 16. 响应式适配 ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .main { padding: 12px 16px; }
  .header { padding: 0 16px; }
  .header-title { font-size: 16px; }

  .col-date, .col-size { display: none; }
  .col-actions { width: 90px; }

  .file-name-text { max-width: 200px; }
  .preview-filename { max-width: 200px; }

  .toolbar { gap: 8px; }
  .toolbar-left { gap: 6px; }
  .btn { padding: 7px 12px; font-size: 12px; }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }

  .toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }
  .toast { max-width: 100%; }

  .preview-container {
    width: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }

  .modal-box {
    padding: 24px 20px;
  }
}

@media (max-width: 480px) {
  .breadcrumb-item { padding: 4px 6px; font-size: 12px; }
  .action-group { opacity: 1; }
  .grid-item-actions { opacity: 1; }
}

/* ─── 17. 辅助工具类 ─────────────────────────────────────────────────────────── */
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* 滚动条美化（Webkit） */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--color-border-hover); }
