/* ============================================================
   留言本 - 管理后台样式
   ============================================================ */

:root {
    --primary: #6366f1;
    --primary-grad: linear-gradient(135deg, #6366f1, #8b5cf6);
    --bg: #f4f5fb;
    --card: #ffffff;
    --text: #1f2430;
    --text-sub: #6b7280;
    --border: #e5e7f0;
    --danger: #ef4444;
    --ok: #22c55e;
    --warn: #f59e0b;
    --blue: #3b82f6;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.7;
}

/* 顶栏 */
.admin-topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .04);
}
.admin-brand { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.brand-logo {
    font-size: 24px;
    width: 46px; height: 46px;
    line-height: 46px;
    text-align: center;
    background: var(--primary-grad);
    color: #fff;
    border-radius: 12px;
}
.admin-brand strong { display: block; font-size: 15px; }
.admin-brand small { color: var(--text-sub); font-size: 12px; }
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-nav a {
    padding: 8px 14px;
    color: var(--text-sub);
    text-decoration: none;
    border-radius: 10px;
    font-size: 13px;
    transition: all .2s ease;
}
.admin-nav a:hover { color: var(--primary); background: rgba(99, 102, 241, .08); }
.admin-nav a.active { color: var(--primary); background: rgba(99, 102, 241, .12); font-weight: 600; }

.admin-main { max-width: 1100px; margin: 24px auto; padding: 0 20px 60px; }
.admin-page-title { margin-bottom: 20px; }
.admin-page-title h1 { font-size: 24px; }

/* 提示 */
.flash {
    padding: 13px 18px;
    border-radius: 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    background: var(--card);
}
.flash-ok { border-left: 4px solid var(--ok); }
.flash-err { border-left: 4px solid var(--danger); }
.flash-warn { border-left: 4px solid var(--warn); }

/* 统计卡片 */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px 22px;
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: "";
    position: absolute;
    top: -40px; right: -40px;
    width: 120px; height: 120px;
    border-radius: 50%;
    opacity: .12;
}
.sc-blue::after { background: #3b82f6; }
.sc-orange::after { background: #f59e0b; }
.sc-green::after { background: #22c55e; }
.sc-purple::after { background: #8b5cf6; }
.stat-num { font-size: 34px; font-weight: 800; }
.sc-blue .stat-num { color: #3b82f6; }
.sc-orange .stat-num { color: #f59e0b; }
.sc-green .stat-num { color: #22c55e; }
.sc-purple .stat-num { color: #8b5cf6; }
.stat-label { font-size: 14px; color: var(--text-sub); }
.stat-sub { font-size: 12px; color: var(--text-sub); margin-top: 4px; }

/* 面板 */
.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px 22px;
    margin-bottom: 18px;
}
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.panel-head h3 { font-size: 17px; }
.panel-title { font-size: 16px; margin: 20px 0 14px; color: var(--primary); }
.panel-empty { text-align: center; padding: 36px 20px; color: var(--text-sub); }

/* 表格 */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
    padding: 11px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.data-table th { color: var(--text-sub); font-weight: 600; background: rgba(99, 102, 241, .04); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(99, 102, 241, .03); }
.cell-content { max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-time { white-space: nowrap; color: var(--text-sub); }
.cell-ops { white-space: nowrap; }

/* 徽章 */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    background: rgba(107, 114, 128, .12);
    color: var(--text-sub);
    margin-right: 4px;
}
.badge-ok { background: rgba(34, 197, 94, .15); color: #16a34a; }
.badge-warn { background: rgba(245, 158, 11, .15); color: #d97706; }
.badge-blue { background: rgba(59, 130, 246, .15); color: #2563eb; }
.badge-danger { background: rgba(239, 68, 68, .15); color: #dc2626; }

/* 操作链接 */
.op {
    display: inline-block;
    padding: 4px 12px;
    margin-right: 6px;
    border-radius: 8px;
    font-size: 12px;
    color: var(--blue);
    text-decoration: none;
    border: 1px solid rgba(59, 130, 246, .3);
    transition: all .2s ease;
}
.op:hover { background: rgba(59, 130, 246, .1); }
.op-ok { color: #16a34a; border-color: rgba(34, 197, 94, .35); }
.op-ok:hover { background: rgba(34, 197, 94, .12); }
.op-blue { color: #2563eb; border-color: rgba(59, 130, 246, .35); }
.op-danger { color: #dc2626; border-color: rgba(239, 68, 68, .35); }
.op-danger:hover { background: rgba(239, 68, 68, .1); }

/* 标签页 */
.tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 18px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.tab-bar a {
    padding: 8px 20px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-sub);
    font-size: 13px;
    transition: all .2s ease;
}
.tab-bar a:hover { color: var(--primary); }
.tab-bar a.active { background: var(--primary-grad); color: #fff; font-weight: 600; }
.tab-total { margin-left: auto; font-size: 13px; color: var(--text-sub); padding-right: 12px; }

/* 留言面板 */
.msg-panel { padding: 18px 22px; }
.msg-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.msg-panel-user strong { font-size: 15px; }
.msg-panel-user span { display: inline-block; color: var(--text-sub); font-size: 12px; margin-left: 10px; }
.msg-panel-user .msg-panel-email { color: var(--blue); }
.msg-panel-content {
    background: var(--bg);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 14px;
    white-space: pre-line;
    word-break: break-word;
    margin-bottom: 14px;
}
.msg-panel-ops { display: flex; gap: 6px; flex-wrap: wrap; }

.admin-replies { margin: 12px 0; }
.admin-reply {
    border-left: 3px solid var(--border);
    padding: 10px 16px;
    margin-bottom: 8px;
    background: rgba(99, 102, 241, .04);
    border-radius: 0 10px 10px 0;
}
.admin-reply-head { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-sub); }
.admin-reply-head strong { color: var(--text); font-size: 13px; }
.admin-reply-head .op { margin-left: auto; }
.admin-reply-content { font-size: 13px; white-space: pre-line; word-break: break-word; margin-top: 4px; }

.admin-reply-form { display: flex; gap: 10px; margin-top: 12px; align-items: flex-end; }
.admin-reply-form textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    outline: none;
    background: var(--bg);
}
.admin-reply-form textarea:focus { border-color: var(--primary); }

/* 表单 */
.btn {
    display: inline-block;
    padding: 10px 22px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all .25s ease;
    font-family: inherit;
}
.btn-primary { background: var(--primary-grad); color: #fff; box-shadow: 0 6px 16px rgba(99, 102, 241, .3); }
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 9px; }
.btn-block { width: 100%; }

.settings-form { max-width: 720px; }
.form-item { margin-bottom: 16px; }
.form-item label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-item input[type="text"],
.form-item input[type="password"],
.form-item input[type="number"],
.form-item textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: var(--bg);
    color: var(--text);
}
.form-item input:focus, .form-item textarea:focus { border-color: var(--primary); }
.form-item input:disabled { opacity: .6; }
.form-item small { color: var(--text-sub); font-size: 12px; display: block; margin-top: 4px; }
.form-item.form-inline { display: flex; align-items: center; gap: 14px; }
.form-item.form-inline label { margin: 0; }
.form-item.form-inline input { width: 110px; }

.form-switch { padding: 12px 16px; background: var(--bg); border-radius: 12px; }
.switch-label { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14px; }
.switch-label input { display: none; }
.switch-ui {
    width: 44px; height: 24px;
    background: #cbd5e1;
    border-radius: 999px;
    position: relative;
    transition: background .25s ease;
    flex-shrink: 0;
}
.switch-ui::after {
    content: "";
    position: absolute;
    top: 3px; left: 3px;
    width: 18px; height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: left .25s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}
.switch-label input:checked + .switch-ui { background: var(--primary); }
.switch-label input:checked + .switch-ui::after { left: 23px; }
.switch-desc { display: block; margin-left: 56px; color: var(--text-sub); font-size: 12px; }

.form-actions { margin-top: 20px; }

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 24px 0;
    flex-wrap: wrap;
}
.pagination a, .pagination .current, .pagination .page-info {
    padding: 7px 14px;
    border-radius: 10px;
    font-size: 13px;
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary-grad); color: #fff; border-color: transparent; font-weight: 600; }
.pagination .page-info { border: none; background: transparent; color: var(--text-sub); }

.admin-footer { text-align: center; padding: 20px; color: var(--text-sub); font-size: 12px; }

/* 登录页 */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #a855f7 100%);
    padding: 20px;
}
.login-card {
    background: var(--card);
    border-radius: 20px;
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .3);
    text-align: center;
}
.login-logo {
    font-size: 34px;
    width: 72px; height: 72px;
    line-height: 72px;
    margin: 0 auto 16px;
    background: var(--primary-grad);
    color: #fff;
    border-radius: 20px;
}
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-sub { color: var(--text-sub); margin-bottom: 24px; }
.login-form { text-align: left; }
.login-form .form-item { margin-bottom: 18px; }
.login-form input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    background: var(--bg);
}
.login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, .15); }
.back-link { display: block; text-align: center; margin-top: 16px; color: var(--text-sub); font-size: 13px; text-decoration: none; }
.back-link:hover { color: var(--primary); }

/* 响应式 */
@media (max-width: 768px) {
    .admin-topbar { flex-direction: column; padding: 12px 16px; }
    .admin-nav { justify-content: center; }
    .cell-content { max-width: 120px; }
}
