/* ============ 后台管理 - 样式 ============ */
:root {
    --primary: #6366f1;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --sub: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* 修复：hidden 属性不能被 .modal-mask 的 display:flex 覆盖 */
[hidden] { display: none !important; }

body {
    font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ---------- 登录 ---------- */
.login-panel {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    background: linear-gradient(135deg, #1e293b, #334155);
}
.login-panel h1 { color: #fff; font-size: 26px; margin-bottom: 4px; }
.login-tip { color: rgba(255,255,255,0.7); font-size: 14px; }
.login-panel label {
    width: 300px; max-width: 90%;
    text-align: left;
    color: rgba(255,255,255,0.75);
    font-size: 13px;
}
.login-panel input {
    width: 300px; max-width: 90%;
    padding: 12px 14px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    outline: none;
}
.login-panel .btn-primary { margin-top: 6px; width: 300px; max-width: 90%; padding: 12px; }
.back-link {
    display: block;
    width: 300px; max-width: 90%;
    margin-top: 14px;
    padding: 10px 0;
    text-align: center;
    border-radius: 8px;
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.4);
    color: #fff;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s;
}
.back-link:hover { background: rgba(255,255,255,0.3); }

/* ---------- 布局 ---------- */
.admin-wrap { min-height: 100vh; }
#main-panel { display: flex; min-height: 100vh; }

.sidebar {
    width: 210px;
    flex-shrink: 0;
    background: #1e293b;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand { padding: 22px 20px; font-size: 16px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,0.1); }
.menu { flex: 1; padding: 12px 10px; }
.menu-item {
    display: block;
    padding: 11px 14px;
    color: rgba(255,255,255,0.78);
    text-decoration: none;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all 0.15s;
}
.menu-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.menu-item.active { background: var(--primary); color: #fff; }
.sidebar-foot { padding: 16px; border-top: 1px solid rgba(255,255,255,0.1); display: flex; gap: 8px; flex-wrap: wrap; }
.btn-mini {
    padding: 7px 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: background 0.2s;
}
.btn-mini:hover { background: rgba(255,255,255,0.25); }

/* ---------- 内容区 ---------- */
.content { flex: 1; padding: 28px 32px; overflow-x: auto; }
.view { display: none; }
.view.active { display: block; }
.view-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
}
.view-head h2 { font-size: 22px; }

.btn-primary {
    padding: 9px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: filter 0.15s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-plain {
    padding: 9px 20px;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}
.btn-plain:hover { border-color: #94a3b8; }
.btn-danger {
    padding: 6px 12px;
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.btn-danger:hover { filter: brightness(1.1); }
.btn-ghost {
    padding: 6px 12px;
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    margin-right: 6px;
}
.btn-ghost:hover { background: rgba(99,102,241,0.08); }

/* ---------- 表格 ---------- */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.table th, .table td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}
.table th { background: #f8fafc; font-weight: 600; color: var(--sub); white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fafc; }
.table a { color: var(--primary); text-decoration: none; }
.table a:hover { text-decoration: underline; }
.table .url-cell { color: var(--sub); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .icon-cell img { width: 24px; height: 24px; object-fit: contain; vertical-align: middle; cursor: pointer; }
.table-tip { margin-top: 12px; font-size: 13px; color: var(--sub); }
.tag-admin {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(99,102,241,0.12);
    color: var(--primary);
    font-size: 12px;
    border: 1px solid rgba(99,102,241,0.35);
}

/* ---------- 卡片/表单 ---------- */
.card {
    background: var(--card);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    max-width: 760px;
}
.card h3 { margin: 18px 0 10px; font-size: 15px; }
.card h3:first-child { margin-top: 0; }
.card label { display: block; font-size: 13px; color: var(--sub); margin: 14px 0 6px; }
.card input[type="text"], .card input[type="password"], .card select, .card textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}
.card input:focus, .card select:focus, .card textarea:focus { border-color: var(--primary); }
.card textarea { resize: vertical; font-family: Consolas, monospace; }
.card code { background: #f1f5f9; padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.btns-row { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.card hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ---------- 壁纸 ---------- */
.wp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}
.wp-item {
    position: relative;
    height: 88px;
    border-radius: 10px;
    border: 3px solid transparent;
    cursor: pointer;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    transition: transform 0.15s;
}
.wp-item:hover { transform: scale(1.03); }
.wp-item.active { border-color: var(--primary); }
.wp-item .wp-name {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 12px;
    padding: 4px 6px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wp-item .wp-del {
    position: absolute; top: 4px; right: 4px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: rgba(220,38,38,0.9);
    color: #fff;
    border: none;
    font-size: 12px;
    cursor: pointer;
    line-height: 1;
}
.upload-row { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.upload-row input[type="file"] { font-size: 13px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal {
    width: 100%;
    max-width: 460px;
    background: #fff;
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    animation: pop 0.2s ease;
}
@keyframes pop {
    from { transform: scale(0.94); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.modal h3 { margin-bottom: 14px; }
.modal label { display: block; font-size: 13px; color: var(--sub); margin: 12px 0 4px; }
.modal input, .modal select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}
.modal input:focus, .modal select:focus { border-color: var(--primary); }
.modal-btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.icon-row { display: flex; gap: 8px; }
.icon-row input { flex: 1; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; top: 20px; left: 50%;
    transform: translateX(-50%);
    background: rgba(15,23,42,0.92);
    color: #fff;
    padding: 10px 22px;
    border-radius: 999px;
    font-size: 14px;
    z-index: 300;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    animation: pop 0.25s ease;
}
.toast.error { background: rgba(220,38,38,0.92); }

/* ---------- 响应式 ---------- */
@media (max-width: 820px) {
    #main-panel { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .menu { display: flex; flex-wrap: wrap; padding: 8px; }
    .menu-item { margin-bottom: 0; }
    .sidebar-foot { justify-content: center; }
    .content { padding: 20px 14px; }
}
