/*
 * Biblioma
 * Copyright (c) 2026 Aguinel J. Bastian Jr.
 * All rights reserved.
 */

/* =====================================================================
   Biblioma - CSS principal
   Light/dark mode controlado via data-theme="light|dark" no <html>
   ===================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f7f7f5;
  --bg-tertiary: #ededea;
  --bg-info: #ecfeff;
  --bg-success: #e1f5ee;
  --bg-warning: #faeeda;
  --bg-danger: #fcebeb;
  --text-primary: #1a1a1a;
  --text-secondary: #5f5e5a;
  --text-tertiary: #888780;
  --text-info: #0891b2;
  --text-success: #0f6e56;
  --text-warning: #854f0b;
  --text-danger: #a32d2d;
  --border-tertiary: rgba(0, 0, 0, 0.08);
  --border-secondary: rgba(0, 0, 0, 0.16);
  --border-primary: rgba(0, 0, 0, 0.24);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --accent-glow: rgba(8, 145, 178, 0.18);
  --topbar-bg: rgba(255, 255, 255, 0.88);
}

[data-theme="dark"] {
  --bg-primary: #1c1c1a;
  --bg-secondary: #252523;
  --bg-tertiary: #2e2e2c;
  --bg-info: rgba(34, 211, 238, 0.09);
  --bg-success: #0a3d2d;
  --bg-warning: #3d2a08;
  --bg-danger: #3d1414;
  --text-primary: #f5f4ef;
  --text-secondary: #b8b6ae;
  --text-tertiary: #8b8a82;
  --text-info: #22d3ee;
  --text-success: #5dcaa5;
  --text-warning: #f0b260;
  --text-danger: #f09595;
  --border-tertiary: rgba(255, 255, 255, 0.08);
  --border-secondary: rgba(255, 255, 255, 0.16);
  --border-primary: rgba(255, 255, 255, 0.24);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --accent-glow: rgba(34, 211, 238, 0.14);
  --topbar-bg: rgba(28, 28, 26, 0.88);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-secondary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--text-info); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === TOPBAR === */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--topbar-bg);
  border-bottom: 0.5px solid var(--border-tertiary);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-info);
  color: var(--text-info);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: box-shadow var(--transition);
}

[data-theme="dark"] .brand-icon {
  box-shadow: 0 0 14px var(--accent-glow);
}

.brand-icon-large {
  width: 56px;
  height: 56px;
  font-size: 28px;
  margin-bottom: 20px;
}

.brand-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.brand-subtitle { font-size: 12px; color: var(--text-secondary); }

.topbar-nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}

.nav-link:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-link.active {
  background: var(--bg-info);
  color: var(--text-info);
}

[data-theme="dark"] .nav-link.active {
  box-shadow: inset 0 0 0 0.5px rgba(34, 211, 238, 0.2);
}

.nav-link i { font-size: 18px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 0.5px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background var(--transition), border-color var(--transition);
}

.icon-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--border-tertiary);
  color: var(--text-primary);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-info);
  color: var(--text-info);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

/* === MAIN CONTENT === */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* === METRIC CARDS === */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-primary);
  border: 0.5px solid var(--border-tertiary);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: border-color var(--transition);
}

.metric-card:hover { border-color: var(--border-secondary); }

.metric-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.metric-value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.metric-hint { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }

/* === MONITOR CARDS === */
.monitor-list { display: flex; flex-direction: column; gap: 12px; }

.monitor-card {
  background: var(--bg-primary);
  border: 0.5px solid var(--border-tertiary);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.monitor-card:hover {
  border-color: var(--border-secondary);
}

[data-theme="dark"] .monitor-card:hover {
  box-shadow: 0 0 0 0.5px rgba(34, 211, 238, 0.08);
}

.monitor-card.paused { opacity: 0.65; }

.monitor-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.monitor-info { flex: 1; min-width: 0; }
.monitor-title-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.monitor-title { font-size: 15px; font-weight: 600; }
.monitor-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; }
.monitor-meta { display: flex; gap: 16px; font-size: 12px; color: var(--text-tertiary); flex-wrap: wrap; }
.monitor-meta i { font-size: 13px; vertical-align: -1px; margin-right: 4px; }

