/* ============================================================
   BrightMoon CloudDrive - Apple-inspired design
   ============================================================ */

:root {
    --bg: #f5f5f7;
    --bg-elev: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.72);
    --border: rgba(0, 0, 0, 0.08);
    --text: #1d1d1f;
    --text-sub: #6e6e73;
    --text-mute: #86868b;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --danger: #ff3b30;
    --success: #34c759;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    --radius: 14px;
    --radius-sm: 10px;
    --sidebar-w: 240px;
    --topbar-h: 56px;
    --mobile-tab-h: 60px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000000;
        --bg-elev: #1c1c1e;
        --bg-glass: rgba(28, 28, 30, 0.72);
        --border: rgba(255, 255, 255, 0.1);
        --text: #f5f5f7;
        --text-sub: #a1a1a6;
        --text-mute: #86868b;
        --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
                 "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100%;
}

button, input, select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

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

/* =================== 登录页 =================== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
      radial-gradient(circle at 20% 20%, rgba(0, 122, 255, 0.12), transparent 50%),
      radial-gradient(circle at 80% 80%, rgba(191, 90, 242, 0.10), transparent 50%),
      var(--bg);
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-elev);
    border-radius: 20px;
    padding: 40px 32px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.login-card .logo {
    width: 56px; height: 56px;
    margin: 0 auto 20px;
    border-radius: 14px;
    background: linear-gradient(135deg, #0a84ff, #bf5af2);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 28px; font-weight: 600;
}
.login-card h1 {
    text-align: center;
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 6px;
    letter-spacing: -0.01em;
}
.login-card .subtitle {
    text-align: center;
    color: var(--text-sub);
    margin: 0 0 28px;
    font-size: 13px;
}
.field { margin-bottom: 14px; }
.field label {
    display: block;
    font-size: 12px;
    color: var(--text-sub);
    margin-bottom: 6px;
    font-weight: 500;
}
.input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 980px;
    border: none;
    background: var(--accent);
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, transform .05s;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(0.98); }
.btn.block { width: 100%; padding: 12px; }
.btn.ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.alert {
    padding: 10px 12px;
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 12px;
    display: none;
}
.alert.show { display: block; }

/* =================== 主布局 =================== */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    height: 100vh;
}
.topbar {
    grid-area: topbar;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--bg-glass);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.topbar .title { font-weight: 600; font-size: 15px; }
.topbar .right { display: flex; align-items: center; gap: 12px; }
.topbar .user {
    display: flex; align-items: center; gap: 8px;
    color: var(--text-sub); font-size: 13px;
}

.sidebar {
    grid-area: sidebar;
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    padding: 20px 12px;
    overflow-y: auto;
}
.sidebar .brand {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 10px 20px;
}
.sidebar .brand .logo {
    width: 30px; height: 30px; border-radius: 8px;
    background: linear-gradient(135deg, #0a84ff, #bf5af2);
}
.sidebar .brand .name { font-weight: 600; font-size: 15px; }

.side-nav { list-style: none; margin: 0; padding: 0; }
.side-nav li {
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-sub);
    font-weight: 500;
    margin-bottom: 2px;
    -webkit-tap-highlight-color: transparent;
    transition: background .12s, color .12s;
}
.side-nav li:hover { background: var(--bg); color: var(--text); }
.side-nav li.active { background: var(--accent); color: white; }
.side-nav li.active .count { color: rgba(255,255,255,0.85); }
.side-nav li .icon { margin-right: 10px; font-size: 16px; }
.side-nav li .count { font-size: 12px; color: var(--text-mute); }

.sidebar .section-title {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-mute); padding: 12px 12px 6px; font-weight: 600;
}

.main {
    grid-area: main;
    overflow-y: auto;
    padding: 20px 28px 40px;
}
.toolbar {
    display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.toolbar .search {
    flex: 1; min-width: 180px;
    padding: 8px 14px;
    border-radius: 980px;
    border: 1px solid var(--border);
    background: var(--bg-elev);
    outline: none;
}
.toolbar .search:focus { border-color: var(--accent); }
.select {
    padding: 8px 14px;
    border-radius: 980px;
    border: 1px solid var(--border);
    background: var(--bg-elev);
    cursor: pointer;
}

/* =================== 文件网格 =================== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}
.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
    display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card .thumb {
    aspect-ratio: 1 / 1;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    font-size: 40px;
    color: var(--text-mute);
    overflow: hidden;
    position: relative;
}
.card .thumb img, .card .thumb video {
    width: 100%; height: 100%; object-fit: cover;
}
.card .meta { padding: 10px 12px; }
.card .fname {
    font-size: 13px; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card .fsub {
    font-size: 11px; color: var(--text-mute); margin-top: 3px;
    display: flex; justify-content: space-between;
}

.empty {
    text-align: center; padding: 80px 20px; color: var(--text-mute);
}
.empty .big { font-size: 48px; margin-bottom: 12px; }

/* =================== 上传 =================== */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    color: var(--text-sub);
    margin-bottom: 16px;
    transition: border-color .15s, background .15s;
}
.upload-zone.drag { border-color: var(--accent); background: rgba(0,113,227,0.06); }
.upload-zone input[type="file"] { display: none; }
.upload-progress {
    margin-top: 10px;
    height: 4px; border-radius: 2px;
    background: var(--border); overflow: hidden;
    display: none;
}
.upload-progress.show { display: block; }
.upload-progress .bar {
    height: 100%; background: var(--accent); width: 0%;
    transition: width .2s;
}

