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

:root {
  /* ── Couleurs de base ── */
  --bg-base:      #0d0d1a;
  --bg-card:      #13132b;
  --bg-hover:     #1a1a35;
  --bg-input:     #0a0a18;
  --border:       #1e1e40;
  --text:         #e2e2f0;
  --text-muted:   #6b6b9a;
  --text-dim:     #3a3a6a;
  --accent:       #4e9eff;
  --accent-dim:   #1a3a6a;
  --critical:     #ff4444;
  --high:         #ff8c00;
  --medium:       #ffd700;
  --low:          #00c851;
  --info:         #4e9eff;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-sans:    'Inter', system-ui, sans-serif;
  --radius:       6px;
  --shadow:       0 2px 12px rgba(0,0,0,0.5);
  --sidebar-w:    220px;
  --sidebar-w-sm: 52px;
  --topbar-h:     48px;

  /* ── Alias pour les nouveaux modules ── */
  --card-bg:       var(--bg-card);
  --bg-deep:       var(--bg-base);
  --sidebar-bg:    #0f0f20;
  --text-primary:  var(--text);
  --text-secondary: #c8c8e0;
}

body {
  background: var(--bg-base);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Topbar ──────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 200;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: all 0.15s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text); }

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
}
.brand-icon { font-size: 18px; }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-label { font-size: 11px; color: var(--text-dim); }

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

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: calc(100vh - var(--topbar-h));
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.2s ease;
  z-index: 100;
}

.sidebar.collapsed { width: var(--sidebar-w-sm); }

.sidebar-section-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 14px 16px 10px;
  line-height: 1.6;
  min-height: 28px;
  white-space: nowrap;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-section-label .section-emoji {
  font-size: 14px;
  letter-spacing: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
}
.sidebar.collapsed .sidebar-section-label { opacity: 0; }

.sidebar-nav { display: flex; flex-direction: column; gap: 1px; padding: 0 8px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}
.sidebar-link:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-link.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-icon {
  font-size: 15px;
  flex-shrink: 0;
  width: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.sidebar-text {
  font-size: 13px;
  transition: opacity 0.15s;
}
.sidebar.collapsed .sidebar-text { opacity: 0; width: 0; }

.sidebar-badge {
  margin-left: auto;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.sidebar.collapsed .sidebar-badge { opacity: 0; }

/* ── Sidebar mini stats ──────────────────────────────────────────── */
.sidebar-stats {
  margin-top: auto;
  padding: 16px 12px 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: opacity 0.15s;
}
.sidebar.collapsed .sidebar-stats { opacity: 0; }

.sidebar-stat { display: flex; justify-content: space-between; align-items: center; }
.sidebar-stat-label { font-size: 11px; color: var(--text-muted); }
.sidebar-stat-value { font-size: 13px; font-weight: 700; font-family: var(--font-mono); color: var(--accent); }

/* ── Status dots ────────────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
}
.status-connected    { background: var(--low); box-shadow: 0 0 6px var(--low); }
.status-disconnected { background: var(--text-dim); }
.status-error        { background: var(--critical); }

/* ── Badge ──────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.6;
}
.badge-critical { background: var(--critical); color: #fff; }
.badge-high     { background: var(--high);     color: #000; }
.badge-medium   { background: var(--medium);   color: #000; }
.badge-low      { background: var(--low);      color: #000; }
.badge-info     { background: var(--info);     color: #fff; }

/* ── Main layout ────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 28px 40px;
  max-width: 100%;
  min-width: 0;
  transition: margin-left 0.2s ease;
}
.layout.sidebar-collapsed .main-content { margin-left: var(--sidebar-w-sm); }

.page-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

/* ── Stat Cards ─────────────────────────────────────────────────── */
.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);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card.critical { border-left: 3px solid var(--critical); }
.stat-card.high     { border-left: 3px solid var(--high); }
.stat-card.medium   { border-left: 3px solid var(--medium); }
.stat-card.low      { border-left: 3px solid var(--low); }
.stat-card.info     { border-left: 3px solid var(--info); }

.stat-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 28px; font-weight: 700; font-family: var(--font-mono); }
.stat-sub   { font-size: 11px; color: var(--text-dim); }