.monitor-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* === BADGES === */
.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-success { background: var(--bg-success); color: var(--text-success); }
.badge-info { background: var(--bg-info); color: var(--text-info); }
.badge-warning { background: var(--bg-warning); color: var(--text-warning); }
.badge-danger { background: var(--bg-danger); color: var(--text-danger); }
.badge-neutral { background: var(--bg-tertiary); color: var(--text-secondary); }

/* === BUTTONS === */
button, .btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border-secondary);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition), border-color var(--transition), transform var(--transition), opacity var(--transition);
}

button:hover, .btn:hover {
  background: var(--bg-secondary);
  border-color: var(--border-primary);
}

button:active, .btn:active { transform: scale(0.98); }

button:disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--text-info) 0%, #6366f1 100%);
  color: white;
  border-color: transparent;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--text-info) 0%, #6366f1 100%);
  opacity: 0.88;
  border-color: transparent;
}

.btn-sm { font-size: 12px; padding: 6px 10px; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; }

button i, .btn i { font-size: 16px; }

/* === FORM ELEMENTS === */
input[type="text"], input[type="email"], input[type="password"], input[type="search"], textarea, select {
  width: 100%;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 0.5px solid var(--border-secondary);
  border-radius: var(--radius-md);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--text-info);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder, textarea::placeholder { color: var(--text-tertiary); }

.input-with-icon {
  position: relative;
}
.input-with-icon i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}
.input-with-icon input { padding-left: 36px; }

label.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.form-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.form-group { margin-bottom: 16px; }

/* === STEPPER === */
.stepper {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--bg-primary);
  border: 0.5px solid var(--border-tertiary);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
}

.step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.step-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.step-pending .step-circle { background: var(--bg-tertiary); color: var(--text-tertiary); }
.step-active .step-circle { background: var(--bg-info); color: var(--text-info); }
.step-done .step-circle { background: var(--bg-success); color: var(--text-success); }

.step-label { font-size: 13px; color: var(--text-secondary); }
.step-active .step-label { color: var(--text-primary); font-weight: 500; }
.step-pending .step-label { color: var(--text-tertiary); }

/* === MESH SEARCH === */
.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  min-height: 28px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-info);
  color: var(--text-info);
  border-radius: var(--radius-md);
  font-size: 12px;
}

.chip-qualifier {
  opacity: 0.7;
  font-size: 11px;
}

.chip-majr {
  font-size: 10px;
  padding: 1px 6px;
  background: var(--bg-warning);
  color: var(--text-warning);
  border-radius: var(--radius-sm);
}

.chip-remove { cursor: pointer; font-size: 14px; }

.mesh-dropdown {
  background: var(--bg-primary);
  border: 0.5px solid var(--border-secondary);
  border-radius: var(--radius-md);
  margin-top: 4px;
  max-height: 320px;
  overflow-y: auto;
}

.mesh-dropdown-header {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-tertiary);
  background: var(--bg-secondary);
  border-bottom: 0.5px solid var(--border-tertiary);
}

.mesh-item {
  padding: 10px 12px;
  border-bottom: 0.5px solid var(--border-tertiary);
  cursor: pointer;
  transition: background var(--transition);
}

.mesh-item:last-child { border-bottom: none; }
.mesh-item:hover { background: var(--bg-secondary); }

.mesh-item-name {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mesh-item-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.mesh-item-qualifiers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.qualifier-pill {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.qualifier-pill:hover { background: var(--bg-info); color: var(--text-info); }
.qualifier-pill.selected { background: var(--bg-info); color: var(--text-info); }

/* === QUERY PREVIEW === */
.query-preview {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 20px;
}

.query-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.query-preview-label {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.query-preview-text {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  word-break: break-all;
  color: var(--text-primary);
}

.query-preview-text .mesh { color: var(--text-info); }
.query-preview-text .pubtype { color: var(--text-warning); }

/* === SEARCH RESULTS === */
.search-result {
  background: var(--bg-primary);
  border: 0.5px solid var(--border-tertiary);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color var(--transition);
}

.search-result:hover { border-color: var(--border-secondary); }

.result-row { display: flex; align-items: start; gap: 16px; }

.relevance-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 56px;
  padding-top: 4px;
}

.relevance-value { font-size: 22px; font-weight: 600; color: var(--text-info); letter-spacing: -0.02em; }
.relevance-label { font-size: 10px; color: var(--text-tertiary); text-align: center; }

.result-content { flex: 1; min-width: 0; }

.result-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-tertiary);
}

