/* ===================================
   云盘系统样式
   =================================== */

:root {
    --pri: #4f46e5;
    --pri-h: #4338ca;
    --pri-l: #eef2ff;
    --dan: #ef4444;
    --dan-h: #dc2626;
    --suc: #10b981;
    --bg: #f8fafc;
    --card: #ffffff;
    --txt: #1e293b;
    --txt2: #64748b;
    --bd: #e2e8f0;
    --r: 12px;
    --sh: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background: var(--bg); color: var(--txt); line-height: 1.6; min-height: 100vh;
    display: flex; flex-direction: column;
}

a { color: var(--pri); text-decoration: none; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; width: 100%; }

/* ====== 导航 ====== */
.navbar { background: var(--card); border-bottom: 1px solid var(--bd); padding: 0 20px; position: sticky; top: 0; z-index: 100; }
.nav-inner { display: flex; justify-content: space-between; align-items: center; height: 60px; }
.nav-brand { font-size: 1.2rem; font-weight: 700; color: var(--txt); display: flex; align-items: center; gap: 6px; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-link { color: var(--txt2); padding: 6px 14px; border-radius: 8px; font-size: 0.9rem; transition: 0.15s; }
.nav-link:hover { background: var(--pri-l); color: var(--pri); }
.nav-link.active { background: var(--pri); color: #fff; }

/* ====== 按钮 ====== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 20px; border: none; border-radius: 8px; font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: 0.15s; text-decoration: none; white-space: nowrap; }
.btn-pri { background: var(--pri); color: #fff; }
.btn-pri:hover { background: var(--pri-h); }
.btn-dan { background: var(--dan); color: #fff; }
.btn-dan:hover { background: var(--dan-h); }
.btn-out { background: transparent; color: var(--pri); border: 1.5px solid var(--bd); }
.btn-out:hover { background: var(--pri-l); border-color: var(--pri); }
.btn-sm { padding: 5px 12px; font-size: 0.82rem; }
.btn-lg { padding: 12px 26px; font-size: 1rem; border-radius: 10px; }
.btn:disabled { opacity: 0.45; pointer-events: none; }

/* ====== 页面头 ====== */
.page-header { text-align: center; padding: 36px 0 24px; }
.page-header h1 { font-size: 1.7rem; font-weight: 700; margin-bottom: 6px; }
.page-header p { color: var(--txt2); }
.announce-bar { background: linear-gradient(135deg, #eef2ff, #e0e7ff); border: 1px solid #c7d2fe; border-radius: 12px; padding: 16px 20px; margin-bottom: 20px; font-size: 0.9rem; line-height: 1.7; color: #3730a3; }
.announce-bar a { color: #4f46e5; font-weight: 500; }

/* ====== 表单 ====== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--txt2); margin-bottom: 4px; }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"] {
    padding: 10px 14px; border: 1.5px solid var(--bd); border-radius: 8px;
    font-size: 0.93rem; outline: none; font-family: inherit; width: 100%; transition: 0.15s;
}
.form-group input:focus { border-color: var(--pri); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }

.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--txt2); cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--pri); }

/* ====== 统计卡片 ====== */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--card); border-radius: var(--r); padding: 18px; text-align: center; box-shadow: var(--sh); }
.stat-value { font-size: 1.7rem; font-weight: 700; color: var(--pri); }
.stat-label { font-size: 0.82rem; color: var(--txt2); margin-top: 2px; }

/* ====== 面包屑 ====== */
.breadcrumb { display: flex; align-items: center; gap: 4px; padding: 8px 0; font-size: 0.88rem; flex-wrap: wrap; margin-bottom: 8px; }
.breadcrumb a { color: var(--pri); }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--txt2); margin: 0 4px; }
.breadcrumb-current { color: var(--txt2); font-weight: 500; }

/* ====== 工具栏 ====== */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar-right { margin-left: auto; }
.toolbar-hint { font-size: 0.8rem; color: var(--txt2); }
.upload-dropdown { position: absolute; top: 100%; right: 0; margin-top: 4px; background: #fff; border: 1px solid var(--bd); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); z-index: 50; min-width: 150px; overflow: hidden; }
.upload-dropdown a { display: block; padding: 10px 16px; font-size: 0.88rem; color: var(--txt); text-decoration: none; transition: 0.1s; }
.upload-dropdown a:hover { background: var(--pri-l); color: var(--pri); }

/* ====== 卡片 ====== */
.section-card { background: var(--card); border-radius: var(--r); padding: 24px; margin-bottom: 24px; box-shadow: var(--sh); }
.section-card h3 { font-size: 1.05rem; margin-bottom: 14px; }

/* ====== 空状态 ====== */
.empty-state { text-align: center; padding: 50px 20px; color: var(--txt2); }
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1.1rem; color: var(--txt); margin-bottom: 6px; }

/* ====== 页脚 ====== */
.footer { margin-top: auto; padding: 16px 0; text-align: center; color: var(--txt2); font-size: 0.8rem; border-top: 1px solid var(--bd); }

/* ====== 认证页 ====== */
.auth-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 20px; background: linear-gradient(135deg, var(--pri-l), #e0e7ff); }
.auth-card { background: var(--card); border-radius: 16px; padding: 36px; width: 100%; max-width: 400px; box-shadow: 0 10px 40px rgba(0,0,0,0.08); }
.auth-card h1 { text-align: center; font-size: 1.7rem; margin-bottom: 4px; }
.auth-card h2 { text-align: center; font-size: 1rem; color: var(--txt2); margin-bottom: 22px; font-weight: 400; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-link { text-align: center; margin-top: 16px; font-size: 0.88rem; color: var(--txt2); }

/* ====== 表格 ====== */
.file-table-wrapper { overflow-x: auto; }
.file-table { width: 100%; border-collapse: collapse; }
.file-table th { text-align: left; padding: 10px 14px; font-size: 0.8rem; color: var(--txt2); font-weight: 600; border-bottom: 2px solid var(--bd); white-space: nowrap; }
.file-table td { padding: 12px 14px; border-bottom: 1px solid var(--bd); font-size: 0.88rem; vertical-align: middle; }
.file-table tbody tr:hover { background: #f8fafc; }
.folder-row { background: #f8fafc; }
.folder-row:hover { background: #eef2ff !important; }
.file-name-cell { display: flex; align-items: center; gap: 8px; min-width: 180px; }
.file-icon-sm { font-size: 1.2rem; flex-shrink: 0; }
.file-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.action-cell { display: flex; gap: 5px; white-space: nowrap; flex-shrink: 0; min-width: 100px; }

/* ====== 文件网格 ====== */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-bottom: 24px; }
.file-card { background: var(--card); border-radius: var(--r); padding: 18px; box-shadow: var(--sh); display: flex; align-items: center; gap: 12px; transition: 0.15s; }
.file-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.file-card .file-icon { font-size: 2rem; flex-shrink: 0; }
.file-card .file-info { flex: 1; min-width: 0; }
.file-card .file-name { font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 3px; }
.file-card .file-meta { font-size: 0.76rem; color: var(--txt2); display: flex; gap: 10px; flex-wrap: wrap; }
.file-card .file-actions { display: flex; flex-direction: column; gap: 5px; flex-shrink: 0; }
.folder-card { cursor: default; }
.folder-link { font-weight: 600; font-size: 0.92rem; color: var(--txt); text-decoration: none; }
.folder-link:hover { color: var(--pri); }

/* ====== Switch 开关 ====== */
.toggle-switch { position: relative; display: inline-block; width: 42px; height: 22px; vertical-align: middle; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #cbd5e1; border-radius: 22px; transition: 0.2s; }
.toggle-slider::before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.toggle-switch input:checked + .toggle-slider { background: var(--suc); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.share-label { margin-left: 6px; font-size: 0.8rem; color: var(--txt2); vertical-align: middle; }

/* ====== 上传 ====== */
.upload-dropzone { border: 2px dashed var(--bd); border-radius: var(--r); padding: 36px 20px; text-align: center; cursor: pointer; transition: 0.15s; }
.upload-dropzone:hover, .upload-dropzone.dragover { border-color: var(--pri); background: var(--pri-l); }
.upload-icon { font-size: 2.2rem; margin-bottom: 8px; }
.upload-hint { font-size: 0.8rem; color: var(--txt2); margin-top: 2px; }
.upload-preview { margin-top: 10px; padding: 10px 14px; background: var(--pri-l); border-radius: 8px; display: flex; justify-content: space-between; align-items: center; font-size: 0.88rem; }

/* ============================================================
   管理后台
   ============================================================ */
.admin-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 10px; flex-wrap: wrap; }

/* Tab 按钮 */
.admin-tabs { display: inline-flex; background: var(--bd); border-radius: 10px; padding: 3px; }
.admin-tab { padding: 9px 24px; border-radius: 8px; font-size: 0.88rem; font-weight: 500; color: var(--txt2); text-decoration: none; transition: 0.15s; display: inline-block; }
.admin-tab.active { background: #fff; color: var(--pri); box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.admin-tab:hover:not(.active) { color: var(--txt); }

/* 设置区块 */
.setting-block { background: var(--card); border-radius: var(--r); padding: 24px 28px; margin-bottom: 18px; box-shadow: var(--sh); }
.setting-block h3 { font-size: 1rem; margin: 0 0 4px; }
.setting-desc { font-size: 0.82rem; color: var(--txt2); margin-bottom: 16px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--bd); gap: 16px; flex-wrap: wrap; }
.setting-row:first-of-type { border-top: none; }
.setting-label { font-weight: 500; font-size: 0.9rem; min-width: 110px; color: var(--txt); }
.setting-control { flex: 1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* 大号开关 */
.big-switch-wrap { display: flex; align-items: center; gap: 10px; }
.big-switch { position: relative; display: inline-block; width: 46px; height: 24px; }
.big-switch input { opacity: 0; width: 0; height: 0; }
.big-switch-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #cbd5e1; border-radius: 24px; transition: 0.2s; }
.big-switch-slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.big-switch input:checked + .big-switch-slider { background: var(--pri); }
.big-switch input:checked + .big-switch-slider::before { transform: translateX(22px); }
.big-switch-hint { font-size: 0.8rem; color: var(--txt2); }

/* 用户卡片选择器 */
.user-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.user-card { border: 2px solid var(--bd); border-radius: 10px; padding: 12px 16px; cursor: pointer; transition: 0.15s; display: flex; align-items: center; gap: 10px; }
.user-card:hover { border-color: var(--pri); background: var(--pri-l); }
.user-card.selected { border-color: var(--pri); background: var(--pri-l); box-shadow: 0 0 0 3px rgba(79,70,229,0.12); }
.user-card input[type="radio"] { display: none; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--pri); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem; flex-shrink: 0; }
.user-info { line-height: 1.3; }
.user-name { font-weight: 600; font-size: 0.9rem; }
.user-meta { font-size: 0.74rem; color: var(--txt2); }
.user-check { margin-left: auto; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--bd); display: flex; align-items: center; justify-content: center; font-size: 10px; color: transparent; transition: 0.15s; flex-shrink: 0; }
.user-card.selected .user-check { border-color: var(--pri); background: var(--pri); color: #fff; }

/* 角色徽章 */
.role-badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 0.76rem; font-weight: 500; }
.role-admin { background: #fef3c7; color: #92400e; }
.role-user { background: #e0e7ff; color: #3730a3; }

/* ============================================================
   弹窗 — 关键修复：用纯 JS 控制，遮罩+卡片分离
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15,23,42,0.5); z-index: 9999;
}
.modal-overlay.show { display: block; }

.modal-card {
    display: none;
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: #fff; border-radius: 14px; padding: 30px; width: 92%;
    max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    z-index: 10000; max-height: 85vh; overflow-y: auto;
}
.modal-card.show { display: block; }
.modal-card.wide { max-width: 520px; }
.modal-card h3 { font-size: 1.1rem; margin-bottom: 18px; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 768px) {
    .stats-row { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .stat-card { padding: 12px 8px; }
    .stat-value { font-size: 1.3rem; }
    .file-grid { grid-template-columns: 1fr; }
    .action-cell { flex-direction: column; }
    .nav-inner { flex-wrap: wrap; height: auto; padding: 8px 0; gap: 6px; }
    .nav-links { flex-wrap: wrap; }
    .setting-row { flex-direction: column; align-items: stretch; }
    .admin-toolbar { flex-direction: column; align-items: stretch; }
    .admin-tabs { width: 100%; }
    .admin-tab { flex: 1; text-align: center; }
}

.msg-ok { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }

/* 上传弹窗 */
.upload-modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 1000; justify-content: center; align-items: center; }
.upload-modal { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: var(--bg); border-radius: 16px; padding: 28px; min-width: 420px; max-width: 560px; z-index: 1001; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.upload-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.upload-toggle button { flex: 1; padding: 10px; border: 2px solid var(--bd); border-radius: 10px; background: transparent; cursor: pointer; font-size: 0.9rem; font-family: inherit; transition: 0.15s; }
.upload-toggle button.active { border-color: var(--pri); background: var(--pri-l); color: var(--pri); font-weight: 600; }
.dropzone { border: 2px dashed var(--bd); border-radius: 12px; padding: 32px 16px; text-align: center; cursor: pointer; transition: 0.15s; min-height: 100px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dropzone.dragover { border-color: var(--pri); background: var(--pri-l); }
.dropzone-icon { font-size: 2rem; margin-bottom: 8px; }
.dropzone-text { color: var(--txt2); font-size: 0.9rem; }
.upload-preview { display: none; flex-direction: column; max-height: 180px; overflow-y: auto; margin-top: 12px; padding: 12px; background: var(--bg2); border-radius: 8px; font-size: 0.85rem; }
.upload-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }
.upload-progress-wrap { display: none; margin-top: 12px; }
.upload-progress-bar { height: 8px; background: var(--bd); border-radius: 4px; overflow: hidden; }
.upload-progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--pri), #818cf8); border-radius: 4px; transition: width 0.2s; }
.upload-progress-text { font-size: 0.8rem; color: var(--txt2); text-align: center; margin-top: 4px; }


/* 操作菜单 */
.action-menu { display: inline-flex; align-items: center; gap: 6px; }
.action-menu-btn { width: 32px; height: 32px; border: 1px solid var(--bd); border-radius: 8px; background: #fff; cursor: pointer; font-size: 1rem; display: flex; align-items: center; justify-content: center; transition: 0.15s; }
.action-menu-btn:hover { border-color: var(--pri); background: var(--pri-l); }
.btn-dl { width: 32px; height: 32px; border: 1px solid var(--bd); border-radius: 8px; background: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--txt); font-size: 0.85rem; transition: 0.15s; padding: 0; }
.btn-dl:hover { border-color: var(--pri); background: var(--pri-l); color: var(--pri); }
.action-dropdown { display: none; position: fixed; background: #fff; border: 1px solid var(--bd); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); z-index: 100; min-width: 140px; padding: 4px 0; }
.action-dropdown.show { display: block; }
.action-dropdown a, .action-dropdown button { display: block; width: 100%; text-align: left; padding: 8px 14px; font-size: 0.85rem; color: var(--txt); background: none; border: none; cursor: pointer; font-family: inherit; text-decoration: none; white-space: nowrap; }
.action-dropdown a:hover, .action-dropdown button:hover { background: var(--pri-l); }
.action-dropdown .danger { color: #dc2626; }
.action-dropdown .danger:hover { background: #fef2f2; }


/* 文件行悬停效果 */
.file-table tr.file-type { cursor: pointer; transition: background 0.12s; }
.file-table tr.file-type:hover { background: var(--pri-l); }
.file-table tr.file-type:hover td:last-child .action-menu-btn { background: #fff; }
.file-table tr.folder-row { cursor: default; }


/* 预览浮窗 */
.preview-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 10000; }
.preview-window { display: none; position: fixed; top: 5%; left: 10%; width: 80%; height: 85%; background: #fff; border-radius: 12px; box-shadow: 0 12px 48px rgba(0,0,0,0.2); z-index: 10001; overflow: hidden; }
.preview-toolbar { display: flex; align-items: center; padding: 8px 12px; background: #f1f5f9; border-bottom: 1px solid var(--bd); flex-shrink: 0; user-select: none; }
.preview-title { font-size: 0.85rem; font-weight: 600; color: var(--txt); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-btn { width: 30px; height: 30px; border: none; background: transparent; border-radius: 6px; cursor: pointer; font-size: 0.9rem; color: var(--txt2); display: flex; align-items: center; justify-content: center; transition: 0.1s; }
.preview-btn:hover { background: var(--pri-l); color: var(--pri); }
.preview-window iframe { flex: 1; border: none; width: 100%; }
.preview-resize { position: absolute; right: 0; bottom: 0; width: 20px; height: 20px; cursor: nwse-resize; }
.preview-window.max { top: 0 !important; left: 0 !important; width: 100% !important; height: 100% !important; border-radius: 0; }


/* 分享面板 */
.share-panel { display: none; position: fixed; top: 10%; left: 50%; transform: translateX(-50%); width: 440px; max-width: 95vw; background: #fff; border-radius: 12px; box-shadow: 0 12px 48px rgba(0,0,0,0.2); z-index: 10001; overflow: hidden; }
.share-body { padding: 20px 24px; }
.share-item-name { font-size: 0.95rem; font-weight: 600; color: var(--txt); margin-bottom: 16px; word-break: break-all; }
.share-body .form-group { margin-bottom: 14px; }
.share-body .form-group label { display: block; font-size: 0.82rem; color: var(--txt2); margin-bottom: 4px; }
.share-body .form-group input,
.share-body .form-group select { width: 100%; padding: 9px 12px; border: 1.5px solid var(--bd); border-radius: 8px; font-size: 0.9rem; font-family: inherit; outline: none; }
.share-body .form-group input:focus,
.share-body .form-group select:focus { border-color: var(--pri); }
#shareUrl { background: var(--pri-l); border-color: var(--pri); }


.btn-share { width: 32px; height: 32px; border: 1px solid var(--bd); border-radius: 8px; background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; transition: 0.15s; padding: 0; color: var(--txt2); }
.btn-share:hover { border-color: #f59e0b; background: #fffbeb; color: #f59e0b; }
.btn-share.active { border-color: #f59e0b; background: #fef3c7; color: #f59e0b; }


.btn-pub { width: 32px; height: 32px; border: 1px solid var(--bd); border-radius: 8px; background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; transition: 0.15s; padding: 0; color: var(--txt2); }
.btn-pub:hover { border-color: #10b981; background: #ecfdf5; color: #10b981; }
.btn-pub.active { border-color: #10b981; background: #d1fae5; color: #10b981; }