/* =================== 弹窗 =================== */
.modal-mask {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    align-items: center; justify-content: center;
    z-index: 100;
    padding: 16px;
}
.modal-mask.show { display: flex; }
.modal {
    background: var(--bg-elev);
    border-radius: var(--radius);
    max-width: 92vw; max-height: 92vh;
    overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: var(--shadow);
}
.modal .mhead {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.modal .mhead .name { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal .mhead .close {
    background: transparent; border: none; cursor: pointer;
    font-size: 20px; color: var(--text-sub);
    width: 32px; height: 32px; border-radius: 50%;
}
.modal .mhead .close:hover { background: var(--bg); }
.modal .mbody {
    flex: 1; overflow: auto;
    display: flex; align-items: center; justify-content: center;
    background: #000;
}
.modal .mbody img, .modal .mbody video { max-width: 100%; max-height: 80vh; }
.modal .mbody iframe { width: 90vw; height: 80vh; border: 0; background: white; }
.modal .mbody .fallback { color: #ccc; padding: 40px; text-align: center; }

/* =================== 管理员面板 =================== */
.panel {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}
.panel h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td {
    text-align: left; padding: 10px 8px;
    border-bottom: 1px solid var(--border);
}
.table th { color: var(--text-sub); font-weight: 500; }

.tag {
    display: inline-block; padding: 2px 8px;
    border-radius: 980px; font-size: 11px;
    background: var(--bg);
    color: var(--text-sub);
}
.tag.admin { background: rgba(10,132,255,0.12); color: var(--accent); }

/* =================== 移动端底部 Tab =================== */
.mobile-tabs {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--mobile-tab-h);
    background: var(--bg-glass);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--border);
    z-index: 20;
    padding-bottom: env(safe-area-inset-bottom);
}
.mobile-tabs .tab {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px; color: var(--text-mute); cursor: pointer;
    font-size: 11px;
    -webkit-tap-highlight-color: transparent;
}
.mobile-tabs .tab .icon { font-size: 18px; }
.mobile-tabs .tab.active { color: var(--accent); }

/* =================== 移动适配 =================== */
@media (max-width: 768px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: var(--topbar-h) 1fr;
        grid-template-areas:
            "topbar"
            "main";
    }
    .sidebar { display: none; }
    .sidebar.open {
        display: block;
        position: fixed; top: var(--topbar-h); left: 0;
        width: 80%; max-width: 320px;
        height: calc(100vh - var(--topbar-h));
        z-index: 30;
        box-shadow: var(--shadow);
    }
    .main {
        padding: 16px 16px calc(var(--mobile-tab-h) + 20px);
    }
    .mobile-tabs { display: flex; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
    .topbar { padding: 0 16px; }
    .topbar .user .username { display: none; }
    .menu-btn {
        display: inline-flex !important;
        background: transparent; border: none; cursor: pointer;
        font-size: 20px; padding: 4px 8px;
    }
}
.menu-btn { display: none; }

/* 遮罩关闭侧栏 */
.side-mask {
    display: none;
    position: fixed; inset: var(--topbar-h) 0 0 0;
    background: rgba(0,0,0,0.35);
    z-index: 25;
}
.side-mask.show { display: block; }

/* 加载 */
.loader {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =================== 面包屑 =================== */
.crumbs {
    display: flex; align-items: center; flex-wrap: wrap;
    gap: 4px;
    font-size: 14px;
    margin-bottom: 14px;
    color: var(--text-sub);
}
.crumbs .seg {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    -webkit-tap-highlight-color: transparent;
}
.crumbs .seg:hover { background: var(--bg-elev); color: var(--text); }
.crumbs .seg.current { color: var(--text); font-weight: 500; cursor: default; }
.crumbs .seg.current:hover { background: transparent; }
.crumbs .sep { color: var(--text-mute); user-select: none; }

/* 文件夹卡片：和文件卡复用 .card，区别靠 icon + 双击/单击进入 */
.card.folder .thumb {
    background: linear-gradient(135deg, rgba(10,132,255,0.10), rgba(191,90,242,0.08));
    font-size: 46px;
}

/* 上传列队浮层 */
.uploader {
    position: fixed; right: 20px; bottom: 20px;
    width: 340px; max-height: 50vh; overflow: auto;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 50;
    display: none;
}
.uploader.show { display: block; }
.uploader .uhead {
    padding: 10px 14px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 13px; font-weight: 500;
}
.uploader .uhead .close { cursor: pointer; color: var(--text-mute); border: none; background: transparent; font-size: 18px; }
.uploader .ulist { padding: 6px; }
.uploader .uitem {
    padding: 8px 10px; border-radius: var(--radius-sm);
    font-size: 12px; display: flex; flex-direction: column; gap: 4px;
}
.uploader .uitem + .uitem { margin-top: 2px; }
.uploader .uitem .row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.uploader .uitem .row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uploader .uitem .bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.uploader .uitem .bar i { display: block; height: 100%; background: var(--accent); width: 0%; transition: width .2s; }
.uploader .uitem.err { color: var(--danger); }
.uploader .uitem.ok .row .state { color: var(--success); }

@media (max-width: 768px) {
    .uploader { right: 10px; left: 10px; width: auto; bottom: calc(var(--mobile-tab-h) + 10px); }
}

/* =================== 密码框 + 可视切换 =================== */
.pwd-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.pwd-wrap .input {
    padding-right: 42px;   /* 给眼睛按钮让位 */
}
.pwd-wrap .eye {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex; align-items: center; justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-mute);
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    transition: color .15s, background .15s;
}
.pwd-wrap .eye:hover {
    color: var(--text);
    background: var(--bg);
}
.pwd-wrap .eye:focus { outline: none; }
.pwd-wrap .eye svg {
    width: 18px; height: 18px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}
