/* ============================================================
   CyberWatch — style.css — Thème sombre
   ============================================================ */

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

:root {
  --bg-primary:   #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary:  #1c2128;
  --bg-hover:     #21262d;
  --border:       #30363d;
  --border-light: #21262d;

  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #484f58;

  --accent:      #e74c3c;
  --accent-dim:  rgba(231,76,60,0.15);
  --green:       #2ea043;
  --green-dim:   rgba(46,160,67,0.15);
  --blue:        #1f6feb;
  --blue-dim:    rgba(31,111,235,0.15);
  --orange:      #d29922;
  --orange-dim:  rgba(210,153,34,0.15);
  --purple:      #8957e5;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --sidebar-width: 220px;
  --topbar-height: 56px;
}

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

a { color: var(--text-primary); text-decoration: none; }
a:hover { color: #fff; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px; gap: 12px;
}
.topbar-logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 600; color: #fff;
  white-space: nowrap;
}
.logo-icon {
  width: 28px; height: 28px;
  background: var(--accent); border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.topbar-meta {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-secondary); font-size: 12px; flex: 1;
}
.refresh-info { display: flex; align-items: center; gap: 6px; }
.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
}
.dot.ok      { background: var(--green); }
.dot.error   { background: var(--accent); }
.dot.running { background: var(--orange); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

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

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-md);
  font-size: 12px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-tertiary); color: var(--text-primary);
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover  { background: var(--bg-hover); border-color: var(--text-muted); }
.btn:active { transform: scale(0.98); }
.btn.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.btn-primary:hover { background: #c0392b; border-color: #c0392b; }
.btn.loading { opacity: 0.6; pointer-events: none; }

.search-wrap { position: relative; flex: 0 0 220px; }
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none; font-size: 13px;
}
#searchInput {
  width: 100%; padding: 6px 10px 6px 30px;
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-primary);
  font-size: 13px; font-family: var(--font);
}
#searchInput:focus { outline: none; border-color: var(--blue); }
#searchInput::placeholder { color: var(--text-muted); }

.topbar-admin {
  color: var(--text-secondary); font-size: 12px;
  padding: 6px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.topbar-admin:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Layout ───────────────────────────────────────────────── */
.layout { display: flex; padding-top: var(--topbar-height); min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width); flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  position: fixed; top: var(--topbar-height); left: 0; bottom: 0;
  overflow-y: auto; padding: 12px 0;
}
.sidebar-section { margin-bottom: 4px; }
.sidebar-section-title {
  padding: 6px 16px 4px;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.sidebar-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 16px; cursor: pointer;
  color: var(--text-secondary); font-size: 13px;
  border-left: 2px solid transparent;
  transition: background 0.1s;
}
.sidebar-item:hover  { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-item.active { background: var(--accent-dim); color: var(--text-primary); border-left-color: var(--accent); }
.sidebar-item-left   { display: flex; align-items: center; gap: 8px; }
.sidebar-count {
  font-size: 11px; background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 1px 6px;
  color: var(--text-muted);
}
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 0; }
.sidebar-tags { padding: 4px 12px 8px; display: flex; flex-wrap: wrap; gap: 4px; }

.score-filter { padding: 4px 16px 8px; }
.score-filter input[type="range"] {
  width: 100%; accent-color: var(--accent);
  cursor: pointer;
}
.score-filter-value {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--text-muted); margin-top: 4px;
}
#scoreFilterReset {
  cursor: pointer; color: var(--text-muted); display: none;
  padding: 0 2px;
}
#scoreFilterReset:hover { color: var(--text-primary); }

.tag-pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.15s;
}
.tag-pill:hover  { opacity: 0.8; }
.tag-pill.active { border-color: rgba(255,255,255,0.35); }

/* ── Stats bar ────────────────────────────────────────────── */
.stats-bar {
  margin-left: var(--sidebar-width);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.stat-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-secondary);
}
.stat-item strong { color: var(--text-primary); font-weight: 600; }
.stat-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ── Pouls CVE ────────────────────────────────────────────── */
.cve-pulse {
  margin-left: var(--sidebar-width);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px 8px;
}
.cve-pulse-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.cve-pulse-title { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.cve-pulse-total { font-size: 11px; color: var(--text-muted); }
.cve-pulse-chart { width: 100%; height: 40px; }
.cve-pulse-svg   { width: 100%; height: 40px; display: block; }
.cve-pulse-empty { font-size: 12px; color: var(--text-muted); padding: 10px 0; }

/* ── Carte DDoSia ─────────────────────────────────────────── */
.ddosia-map {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px 8px;
  margin-bottom: 16px;
}
.ddosia-map-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin-bottom: 8px;
}
.ddosia-map-title { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.ddosia-map-legend {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-muted);
}
.legend-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.ddosia-map-canvas { width: 100%; }
#ddosia-world-svg {
  width: 100%; height: auto; max-height: 380px; display: block;
  background: #0d1117; border-radius: 6px;
}
.ddosia-map-empty { font-size: 12px; color: var(--text-muted); padding: 30px 0; text-align: center; }

