/* ============================================================
   素材库 · 管理后台
   风格：中性灰 + 细边框 + 单一蓝色主色，不用渐变和装饰元素
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --brand: #2563eb;
    --brand-hover: #1d4ed8;
    --bg: #f5f6f8;
    --panel: #ffffff;
    --border: #e4e6eb;
    --border-strong: #d3d6dc;
    --text: #1f2329;
    --text-2: #646a73;
    --text-3: #8f959e;
    --danger: #d93026;
    --success: #1a7f37;
    --radius: 6px;
}

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;
}

button, input, select { font-family: inherit; font-size: inherit; }

/* ==================== 布局 ==================== */

.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 216px;
    flex-shrink: 0;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    padding: 22px 20px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.brand-sub { font-size: 12px; color: var(--text-3); }

.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 1px; flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    padding: 9px 12px;
    border: none;
    background: none;
    border-radius: var(--radius);
    color: var(--text-2);
    text-align: left;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.nav-item:hover { background: #f2f3f5; color: var(--text); }
.nav-item.active { background: #eef3ff; color: var(--brand); font-weight: 500; }

.sidebar-foot {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
}
.conn { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.conn-meta {
    margin-top: 5px;
    font-size: 11.5px;
    color: var(--text-3);
    word-break: break-all;
    line-height: 1.5;
}

.dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-3); flex-shrink: 0;
}
.dot.on { background: var(--success); }
.dot.off { background: #d97706; }

/* ==================== 主区域 ==================== */

.main { flex: 1; min-width: 0; padding: 28px 32px 56px; }

.view { display: none; }
.view.active { display: block; }

.view-head { margin-bottom: 22px; }
.view-head h2 { font-size: 19px; font-weight: 600; }
.view-head p { margin-top: 5px; font-size: 13px; color: var(--text-3); }
.view-head code {
    background: #f2f3f5; padding: 1px 5px; border-radius: 3px;
    font-size: 12px; color: var(--text-2);
}

/* ==================== 表单控件 ==================== */

.control { display: flex; flex-direction: column; gap: 6px; }
.control-label { font-size: 13px; color: var(--text-2); }
.control-label i { color: var(--danger); font-style: normal; }

.input, .control input[type="text"], .control input[type="password"] {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.input:hover, .control input:hover { border-color: #b8bcc4; }
.input:focus, .control input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, .1);
}
.input::placeholder, .control input::placeholder { color: #b6babf; }

.control-check {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-2);
}
.control-check input { width: 14px; height: 14px; accent-color: var(--brand); cursor: pointer; }

.row-inline { display: flex; gap: 16px; margin-bottom: 18px; }
.row-inline .control { max-width: 280px; flex: 1; }

/* ==================== 按钮 ==================== */

.btn {
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color .15s, background .15s, color .15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn.sm { height: 27px; padding: 0 8px; font-size: 12px; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ==================== 目录选择 ==================== */

.control-folder { max-width: 460px; }

.folder-picker { display: flex; gap: 6px; align-items: center; }
.folder-picker .folder-select { flex: 1; min-width: 0; }
.folder-picker .icon-btn {
    width: 34px;
    padding: 0;
    font-size: 15px;
    line-height: 1;
    color: var(--text-2);
    flex-shrink: 0;
}
.folder-picker .icon-btn:hover { color: var(--brand); border-color: var(--brand); }

.folder-custom { margin-top: 8px; }

.folder-hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-3);
    min-height: 16px;
    line-height: 1.5;
}
.folder-hint.err { color: var(--danger); }

/* ==================== 上传区 ==================== */

.dropzone {
    border: 1px dashed var(--border-strong);
    border-radius: 8px;
    background: #fff;
    padding: 52px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: #fafcff; }
.dz-title { font-size: 14px; color: var(--text); }
.dz-hint { margin-top: 7px; font-size: 12.5px; color: var(--text-3); }

.queue { margin-top: 16px; display: flex; flex-direction: column; gap: 1px; }
.q-item {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 11px 14px;
    margin-bottom: -1px;
}
.q-top { display: flex; justify-content: space-between; gap: 14px; font-size: 13px; }
.q-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.q-state { flex-shrink: 0; font-size: 12.5px; color: var(--text-3); }
.q-state.ok { color: var(--success); }
.q-state.err { color: var(--danger); }
.q-state.run { color: var(--brand); }

.bar { height: 2px; background: #eef0f3; margin-top: 9px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s linear; }

/* ==================== 统计 ==================== */

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px 16px;
}
.stat-label { font-size: 12.5px; color: var(--text-3); }
.stat-value { margin-top: 7px; font-size: 22px; font-weight: 600; letter-spacing: -.3px; }
.stat-value-sm { font-size: 15px; font-weight: 500; word-break: break-all; }

/* ==================== 工具栏 ==================== */

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.search { flex: 1; min-width: 200px; }
.select { min-width: 160px; cursor: pointer; }

/* ==================== 图片网格 ==================== */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
    gap: 14px;
}

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color .15s;
}
.card:hover { border-color: var(--border-strong); }

.card-thumb {
    height: 132px;
    background: #fafbfc;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.card-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; }

.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 5px; }
.card-name {
    font-size: 13px; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-url {
    font-size: 11.5px; color: var(--text-3);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    cursor: pointer;
}
.card-url:hover { color: var(--brand); }
.card-meta { font-size: 11.5px; color: var(--text-3); }

.card-actions {
    display: flex; gap: 6px; margin-top: 6px;
    padding-top: 9px; border-top: 1px solid #f0f1f3;
}
.card-actions .btn { flex: 1; }

.placeholder {
    grid-column: 1 / -1;
    padding: 64px 20px;
    text-align: center;
    color: var(--text-3);
    font-size: 13px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    line-height: 1.7;
}
.placeholder.err { color: var(--danger); }

.more-wrap { text-align: center; margin-top: 20px; }

/* ==================== 设置表单 ==================== */

.form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(268px, 1fr));
    gap: 16px;
    max-width: 900px;
}
.control-check { grid-column: 1 / -1; }

