/* ========== CSS 变量与主题 ========== */
:root {
  --bg-primary: #f0f4f8;
  --bg-secondary: #e2e8f0;
  --text-primary: #1a202c;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: rgba(59, 130, 246, 0.1);
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(255, 255, 255, 0.8);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  --input-bg: rgba(255, 255, 255, 0.8);
  --input-border: rgba(0, 0, 0, 0.1);
  --card-hover: rgba(59, 130, 246, 0.08);
  --orb-1: rgba(59, 130, 246, 0.3);
  --orb-2: rgba(139, 92, 246, 0.25);
  --orb-3: rgba(16, 185, 129, 0.2);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --accent: #60a5fa;
  --accent-hover: #3b82f6;
  --accent-light: rgba(96, 165, 250, 0.15);
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --input-bg: rgba(15, 23, 42, 0.6);
  --input-border: rgba(255, 255, 255, 0.1);
  --card-hover: rgba(96, 165, 250, 0.1);
  --orb-1: rgba(59, 130, 246, 0.2);
  --orb-2: rgba(139, 92, 246, 0.15);
  --orb-3: rgba(16, 185, 129, 0.12);
}

/* ========== 基础重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: var(--transition);
  overflow-x: hidden;
}

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

/* ========== 背景装饰 ========== */
.bg-decoration {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--bg-primary);
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: float 20s ease-in-out infinite;
}

.orb-1 { width: 500px; height: 500px; background: var(--orb-1); top: -100px; left: -100px; }
.orb-2 { width: 400px; height: 400px; background: var(--orb-2); bottom: -50px; right: -50px; animation-delay: -7s; }
.orb-3 { width: 350px; height: 350px; background: var(--orb-3); top: 40%; left: 60%; animation-delay: -14s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ========== 毛玻璃效果 ========== */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* ========== 主题切换 ========== */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.theme-toggle:hover { transform: scale(1.1); }

/* ========== 认证页面 ========== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 40px 36px;
  border-radius: var(--radius);
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo {
  font-size: 56px;
  margin-bottom: 12px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.auth-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

/* ========== 表单 ========== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
  text-align: center;
}

/* 密码强度 */
.password-strength {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.strength-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: var(--transition);
  background: var(--danger);
}

.strength-text {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 50px;
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: white;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-hover), #4f46e5); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--input-border);
}
.btn-ghost:hover { background: var(--accent-light); color: var(--accent); }
.btn-ghost.active { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

.btn-block { width: 100%; padding: 14px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }

.btn-loading { display: inline-flex; align-items: center; gap: 8px; }

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-footer {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--input-border);
}

.security-badges {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}

/* ========== 文件管理页面 ========== */
.file-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
}

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

.topbar-logo { font-size: 24px; }

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-center { flex: 1; max-width: 400px; margin: 0 24px; }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  font-size: 14px;
  opacity: 0.5;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--input-border);
  border-radius: 20px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

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

.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-stats {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.toolbar-right {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

/* 上传队列 */
.upload-queue {
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
}

.queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 14px;
}

.upload-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
}

.upload-item-icon { font-size: 24px; }
.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;
}
.upload-item-progress {
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.upload-item-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #10b981);
  border-radius: 2px;
  transition: width 0.3s;
}
.upload-item-status {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 60px;
  text-align: right;
}
.upload-item-status.done { color: var(--success); }
.upload-item-status.error { color: var(--danger); }

/* 文件列表 - 网格视图 */
.file-list.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.file-list.list-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-card {
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
}

.file-list.list-view .file-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
}

.file-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.15);
}

.file-icon {
  font-size: 42px;
  margin-bottom: 10px;
  text-align: center;
}
.file-list.list-view .file-icon { font-size: 32px; margin-bottom: 0; }

.file-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.file-list.list-view .file-name { flex: 1; margin-bottom: 0; }

.file-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}
.file-list.list-view .file-meta { min-width: 150px; }

.file-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: var(--transition);
}
.file-card:hover .file-actions { opacity: 1; }
.file-list.list-view .file-actions { opacity: 1; position: static; }

.file-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: var(--input-bg);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.file-action-btn:hover { background: var(--accent-light); }
.file-action-btn.delete:hover { background: rgba(239, 68, 68, 0.1); }

/* 缩略图 */
.file-thumbnail {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 10px;
}
.file-list.list-view .file-thumbnail {
  width: 48px;
  height: 48px;
  margin-bottom: 0;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  border-radius: var(--radius);
  margin-top: 20px;
}

.empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state h3 { font-size: 20px; margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); font-size: 14px; margin-bottom: 6px; }
.empty-hint { font-size: 12px !important; opacity: 0.7; }

/* 加载状态 */
.loading-state {
  text-align: center;
  padding: 60px 20px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-secondary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

/* ========== 模态框 ========== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  border-radius: var(--radius);
  width: 100%;
  max-width: 700px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-sm { max-width: 400px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--input-border);
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  transition: var(--transition);
}
.modal-close:hover { background: var(--accent-light); color: var(--accent); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-body img {
  max-width: 100%;
  border-radius: 8px;
}

.modal-body pre {
  background: var(--input-bg);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--input-border);
}

.text-warning { color: var(--warning); font-size: 13px; margin-top: 8px; }

/* ========== Toast 通知 ========== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  font-size: 13px;
  font-weight: 500;
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 350px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }

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

.toast.fade-out { animation: fadeOut 0.3s ease forwards; }
@keyframes fadeOut { to { opacity: 0; transform: translateX(20px); } }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; gap: 10px; }
  .topbar-center { order: 3; width: 100%; max-width: 100%; margin: 0; }
  .topbar-title { font-size: 15px; }
  .user-name { display: none; }
  .file-main { padding: 12px; }
  .toolbar { padding: 12px; gap: 10px; }
  .toolbar-stats { display: none; }
  .file-list.grid-view { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .file-card { padding: 12px; }
  .file-icon { font-size: 32px; }
  .auth-container { padding: 28px 20px; }
  .theme-toggle { top: 12px; right: 12px; width: 38px; height: 38px; }
  .modal { max-height: 95vh; }
}

@media (max-width: 480px) {
  .file-list.grid-view { grid-template-columns: repeat(2, 1fr); }
  .file-list.list-view .file-meta { display: none; }
  .security-badges .badge:nth-child(3) { display: none; }
}
