/* ─── Variables ────────────────────────────────────────────────────────────── */
:root {
  --bg:          #0f1117;
  --surface:     #16181f;
  --surface-2:   #1c1f28;
  --surface-3:   #13151b;
  --border:      #252830;
  --border-2:    #2d313d;

  --text:        #d4d8e8;
  --text-muted:  #8891a8;
  --text-dim:    #555c70;

  --accent:      #7289da;
  --accent-hover:#8fa0f0;

  --radius:      6px;
  --radius-lg:   10px;

  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size:   14px;
  line-height: 1.5;
  color-scheme: dark;
}

/* ─── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body   { background: var(--bg); color: var(--text); min-height: 100vh; }
a      { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; font-size: inherit; }
input, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ─── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.topbar-left  { display: flex; align-items: center; gap: 1.25rem; }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }

.logo {
  color: var(--accent);
  display: flex;
  align-items: center;
}

.topbar-nav {
  display: flex;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.nav-item:hover  { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: rgba(114,137,218,.15); color: var(--accent); }

/* Indicateur LIVE */
.live-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  transition: border-color .3s, color .3s;
}
.live-indicator.connected { border-color: #3ba55c33; color: #3ba55c; }
.live-indicator.connected .live-dot { background: #3ba55c; box-shadow: 0 0 6px #3ba55c; }
.live-indicator.error { border-color: #ed424533; color: #ed4245; }

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
}
.live-indicator.connected .live-dot { animation: pulse 2s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* Infos utilisateur */
.user-info  { display: flex; align-items: center; gap: 0.6rem; }
.user-name  { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.user-tags  { display: flex; gap: 0.3rem; }

.user-tag {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  background: rgba(114,137,218,.2);
  color: #aab8f0;
  border: 1px solid rgba(114,137,218,.3);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-2);
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.logout-btn:hover { background: rgba(237,66,69,.15); color: #ed4245; }

/* ─── Main ─────────────────────────────────────────────────────────────────── */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

/* ─── Filtres ──────────────────────────────────────────────────────────────── */
.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.filter-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.select-wrap {
  position: relative;
  min-width: 180px;
}

.select-arrow {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* Champs de saisie */
.input-field {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 0.55rem 0.875rem;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
  appearance: none;
  -webkit-appearance: none;
}

.input-field::placeholder { color: var(--text-dim); }
.input-field:focus        { border-color: var(--accent); }

.search-wrap .input-field { padding-left: 2.25rem; }
.select-wrap .input-field { padding-right: 2rem; cursor: pointer; }
.date-input               { width: auto; min-width: 220px; }
.date-input::-webkit-calendar-picker-indicator {
  filter: invert(.5);
  cursor: pointer;
}

/* Boutons */
.btn {
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-ghost:disabled { opacity: .4; cursor: not-allowed; }

.btn-accent {
  background: transparent;
  border-color: #ed4245;
  color: #ed4245;
  font-weight: 600;
}
.btn-accent:hover { background: rgba(237,66,69,.1); }

.date-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type=checkbox] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.results-info {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 0.75rem;
}

/* ─── Logs ─────────────────────────────────────────────────────────────────── */
.logs-container { display: flex; flex-direction: column; gap: 0; }

/* Log card */
.log-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--category-color, var(--accent));
  border-radius: 0;
  padding: 0.875rem 1.25rem;
  border-bottom: none;
  position: relative;
  transition: background .1s;
}

.log-card:first-child { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.log-card:last-child  { border-radius: 0 0 var(--radius-lg) var(--radius-lg); border-bottom: 1px solid var(--border); }
.log-card:only-child  { border-radius: var(--radius-lg); border-bottom: 1px solid var(--border); }
.log-card:hover       { background: var(--surface-2); }

/* Separator between cards */
.log-card + .log-card { border-top: 1px solid var(--border); }

.log-card.new-log {
  animation: slideIn .3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
  gap: 1rem;
}

.log-category {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--category-color, var(--accent));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.log-time {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

.log-action {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.65rem;
}

.log-details {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.875rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.7;
}

.log-details:empty { display: none; }

/* ─── États vides / chargement ─────────────────────────────────────────────── */
.loading-state, .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 4rem 2rem;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Pagination ────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  gap: 0.75rem;
}

.page-info {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ─── Toast notifications ───────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 9999;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  font-size: 0.8rem;
  color: var(--text);
  animation: toastIn .25s ease, toastOut .25s ease 3s forwards;
  max-width: 320px;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}

@keyframes toastIn  { from { opacity: 0; transform: translateX(10px); } }
@keyframes toastOut { to   { opacity: 0; transform: translateX(10px); } }

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

/* ─── Multi-select catégories ──────────────────────────────────────────────── */
.multiselect-wrap {
  position: relative;
  min-width: 220px;
}

.multiselect-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  cursor: pointer;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  text-align: left;
  user-select: none;
  transition: border-color .15s;
}
.multiselect-btn:hover,
.multiselect-btn.open { border-color: var(--accent); }

.multiselect-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  z-index: 200;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.multiselect-dropdown.open { display: block; }

.multiselect-option {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .875rem;
  font-size: .825rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .1s;
  user-select: none;
}
.multiselect-option:hover { background: var(--surface-2); }

.multiselect-all {
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
}

.multiselect-option input[type=checkbox] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.multiselect-option.selected { color: var(--text); }

.multiselect-count {
  margin-left: auto;
  font-size: .72rem;
  color: var(--dim);
}

/* ─── Bouton kick dans la topbar ────────────────────────────────────────── */
.kick-panel-btn {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}
.kick-panel-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(91,124,246,.08);
}

.kick-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  background: var(--accent);
  color: #fff;
  border-radius: 99px;
  font-size: .62rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 2px solid var(--bg);
}

/* ─── Modal kick ─────────────────────────────────────────────────────────── */
.kick-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 62px 1rem 1rem;
}

.kick-modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  width: 340px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
  overflow: hidden;
}

