/* ====== VARIABLES THÈME DARK - AUDIT ====== */
:root {
  --bg: #0f172a;
  --bg-alt: #1e293b;
  --panel: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --success-dark: #16a34a;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --header-height: 56px;
}

/* ====== RESET & BASE ====== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ====== HEADER ====== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--accent);
  transition: opacity 0.2s;
}

.header-brand.console-admin {
  color: var(--warning);
  cursor: default;
}

.header-brand.console-admin i {
  color: var(--warning);
}

/* Navigation */
.header-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 2rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.nav-link:hover {
  background: var(--bg);
  color: var(--text);
}

.nav-link.active {
  background: var(--accent);
  color: white;
}

/* Header right */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.9rem;
}

.user-badge i {
  font-size: 1.2rem;
  color: var(--accent);
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.logout-btn:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.hidden {
  display: none !important;
}

/* ====== MAIN CONTAINER ====== */
.main-container {
  margin-top: var(--header-height);
  padding: 1.5rem;
  max-width: 1600px;
  margin-left: auto;
  margin-right: auto;
}

/* ====== PAGE HEADER ====== */
.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-header h1 i {
  color: var(--warning);
}

.page-header .subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* ====== KPI CARDS ====== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.kpi-icon {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
}

.kpi-content {
  flex: 1;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

/* ====== FILTERS ====== */
.filters-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.filter-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.filter-input,
.filter-select {
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  min-width: 150px;
  transition: border-color 0.2s;
}

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

.filter-input::placeholder {
  color: var(--text-muted);
}

.filter-dates {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.filter-dates label {
  margin-bottom: 0;
}

.filter-dates .filter-input {
  min-width: 140px;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

/* ====== BUTTONS ====== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

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

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: var(--success-dark);
}

/* ====== RESULTS INFO ====== */
.results-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

#resultsCount {
  font-weight: 600;
  color: var(--text);
}

/* ====== TABLE ====== */
.table-container {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.logs-table {
  width: 100%;
  border-collapse: collapse;
}

.logs-table thead {
  background: var(--bg);
}

.logs-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.logs-table td {
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.logs-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.05);
}

.logs-table tbody tr:last-child td {
  border-bottom: none;
}

/* Column widths */
.col-date { width: 150px; }
.col-type { width: 160px; }
.col-user { width: 180px; }
.col-target { width: 140px; }
.col-details { min-width: 200px; }
.col-ip { width: 120px; }
.col-status { width: 80px; text-align: center; }

/* Action type badges */
.action-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
}

.action-badge.auth {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.action-badge.auth-out {
  background: rgba(251, 146, 60, 0.15);
  color: #fb923c;
}

.action-badge.auth-fail {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.action-badge.si {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.action-badge.discussion {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
}

.action-badge.import {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.action-badge.user {
  background: rgba(236, 72, 153, 0.15);
  color: #ec4899;
}

.action-badge.file {
  background: rgba(6, 182, 212, 0.15);
  color: #06b6d4;
}

.action-badge.notif {
  background: rgba(107, 114, 128, 0.15);
  color: #6b7280;
}

.action-badge.export {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

/* User cell */
.user-cell {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.user-name {
  font-weight: 500;
  color: var(--text);
}

.user-id {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.user-role {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  display: inline-block;
  margin-top: 0.2rem;
}

.user-role.admin {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.user-role.soc {
  background: rgba(168, 85, 247, 0.2);
  color: #a855f7;
}

.user-role.user {
  background: rgba(107, 114, 128, 0.2);
  color: #9ca3af;
}

/* Target cell */
.target-cell {
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  color: var(--accent);
}

/* Details cell */
.details-cell {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.details-cell:hover {
  white-space: normal;
  word-break: break-word;
}

/* IP cell */
.ip-cell {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.75rem;
}

.status-badge.success {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.status-badge.failure {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* Date cell */
.date-cell {
  font-size: 0.85rem;
}

.date-cell .date {
  color: var(--text);
}

.date-cell .time {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state p {
  font-size: 1rem;
}

/* ====== PAGINATION ====== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1rem;
}

#pageInfo {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ====== LOADING OVERLAY ====== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: var(--text);
}

.loading-spinner i {
  font-size: 2.5rem;
  color: var(--accent);
}

/* ====== RESPONSIVE ====== */
@media (max-width: 1200px) {
  .filters-row {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    width: 100%;
  }

  .filter-input,
  .filter-select {
    width: 100%;
  }

  .filter-actions {
    margin-left: 0;
    justify-content: flex-end;
  }
}

@media (max-width: 768px) {
  .header-nav {
    display: none;
  }

  .main-container {
    padding: 1rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .table-container {
    overflow-x: auto;
  }

  .logs-table {
    min-width: 900px;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ====== SCROLLBARS ====== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg);
}
