/* =====================================================
   后台管理样式
   ===================================================== */

:root {
    --primary: #4a6cf7;
    --primary-dark: #3555d8;
    --primary-light: #e8edff;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --sidebar-bg: #1e293b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}
a { text-decoration: none; color: inherit; }

/* ====== 登录页 ====== */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}
.login-box {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 40px;
    width: 100%; max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-box h1 { text-align: center; margin-bottom: 8px; font-size: 1.5rem; }
.login-box .sub { text-align: center; color: var(--text-muted); font-size: .88rem; margin-bottom: 28px; }
.login-error {
    text-align: center;
    color: var(--danger);
    font-size: .85rem;
    margin-top: 12px;
    padding: 8px 12px;
    background: #fef2f2;
    border-radius: 8px;
    border: 1px solid #fecaca;
}
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; margin-bottom: 6px; font-size: .9rem; font-weight: 600;
}
.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: .95rem; outline: none;
    transition: all .25s;
    font-family: inherit;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.btn {
    display: inline-block; padding: 11px 28px;
    border-radius: 10px; border: none; cursor: pointer;
    font-size: .95rem; font-weight: 600; transition: all .25s;
    font-family: inherit;
}
.btn-primary { width: 100%; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; }
.btn-primary:hover { box-shadow: 0 4px 15px rgba(74,108,247,.4); transform: translateY(-1px); }
.btn-sm { padding: 7px 16px; font-size: .82rem; border-radius: 8px; }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }

/* ====== 后台布局 ====== */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px; background: var(--sidebar-bg); color: white;
    flex-shrink: 0; position: fixed; top: 0; left: 0;
    bottom: 0; overflow-y: auto; z-index: 50;
    transition: transform .3s ease;
}
.sidebar-header {
    padding: 24px 20px; text-align: center;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-header h2 { font-size: 1.15rem; }
.sidebar-header span { font-size: .78rem; opacity: .55; }
.sidebar-nav { padding: 14px 0; list-style: none; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 13px 22px; color: rgba(255,255,255,.65);
    font-size: .92rem; transition: all .2s;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,.06);
    color: white; border-left-color: var(--primary);
}
.sidebar-nav .icon { width: 20px; text-align: center; font-size: 1.05rem; }

.main-content { flex: 1; margin-left: 240px; min-height: 100vh; }
.top-bar {
    background: var(--card-bg);
    padding: 14px 24px;
    display: flex; justify-content: space-between; align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    position: sticky; top: 0; z-index: 40;
}
.top-bar h3 { font-size: 1.05rem; }
.top-bar .admin-info { display: flex; align-items: center; gap: 12px; font-size: .88rem; color: var(--text-light); }
.page-body { padding: 24px; }

/* ====== 数据表格 ====== */
.data-table-wrap {
    background: var(--card-bg); border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06); overflow: hidden;
}
.table-toolbar {
    padding: 16px 20px;
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 12px;
    border-bottom: 1px solid var(--border);
}
.data-table {
    width: 100%; border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 12px 16px; text-align: left; font-size: .9rem;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    background: #f8fafc; font-weight: 600;
    color: var(--text-light); font-size: .82rem; text-transform: uppercase;
    letter-spacing: .5px;
}
.data-table tr:hover { background: #f8fafc; }
.status-badge {
    padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 600;
}
.status-on { background: #d1fae5; color: #065f46; }
.status-off { background: #fee2e2; color: #991b1b; }

/* ====== 编辑表单 ====== */
.form-card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    padding: 24px;
    max-width: 700px;
}
.form-card h3 { margin-bottom: 20px; font-size: 1.15rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full-span { grid-column: 1 / -1; }

/* ====== 统计卡片 ====== */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--card-bg); border-radius: 12px;
    padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.stat-num { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat-label { font-size: .85rem; color: var(--text-light); margin-top: 4px; }

/* ====== 弹窗 ====== */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.45); z-index: 200; backdrop-filter: blur(3px);
    align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.show { display: flex; animation: fadeIn .2s ease; }
@keyframes fadeIn{from{opacity:0}to{opacity:1}}
.admin-modal {
    background: var(--card-bg); border-radius: 14px;
    width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-header-bar {
    padding: 18px 24px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header-bar h3 { font-size: 1.1rem; }
.close-btn { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); }
.modal-body-form { padding: 24px; }

/* Toast */
.toast {
    position: fixed; top: 20px; right: 20px;
    padding: 12px 24px; border-radius: 10px;
    color: white; font-size: .9rem; z-index: 9999;
    animation: slideInRight .3s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideInRight{from{transform:translateX(100%)}to{transform:none}}

/* 移动端遮罩 */
.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 40;
}
.sidebar-overlay.show { display: block; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: none; }
    .main-content { margin-left: 0; }
    .page-body { padding: 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .data-table-wrap { overflow-x: auto; }
    .stats-row { grid-template-columns: repeat(2,1fr); }
    .table-toolbar { flex-direction: column; align-items: stretch; }
}