.kick-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1rem 1.1rem .875rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
.kick-modal-title { font-weight: 700; color: #fff; font-size: .95rem; }
.kick-modal-sub   { font-size: .72rem; color: var(--text-dim); margin-top: .15rem; }
.kick-modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  margin-top: 2px;
  transition: color .1s;
}
.kick-modal-close:hover { color: var(--text); }

.kick-modal-body {
  overflow-y: auto;
  flex: 1;
  padding: .5rem;
}

.kick-user-card {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .75rem;
  border-radius: 8px;
  transition: background .1s;
}
.kick-user-card:hover { background: var(--surface-2); }

.kick-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border-2);
  object-fit: cover;
  flex-shrink: 0;
}
.kick-user-info    { flex: 1; min-width: 0; }
.kick-user-name    { font-size: .85rem; font-weight: 600; color: #fff; }
.kick-user-time    { font-size: .7rem; color: var(--text-dim); }
.kick-me-tag       { font-size: .62rem; background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.25); color: #4ade80; border-radius: 99px; padding: .05rem .35rem; margin-left: .3rem; }

.kick-btn-inline {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.25);
  color: #fca5a5;
  border-radius: 6px;
  padding: .3rem .65rem;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
  transition: all .15s;
}
.kick-btn-inline:hover    { background: rgba(239,68,68,.2); }
.kick-btn-inline:disabled { opacity: .4; cursor: not-allowed; }
.kick-btn-inline.done     { background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.25); color: #4ade80; }

.kick-loading { padding: 2rem; text-align: center; color: var(--text-dim); font-size: .85rem; }

/* ─── Statistiques ──────────────────────────────────────────────────── */
#viewStats { min-height: calc(100vh - 52px); }

.stats-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  padding: .875rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 52px;
  z-index: 10;
}

.stats-controls-left { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

.stats-period { display: flex; gap: .3rem; }

.period-btn {
  padding: .3rem .8rem;
  border-radius: 6px;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.period-btn:hover  { border-color: var(--accent); color: var(--accent); }
.period-btn.active { background: rgba(91,124,246,.15); border-color: var(--accent); color: #93b4ff; }

.stats-summary { font-size: .82rem; color: var(--text-dim); }
.stats-summary strong { color: var(--text); }

#statsCatWrap { min-width: 200px; }

.stats-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.stats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem 1.25rem;
}

.stats-card-title {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 1rem;
}

.stats-chart-box { position: relative; }

/* ─── Totaux catégories ──────────────────────────────────────────────── */
.stats-bar-wrap {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}

.stats-bar-wrap .stats-chart-box { flex: 1; min-width: 0; }

.stats-totals {
  min-width: 180px;
  max-width: 220px;
  flex-shrink: 0;
  padding-top: .25rem;
}

.stats-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .28rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
}
.stats-total-row:last-child { border-bottom: none; }

.stats-total-name {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.stats-total-count {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
