/* ===== WebSpace 全局样式 ===== */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #dbeafe;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --bg: #f1f5f9;
  --card-bg: rgba(255, 255, 255, 0.85);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
  --radius: 12px;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--bg);
  min-height: 100vh;
}

body {
  background: linear-gradient(135deg, #e0e7ff 0%, #f0f9ff 50%, #faf5ff 100%);
  background-attachment: fixed;
}

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

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ===== 通用组件 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border: none; border-radius: 8px; font-size: 14px;
  font-weight: 500; cursor: pointer; transition: all 0.2s;
  background: var(--primary); color: white;
}
.btn:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn:disabled { background: var(--gray-300); cursor: not-allowed; transform: none; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-ghost { background: transparent; color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #059669; }
.btn-warning { background: var(--warning); }
.btn-warning:hover { background: #d97706; }

.card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  background: white;
  transition: border 0.2s, box-shadow 0.2s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.textarea { resize: vertical; min-height: 80px; }

label { display: block; font-size: 13px; color: var(--gray-700); margin-bottom: 6px; font-weight: 500; }

.alert {
  padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px;
  border-left: 4px solid;
}
.alert-info { background: #eff6ff; color: #1e40af; border-color: var(--primary); }
.alert-success { background: #ecfdf5; color: #065f46; border-color: var(--success); }
.alert-warning { background: #fffbeb; color: #92400e; border-color: var(--warning); }
.alert-danger { background: #fef2f2; color: #991b1b; border-color: var(--danger); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 500; line-height: 1.5;
}
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--gray-200); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-mask {
  position: fixed; inset: 0; background: rgba(255,255,255,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}

/* ===== 表格 ===== */
.table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
.table th { background: var(--gray-50); color: var(--gray-700); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--gray-50); }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== 分页 ===== */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 16px; }
.pagination button { padding: 6px 10px; border: 1px solid var(--gray-200); background: white; border-radius: 6px; cursor: pointer; }
.pagination button:hover:not(:disabled) { background: var(--gray-50); }
.pagination button:disabled { background: var(--primary); color: white; border-color: var(--primary); cursor: default; }
.pagination .info { font-size: 12px; color: var(--gray-500); margin: 0 8px; }

/* ===== 模态框 ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: white; border-radius: 12px; padding: 24px;
  width: 90%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2); animation: slideUp 0.2s;
}
.modal-lg { max-width: 720px; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-size: 17px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--gray-400); cursor: pointer; padding: 0; line-height: 1; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ===== 安全横幅 ===== */
.security-banner {
  padding: 8px 16px; text-align: center; font-size: 13px;
  border-bottom: 2px solid; font-weight: 500;
}
.security-banner-danger {
  background: #fee2e2; color: #991b1b; border-bottom-color: #ef4444;
}
.security-banner-warn {
  background: #fef3c7; color: #92400e; border-bottom-color: #f59e0b;
}
.security-banner-info {
  background: #dbeafe; color: #1e40af; border-bottom-color: #3b82f6;
}

/* ===== 登录页 ===== */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: rgba(255,255,255,0.95); backdrop-filter: blur(20px);
  border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.login-logo { text-align: center; margin-bottom: 8px; }
.login-logo-icon { display: inline-block; width: 56px; height: 56px; line-height: 56px;
                   background: linear-gradient(135deg, #3b82f6, #2563eb);
                   color: white; font-size: 28px; font-weight: bold; border-radius: 14px; }
.login-title { text-align: center; font-size: 22px; font-weight: 600; margin: 12px 0 4px; }
.login-sub { text-align: center; color: var(--gray-500); font-size: 13px; margin-bottom: 24px; }
.login-form .form-group { margin-bottom: 14px; }
.login-form .btn { width: 100%; padding: 11px; font-size: 15px; }
.login-footer { text-align: center; margin-top: 16px; font-size: 12px; color: var(--gray-400); }

/* ===== 应用布局 ===== */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: rgba(255,255,255,0.9);
  backdrop-filter: blur(10px); border-right: 1px solid var(--gray-200);
  display: flex; flex-direction: column;
}
.sidebar-header { padding: 18px 20px; border-bottom: 1px solid var(--gray-100); }
.sidebar-logo { font-size: 17px; font-weight: 600; color: var(--primary-dark); display: flex; align-items: center; gap: 8px; }
.sidebar-logo-icon { width: 30px; height: 30px; line-height: 30px; text-align: center;
                     background: linear-gradient(135deg, #3b82f6, #2563eb); color: white;
                     border-radius: 8px; font-size: 14px; font-weight: bold; }
.sidebar-nav { flex: 1; padding: 12px 8px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  border-radius: 8px; color: var(--gray-700); font-size: 14px;
  margin-bottom: 2px; transition: all 0.15s; cursor: pointer;
}
.sidebar-link:hover { background: var(--gray-100); color: var(--primary); }
.sidebar-link.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 500; }
.sidebar-link-icon { font-size: 16px; width: 18px; text-align: center; }
.sidebar-footer { padding: 12px 20px; border-top: 1px solid var(--gray-100); font-size: 12px; color: var(--gray-500); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; background: rgba(255,255,255,0.9);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
}
.topbar-title { font-size: 15px; font-weight: 500; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.topbar-user-name { color: var(--gray-700); }

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

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 20px; font-weight: 600; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .input, .toolbar .select { width: auto; }

/* ===== 用户端布局 ===== */
.user-layout { display: flex; min-height: 100vh; gap: 16px; padding: 16px; }
.user-side {
  width: 280px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px;
}
.user-main { flex: 1; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.user-topbar { display: flex; align-items: center; justify-content: space-between; }

.upload-area {
  border: 2px dashed var(--gray-300); border-radius: 12px; padding: 32px;
  text-align: center; background: rgba(255,255,255,0.5);
  transition: all 0.2s; cursor: pointer;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--primary); background: var(--primary-light);
}
.upload-area-icon { font-size: 36px; color: var(--gray-400); margin-bottom: 8px; }
.upload-area-text { color: var(--gray-600); margin-bottom: 4px; }
.upload-area-hint { color: var(--gray-400); font-size: 12px; }

.upload-list { margin-top: 12px; }
.upload-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: var(--gray-50); border-radius: 6px; margin-bottom: 4px; font-size: 12px;
}
.upload-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item-status { font-size: 11px; }
.upload-item-bar { flex: 1; height: 4px; background: var(--gray-200); border-radius: 2px; overflow: hidden; }
.upload-item-bar-fill { height: 100%; background: var(--primary); transition: width 0.2s; }

.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 13px; }
.breadcrumb a { color: var(--gray-500); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--gray-300); }
.breadcrumb .current { color: var(--gray-800); font-weight: 500; }

.file-list { background: white; border-radius: 12px; overflow: hidden; }
.file-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-bottom: 1px solid var(--gray-100); transition: background 0.15s;
}
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--gray-50); }
.file-item.selected { background: var(--primary-light); }
.file-icon { font-size: 20px; width: 28px; text-align: center; flex-shrink: 0; }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name a { color: var(--gray-800); }
.file-size { color: var(--gray-500); font-size: 12px; width: 70px; text-align: right; flex-shrink: 0; }
.file-time { color: var(--gray-400); font-size: 12px; width: 120px; flex-shrink: 0; }
.file-actions { display: flex; gap: 4px; flex-shrink: 0; }