/* ── Main ─────────────────────────────────────────────────── */
.main { flex: 1; margin-left: var(--sidebar-width); padding: 16px 20px; min-width: 0; }

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
  display: flex; align-items: center; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px; overflow-x: auto;
}
.tab {
  padding: 8px 14px; font-size: 13px; cursor: pointer;
  color: var(--text-secondary); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.15s;
}
.tab:hover  { color: var(--text-primary); }
.tab.active { color: #fff; border-bottom-color: var(--accent); font-weight: 500; }
.tab-count  { font-size: 11px; color: var(--text-muted); margin-left: 4px; }

/* ── Article cards ────────────────────────────────────────── */
.articles-list { display: flex; flex-direction: column; gap: 8px; }

.article-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  transition: border-color 0.15s;
}
.article-card:hover { border-color: var(--text-muted); }
.article-card.severity-critical { border-left-color: var(--accent); }
.article-card.severity-high     { border-left-color: var(--orange); }

.article-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 5px; flex-wrap: wrap;
}
.source-badge {
  font-size: 11px; font-weight: 500;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1px 6px;
  color: var(--text-secondary);
}
.cat-badge   { font-size: 11px; color: var(--text-muted); }
.type-badge  {
  font-size: 10px; padding: 1px 6px;
  border-radius: var(--radius-sm); font-weight: 500;
}
.type-badge.rss      { background: var(--blue-dim); color: #58a6ff; }
.type-badge.telegram { background: rgba(137,87,229,0.2); color: #b392f0; }
.type-badge.manual   { background: var(--orange-dim); color: #d29922; }
.article-date { margin-left: auto; font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.article-title { font-size: 14px; font-weight: 500; line-height: 1.4; margin-bottom: 4px; }
.article-title a { color: var(--text-primary); }
.article-title a:hover { color: #fff; text-decoration: underline; }

.article-excerpt {
  font-size: 12px; color: var(--text-secondary);
  line-height: 1.5; margin-bottom: 7px;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.article-tags { display: flex; flex-wrap: wrap; gap: 4px; }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 32px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }
.empty-hint { font-size: 12px; margin-top: 6px; }

/* ── Toast ────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px; z-index: 999;
}
.toast {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 10px 14px;
  font-size: 13px; color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
  animation: slideIn 0.2s ease; max-width: 320px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--accent); }
.toast.info    { border-left: 3px solid var(--blue); }
@keyframes slideIn { from{transform:translateX(20px);opacity:0} to{transform:translateX(0);opacity:1} }

.spinner {
  width: 12px; height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--text-secondary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite; display: inline-block;
}
@keyframes spin { to{transform:rotate(360deg)} }

mark { background: rgba(210,153,34,0.35); color: inherit; border-radius: 2px; padding: 0 1px; }

.hype-badge {
  font-size: 11px; font-weight: 600;
  background: rgba(231,76,60,0.2); color: #e74c3c;
  border-radius: var(--radius-sm); padding: 1px 6px;
  border: 1px solid rgba(231,76,60,0.3);
}

.score-badge {
  font-size: 11px; font-weight: 700;
  border-radius: var(--radius-sm); padding: 1px 7px;
  border: 1px solid; background: transparent;
  font-variant-numeric: tabular-nums;
  min-width: 28px; text-align: center; display: inline-block;
}

.cvss-badge {
  font-size: 11px; font-weight: 700;
  border-radius: var(--radius-sm); padding: 1px 7px;
  border: 1px solid rgba(231,76,60,0.4); color: #e74c3c;
  background: rgba(231,76,60,0.12);
  font-variant-numeric: tabular-nums;
  display: inline-block;
}

@media (max-width: 900px) {
  :root { --sidebar-width: 0px; }
  .sidebar { display: none; }
  .stats-bar, .main { margin-left: 0; }
}
