/* ═══════════════════════════════════════════════════════
   Sabre Knowledge — Dashboard Styles (Dark Theme)
   Following APPLICATION_STANDARDS.md + SIDEBAR_FOOTER_TEMPLATE.md
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #111127;
  --bg-card: #161636;
  --bg-hover: #1e1e42;
  --bg-input: #0f0f2a;
  --border-color: rgba(99, 102, 241, 0.12);
  --border-hover: rgba(99, 102, 241, 0.3);
  --text-primary: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #6366f1;
  --primary-light: #818cf8;
  --accent: #22d3ee;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --font: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font); background: var(--bg-primary); color: var(--text-primary); overflow-x: hidden; }
.accent { color: var(--accent); }

/* ─── Sidebar ──────────────────────────────────── */
.sidebar {
  width: 260px; background: var(--bg-secondary); border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column; position: fixed; height: 100vh; left: 0; top: 0;
  transition: width 0.3s ease; z-index: 100;
}
.sidebar-header {
  display: flex; align-items: center; gap: 10px; padding: 16px;
  border-bottom: 1px solid var(--border-color);
}
.logo-icon {
  width: 36px; height: 36px; min-width: 36px; border-radius: 8px;
  background: transparent; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.logo-text { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.sidebar-collapse-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  margin-left: auto; padding: 4px; display: flex; align-items: center;
}

/* ─── Sidebar Collapse ─────────────────────────── */
.sidebar.collapsed { width: 70px; }
.sidebar.collapsed .logo-text, .sidebar.collapsed .nav-item span:not(.nav-icon) { display: none; }
.sidebar.collapsed .sidebar-header { padding: 16px 0; justify-content: center; }
.sidebar.collapsed .logo-icon { margin: 0 auto; }
.sidebar.collapsed .sidebar-collapse-btn { display: none; }
.sidebar.collapsed .sidebar-nav { padding: 16px 0; }
.sidebar.collapsed .nav-item { padding: 12px 0; justify-content: center; margin: 0; border-radius: 0; }
.sidebar.collapsed .nav-icon { margin: 0; }
.sidebar.collapsed #sidebarFooterContent { display: none !important; }
.sidebar.collapsed .sidebar-footer { padding: 0; }
.sidebar.collapsed #sidebarFooterToggle { justify-content: center; padding: 12px 0; }
.sidebar.collapsed #sidebarFooterToggle > .sidebar-footer-toggle-text { display: flex !important; justify-content: center; }
.sidebar.collapsed #sidebarFooterToggle #footerOrgLogo { display: flex !important; margin: 0 auto; }
.sidebar.collapsed #sidebarFooterToggle #footerOrgName { display: none !important; }
.sidebar.collapsed #sidebarFooterToggle > svg.sidebar-footer-toggle-text { display: none !important; }
.sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .nav-section-divider { justify-content: center; padding: 16px 0 8px; }
.sidebar.collapsed .nav-section-divider::after { display: none; }
.sidebar.collapsed ~ .main-content { margin-left: 70px; }

/* ─── Nav Items ────────────────────────────────── */
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius);
  cursor: pointer; transition: all 0.2s; color: var(--text-muted); text-decoration: none; position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: rgba(99, 102, 241, 0.12); color: var(--primary-light); font-weight: 600; }
.nav-icon { font-size: 1.1rem; width: 24px; text-align: center; flex-shrink: 0; }
.nav-badge {
  position: absolute; right: 12px; background: var(--danger); color: white;
  font-size: 0.65rem; font-weight: 700; padding: 2px 6px; border-radius: 10px; min-width: 18px; text-align: center;
}
.nav-section-divider {
  display: flex; align-items: center; gap: 8px; padding: 20px 14px 8px;
  font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; font-weight: 600;
}
.nav-section-divider::after { content: ''; flex: 1; height: 1px; background: var(--border-color); }

/* ─── Main Content ──────────────────────────────── */
.main-content { margin-left: 260px; min-height: 100vh; transition: margin-left 0.3s ease; padding: 24px; }

/* ─── Page Header ──────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 4px; }
.page-header p { color: var(--text-muted); font-size: 0.9rem; }

/* ─── Cards ─────────────────────────────────────── */
.card {
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: 24px; transition: all 0.2s;
}
.card:hover { border-color: var(--border-hover); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.card-header h2 { font-size: 1.1rem; font-weight: 700; }

/* ─── Stats Grid ────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: 20px; transition: all 0.3s;
}
.stat-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 1.8rem; font-weight: 800; }
.stat-value.primary { color: var(--primary-light); }
.stat-value.accent { color: var(--accent); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }

/* ─── Tables ────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 12px 16px; font-size: 0.75rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border-color);
}
.data-table td { padding: 14px 16px; border-bottom: 1px solid var(--border-color); font-size: 0.9rem; }
.data-table tr:hover td { background: var(--bg-hover); }

/* ─── Buttons ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius); font-family: var(--font);
  font-weight: 600; font-size: 0.85rem; text-decoration: none; cursor: pointer;
  transition: all 0.2s; border: 1px solid transparent;
}
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }
.btn-outline { background: transparent; color: var(--text-muted); border-color: var(--border-color); }
.btn-outline:hover { color: var(--text-primary); border-color: var(--border-hover); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-icon { width: 36px; height: 36px; padding: 0; }

/* ─── Forms ─────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.form-input, .form-textarea, .form-select {
  width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: var(--radius); color: var(--text-primary); font-family: var(--font); font-size: 0.9rem;
  transition: border-color 0.2s; box-sizing: border-box;
}
.form-input:focus, .form-textarea:focus, .form-select:focus { outline: none; border-color: var(--primary); }
.form-textarea { resize: vertical; min-height: 100px; }

/* ─── Tags ──────────────────────────────────────── */
.tag { display: inline-flex; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.tag-published { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.tag-draft { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.tag-archived { background: rgba(100, 116, 139, 0.15); color: var(--text-dim); }
.tag-pending { background: rgba(99, 102, 241, 0.15); color: var(--primary-light); }
.tag-answered { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.tag-dismissed { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.tag-scrape { background: rgba(34, 211, 238, 0.15); color: var(--accent); }
.tag-website { background: rgba(99, 102, 241, 0.15); color: var(--primary-light); }
.tag-youtube { background: rgba(255, 0, 0, 0.15); color: #ff4444; }
.tag-document { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

/* ─── Empty State ───────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { font-weight: 700; margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); margin-bottom: 20px; }

/* ─── Modal ─────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
  z-index: 9998; align-items: center; justify-content: center; backdrop-filter: blur(2px);
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  width: 600px; max-width: 95vw; max-height: 90vh; overflow-y: auto; padding: 28px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h2 { font-size: 1.2rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.5rem; padding: 4px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* ─── Loading ───────────────────────────────────── */
.content-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 50vh; gap: 16px; }
.spinner {
  width: 40px; height: 40px; border: 3px solid var(--border-color); border-top: 3px solid var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toast ─────────────────────────────────────── */
.toast {
  background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius);
  padding: 12px 20px; font-size: 0.85rem; box-shadow: var(--shadow); display: flex; align-items: center; gap: 8px;
  min-width: 280px; animation: slideIn 0.3s ease;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--primary); }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Responsive ────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.active { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
