/* ============================================================
   PHP 云盘 前端样式
   ============================================================ */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --success: #16a34a;
    --warning: #d97706;
    --bg: #f5f7fa;
    --panel: #ffffff;
    --border: #e5e7eb;
    --text: #1f2937;
    --text-2: #6b7280;
    --text-3: #9ca3af;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.05);
    --shadow-lg: 0 8px 30px rgba(0,0,0,.16);
    --sidebar-w: 220px;
    --tree-w: 210px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
input[type=text], input[type=password], input[type=number], select, textarea {
    width: 100%; padding: 8px 12px;
    border: 1px solid var(--border); border-radius: 8px;
    background: #fff; color: var(--text); outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
input:disabled { background: #f3f4f6; color: var(--text-3); }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; border: 1px solid transparent; border-radius: 8px;
    background: var(--panel); color: var(--text); cursor: pointer;
    transition: all .15s; white-space: nowrap; font-weight: 500;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: #f3f4f6; }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border: none; border-radius: 8px;
    background: transparent; color: var(--text-2); cursor: pointer; font-size: 15px;
    transition: background .15s;
}
.icon-btn:hover { background: #eef1f5; color: var(--text); }
.icon-btn.active { background: var(--primary-light); color: var(--primary); }

/* ---------- 布局 ---------- */
.app-body { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    background: var(--panel); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; padding: 16px 12px;
}
.sidebar-logo {
    display: flex; align-items: center; gap: 8px;
    font-size: 18px; font-weight: 700; padding: 4px 8px 18px;
}
.logo-icon { font-size: 22px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px; color: var(--text-2);
    font-weight: 500; cursor: pointer; transition: all .15s;
}
.nav-item:hover { background: #f3f4f6; color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-light); color: var(--primary); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-user {
    border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px;
}
.user-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.badge-admin {
    font-size: 11px; background: var(--primary-light); color: var(--primary);
    padding: 1px 6px; border-radius: 4px; font-weight: 500;
}
.logout-link { font-size: 12px; color: var(--text-3); margin-top: 4px; display: inline-block; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 58px; background: var(--panel); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px; gap: 16px; flex-shrink: 0;
}
.page-title { font-size: 17px; font-weight: 700; }
.page-subtitle { font-size: 13px; color: var(--text-3); margin-left: 8px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.search-box { position: relative; }
.search-box input { width: 240px; padding-left: 34px; border-radius: 20px; }
.search-box::before {
    content: "🔍"; position: absolute; left: 10px; top: 50%;
    transform: translateY(-50%); font-size: 13px; opacity: .7;
}

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

/* ---------- 主页布局 ---------- */
.home-layout { display: flex; gap: 16px; height: 100%; }
.tree-panel {
    width: var(--tree-w); flex-shrink: 0; background: var(--panel);
    border: 1px solid var(--border); border-radius: var(--radius);
    display: flex; flex-direction: column; overflow: hidden;
}
.tree-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px; border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.tree-body { flex: 1; overflow: auto; padding: 8px 6px; }
.tree-node { padding: 4px 0; }
.tree-row {
    display: flex; align-items: center; gap: 4px; padding: 5px 8px;
    border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text-2);
}
.tree-row:hover { background: #f3f4f6; }
.tree-row.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }
.tree-caret { width: 16px; text-align: center; font-size: 10px; color: var(--text-3); flex-shrink: 0; }
.tree-children { margin-left: 18px; display: none; }
.tree-children.open { display: block; }

.file-panel {
    flex: 1; background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); display: flex; flex-direction: column;
    min-width: 0; position: relative; overflow: hidden;
}
.file-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; border-bottom: 1px solid var(--border); gap: 10px; flex-wrap: wrap;
}
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    padding: 5px 12px; border-radius: 16px; border: 1px solid var(--border);
    background: #fff; color: var(--text-2); cursor: pointer; font-size: 13px;
    transition: all .15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.view-switch { display: flex; gap: 2px; }