.result-title { font-size: 15px; font-weight: 600; line-height: 1.4; margin-bottom: 8px; }
.result-authors { font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; }

.result-reason {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
  padding: 10px 12px;
  background: var(--bg-info);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}

.result-reason-label { color: var(--text-info); font-weight: 500; margin-right: 6px; }

.result-actions { display: flex; gap: 8px; }

/* === DIGEST CARDS === */
.timeline-section-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 24px 0 8px;
}

.digest-card {
  background: var(--bg-primary);
  border: 0.5px solid var(--border-tertiary);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color var(--transition);
}

.digest-card:hover { border-color: var(--border-secondary); }

.digest-preview {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 10px 0;
  max-height: 120px;
  overflow: hidden;
  position: relative;
}

.digest-preview-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--bg-secondary));
}

/* === LOGIN — always dark, futuristic === */
.login-screen {
  /* Force dark aesthetic regardless of user theme */
  --text-primary: #e8eaf2;
  --text-secondary: #8b93a8;
  --text-tertiary: #4a5168;
  --bg-primary: rgba(12, 16, 28, 0.82);
  --bg-secondary: rgba(255, 255, 255, 0.04);
  --border-secondary: rgba(255, 255, 255, 0.11);
  --border-tertiary: rgba(255, 255, 255, 0.06);
  --text-info: #22d3ee;
  --bg-info: rgba(34, 211, 238, 0.08);
  --text-danger: #f87171;
  --bg-danger: rgba(248, 113, 113, 0.1);
  --text-success: #34d399;
  --bg-success: rgba(52, 211, 153, 0.1);
  --accent-glow: rgba(34, 211, 238, 0.14);

  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  /* Dark grid background */
  background-color: #080c16;
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  position: relative;
  overflow: hidden;
  color: var(--text-primary);
}

/* Radial glow behind card */
.login-screen::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 720px;
  height: 720px;
  background: radial-gradient(ellipse, rgba(34, 211, 238, 0.055) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
}

.login-card {
  position: relative;
  z-index: 1;
  background: rgba(10, 14, 26, 0.72);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 0.5px solid rgba(34, 211, 238, 0.18);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow:
    0 0 0 0.5px rgba(34, 211, 238, 0.07),
    0 24px 80px rgba(0, 0, 0, 0.55),
    0 0 120px rgba(34, 211, 238, 0.04);
}

/* Brand icon in login: always cyan, pulsing */
.brand-icon-large {
  width: 56px;
  height: 56px;
  font-size: 28px;
  margin-bottom: 20px;
  background: rgba(34, 211, 238, 0.1);
  color: #22d3ee;
  border: 0.5px solid rgba(34, 211, 238, 0.25);
  border-radius: var(--radius-md);
  animation: iconPulse 2.8s ease-in-out infinite;
}

@keyframes iconPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(34, 211, 238, 0),
                0 0 10px rgba(34, 211, 238, 0.2);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(34, 211, 238, 0.06),
                0 0 28px rgba(34, 211, 238, 0.38);
  }
}

.login-card h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #e8eaf2;
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 13px;
  color: #8b93a8;
  margin-bottom: 24px;
}

.login-card form { display: flex; flex-direction: column; gap: 12px; }

/* Login inputs — always dark */
.login-card input[type="email"],
.login-card input[type="password"] {
  background: rgba(255, 255, 255, 0.05);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  color: #e8eaf2;
  height: 40px;
  padding: 9px 12px;
  padding-right: 40px;
  font-size: 14px;
  -webkit-appearance: none;
  appearance: none;
}

.login-card input[type="email"]:focus,
.login-card input[type="password"]:focus {
  border-color: rgba(34, 211, 238, 0.45);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1);
  outline: none;
}