.form-actions { display: flex; gap: 8px; margin-top: 20px; }

.notice {
    display: none;
    margin-top: 16px;
    padding: 10px 13px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.6;
    max-width: 900px;
}
.notice.show { display: block; }
.notice.ok { background: #f0f9f2; border: 1px solid #c8e6cf; color: #1a7f37; }
.notice.err { background: #fdf2f1; border: 1px solid #f5cdc9; color: #b3261e; }
.notice.info { background: #f5f7fa; border: 1px solid var(--border); color: var(--text-2); }

.tip {
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    max-width: 900px;
    font-size: 12.5px;
    color: var(--text-3);
    line-height: 1.7;
}

[hidden] { display: none !important; }

/* ==================== 登录页 ==================== */

.login-page {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
    padding: 20px;
    z-index: 1200;
}
.login-page[hidden] { display: none !important; }

.login-card {
    width: 100%;
    max-width: 340px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 36px 28px 30px;
    text-align: center;
}
.logo {
    width: 52px; height: 52px;
    margin: 0 auto 14px;
    border-radius: 12px;
    background: var(--brand);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
}
.login-title { font-size: 18px; font-weight: 600; }
.login-sub { margin-top: 5px; font-size: 12.5px; color: var(--text-3); }
.login-form {
    margin-top: 24px;
    display: flex; flex-direction: column; gap: 10px;
    text-align: left;
}
.login-form .input { width: 100%; height: 36px; }
.login-form .btn { width: 100%; height: 36px; margin-top: 4px; }
.login-err {
    min-height: 17px;
    font-size: 12.5px;
    color: var(--danger);
}

/* ==================== 只读提示 ==================== */

.readonly-bar {
    display: none;
    margin-bottom: 18px;
    padding: 10px 13px;
    border-radius: var(--radius);
    background: #f5f7fa;
    border: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--text-2);
    line-height: 1.6;
    max-width: 900px;
}
.readonly-bar.show { display: block; }
.readonly-bar code {
    background: #e8ebf0;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}

/* ==================== 预览 ==================== */

.lightbox {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, .82);
    display: none;
    align-items: center; justify-content: center;
    z-index: 1000;
    padding: 40px;
    cursor: zoom-out;
}
.lightbox.show { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ==================== 提示条 ==================== */

.toasts {
    position: fixed;
    top: 18px; right: 18px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 1100;
}
.toast {
    min-width: 200px; max-width: 380px;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: #fff;
    border: 1px solid var(--border);
    border-left: 3px solid var(--text-3);
    font-size: 13px;
    color: var(--text);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .08);
    animation: toastIn .18s ease;
}
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--brand); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ==================== 响应式 ==================== */

@media (max-width: 760px) {
    .layout { flex-direction: column; }
    .sidebar {
        width: 100%; height: auto; position: static;
        border-right: none; border-bottom: 1px solid var(--border);
    }
    .brand { padding: 16px; }
    .nav { flex-direction: row; overflow-x: auto; padding: 8px; }
    .nav-item { flex: 1; justify-content: center; }
    .sidebar-foot { display: none; }
    .main { padding: 20px 16px 44px; }
    .stats { grid-template-columns: 1fr; }
    .row-inline { flex-direction: column; }
    .row-inline .control { max-width: none; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