/* ── Card / Panel ───────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

/* ── Table ──────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

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

thead th {
  background: var(--bg-base);
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

thead th:hover { color: var(--text); }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:hover { background: var(--bg-hover); }

td {
  padding: 8px 12px;
  vertical-align: middle;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.mono { font-family: var(--font-mono); font-size: 12px; }

/* ── Severity colors ────────────────────────────────────────────── */
.sev-critical { color: var(--critical); font-weight: 700; }
.sev-high     { color: var(--high);     font-weight: 600; }
.sev-medium   { color: var(--medium); }
.sev-low      { color: var(--low); }
.sev-info     { color: var(--info); }

/* ── Alert feed ─────────────────────────────────────────────────── */
.alert-feed { display: flex; flex-direction: column; gap: 8px; }

.alert-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  transition: background 0.1s;
}

.alert-item:hover { background: var(--bg-hover); }
.alert-item.critical { border-left: 3px solid var(--critical); }
.alert-item.high     { border-left: 3px solid var(--high); }
.alert-item.medium   { border-left: 3px solid var(--medium); }
.alert-item.low      { border-left: 3px solid var(--low); }

.alert-severity { font-weight: 700; font-size: 12px; text-transform: uppercase; width: 70px; padding-top: 2px; }
.alert-body .alert-title { font-weight: 600; margin-bottom: 2px; }
.alert-body .alert-desc  { color: var(--text-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-meta { text-align: right; font-size: 11px; color: var(--text-dim); white-space: nowrap; }

/* ── Filters / Controls ─────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}

.filter-input, .filter-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.15s;
}

.filter-input:focus, .filter-select:focus {
  border-color: var(--accent);
}

.filter-input { min-width: 200px; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn:hover { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 3px 8px; font-size: 11px; }
.btn-danger:hover { background: rgba(255,68,68,0.15); border-color: var(--critical); color: var(--critical); }
.btn-success:hover { background: rgba(0,200,81,0.15); border-color: var(--low); color: var(--low); }

/* ── Toast notifications ────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 9999;
}

.toast {
  min-width: 280px;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
}

.toast.critical { border-left: 3px solid var(--critical); }
.toast.high     { border-left: 3px solid var(--high); }
.toast.medium   { border-left: 3px solid var(--medium); }

.toast-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.toast-body  { font-size: 12px; color: var(--text-muted); }

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

/* ── IOC type chips ─────────────────────────────────────────────── */
.ioc-type {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.ioc-ipv4    { background: rgba(78,158,255,0.15); color: #4e9eff; }
.ioc-domain  { background: rgba(78,255,158,0.12); color: #4eff9e; }
.ioc-url     { background: rgba(180,78,255,0.15); color: #b44eff; }
.ioc-md5     { background: rgba(255,200,78,0.12); color: #ffc84e; }
.ioc-sha1    { background: rgba(255,200,78,0.15); color: #ffc84e; }
.ioc-sha256  { background: rgba(255,200,78,0.18); color: #ffc84e; }
.ioc-cve     { background: rgba(255,68,68,0.15);  color: #ff6b6b; }
.ioc-email   { background: rgba(78,200,255,0.12); color: #4ec8ff; }
.ioc-ipv6    { background: rgba(78,158,255,0.10); color: #7ab8ff; }
.ioc-wallet_btc { background: rgba(255,165,0,0.15); color: #ffa500; }

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Utility ────────────────────────────────────────────────────── */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.mt-1 { margin-top: 8px; }
.text-muted { color: var(--text-muted); }
.text-mono  { font-family: var(--font-mono); font-size: 12px; }

/* ── Page header ────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 22px;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Global modal / overlay ─────────────────────────────────────── */
/* Toutes les overlays doivent être AU-DESSUS de la topbar (z-index 200)
   et de la sidebar (z-index 100). On utilise 500+ pour les modals. */

.modal-overlay,
[id$="-overlay"],
[id="detail-overlay"],
[id="hist-overlay"] {
  z-index: 500 !important;
}

.modal,
.detail-panel,
.history-panel,
[id="detail-panel"],
[id="hist-panel"] {
  z-index: 501 !important;
}

/* Fond des overlays — solide, pas transparent */
.modal-overlay {
  background: rgba(5, 5, 15, 0.82) !important;
  backdrop-filter: blur(2px);
}

/* Fond des modals — couleur pleine, jamais transparent */
.modal,
.detail-panel,
.history-panel {
  background: var(--sidebar-bg) !important;
}