.login-card input::placeholder { color: #4a5168; }

/* Login submit — gradient */
.login-card button[type="submit"] {
  background: linear-gradient(135deg, #0891b2 0%, #6366f1 100%);
  color: white;
  border: none;
  justify-content: center;
  padding: 11px 16px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: opacity 200ms ease, transform 150ms ease;
}

.login-card button[type="submit"]:hover {
  background: linear-gradient(135deg, #0891b2 0%, #6366f1 100%);
  opacity: 0.88;
  border-color: transparent;
}

.loading-icon { display: none; animation: spin 1s linear infinite; }
.loading button .loading-icon { display: inline-block; }
.loading button .btn-label { display: none; }

.login-message {
  margin-top: 16px;
  font-size: 13px;
  padding: 10px;
  border-radius: var(--radius-md);
  display: none;
}
.login-message.show { display: block; }
.login-message.success { background: rgba(52, 211, 153, 0.1); color: #34d399; }
.login-message.error { background: rgba(248, 113, 113, 0.1); color: #f87171; }

/* === MISC === */
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.initial-loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--text-tertiary);
}

.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-secondary);
}

.empty-state i { font-size: 48px; color: var(--text-tertiary); margin-bottom: 16px; display: inline-block; }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }
.empty-state p { font-size: 13px; margin-bottom: 16px; }

/* === TOAST === */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-primary);
  border: 0.5px solid var(--border-secondary);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  min-width: 240px;
  max-width: 380px;
  animation: slideIn 200ms ease-out;
}

.toast.success { border-left: 3px solid var(--text-success); border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.toast.error { border-left: 3px solid var(--text-danger); border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.toast.info { border-left: 3px solid var(--text-info); border-radius: 0 var(--radius-md) var(--radius-md) 0; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* === MODAL === */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 150ms ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.modal h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; letter-spacing: -0.01em; }
.modal p { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; }

.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; gap: 12px; }
  .topbar-nav .nav-link span { display: none; }
  .brand-subtitle { display: none; }
  .main-content { padding: 20px 16px 48px; }
  .stepper { padding: 10px 12px; }
  .step-label { display: none; }
  .monitor-meta { flex-direction: column; gap: 4px; }
  .result-row { flex-direction: column; }
  .relevance-score { flex-direction: row; min-width: auto; }
}

/* =====================================================================
   Página pública de digest
   ===================================================================== */

.digest-page {
  max-width: 760px;
  margin: 0 auto;
  background: var(--bg-primary);
  border: 0.5px solid var(--border-tertiary);
  border-radius: var(--radius-xl);
  padding: 40px 48px;
}

.digest-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 0.5px solid var(--border-tertiary);
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.digest-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
}
.digest-back-link:hover { color: var(--text-info); text-decoration: none; }
.digest-back-link i { font-size: 14px; }

.digest-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-tertiary);
}
.digest-meta i { font-size: 13px; vertical-align: -1px; margin-right: 4px; }

.digest-content h1 { font-size: 28px; font-weight: 700; margin: 0 0 4px; line-height: 1.2; letter-spacing: -0.02em; }
.digest-content h2 { font-size: 18px; font-weight: 500; color: var(--text-secondary); margin: 0 0 32px; line-height: 1.4; }
.digest-content h3 { font-size: 18px; font-weight: 600; margin: 32px 0 12px; color: var(--text-primary); }
.digest-content h4 { font-size: 16px; font-weight: 600; margin: 24px 0 8px; color: var(--text-primary); }
.digest-content h5 { font-size: 14px; font-weight: 600; margin: 20px 0 6px; }

.digest-content p {
  font-size: 15px;
  line-height: 1.7;
  margin: 0 0 14px;
  color: var(--text-primary);
}

.digest-content ul {
  margin: 0 0 14px;
  padding-left: 24px;
}
.digest-content li {
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.digest-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.digest-content em {
  color: var(--text-secondary);
  font-style: italic;
}

.digest-content code {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 2px 6px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.digest-content pre {
  background: var(--bg-secondary);
  padding: 14px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 14px 0;
}

.digest-content a {
  color: var(--text-info);
  text-decoration: underline;
  text-decoration-color: rgba(8, 145, 178, 0.3);
}
.digest-content a:hover { text-decoration-color: var(--text-info); }

[data-theme="dark"] .digest-content a {
  text-decoration-color: rgba(34, 211, 238, 0.3);
}

.digest-page-footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 0.5px solid var(--border-tertiary);
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
}

.app-footer.regulatory-notice {
  padding: 16px 24px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border-tertiary);
}

