:root {
  --bg: #0b0f19;
  --panel: #101622;
  --panel2: #0e1420;

  --line: #222a39;
  --line2: #2f384b;

  --text: #e8eefc;
  --muted: rgba(232, 238, 252, 0.65);

  --accent: #FC003C;

  --warn: rgba(255, 170, 0, 0.20);
  --warnLine: rgba(255, 170, 0, 0.45);

  --error: rgba(255, 80, 80, 0.22);
  --errorLine: rgba(255, 80, 80, 0.55);

  --audit: rgba(120, 80, 255, 0.22);
  --auditLine: rgba(120, 80, 255, 0.55);

  --control-h: 44px;

  --layout-max: 2000px;     /* largeur globale max du panel */
  --col-left-max: 340px;    /* Types de logs */
  --col-right-max: 420px;   /* Détails */
}

/* Box sizing */
*, *::before, *::after { box-sizing: border-box; }

/* Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) rgba(255,255,255,0.08);
}
::-webkit-scrollbar { height: 10px; width: 10px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.06); }
::-webkit-scrollbar-thumb { background: var(--accent); }
::-webkit-scrollbar-thumb:hover { filter: brightness(1.05); }

:root { font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11,15,25,0.95);
  backdrop-filter: blur(10px);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;

  border-bottom: 2px solid var(--accent);
}

.brand { font-weight: 700; letter-spacing: 0.5px; }
.who { display: flex; gap: 10px; align-items: center; }

.layout{
  max-width: var(--layout-max);
  margin: 16px auto;
  padding: 0 16px;
  display: grid;
  gap: 12px;

  /* gauche/droite “clamp” s’adaptent, centre prend le reste */
  grid-template-columns:
    clamp(240px, 18vw, var(--col-left-max))
    minmax(0, 1fr)
    clamp(320px, 26vw, var(--col-right-max));
}


/* Panels (no rounded corners) */
.sidebar,
.panel,
.details {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  padding: 12px;
  border-radius: 0;
}

.panel-title {
  font-weight: 700;
  letter-spacing: 0.3px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line2);
}

.sub-title {
  font-weight: 700;
  margin: 8px 0 8px 0;
}

.sep {
  height: 1px;
  background: var(--line2);
  margin: 10px 0;
}

.maincol { display: grid; gap: 12px; }

/* Filters layout (clean + aligned) */
.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: rgba(232,238,252,0.80);
  min-width: 0;
}

.field.span2 { grid-column: span 2; }

.field input, .field select {
  width: 100%;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: rgba(232,238,252,0.80);
}

input, select {
  height: var(--control-h);
  background: rgba(0,0,0,0.30);
  border: 1px solid var(--line2);
  border-radius: 0;
  padding: 0 10px;
  color: var(--text);
  outline: none;
}
input:focus, select:focus {
  border-color: var(--accent);
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: stretch;
  padding-top: 6px;
}

.btn {
  height: var(--control-h);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;

  border-radius: 0;
  border: 1px solid var(--line2);
  background: rgba(0,0,0,0.30);
  cursor: pointer;

  line-height: 1;

  color: var(--text);
}
.btn:hover { border-color: var(--accent); }
.btn.primary {
  background: rgba(252, 0, 60, 0.20);
  border-color: var(--accent);
}
.btn.wide {
  min-width: 170px;
}

.row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }

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

table { width: 100%; border-collapse: collapse; min-width: 850px; }
th, td {
  padding: 0 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  vertical-align: top;
  font-size: 13px;
}
th {
  position: sticky;
  top: 0;
  background: rgba(11,15,25,0.98);
  text-align: left;
  font-size: 12px;
  color: rgba(232,238,252,0.75);
  border-bottom: 1px solid var(--accent);
}

tr.clickable { cursor: pointer;

  line-height: 1; }
tr.clickable:hover { background: rgba(252, 0, 60, 0.06); }
tr.row-selected { background: rgba(252, 0, 60, 0.12); }

.payload {
  max-width: 420px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  padding: 3px 8px;
  border-radius: 0;
  font-size: 12px;
  border: 1px solid rgba(255,255,255,0.14);
}
.badge.warn { background: var(--warn); border-color: var(--warnLine); }
.badge.error { background: var(--error); border-color: var(--errorLine); }
.badge.audit { background: var(--audit); border-color: var(--auditLine); }

.pager { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; }
.pager-actions { display: flex; gap: 8px; }

/* Sidebar types */
.type-list {
  display: grid;
  gap: 6px;
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding-right: 0px;
}

