/* ============================================
   CMS Admin - 管理后台样式
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --bg: #f5f5f5;
    --card-bg: #fff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --sidebar-w: 240px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout --- */
.admin-wrap { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: var(--sidebar-w);
    background: #1e1b4b;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}
.sidebar-brand { padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-brand h2 { font-size: 18px; font-weight: 700; }
.sidebar-brand small { opacity: 0.6; font-size: 12px; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    transition: all 0.2s;
}
.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    text-decoration: none;
}
.nav-item.active { border-right: 3px solid var(--primary); font-weight: 600; }
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex; align-items: center; justify-content: space-between;
    font-size: 13px;
}
.admin-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
}
.admin-header {
    background: #fff;
    padding: 16px 28px;
    box-shadow: var(--shadow);
    position: sticky; top: 0; z-index: 50;
}
.admin-header h1 { font-size: 20px; font-weight: 600; }
.admin-content { padding: 24px 28px; flex: 1; }

/* --- Cards --- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-header h4 { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }

/* --- Forms --- */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: #374151;
}
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
    background: #fff;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.form-control-sm { padding: 5px 10px; font-size: 13px; }
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }
textarea.editor { font-family: 'Courier New', monospace; font-size: 14px; min-height: 300px; }
.required { color: var(--danger); }
.form-row { display: flex; gap: 16px; }
.form-row-2col .form-group { flex: 1; }
.form-row-3col .form-group { flex: 1; }
.form-row-4col .form-group { flex: 1; }
.flex-1 { flex: 1; }
.form-inline { display: flex; gap: 8px; align-items: center; }
.form-inline-wrap { }
.input-group { display: flex; gap: 8px; }
.form-actions { margin-top: 20px; display: flex; gap: 12px; }

/* --- Table --- */
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 10px 12px; text-align: left; background: #f9fafb; font-weight: 600; font-size: 13px; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table tr:hover td { background: #f9fafb; }

/* --- Badge --- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    border-radius: 12px;
    font-weight: 500;
    background: #e5e7eb;
    color: var(--text);
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* --- Stats --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 16px;
}
.stat-icon { font-size: 32px; }
.stat-number { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 13px; color: var(--text-muted); }

/* --- Toolbar --- */
.toolbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap; gap: 12px;
}
.toolbar-left, .toolbar-right { display: flex; gap: 8px; align-items: center; }

/* --- Pagination --- */
.pagination { display: flex; gap: 4px; margin-top: 16px; justify-content: center; }
.page-link {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text);
    background: #fff;
}
.page-link:hover { background: var(--bg); text-decoration: none; }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* --- Image Grid --- */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.image-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.image-card-img { aspect-ratio: 4/3; overflow: hidden; background: #f3f4f6; display: flex; align-items: center; justify-content: center; }
.image-card-img img { width: 100%; height: 100%; object-fit: cover; }
.image-card-info { padding: 10px; }
.image-card-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.image-card-meta { font-size: 11px; color: var(--text-muted); display: flex; gap: 8px; margin-bottom: 8px; }
.image-card-actions { display: flex; gap: 4px; }

/* --- Image Picker Modal --- */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-content { position: relative; background: #fff; border-radius: var(--radius); max-width: 800px; width: 90%; max-height: 80vh; display: flex; flex-direction: column; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; padding: 0; line-height: 1; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.image-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.image-pick-item { cursor: pointer; border: 2px solid transparent; border-radius: 6px; overflow: hidden; transition: border-color 0.2s; }
.image-pick-item:hover { border-color: var(--primary); }
.image-pick-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.image-pick-item span { display: block; padding: 4px 8px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- Tag Cloud --- */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-item {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 12px;
    background: #f3f4f6;
    border-radius: 20px;
    font-size: 13px;
}
.tag-item a { font-size: 12px; text-decoration: none; }
.tag-checkboxes { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-checkbox {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 12px; border: 1px solid var(--border); border-radius: 6px;
    cursor: pointer; font-size: 13px;
}
.tag-checkbox:hover { background: #f3f4f6; }

/* --- Alerts --- */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* --- Utilities --- */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* --- Responsive --- */
@media (max-width: 768px) {
    .admin-sidebar { width: 100%; height: auto; position: relative; }
    .admin-main { margin-left: 0; }
    .admin-wrap { flex-direction: column; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { flex-direction: column; }
    .image-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .toolbar { flex-direction: column; align-items: stretch; }
}
