/* ===== 物理竞赛博客 - 后台管理样式 ===== */

:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --primary-light: #e0e7ff;
    --accent: #06b6d4;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #1e1b4b;
    --bg-sidebar-hover: #312e81;
    --text: #1e293b;
    --text-light: #64748b;
    --text-lighter: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-hover: 0 8px 25px rgba(0,0,0,0.1);
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-width: 240px;
    --transition: all 0.25s ease;
}

* { 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.6; }

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

/* ===== Login Page ===== */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 50%, #06b6d4 100%); }
.login-container { width: 100%; max-width: 400px; padding: 20px; }
.login-card { background: white; border-radius: 20px; padding: 40px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-header { text-align: center; margin-bottom: 30px; }
.login-icon { font-size: 48px; margin-bottom: 10px; }
.login-header h1 { font-size: 22px; color: var(--text); }
.login-header p { color: var(--text-light); font-size: 14px; margin-top: 5px; }
.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; margin-bottom: 6px; font-weight: 600; color: var(--text-light); font-size: 13px; }
.login-form input { width: 100%; padding: 12px 16px; border: 2px solid var(--border); border-radius: var(--radius-sm); font-size: 15px; transition: var(--transition); }
.login-form input:focus { outline: none; border-color: var(--primary); }
.form-error { color: var(--danger); font-size: 14px; min-height: 20px; margin-bottom: 10px; }
.login-footer { text-align: center; margin-top: 20px; font-size: 13px; }

