/* ─── Parseur DSDEN 93 — Admin Interface ─── */

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-input: #252836;
  --border: #2a2d3a;
  --text: #e4e6f0;
  --text-muted: #8b8fa3;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,.3);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ─── Layout ─── */

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

.sidebar {
  width: 240px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-brand {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-brand h1 {
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-brand small {
  color: var(--text-muted);
  font-size: 11px;
}

.sidebar-nav { flex: 1; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .2s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(99, 102, 241, .08);
  color: var(--text);
  border-left-color: var(--primary);
}

.sidebar-nav a .icon { font-size: 18px; width: 24px; text-align: center; }

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

.sidebar-footer a { color: var(--text-muted); font-size: 13px; }

.main-content {
  margin-left: 240px;
  padding: 32px;
  flex: 1;
  min-width: 0;
}

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

.page-header h2 {
  font-size: 24px;
  font-weight: 700;
}

/* ─── Cards ─── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  transition: transform .2s, border-color .2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 4px;
}

/* ─── Tables ─── */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead {
  background: var(--bg-input);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }
tr:hover { background: rgba(99, 102, 241, .03); }

/* ─── Badges ─── */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.badge-new       { background: rgba(59,130,246,.15); color: #60a5fa; }
.badge-deferred  { background: rgba(148,163,184,.15); color: #94a3b8; }
.badge-scraped   { background: rgba(139,92,246,.15); color: #a78bfa; }
.badge-extracted { background: rgba(236,72,153,.15); color: #f472b6; }
.badge-summarized{ background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-emailed   { background: rgba(34,197,94,.15);  color: #4ade80; }
.badge-error     { background: rgba(239,68,68,.15);  color: #f87171; }
.badge-ignored   { background: rgba(107,114,128,.15); color: #6b7280; }
.badge-running   { background: rgba(59,130,246,.15); color: #60a5fa; }
.badge-completed { background: rgba(34,197,94,.15);  color: #4ade80; }
.badge-partial   { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-failed    { background: rgba(239,68,68,.15);  color: #f87171; }
.badge-pending   { background: rgba(107,114,128,.15); color: #9ca3af; }
.badge-tagged    { background: rgba(34,197,94,.15);  color: #4ade80; }

/* ─── Buttons ─── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all .2s;
}

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

.btn-warning {
  background: rgba(245,158,11,.15);
  color: #fbbf24;
  border: 1px solid rgba(245,158,11,.3);
}
.btn-warning:hover { background: rgba(245,158,11,.25); }

.btn-danger {
  background: rgba(239,68,68,.15);
  color: #f87171;
  border: 1px solid rgba(239,68,68,.3);
}
.btn-danger:hover { background: rgba(239,68,68,.25); }

.btn-sm { padding: 4px 12px; font-size: 12px; }

/* ─── Forms ─── */

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

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

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  transition: border-color .2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

/* ─── Flash messages ─── */

.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
}

.flash-success { background: rgba(34,197,94,.1); color: #4ade80; border: 1px solid rgba(34,197,94,.2); }
.flash-error   { background: rgba(239,68,68,.1); color: #f87171; border: 1px solid rgba(239,68,68,.2); }

/* ─── Pagination ─── */

.pagination {
  display: flex;
  gap: 6px;
  margin-top: 20px;
  justify-content: center;
}

.pagination a, .pagination span {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}

.pagination a {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
}

.pagination a:hover { border-color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; }

/* ─── Log viewer ─── */

.log-viewer {
  background: #0d0f14;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.8;
  max-height: 600px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-line-INFO     { color: #60a5fa; }
.log-line-WARNING  { color: #fbbf24; }
.log-line-ERROR    { color: #f87171; }
.log-line-CRITICAL { color: #f87171; font-weight: bold; }

/* ─── Settings grid ─── */

.settings-category { margin-bottom: 32px; }

.settings-category h3 {
  font-size: 16px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid rgba(42,45,58,.5);
}

.setting-label { font-weight: 600; font-size: 14px; }
.setting-desc  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ─── Toggle switch ─── */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.toggle-switch input[type="checkbox"] { display: none; }
.toggle-slider {
  width: 48px;
  height: 26px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 13px;
  position: relative;
  transition: background .25s, border-color .25s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform .25s, background .25s;
}
.toggle-switch input[type="checkbox"]:checked + .toggle-slider {
  background: var(--primary);
  border-color: var(--primary);
}
.toggle-switch input[type="checkbox"]:checked + .toggle-slider::after {
  transform: translateX(22px);
  background: #fff;
}
.toggle-label {
  font-size: 14px;
  color: var(--text-muted);
}

/* ─── Login page ─── */

.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 400px;
}

.login-box h1 {
  text-align: center;
  margin-bottom: 8px;
  font-size: 22px;
  font-weight: 700;
}

.login-box .subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}

/* ─── Article detail ─── */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 20px 0;
}

.detail-block {
  background: var(--bg-input);
  border-radius: 8px;
  padding: 16px;
}

.detail-block h4 {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: .5px;
  margin-bottom: 8px;
}

.content-block {
  margin: 20px 0;
  padding: 20px;
  background: var(--bg-input);
  border-radius: var(--radius);
  border-left: 3px solid var(--primary);
  line-height: 1.8;
}

/* ─── Pipeline panel ─── */

.pipeline-panel {
  margin: 20px 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.pipeline-title {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: .5px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-input);
}

.pipeline-steps {
  display: flex;
  flex-direction: column;
}

.pipeline-step {
  display: flex;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  transition: background .15s;
}

.pipeline-step:last-child {
  border-bottom: none;
}

.pipeline-step:hover {
  background: rgba(255,255,255,.02);
}

.pipeline-step.done {
  border-left: 3px solid var(--success);
}

.pipeline-step.missed {
  border-left: 3px solid var(--error);
}

.pipeline-step.na {
  border-left: 3px solid var(--border);
  opacity: .6;
}

.pipeline-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.pipeline-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pipeline-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.pipeline-detail {
  font-size: 12px;
  color: var(--text-muted);
}

.pipeline-detail strong {
  color: var(--primary);
  font-weight: 600;
}

.pipeline-detail.pipeline-na {
  font-style: italic;
}

.pipeline-reason {
  font-size: 12px;
  color: var(--warning);
}

/* ─── Tag chips ─── */

.tag-chip {
  display: inline-block;
  padding: 3px 10px;
  background: rgba(99,102,241,.1);
  border: 1px solid rgba(99,102,241,.2);
  border-radius: 20px;
  font-size: 12px;
  color: var(--primary-hover);
  margin: 2px;
}

/* ─── Filters bar ─── */

.filters-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filters-bar .form-control {
  width: auto;
  min-width: 160px;
}

/* ─── Responsive ─── */

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .setting-row { grid-template-columns: 1fr; }
}

/* ─── Tagging UI ─── */

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 4px;
  transition: width 0.4s ease;
}

.stat-card-sm {
  padding: 12px 16px;
}
.stat-card-sm .stat-value {
  font-size: 20px;
}
.stat-card-sm .stat-label {
  font-size: 11px;
}

.confidence-bar {
  display: inline-flex;
  align-items: center;
  width: 80px;
  height: 18px;
  background: var(--bg-input);
  border-radius: 9px;
  overflow: hidden;
  position: relative;
  font-size: 10px;
}

.confidence-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--warning), var(--success));
  border-radius: 9px;
  position: absolute;
  left: 0;
  top: 0;
  transition: width 0.3s ease;
}

.confidence-text {
  position: relative;
  z-index: 1;
  width: 100%;
  text-align: center;
  font-weight: 600;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}

.tag-detail-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.badge-ai         { background: rgba(99,102,241,.15); color: #818cf8; }
.badge-incremental { background: rgba(99,102,241,.15); color: #818cf8; }
.badge-manual      { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-bootstrap   { background: rgba(34,197,94,.15); color: #4ade80; }
.badge-error       { background: rgba(239,68,68,.15); color: #f87171; }

/* ─── Modal ─── */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 460px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
