/* ============================================================
   cacnews AI 采编系统 — 专业界面
   ============================================================ */

:root {
  --sidebar-w: 224px;
  --sidebar-bg: #111827;
  --sidebar-item: #9ca3af;
  --sidebar-item-hover-bg: rgba(255,255,255,0.06);
  --sidebar-item-hover: #e5e7eb;
  --sidebar-active-bg: rgba(99,102,241,0.16);
  --sidebar-active: #a5b4fc;
  --sidebar-divider: rgba(255,255,255,0.07);

  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: rgba(79,70,229,0.1);

  --green: #059669;
  --green-bg: #d1fae5;
  --green-text: #065f46;

  --amber: #d97706;
  --amber-bg: #fef3c7;
  --amber-text: #92400e;

  --red: #dc2626;
  --red-bg: #fee2e2;
  --red-text: #991b1b;

  --blue: #2563eb;
  --blue-bg: #dbeafe;
  --blue-text: #1e40af;

  --purple: #7c3aed;
  --purple-bg: #ede9fe;
  --purple-text: #4c1d95;

  --orange: #ea580c;
  --orange-hover: #c2410c;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   LAYOUT — sidebar + main
   ============================================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 200;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 18px 16px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--sidebar-divider);
  margin-bottom: 6px;
}
.brand-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}
.brand-text { display: flex; flex-direction: column; gap: 0; }
.brand-name { font-size: 14px; font-weight: 700; color: #f1f5f9; letter-spacing: 0.01em; }
.brand-sub  { font-size: 10px; color: #6b7280; letter-spacing: 0.06em; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 4px 8px; }

.nav-section {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #4b5563;
  padding: 14px 8px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-item);
  text-decoration: none;
  font-size: 13px;
  font-weight: 450;
  transition: background 0.1s, color 0.1s;
  cursor: pointer;
  margin-bottom: 1px;
}
.nav-item:hover  { background: var(--sidebar-item-hover-bg); color: var(--sidebar-item-hover); }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); }

.nav-icon {
  width: 16px;
  text-align: center;
  font-size: 13px;
  flex-shrink: 0;
  opacity: 0.9;
}
.nav-divider { height: 1px; background: var(--sidebar-divider); margin: 6px 0; }

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--sidebar-divider);
}

/* ── Main ── */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}

