/* ─── 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); }