/* Modo público (sem login): esconder a top nav */
body.public-view .topbar-nav,
body.public-view .topbar-actions { display: none; }

@media (max-width: 768px) {
  .digest-page { padding: 24px 20px; border-radius: 0; border-left: none; border-right: none; }
  .digest-content h1 { font-size: 22px; }
  .digest-content h2 { font-size: 15px; margin-bottom: 24px; }
  .digest-content h3 { font-size: 16px; }
  .digest-content p, .digest-content li { font-size: 14px; }
}

/* =====================================================================
   Agente sugeridor de perfil
   ===================================================================== */

.agent-card {
  border: 0.5px solid var(--border-tertiary);
  border-radius: var(--radius-xl);
  padding: 20px 24px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--bg-info) 0%, var(--bg-primary) 60%);
  transition: border-color var(--transition), box-shadow var(--transition);
}

[data-theme="dark"] .agent-card {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.06) 0%, var(--bg-primary) 60%);
  box-shadow: inset 0 0 0 0.5px rgba(34, 211, 238, 0.06);
}

.agent-card-header {
  display: flex;
  align-items: start;
  gap: 14px;
  margin-bottom: 14px;
}

.agent-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--text-info) 0%, #6366f1 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.agent-card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
  letter-spacing: -0.01em;
}

.agent-card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.agent-card-form {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.agent-card-form textarea {
  flex: 1;
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}

.agent-card-form button {
  flex-shrink: 0;
  height: auto;
  min-height: 60px;
  padding: 0 20px;
}

.agent-card-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 6px;
}

/* === Banner do agente no wizard === */
.agent-banner {
  background: var(--bg-info);
  border-left: 3px solid var(--text-info);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
}

[data-theme="dark"] .agent-banner {
  background: rgba(34, 211, 238, 0.07);
  border-left-color: rgba(34, 211, 238, 0.6);
}

.agent-banner-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.agent-banner-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--text-info) 0%, #6366f1 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.agent-banner-content {
  flex: 1;
  min-width: 0;
}

.agent-banner-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-info);
  margin-bottom: 2px;
}

.agent-banner-interp {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
}

.agent-banner-reasoning {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 0.5px solid var(--border-tertiary);
}

.reasoning-item {
  margin-bottom: 12px;
}

.reasoning-item:last-child { margin-bottom: 0; }

.reasoning-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-info);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.reasoning-label i { font-size: 14px; }

.reasoning-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  padding-left: 20px;
}

.reasoning-warnings {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 0.5px solid var(--border-tertiary);
}

.warning-block {
  background: var(--bg-warning);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-warning);
}

.warning-block.info {
  background: var(--bg-info);
  color: var(--text-info);
}

.warning-block i {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.warning-block ul {
  margin: 6px 0 0;
  padding-left: 16px;
  font-size: 12px;
}

.warning-block li {
  margin-bottom: 4px;
}

.warning-block code {
  background: rgba(0, 0, 0, 0.08);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
}

[data-theme="dark"] .warning-block code {
  background: rgba(255, 255, 255, 0.12);
}

/* === DIGESTS — VIEW TOGGLE === */
.view-toggle {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.view-toggle-btn {
  color: var(--text-secondary);
  border-color: var(--border-tertiary);
}

.view-toggle-btn.active {
  background: var(--bg-info);
  color: var(--text-info);
  border-color: transparent;
}

/* === DIGESTS — AREA ACCORDION === */
.area-accordion {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.area-accordion-section {
  border: 0.5px solid var(--border-tertiary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-primary);
  transition: border-color var(--transition);
}

.area-accordion-section:hover {
  border-color: var(--border-secondary);
}

.area-accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  gap: 12px;
  transition: background var(--transition);
}

.area-accordion-header:hover {
  background: var(--bg-secondary);
}

.area-accordion-header:active {
  transform: none;
}

.area-accordion-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.area-chevron {
  font-size: 16px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: transform var(--transition);
}

.area-accordion-header.open .area-chevron {
  transform: rotate(90deg);
}

.area-accordion-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  background: var(--bg-secondary);
  padding: 2px 10px;
  border-radius: 99px;
  flex-shrink: 0;
}

.area-accordion-body {
  padding: 0 12px 12px;
  border-top: 0.5px solid var(--border-tertiary);
}