.type-item {
  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 6px 10px;
  border: 1px solid var(--line2);
  background: rgba(0,0,0,0.22);
}
.type-item:hover { border-color: var(--accent); }
.type-item.active {
  border-color: var(--accent);
  background: rgba(252, 0, 60, 0.12);
}

.type-item .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.type-item .c {
  border-left: 1px solid var(--line2);
  padding-left: 10px;
  margin-left: 10px;
  color: var(--muted);
}

.sidebar-note { margin-top: 10px; font-size: 12px; }

.kv{
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 10px;
}

.kv .k{
  color: rgba(232,238,252,0.75);
  font-size: 12px;
  line-height: 1.15;
}

.kv .v{
  font-size: 13px;
}

/* ✅ Spécifique au Metadata : aligne la hauteur/position des labelKey avec le bloc valeur */
.kv.payload-kv .k{
  display: flex;
  align-items: center;      /* centre verticalement dans la ligne */
  min-height: 44px;         /* 🔧 ajuste ici si tu veux plus/moins haut */
  padding: 0 4px 0 0;

  white-space: nowrap;      /* évite que ça prenne 2 lignes */
  overflow: hidden;
  text-overflow: ellipsis;
}


.payload-kv .v {
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line2);
  padding: 8px 44px 8px 8px; /* espace pour le bouton copier */
  position: relative;
}

.payload-kv .v .meta-value {
  display: block;
  min-width: 0;
}

pre.json {
  max-width: 100%;
}

pre.json {
  margin: 0;
  padding: 0 10px;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--line2);
  overflow: auto;
  max-height: 340px;
  border-radius: 0;
}

.details-actions { margin-top: 10px; display: flex; justify-content: flex-end; }

.footer{
  max-width: var(--layout-max);
  margin: 10px auto 30px;
  padding: 0 16px;
}

/* ✅ Responsive propre */
@media (max-width: 1200px){
  /* 2 colonnes : Types + Centre ; Détails passe en dessous */
  .layout{
    grid-template-columns: clamp(240px, 26vw, 340px) minmax(0, 1fr);
  }
  .details{
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px){
  /* 1 colonne : tout empilé */
  .layout{ grid-template-columns: 1fr; }
  .filters{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field.span2{ grid-column: span 2; }
  .sidebar{ order: 2; }
  .details{ order: 3; }
}

/* Login centered */
.login-wrap {
  min-height: calc(100vh - 54px); /* topbar height approx */
  display: grid;
  place-items: center;
  padding: 16px;
}
.login-card {
  width: min(520px, 100%);
}
.login-actions {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}


/* Datetime input with calendar icon */
.control.with-icon {
  position: relative;
  display: flex;
  width: 100%;
}

.control.with-icon input {
  width: 100%;
  padding-right: 44px; /* space for icon button */
}

.icon-btn {
  position: absolute;
  right: 0;
  top: 0;
  width: 44px;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-left: 1px solid var(--line2);
  background: rgba(0,0,0,0.25);
  color: rgba(232, 238, 252, 0.70);
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--accent);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* Events table: bigger + cleaner */
.table-wrap {
  overflow: auto;
  border-radius: 0;
  border: 1px solid var(--line);
  min-height: 0px; /* donne un rendu plus “pro” même avec peu de lignes */
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1000px; /* évite la compression des colonnes */
}

th, td {
  padding: 14px 12px;     /* + gros */
  font-size: 14px;        /* + lisible */
  line-height: 1.25;
  vertical-align: middle; /* aligne mieux les cellules */
}

th {
  font-size: 13px;
}

.idcol {
  width: 90px;
  white-space: nowrap;
}

@media (max-width: 1200px) {
  .layout { grid-template-columns: 260px minmax(0, 1fr); }
  .details { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field.span2 { grid-column: span 2; }
  .sidebar { order: 2; }
  .details { order: 3; }
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  opacity: 0;
  display: none;
}
input[type="datetime-local"]::-webkit-inner-spin-button,
input[type="datetime-local"]::-webkit-clear-button {
  display: none;
}

.mini-icon-btn {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line2);
  background: rgba(0,0,0,0.25);
  color: rgba(232, 238, 252, 0.70);
  cursor: pointer;
}

.mini-icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.mini-icon-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.mini-icon-btn.copied {
  color: var(--accent);
  border-color: var(--accent);
}

.sidebar, .panel, .details, .maincol, .table-wrap, .kv, .payload-kv{
  min-width: 0;
}

/* ✅ Valeur metadata un peu plus “haute” + place bouton */
.payload-kv .v{
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;

  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line2);

  /* + confortable verticalement */
  padding: 10px 52px 10px 10px;
  min-height: 44px;          /* aligne visuellement avec tes inputs */
  line-height: 0.34;

  position: relative;
}

.payload-kv .v .meta-value{
  display:block;
  min-width:0;
}

/* ✅ Bouton copier parfaitement centré verticalement */
.mini-icon-btn{
  position:absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);

  width: 32px;
  height: 32px;

  display:inline-flex;
  align-items:center;
  justify-content:center;

  border: 1px solid var(--line2);
  background: rgba(0,0,0,0.25);
  color: rgba(232, 238, 252, 0.70);
  cursor: pointer;
}