.empty-state { padding: 60px 20px; text-align: center; color: var(--gray-400); }
.empty-state-icon { font-size: 48px; margin-bottom: 8px; opacity: 0.5; }
.empty-state-text { font-size: 14px; }

/* 配额环 */
.quota-ring { display: flex; flex-direction: column; align-items: center; padding: 16px 0; }
.quota-ring svg { width: 140px; height: 140px; }
.quota-ring-text { margin-top: -86px; text-align: center; }
.quota-ring-used { font-size: 20px; font-weight: 600; color: var(--gray-800); }
.quota-ring-total { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.quota-ring-label { font-size: 12px; color: var(--gray-500); margin-top: 6px; }

.expiry-info {
  text-align: center; padding: 8px 0;
  font-size: 13px;
}
.expiry-info .label { color: var(--gray-500); }
.expiry-info .value { font-weight: 600; margin-left: 4px; }
.expiry-normal .value { color: var(--gray-700); }
.expiry-warning { background: #fffbeb; padding: 8px; border-radius: 6px; }
.expiry-warning .value { color: var(--warning); }
.expiry-expired { background: #fef2f2; padding: 8px; border-radius: 6px; }
.expiry-expired .value { color: var(--danger); }

/* 移动端 */
.mobile-menu-btn { display: none; background: none; border: none; font-size: 20px; padding: 4px; }

@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--gray-200); }
  .sidebar.collapsed .sidebar-nav { display: none; }
  .sidebar.collapsed { width: auto; }
  .sidebar.collapsed .sidebar-header { padding: 12px 16px; }
  .sidebar.collapsed .sidebar-footer { display: none; }
  .mobile-menu-btn { display: inline-block; }
  .user-layout { flex-direction: column; padding: 8px; gap: 8px; }
  .user-side { width: 100%; }
  .table { font-size: 12px; }
  .table th, .table td { padding: 8px 6px; }
  .file-item { padding: 8px 10px; }
  .file-time { display: none; }
  .file-size { width: 60px; }
  .table-card-view { display: block; }
  .table-card-view .table thead { display: none; }
  .table-card-view .table tr { display: block; padding: 12px; border-bottom: 1px solid var(--gray-100); }
  .table-card-view .table td { display: flex; justify-content: space-between; padding: 4px 0; border: none; }
  .table-card-view .table td::before { content: attr(data-label); font-weight: 600; color: var(--gray-500); }
}

/* Toast 通知 */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: white; padding: 10px 16px; border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15); border-left: 4px solid;
  animation: slideIn 0.3s; min-width: 240px; font-size: 13px;
}
.toast-success { border-color: var(--success); color: #065f46; }
.toast-error { border-color: var(--danger); color: #991b1b; }
.toast-info { border-color: var(--primary); color: #1e40af; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