.container {
  max-width: 1440px;
  padding: 28px 32px;
  width: 100%;
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.page-header h2 { font-size: 20px; font-weight: 700; }
.page-header-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4 { line-height: 1.3; font-weight: 600; }
h2 { font-size: 18px; color: var(--text); margin-bottom: 4px; }
h3 { font-size: 14px; color: var(--text); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-2);
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.1s;
  white-space: nowrap;
  line-height: 1.4;
  font-family: inherit;
}
.btn:hover   { background: #f8fafc; border-color: #94a3b8; color: var(--text); }
.btn:active  { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.btn-success { background: var(--green); color: #fff; border-color: var(--green); }
.btn-success:hover { background: #047857; border-color: #047857; color: #fff; }

.btn-danger  { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover  { background: #b91c1c; border-color: #b91c1c; color: #fff; }

.btn-orange  { background: var(--orange); color: #fff; border-color: var(--orange); }
.btn-orange:hover  { background: var(--orange-hover); border-color: var(--orange-hover); color: #fff; }

.btn-sm    { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  border-left: 3px solid transparent;
}
.alert-success { background: var(--green-bg); color: var(--green-text); border-left-color: var(--green); }
.alert-error   { background: var(--red-bg);   color: var(--red-text);   border-left-color: var(--red); }
.alert-info    { background: var(--blue-bg);  color: var(--blue-text);  border-left-color: var(--blue); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge-pending    { background: var(--amber-bg);  color: var(--amber-text); }
.badge-processing {
  background: var(--blue-bg); color: var(--blue-text);
  animation: badge-pulse 1.6s ease-in-out infinite;
}
@keyframes badge-pulse { 0%,100%{ opacity:1 } 50%{ opacity:.55 } }

/* AI处理状态条 */
.ai-status-bar {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0;
  z-index: 200;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  transition: background .4s;
}
.ai-status-bar.processing { background: var(--accent); }
.ai-status-bar.done       { background: var(--green); }
.ai-status-bar-track {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  overflow: hidden;
}
.ai-status-bar-fill {
  height: 100%;
  background: rgba(255,255,255,0.9);
  border-radius: 2px;
}
.ai-status-bar.processing .ai-status-bar-fill {
  width: 30%;
  animation: ai-indeterminate 1.4s ease-in-out infinite;
}
.ai-status-bar.done .ai-status-bar-fill { width: 100%; transition: width .4s; }
@keyframes ai-indeterminate {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(450%); }
}
.badge-processed  { background: var(--purple-bg); color: var(--purple-text); }
.badge-published  { background: var(--green-bg);  color: var(--green-text); }
.badge-discarded  { background: #f1f5f9; color: #64748b; }
.badge-source     { background: #f1f5f9; color: #475569; }
.badge-lang-en    { background: #f1f5f9; color: #475569; font-size: 10px; font-weight: 700; letter-spacing: 0.05em; }
.badge-lang-zh    { background: var(--amber-bg); color: var(--amber-text); font-size: 10px; font-weight: 700; letter-spacing: 0.05em; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: var(--text-2);
  font-size: 13px;
}
.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="password"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  transition: border-color 0.12s, box-shadow 0.12s;
  appearance: none;
}
.form-group textarea { resize: vertical; }
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-row     { display: flex; gap: 16px; }
.flex-1       { flex: 1; min-width: 0; }
.form-actions { margin-top: 20px; display: flex; gap: 8px; flex-wrap: wrap; }

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-weight: 500 !important;
  color: var(--text-2);
  font-size: 13px;
}
.checkbox-label input[type="checkbox"] { width: 14px; height: 14px; }

.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-form label { margin-bottom: 0; white-space: nowrap; color: var(--text-3); font-size: 12px; font-weight: 500; }
.inline-form select {
  width: auto;
  padding: 5px 8px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
}
.inline-form select:focus { outline:none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

.required { color: var(--red); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 55%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-container {
  width: 380px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.32);
  padding: 36px;
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo-mark {
  display: inline-flex;
  width: 52px;
  height: 52px;
  background: var(--accent);
  border-radius: 14px;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 14px;
}
.login-logo h2 { font-size: 20px; color: var(--text); margin-bottom: 4px; }
.login-logo p  { font-size: 13px; color: var(--text-3); }

/* ============================================================
   STATUS TABS
   ============================================================ */
.status-tabs {
  display: inline-flex;
  gap: 2px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 4px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  border: none;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
  cursor: pointer;
}
.tab:hover  { background: var(--bg); color: var(--text); }
.tab.active { background: var(--accent); color: #fff; }

/* ============================================================
   LIST PAGE TOOLBAR
   ============================================================ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.list-header { display: flex; align-items: center; margin-bottom: 14px; }
.list-header h2 { font-size: 18px; }
.list-header .count {
  color: var(--text-3);
  font-size: 13px;
  font-weight: 400;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1px 9px;
  margin-left: 10px;
}

/* ============================================================
   ARTICLE TABLE
   ============================================================ */
.article-table {
  width: 100%;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-collapse: collapse;
}
.article-table th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  color: var(--text-3);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.article-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
  vertical-align: middle;
}
.article-table tr:last-child td { border-bottom: none; }
.article-table tbody tr:hover td { background: #fafbff; }

.title-cell { max-width: 380px; }
.title-en   { color: var(--text-2); font-size: 12.5px; line-height: 1.45; }
.title-cn   { color: var(--text); font-weight: 600; margin-top: 3px; font-size: 13px; }
.time-cell  { white-space: nowrap; color: var(--text-3); font-size: 12px; }
.action-cell { white-space: nowrap; }
.empty-row  { text-align: center; color: var(--text-3); padding: 56px !important; font-size: 14px; }
.truncate   { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.processing-indicator { color: var(--blue); font-size: 12px; font-style: italic; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination { display: flex; gap: 4px; margin-top: 20px; justify-content: center; }
.page-link {
  padding: 5px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  background: var(--card);
  transition: all 0.1s;
}
.page-link:hover  { background: var(--bg); border-color: #94a3b8; }
.page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ============================================================
   CARD / SUBMIT FORM
   ============================================================ */
.submit-form {
  background: var(--card);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 18px;
}

.tip-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 13px;
  color: var(--text-2);
}
.tip-box strong { color: var(--text); }
.tip-box ul { margin-top: 7px; padding-left: 18px; }
.tip-box li { margin-bottom: 4px; }
.tip-box a  { color: var(--accent); }

/* ============================================================
   EDIT PAGE
   ============================================================ */
.edit-header { margin-bottom: 14px; }
.edit-meta {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-3);
  flex-wrap: wrap;
}
.edit-meta a { color: var(--accent); text-decoration: none; }
.edit-meta a:hover { text-decoration: underline; }

.reprocess-bar {
  background: var(--card);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.edit-columns { display: flex; gap: 16px; margin-bottom: 18px; }
.edit-col {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  min-width: 0;
}
.edit-col h3 {
  margin-bottom: 14px;
  font-size: 11px;
  color: var(--text-3);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.edit-col-left { max-height: 82vh; overflow-y: auto; }

.title-input { font-size: 16px !important; font-weight: 600 !important; }

#editor       { min-height: 420px; }
.ql-container { font-size: 15px; border-color: var(--border) !important; border-radius: 0 0 var(--radius-sm) var(--radius-sm) !important; }
.ql-toolbar   { border-color: var(--border) !important; border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important; background: #f8fafc !important; }
.ql-editor    { min-height: 420px; line-height: 1.8; }

/* ============================================================
   IMAGE GALLERY
   ============================================================ */
.image-gallery {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 18px;
}
.image-gallery h3 {
  margin-bottom: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}

.gallery-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.gallery-item {
  width: 148px;
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.gallery-item:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.gallery-item img { width: 100%; height: 96px; object-fit: cover; display: block; }
.gallery-caption   { padding: 5px 7px; font-size: 11px; color: var(--text-3); text-align: center; background: #f8fafc; }

/* ============================================================
   BOTTOM ACTIONS
   ============================================================ */
.bottom-actions { display: flex; gap: 10px; padding: 16px 0 8px; flex-wrap: wrap; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 960px) {
  .sidebar { width: 0; overflow: hidden; }
  .main-wrap { margin-left: 0; }
  .edit-columns { flex-direction: column; }
  .form-row { flex-direction: column; gap: 0; }
}