/* =========================
   FIX: Détails ne doit pas “pousser” Filtres
   ========================= */

/* ✅ Empêche le stretch des colonnes par la hauteur de Détails */
.layout{
  align-items: start;
}

/* ✅ Filtres: largeur plafonnée (ne grandit plus quand la page s’élargit) */
:root{
  --filters-max: 1220px; /* 🔧 ajuste ici si tu veux plus/moins large */
}

.filters-panel{
  width: 100%;
  max-width: var(--filters-max);
  margin: 0 auto;       /* centré dans la colonne centrale */
}

/* ✅ Événements garde toute la largeur */
.events-panel{
  width: 100%;
  max-width: none;
}

/* ✅ Détails: si contenu trop large => scroll interne, sans élargir le layout */
.details{
  overflow-x: auto;
}

/* 🔒 Anti “min-content” sur contenus qui peuvent être longs */
.details pre.json,
.details .kv,
.details .payload-kv,
.details .payload-kv .v,
.details .payload-kv .meta-value{
  min-width: 0;
  max-width: 100%;
}

/* ⚠️ Tu as actuellement un line-height à 0.34 sur payload (ça peut casser l’alignement) */
.payload-kv .v{
  line-height: 0.35;
}

/* Boolean icons (true/false) in metadata */
.bool-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line2);
  background: rgba(0,0,0,0.25);
}

.bool-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.bool-true { color: #22c55e; }  /* vert validé */
.bool-false { color: #ef4444; } /* rouge refusé */

/* Copy button (payload details) */
.mini-icon-btn {
  margin-left: 8px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  border: 1px solid var(--line2);
  background: rgba(0,0,0,0.25);
  color: rgba(232, 238, 252, 0.70);
  cursor: pointer;
}

.mini-icon-btn:hover { border-color: var(--accent); color: var(--accent); }

.mini-icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.mini-icon-btn.copied {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Metadata (format propre) : compact ---------- */
.kv.payload-kv {
  gap: 6px 10px;              /* moins d’espace entre lignes */
}

.payload-kv .k {
  align-self: center;         /* centre le label verticalement */
}

.payload-kv .v {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line2);

  padding: 6px 10px;          /* ✅ plus compact */
  min-height: 36px;           /* ✅ empêche les gros blocs */
  line-height: 1.1;

  white-space: normal;        /* autorise le wrap si long */
  word-break: break-word;
  overflow-wrap: anywhere;
}

.payload-kv .v .meta-value {
  flex: 1;                    /* prend la place dispo */
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Bouton copier : un peu plus petit */
.mini-icon-btn {
  width: 30px;
  height: 30px;
  margin-left: 8px;
}

/* Bool icon : un poil plus petit (évite l’effet “case géante”) */
.bool-icon {
  width: 20px;
  height: 20px;
}
.bool-icon svg {
  width: 16px;
  height: 16px;
}

/* =========================
   Sidebar: catégories déroulantes
   ========================= */

.type-group {
  border: 1px solid var(--line2);
  background: rgba(0,0,0,0.18);
}

.type-cat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 6px 10px;
  border: 0;
  background: rgba(0,0,0,0.22);
  color: var(--text);
  cursor: pointer;
}

.type-cat-btn:hover {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.type-cat-btn .t {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.type-cat-btn .c {
  border-left: 1px solid var(--line2);
  padding-left: 10px;
  margin-left: 10px;
  color: var(--muted);
}

.type-cat-btn .chev {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 10px;
  color: rgba(232, 238, 252, 0.70);
  transform: rotate(0deg);
  transition: transform 120ms ease;
}

.type-cat-btn .chev svg { width: 18px; height: 18px; display: block; }

.type-sublist {
  display: none;
  padding: 6px 0 6px 0;
  border-top: 1px solid var(--line2);
}

.type-group.open .type-sublist {
  display: grid;
  gap: 6px;
}

.type-item.sub {
  margin: 0 8px;
  padding-left: 18px;
  background: rgba(0,0,0,0.16);
}

.type-group.open .type-cat-btn .chev {
  transform: rotate(180deg);
}