/* ===== Buttons ===== */
.btn { display: inline-block; padding: 8px 18px; background: #f1f5f9; color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; cursor: pointer; transition: var(--transition); text-decoration: none; }
.btn:hover { background: #e2e8f0; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-edit { background: var(--accent); color: white; border-color: var(--accent); }
.btn-edit:hover { background: #0891b2; }
.btn-success { background: #16a34a; color: white; border-color: #16a34a; }
.btn-success:hover { background: #15803d; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-block { display: block; width: 100%; text-align: center; margin-bottom: 8px; }

/* Filter Tabs */
.filter-tabs { display: flex; gap: 4px; }
.filter-tab { padding: 5px 14px; border-radius: var(--radius-sm); font-size: 13px; color: var(--text-light); background: var(--bg); text-decoration: none; transition: var(--transition); }
.filter-tab:hover { background: var(--border); }
.filter-tab.active { background: var(--primary); color: white; }

/* ===== Admin Layout ===== */
.admin-wrapper { display: flex; min-height: 100vh; }

.sidebar { width: var(--sidebar-width); background: var(--bg-sidebar); color: rgba(255,255,255,0.9); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 100; overflow-y: auto; }
.sidebar-header { padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo { display: flex; align-items: center; gap: 8px; color: white; font-size: 16px; font-weight: 700; }
.sidebar-logo:hover { color: white; }
.logo-icon { font-size: 24px; }
.sidebar-nav { flex: 1; padding: 12px 8px; }
.sidebar-footer { padding: 8px; border-top: 1px solid rgba(255,255,255,0.1); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: rgba(255,255,255,0.7); border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 2px; transition: var(--transition); }
.nav-item:hover { background: var(--bg-sidebar-hover); color: white; }
.nav-item.active { background: var(--primary); color: white; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.main-wrapper { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-height: 100vh; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 0 24px; height: 60px; background: white; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 50; }
.sidebar-toggle { background: none; border: none; font-size: 20px; cursor: pointer; padding: 8px; color: var(--text-light); }
.page-title { font-size: 18px; font-weight: 700; flex: 1; margin-left: 16px; }
.user-info { display: flex; align-items: center; gap: 8px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
.user-avatar-sm { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: white; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-right: 6px; }
.user-name { font-weight: 600; font-size: 14px; }
.user-role { font-size: 12px; color: var(--text-lighter); text-transform: uppercase; }

.content-area { padding: 24px; flex: 1; }

/* ===== Cards ===== */
.card { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 10px; }
.card-header h3 { font-size: 16px; font-weight: 700; }
.card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 20px; }

/* ===== Stats ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: white; border-radius: var(--radius); padding: 20px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow); }
.stat-icon { font-size: 36px; width: 56px; height: 56px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.stat-blue .stat-icon { background: #dbeafe; }
.stat-green .stat-icon { background: #dcfce7; }
.stat-purple .stat-icon { background: #f3e8ff; }
.stat-orange .stat-icon { background: #ffedd5; }
.stat-cyan .stat-icon { background: #cffafe; }
.stat-pink .stat-icon { background: #fce7f3; }
.stat-indigo .stat-icon { background: #e0e7ff; }
.stat-red { background: linear-gradient(135deg, #fee2e2, #fecaca); }
.stat-red .stat-icon { background: rgba(255,255,255,0.5); }
.stat-red .stat-value, .stat-red .stat-label, .stat-red .stat-sub { color: #991b1b; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); }
.stat-label { font-size: 13px; color: var(--text-light); }
.stat-sub { font-size: 12px; color: var(--text-lighter); margin-top: 2px; }

/* ===== Dashboard Row ===== */
.dashboard-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.dashboard-col { min-width: 0; }

/* ===== Data Table ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 10px 12px; font-size: 13px; font-weight: 600; color: var(--text-light); border-bottom: 2px solid var(--border); white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.data-table tr:hover { background: #f8fafc; }
.empty-row { text-align: center; color: var(--text-lighter); padding: 30px !important; }
.action-cell { white-space: nowrap; display: flex; gap: 4px; }

/* ===== Badges ===== */
.badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.badge-published { background: #dcfce7; color: #166534; }
.badge-draft { background: #fef3c7; color: #92400e; }
.badge-archived { background: #f1f5f9; color: #475569; }
.badge-featured { background: #f3e8ff; color: #7e22ce; margin-left: 6px; }
.badge-role-admin { background: #fee2e2; color: #991b1b; }
.badge-role-editor { background: #dbeafe; color: #1e40af; }
.badge-role-author { background: #dcfce7; color: #166534; }

/* ===== Quick Actions ===== */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.quick-action { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px; background: var(--bg); border-radius: var(--radius); transition: var(--transition); color: var(--text); }
.quick-action:hover { background: var(--primary-light); transform: translateY(-2px); }
.qa-icon { font-size: 28px; }

/* ===== Rank Badge ===== */
.rank-badge { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: white; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 13px; color: var(--text-light); }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; transition: var(--transition); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); }
.input { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; }
.input-sm { width: 80px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form .input { flex: 1; min-width: 120px; }
.filter-form { display: flex; gap: 8px; align-items: center; }
.filter-form select, .filter-form .search-input { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; }
.search-input { width: 180px; }
.form-actions { margin-top: 12px; }

/* ===== Article Editor ===== */
.article-editor { display: grid; grid-template-columns: 1fr 280px; gap: 20px; }
.editor-main { background: white; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.title-input { width: 100%; padding: 12px 16px; font-size: 20px; font-weight: 700; border: 2px solid var(--border); border-radius: var(--radius-sm); }
.title-input:focus { outline: none; border-color: var(--primary); }

.editor-sidebar { display: flex; flex-direction: column; gap: 16px; }
.sidebar-box { background: white; border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.sidebar-box h4 { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.sidebar-box select, .sidebar-box input[type="text"], .sidebar-box input[type="number"] { width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; }

/* ===== AI Panel ===== */
.ai-panel { border: 1px solid var(--primary-light); border-radius: var(--radius-sm); margin-bottom: 16px; overflow: hidden; }
.ai-panel-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: linear-gradient(135deg, var(--primary-light), #cffafe); font-weight: 600; font-size: 14px; }
.ai-panel-header .ai-icon { font-size: 18px; }
.ai-panel-header .btn { margin-left: auto; }
.ai-panel-body { padding: 14px; }
.ai-input-group { display: flex; gap: 8px; }
.ai-input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; }
.ai-tips { font-size: 12px; color: var(--text-lighter); margin-top: 8px; }
.ai-result { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.ai-result-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.ai-result-preview { max-height: 300px; overflow-y: auto; background: var(--bg); padding: 12px; border-radius: var(--radius-sm); font-size: 13px; white-space: pre-wrap; font-family: 'Fira Code', monospace; }

/* ===== Markdown Editor ===== */
.editor-toolbar { display: flex; gap: 4px; padding: 8px; background: var(--bg); border: 1px solid var(--border); border-bottom: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; flex-wrap: wrap; }
.toolbar-btn { padding: 6px 10px; background: white; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; font-size: 14px; transition: var(--transition); }
.toolbar-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }
.toolbar-btn.active { background: var(--primary); color: white; }
.toolbar-divider { width: 1px; background: var(--border); margin: 2px 4px; }
.toolbar-toggle { margin-left: auto; }

.editor-area { display: flex; gap: 0; border: 1px solid var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.editor-pane { flex: 1; }
.preview-pane { flex: 1; border-left: 1px solid var(--border); overflow-y: auto; max-height: 600px; }
.markdown-editor { width: 100%; min-height: 500px; padding: 16px; border: none; outline: none; font-family: 'Fira Code', 'Consolas', monospace; font-size: 14px; line-height: 1.7; resize: vertical; }
.preview-content { padding: 16px; }
.preview-content h1, .preview-content h2, .preview-content h3 { margin: 16px 0 8px; }
.preview-content p { margin: 8px 0; }
.preview-content pre { background: #1e293b; color: #e2e8f0; padding: 12px; border-radius: 6px; overflow-x: auto; margin: 8px 0; }
.preview-content code { background: rgba(0,0,0,0.06); padding: 2px 6px; border-radius: 3px; font-size: 13px; }
.preview-content blockquote { border-left: 4px solid var(--primary); padding: 8px 12px; background: var(--primary-light); margin: 8px 0; }
.preview-content table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.preview-content th, .preview-content td { border: 1px solid var(--border); padding: 6px 10px; }
.preview-content ul, .preview-content ol { padding-left: 24px; }

/* ===== Tag Selector ===== */
.tag-selector { max-height: 200px; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 6px; }
.tag-checkbox { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.tag-checkbox input { width: auto; }
.tag-checkbox span { padding: 3px 10px; background: var(--bg); border-radius: 12px; font-size: 12px; transition: var(--transition); }
.tag-checkbox input:checked + span { background: var(--primary); color: white; }
.tag-add { display: flex; gap: 6px; margin-top: 8px; }
.tag-add input { flex: 1; }

/* ===== Featured Image ===== */
.featured-image-preview { width: 100%; aspect-ratio: 16/9; background: var(--bg); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 8px; display: flex; align-items: center; justify-content: center; }
.featured-image-preview img { width: 100%; height: 100%; object-fit: cover; }
.no-image { color: var(--text-lighter); font-size: 13px; }

/* ===== Inline Edit ===== */
.inline-edit { width: 100%; padding: 4px 8px; border: 1px solid transparent; border-radius: 4px; font-size: 14px; transition: var(--transition); background: transparent; }
.inline-edit:hover { border-color: var(--border); }
.inline-edit:focus { outline: none; border-color: var(--primary); background: white; }
.inline-edit-sm { width: 60px; padding: 4px 6px; border: 1px solid transparent; border-radius: 4px; font-size: 13px; text-align: center; }
.inline-edit-sm:hover { border-color: var(--border); }
.inline-edit-sm:focus { outline: none; border-color: var(--primary); }

/* ===== Tag List (Admin) ===== */
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-item { display: flex; align-items: center; gap: 6px; padding: 6px 12px; background: var(--bg); border-radius: 16px; font-size: 13px; }
.tag-name { font-weight: 500; }
.tag-count { color: var(--text-lighter); font-size: 12px; }

/* ===== Attachment Grid ===== */
.attachment-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.attachment-card { background: var(--bg); border-radius: var(--radius); overflow: hidden; }
.attachment-thumb { width: 100%; aspect-ratio: 16/10; background: #e2e8f0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.attachment-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-icon { font-size: 48px; }
.attachment-info { padding: 10px; }
.attachment-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.attachment-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-lighter); margin-bottom: 6px; }
.attachment-actions { display: flex; gap: 4px; }

/* ===== Settings ===== */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.setting-item { margin-bottom: 12px; }
.setting-full { grid-column: 1 / -1; }
.setting-item label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 13px; color: var(--text-light); }
.setting-item input, .setting-item select { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; }
.setting-item textarea { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; min-height: 60px; }
.setting-hint { font-weight: 400; color: var(--text-lighter); font-size: 12px; }

/* ===== Pagination ===== */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 20px; flex-wrap: wrap; }
.page-btn { padding: 6px 12px; background: white; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; color: var(--text); transition: var(--transition); }
.page-btn:hover { border-color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .article-editor { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .dashboard-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    body.sidebar-collapsed .sidebar { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 6px 8px; }
}