.breadcrumb { display: flex; align-items: center; gap: 4px; padding: 8px 14px; flex-wrap: wrap; }
.crumb { color: var(--text-2); cursor: pointer; padding: 3px 6px; border-radius: 6px; font-size: 13px; }
.crumb:hover { background: #f3f4f6; color: var(--primary); }
.crumb-sep { color: var(--text-3); font-size: 12px; }
.crumb.current { color: var(--text); font-weight: 600; }

.selection-bar {
    display: flex; align-items: center; gap: 10px; padding: 8px 14px;
    background: var(--primary-light); border-bottom: 1px solid #dbeafe;
    font-size: 13px;
}

/* ---------- 文件列表 ---------- */
.file-list { flex: 1; overflow: auto; padding: 12px; }
.grid-view { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.file-card {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 10px; cursor: pointer; text-align: center;
    transition: all .15s; position: relative; background: #fff;
}
.file-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.file-card.selected { border-color: var(--primary); background: var(--primary-light); }
.file-card-icon { font-size: 38px; line-height: 1.2; }
.file-card-name {
    font-size: 13px; margin-top: 8px; word-break: break-all;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.file-card-meta { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.file-card-check {
    position: absolute; top: 8px; right: 8px; width: 18px; height: 18px;
    border: 2px solid var(--border); border-radius: 50%; background: #fff;
    display: none; align-items: center; justify-content: center;
    font-size: 11px; color: #fff;
}
.file-card.selected .file-card-check { display: flex; background: var(--primary); border-color: var(--primary); }

.list-view { display: flex; flex-direction: column; }
.list-row {
    display: flex; align-items: center; gap: 12px; padding: 8px 12px;
    border-bottom: 1px solid #f3f4f6; cursor: pointer; border-radius: 8px;
}
.list-row:hover { background: #f9fafb; }
.list-row.selected { background: var(--primary-light); }
.list-row-icon { font-size: 20px; width: 28px; text-align: center; flex-shrink: 0; }
.list-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row-meta { color: var(--text-3); font-size: 12px; width: 90px; text-align: right; flex-shrink: 0; }
.list-row-time { color: var(--text-3); font-size: 12px; width: 130px; text-align: right; flex-shrink: 0; }

.empty-tip { text-align: center; color: var(--text-3); padding: 60px 0; font-size: 14px; }
.empty-emoji { font-size: 46px; display: block; margin-bottom: 10px; }

/* ---------- 上传面板 ---------- */
.upload-panel {
    position: fixed; right: 14px; bottom: 14px; width: 360px; max-width: calc(100vw - 28px); max-height: 320px;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); display: flex; flex-direction: column; z-index: 30;
}
/* 右下角上传任务角标（点击展开进度面板，不自动弹窗） */
.upload-badge {
    position: fixed; right: 14px; bottom: 14px; z-index: 31;
    display: none; align-items: center; gap: 6px;
    padding: 8px 14px; background: var(--primary); color: #fff;
    border-radius: 999px; font-size: 13px; cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
}
.upload-badge:hover { opacity: .9; }
.upload-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600;
}
.upload-tasks { overflow: auto; padding: 8px 14px; }
.upload-task { padding: 8px 0; border-bottom: 1px solid #f3f4f6; }
.upload-task:last-child { border-bottom: none; }
.upload-task-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.upload-task-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-task-status { font-size: 12px; color: var(--text-3); flex-shrink: 0; }
.upload-progress { height: 6px; background: #eef1f5; border-radius: 4px; margin-top: 6px; overflow: hidden; }
.upload-progress-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width .2s; }
.upload-task-actions { margin-top: 6px; display: flex; gap: 6px; }
.upload-task-actions button { font-size: 12px; padding: 2px 8px; }

/* 拖拽遮罩 */
.drag-overlay {
    position: absolute; inset: 0; background: rgba(37,99,235,.08);
    border: 2px dashed var(--primary); border-radius: var(--radius);
    display: none; align-items: center; justify-content: center;
    font-size: 18px; color: var(--primary); z-index: 20; pointer-events: none;
}
.drag-overlay.show { display: flex; }

/* ---------- 弹窗 ---------- */
.modal-mask {
    position: fixed; inset: 0; background: rgba(17,24,39,.45);
    display: flex; align-items: center; justify-content: center; z-index: 100;
    animation: fadeIn .15s;
}
.modal {
    background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg);
    width: 420px; max-width: 92vw; max-height: 88vh; overflow: auto;
    animation: popIn .18s;
}
.modal-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px 8px; font-size: 16px; font-weight: 700;
}
.modal-body { padding: 12px 20px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 18px; }
.modal-sm { width: 360px; }
.modal-lg { width: 720px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }

/* ---------- 提示 ---------- */
.toast-root {
    position: fixed; top: 20px; right: 20px; z-index: 200;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 10px 16px; border-radius: 10px; background: #1f2937; color: #fff;
    font-size: 13px; box-shadow: var(--shadow-lg); animation: slideIn .2s; max-width: 340px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warn { background: var(--warning); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------- 预览 ---------- */
.preview-img { max-width: 100%; max-height: 70vh; border-radius: 8px; display: block; margin: 0 auto; }
.preview-video { width: 100%; max-height: 70vh; border-radius: 8px; }
.preview-audio { width: 100%; }
.preview-text {
    white-space: pre-wrap; word-break: break-all; font-family: Consolas, Monaco, monospace;
    font-size: 13px; background: #f9fafb; padding: 16px; border-radius: 8px;
    max-height: 60vh; overflow: auto; border: 1px solid var(--border);
}

/* ---------- 分享弹窗 ---------- */
.share-result {
    background: var(--primary-light); border: 1px solid #dbeafe;
    border-radius: 8px; padding: 12px; margin-top: 10px;
}
.share-url {
    display: flex; gap: 8px; align-items: center;
    background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.share-url input { border: none; box-shadow: none; padding: 0; flex: 1; }
.share-url input:focus { box-shadow: none; }

/* ---------- 表格 ---------- */
.data-table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
.data-table th, .data-table td {
    padding: 10px 12px; text-align: left; border-bottom: 1px solid #f3f4f6; vertical-align: middle;
}
.data-table th { background: #f9fafb; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.data-table tr:hover td { background: #fafbfc; }
.data-table .empty-tip { padding: 40px 0; }

/* ---------- 表单 ---------- */
.form-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.form-row label { width: 110px; flex-shrink: 0; color: var(--text-2); font-size: 13px; text-align: right; }
.form-row input, .form-row select { flex: 1; }
.form-error { color: var(--danger); font-size: 13px; margin: 8px 0; padding: 8px 12px; background: var(--danger-light); border-radius: 8px; }

/* ---------- 卡片 ---------- */
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; max-width: 620px; }
.card h3 { margin-bottom: 16px; font-size: 15px; }
.page-desc { color: var(--text-2); font-size: 13px; margin-bottom: 12px; display: block; }

/* ---------- 配额条 ---------- */
.quota-bar {
    position: relative; height: 30px; background: #eef1f5; border-radius: 6px;
    overflow: hidden; margin: 12px 0 0; flex-shrink: 0;
}
.quota-fill { height: 100%; background: linear-gradient(90deg, #60a5fa, var(--primary)); transition: width .3s; }
.quota-text {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 12px; color: var(--text); font-weight: 500; text-shadow: 0 0 4px #fff;
}

/* ---------- 登录/注册 ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #eef4ff 0%, #f8fafc 100%); }
.auth-card {
    width: 380px; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg);
    padding: 32px; animation: popIn .2s;
}
.auth-logo { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 20px; }
.auth-tabs { display: flex; gap: 12px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.auth-tab { padding: 8px 4px; color: var(--text-3); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.auth-tab:hover { text-decoration: none; color: var(--text); }
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- 分享页 ---------- */
.share-body { display: flex; align-items: flex-start; justify-content: center; min-height: 100vh; background: var(--bg); padding: 40px 16px; }
.share-card {
    width: 640px; max-width: 100%; background: #fff; border-radius: 16px;
    box-shadow: var(--shadow); padding: 24px;
}
.share-head { display: flex; align-items: center; gap: 8px; font-weight: 600; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.share-owner { margin-left: auto; font-size: 12px; color: var(--text-3); font-weight: 400; }
.share-lock { text-align: center; padding: 30px 0 10px; }
.lock-icon { font-size: 44px; margin-bottom: 10px; }
.lock-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.share-file { text-align: center; padding: 24px 0 16px; }
.share-icon { font-size: 52px; margin-bottom: 10px; }
.share-name { font-size: 18px; font-weight: 700; word-break: break-all; }
.share-meta { font-size: 12px; color: var(--text-3); margin-top: 8px; }
.share-preview { margin: 14px 0; text-align: center; }
.share-folder { margin: 14px 0; }
.share-actions { display: flex; justify-content: center; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border); margin-top: 8px; }
.share-no-download { color: var(--text-3); font-size: 13px; }
.invalid-card { text-align: center; padding: 40px; }

/* ---------- 管理后台 ---------- */
.admin-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.admin-tab {
    padding: 8px 18px; border-radius: 8px; border: 1px solid var(--border);
    background: #fff; cursor: pointer; font-weight: 500; color: var(--text-2);
}
.admin-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.log-filter { display: flex; gap: 10px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
.log-filter select { width: 160px; }
/* 任务列表页签（上传 / 下载） */
.task-tabs { display: flex; gap: 8px; }
.task-tab {
    padding: 6px 14px; border: 1px solid var(--border); border-radius: 8px;
    background: #fff; color: var(--text-2); font-size: 13px; cursor: pointer;
}
.task-tab:hover { border-color: var(--primary); color: var(--primary); }
.task-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
/* 任务分区标题（上传 / 下载 分开展示） */
.task-section-title { font-size: 15px; font-weight: 600; color: var(--text); margin: 0 0 8px; }
.task-count { font-size: 12px; font-weight: 400; color: var(--text-2); margin-left: 6px; }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 14px; }
.pager button {
    min-width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 6px;
    background: #fff; cursor: pointer; font-size: 13px;
}
.pager button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    .sidebar { display: none; }
    .tree-panel { display: none; }
    .search-box input { width: 140px; }
}
