:root {
  --bg: #15171e;
  --bg-soft: #1b1e27;
  --bg-card: #20232d;
  --bg-input: #15171e;
  --border: #2a2e3a;
  --text: #e6e8ef;
  --text-muted: #8e95a5;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --green: #3ba55d;
  --red: #ed4245;
  --yellow: #faa61a;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

/* ===== Barre de navigation supérieure ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 24px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.nav-icons {
  display: flex;
  gap: 4px;
}

.nav-icon {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-icon span {
  white-space: nowrap;
}

.nav-icon:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.nav-icon.active {
  background: var(--accent);
  color: #fff;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.role-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.role-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  white-space: nowrap;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-info img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.user-info .username {
  font-size: 13px;
  font-weight: 600;
}

/* ===== Contenu principal ===== */
.main {
  padding: 24px 28px 60px;
  max-width: 1100px;
  margin: 0 auto;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
}

.page-subtitle {
  color: var(--text-muted);
  margin: 0 0 20px;
  font-size: 14px;
}

/* ===== Barre de filtres ===== */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-row > * {
  flex: 1;
  min-width: 160px;
}

.filter-bar input[type="text"],
.filter-bar input[type="datetime-local"],
.filter-bar select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
  height: 42px;
}

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

.filter-bar select {
  appearance: none;
  cursor: pointer;
  padding-right: 36px;
}

.select-wrap {
  position: relative;
  flex: 1;
  min-width: 160px;
}

.select-wrap select {
  width: 100%;
}

.select-arrow {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.date-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  height: 42px;
}

.date-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.date-field input {
  border: none !important;
  height: auto !important;
  padding: 0 !important;
  background: transparent !important;
  color: var(--text);
}

.date-field input::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  flex: 0 0 auto;
}

.checkbox-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.btn-filter {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 8px;
  height: 42px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-filter:hover {
  background: var(--red);
  color: #fff;
}

.btn-ghost {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  height: 42px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}

.btn-ghost:hover {
  border-color: var(--text);
  color: var(--text);
}

/* ===== Flux de logs ===== */
.log-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.log-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
}

.log-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
  gap: 12px;
}

.log-category {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.log-time {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.log-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}

.log-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.log-details {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
  padding: 8px 12px;
  margin-top: 8px;
  font-family: "Consolas", "SF Mono", "Cascadia Code", monospace;
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.6;
}

.log-detail-line .field-name {
  color: var(--text-muted);
  font-weight: 600;
}

/* ===== Pagination "plus anciens" ===== */
.load-more {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.load-more .btn-filter {
  border-color: var(--border);
  color: var(--text-muted);
}

.load-more .btn-filter:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ===== Boutons généraux ===== */
.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

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

input[type="text"], input[type="url"] {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  width: 100%;
}

input[type="text"]:focus, input[type="url"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===== Admin ===== */
.admin-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.admin-section h2 {
  margin-top: 0;
  font-size: 17px;
}

.admin-section .hint {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.perm-table th, .perm-table td {
  text-align: center;
  white-space: nowrap;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.perm-table th:first-child, .perm-table td:first-child {
  text-align: left;
  white-space: normal;
}

.perm-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.webhook-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.webhook-row:last-child {
  border-bottom: none;
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}

.alert.success {
  background: rgba(59, 165, 93, 0.15);
  border: 1px solid var(--green);
  color: var(--green);
}

.alert.error {
  background: rgba(237, 66, 69, 0.15);
  border: 1px solid var(--red);
  color: var(--red);
}


/* ===== Login ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-logo {
  width: 100px;
  height: auto;
  display: block;
  margin: 0 auto 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px;
  text-align: center;
  max-width: 360px;
}

.login-card h1 {
  font-size: 22px;
  margin-bottom: 8px;
}

.login-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 0;
}


/* ===== Responsive ===== */
@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .nav-icon span {
    display: none;
  }

  .main {
    padding: 16px;
  }
}

/* ===== Chat Page ===== */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  padding: 16px 24px;
  box-sizing: border-box;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 16px;
}

.chat-message {
  display: flex;
  gap: 16px;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.1s;
}

.chat-message:hover {
  background: rgba(255, 255, 255, 0.03);
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.chat-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 2px;
}

.chat-username {
  font-weight: 600;
  font-size: 15px;
  color: #fff;
}

.chat-time {
  font-size: 12px;
  color: #767982;
}

.chat-text {
  font-size: 15px;
  line-height: 1.4;
  color: #dcddde;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-form {
  display: flex;
  gap: 10px;
  background: #1e1f26;
  border-radius: 10px;
  padding: 4px;
  border: 1px solid #2b2d36;
}

.chat-form input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 15px;
  outline: none;
}

.chat-form input::placeholder {
  color: #767982;
}

.chat-form button {
  padding: 0 22px;
  border-radius: 8px;
  border: none;
  background: #6366f1;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-form button:hover {
  background: #5457d4;
}