/* ==========================================================================
   analytics.css — Styles pour l'authentification et le tableau de bord
   LED Tool · Schréder · Design System 2026
   ========================================================================== */

/* ── VARIABLES (reprises du design system LED Tool) ─────────────── */
:root {
  --bg: #051c2c;
  --surface: #061e30;
  --card: #082436;
  --border: #113050;
  --accent: #1972e1;
  --accent2: #fd5d08;
  --green: #00857e;
  --red: #de2b37;
  --teal: #00857e;
  --txt: #f5f7fa;
  --muted: #8daabf;
  --sans: 'Work Sans', sans-serif;
  --mono: 'DM Mono', monospace;
}

[data-theme="light"] {
  --bg: #fafafa;
  --surface: #ffffff;
  --card: #f0f3f7;
  --border: #dde3ec;
  --txt: #051c2c;
  --muted: #4a6480;
}

/* ══════════════════════════════════════════════════════════════════
   1. COMPOSANTS D'AUTHENTIFICATION (injectés dans le header LED Tool)
   ══════════════════════════════════════════════════════════════════ */

/* Bouton générique auth */
.auth-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-family: var(--sans);
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
  text-decoration: none;
}

/* Bouton Sign in */
.auth-signin {
  background: rgba(25, 114, 225, .12);
  border-color: rgba(25, 114, 225, .4);
  color: #7ab3f0;
}
.auth-signin:hover {
  background: rgba(25, 114, 225, .22);
  border-color: var(--accent);
  color: #fff;
}
[data-theme="light"] .auth-signin {
  background: rgba(25, 114, 225, .08);
  border-color: rgba(25, 114, 225, .3);
  color: var(--accent);
}

/* Bouton Sign out */
.auth-signout {
  background: transparent;
  border-color: rgba(141, 170, 191, .3);
  color: var(--muted);
  font-size: .7rem;
}
.auth-signout:hover {
  border-color: var(--red);
  color: var(--red);
  background: rgba(222, 43, 55, .06);
}

/* Chip utilisateur (avatar + nom) */
.auth-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 9px 3px 3px;
  background: rgba(25, 114, 225, .08);
  border: 1px solid rgba(25, 114, 225, .2);
  border-radius: 99px;
  max-width: 160px;
}

.auth-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1972e1, #00857e);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  font-family: var(--sans);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.auth-name {
  font-size: .72rem;
  font-weight: 600;
  color: var(--txt);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100px;
}
[data-theme="light"] .auth-name { color: var(--txt); }

/* Lien Admin */
.auth-admin-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 5px;
  background: rgba(253, 93, 8, .1);
  border: 1px solid rgba(253, 93, 8, .3);
  color: var(--accent2);
  font-size: .7rem;
  font-weight: 700;
  font-family: var(--sans);
  text-decoration: none;
  transition: all .18s;
  white-space: nowrap;
}
.auth-admin-link:hover {
  background: rgba(253, 93, 8, .18);
  border-color: var(--accent2);
  color: #fff;
}

/* Spinner d'attente d'auth */
.auth-loading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: .7rem;
}
.auth-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: auth-spin .7s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════════
   2. BANDEAU DE CONSENTEMENT RGPD
   ══════════════════════════════════════════════════════════════════ */

#telemetry-consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #061e30;
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, .3);
}
[data-theme="light"] #telemetry-consent-banner {
  background: #fff;
  border-top-color: #dde3ec;
}

.tcb-content {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.tcb-content p {
  flex: 1;
  min-width: 200px;
  font-size: .78rem;
  color: var(--muted);
  font-family: var(--sans);
  margin: 0;
  line-height: 1.5;
}
.tcb-btns {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.tcb-accept, .tcb-decline {
  padding: 7px 16px;
  border-radius: 6px;
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
}
.tcb-accept {
  background: var(--accent);
  color: #fff;
  border: none;
}
.tcb-accept:hover { background: #1560c0; }
.tcb-decline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.tcb-decline:hover { border-color: var(--muted); }

/* ══════════════════════════════════════════════════════════════════
   3. TABLEAU DE BORD ADMIN — LAYOUT
   ══════════════════════════════════════════════════════════════════ */

/* Conteneur principal du dashboard */
.dash-wrapper {
  background: var(--bg);
  color: var(--txt);
  font-family: var(--sans);
  min-height: 100vh;
}

/* Header admin */
.dash-header {
  background: linear-gradient(135deg, #030f18, #062030);
  border-bottom: 1px solid rgba(25, 114, 225, .25);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.dash-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(to right, #fd5d08 0%, #de2b37 5%, #432680 50%, #1972e1 90%, #00857e 100%);
}
.dash-header-title {
  font-size: .92rem;
  font-weight: 700;
  color: var(--txt);
}
.dash-header-sub {
  font-size: .65rem;
  color: var(--muted);
  font-family: var(--mono);
}
.dash-back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
  text-decoration: none;
  font-family: var(--sans);
  transition: color .15s;
  margin-right: auto;
}
.dash-back-link:hover { color: var(--accent); }
.dash-header-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Corps du dashboard */
.dash-body {
  padding: 20px 24px;
  max-width: 1600px;
  margin: 0 auto;
}
@media (max-width: 768px) {
  .dash-body { padding: 12px 16px; }
}

/* ── BARRE DE FILTRES TEMPORELS ────────────────────────────── */
.period-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.period-label {
  font-size: .62rem;
  color: var(--muted);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .1em;
  white-space: nowrap;
}
.period-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.period-btn {
  padding: 5px 12px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.period-btn:hover { border-color: var(--accent); color: var(--accent); }
.period-btn.active {
  background: rgba(25, 114, 225, .12);
  border-color: var(--accent);
  color: var(--accent);
}
.period-custom {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.period-date-input {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--txt);
  padding: 5px 8px;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: .72rem;
  outline: none;
  transition: border-color .15s;
}
.period-date-input:focus { border-color: var(--accent); }
.period-sep { font-size: .62rem; color: var(--muted); }
.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: var(--sans);
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .18s;
  margin-left: auto;
}
.btn-refresh:hover { background: #1560c0; }
.btn-refresh:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }
.refresh-info {
  font-size: .6rem;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
}

/* ── GRILLE DES KPI ──────────────────────────────────────── */
.kpi-grid-dash {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: border-color .2s;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--kpi-color, var(--accent));
  opacity: .5;
}
.kpi-card:hover { border-color: var(--accent); }
.kpi-card.loading { animation: kpi-pulse 1.5s ease-in-out infinite; }
@keyframes kpi-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}
.kpi-card-label {
  font-family: var(--mono);
  font-size: .54rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  line-height: 1.4;
}
.kpi-card-value {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: -.03em;
  color: var(--txt);
  line-height: 1.1;
}
.kpi-card-sub {
  font-size: .62rem;
  color: var(--muted);
  font-family: var(--mono);
}
.kpi-card-value.accent { color: var(--accent); }
.kpi-card-value.green { color: var(--green); }
.kpi-card-value.orange { color: var(--accent2); }

/* ── GRILLE DES GRAPHIQUES ───────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 1100px) {
  .charts-grid { grid-template-columns: 1fr; }
}
.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chart-card.full-width { grid-column: 1 / -1; }
.chart-title {
  font-size: .78rem;
  font-weight: 700;
  color: var(--txt);
  display: flex;
  align-items: center;
  gap: 8px;
}
.chart-title-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.chart-canvas-wrap {
  position: relative;
  height: 220px;
}
.chart-canvas-wrap.sm { height: 180px; }

/* ── SECTION UTILISATEURS ────────────────────────────────── */
.users-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}
.users-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.users-title {
  font-size: .84rem;
  font-weight: 700;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}
.users-badge {
  background: var(--accent);
  color: #fff;
  font-size: .56rem;
  font-family: var(--mono);
  padding: 2px 7px;
  border-radius: 99px;
}
.users-search {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--txt);
  padding: 6px 10px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: .78rem;
  outline: none;
  width: 200px;
  transition: border-color .15s;
}
.users-search:focus { border-color: var(--accent); }
.users-search::placeholder { color: var(--muted); }
.btn-reset {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 5px;
  font-family: var(--sans);
  font-size: .7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.btn-reset:hover { border-color: var(--accent2); color: var(--accent2); }

/* Tableau utilisateurs */
.users-table-wrap {
  overflow-x: auto;
}
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .76rem;
  min-width: 700px;
}
.users-table thead th {
  background: #030e17;
  color: var(--muted);
  font-family: var(--mono);
  font-size: .54rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  padding: 9px 12px;
  text-align: left;
  white-space: nowrap;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  position: relative;
}
.users-table thead th:hover { color: var(--txt); }
.users-table thead th.sorted-asc::after { content: ' ↑'; color: var(--accent); }
.users-table thead th.sorted-desc::after { content: ' ↓'; color: var(--accent); }
.users-table tbody tr { border-bottom: 1px solid rgba(17, 48, 80, .5); transition: background .1s; }
.users-table tbody tr:last-child { border-bottom: none; }
.users-table tbody tr:hover { background: rgba(25, 114, 225, .04); }
.users-table td { padding: 8px 12px; }
.users-table td.mono { font-family: var(--mono); }
.users-table td.accent { font-family: var(--mono); color: var(--accent); }
.users-table td.green { font-family: var(--mono); color: var(--green); }
.users-table td.muted { color: var(--muted); font-size: .7rem; }

/* Indicateur de statut actif */
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
}
.status-dot.active { background: var(--green); }
.status-dot.inactive { background: var(--border); }

/* Pagination */
.users-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}
.page-info {
  font-size: .7rem;
  color: var(--muted);
  font-family: var(--mono);
}
.page-btns {
  display: flex;
  gap: 4px;
}
.page-btn {
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: .7rem;
  cursor: pointer;
  transition: all .15s;
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── ÉTATS : LOADING, VIDE, ERREUR ──────────────────────── */
.state-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  gap: 12px;
  text-align: center;
}
.state-icon {
  font-size: 2rem;
  opacity: .35;
}
.state-title {
  font-size: .84rem;
  font-weight: 700;
  color: var(--txt);
}
.state-sub {
  font-size: .72rem;
  color: var(--muted);
  max-width: 320px;
  line-height: 1.6;
}
.state-box.error .state-title { color: var(--red); }

/* Spinner de chargement global */
.dash-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: auth-spin .8s linear infinite;
}

/* ── ACCÈS REFUSÉ ────────────────────────────────────────── */
#access-denied {
  display: none;
  min-height: calc(100vh - 60px);
}

/* ── STYLES ADAPTATIFS (thème clair) ─────────────────────── */
[data-theme="light"] .dash-header {
  background: linear-gradient(135deg, #ffffff, #f0f5fc);
  border-bottom-color: rgba(25, 114, 225, .15);
}
[data-theme="light"] .users-table thead th { background: #e8edf5; }
[data-theme="light"] .users-table tbody tr:hover { background: rgba(25, 114, 225, .04); }
[data-theme="light"] .period-date-input { background: #fff; border-color: #dde3ec; color: #051c2c; }
[data-theme="light"] .users-search { background: #fff; border-color: #dde3ec; color: #051c2c; }

/* Scrollbar */
.users-table-wrap::-webkit-scrollbar { height: 4px; }
.users-table-wrap::-webkit-scrollbar-track { background: transparent; }
.users-table-wrap::-webkit-scrollbar-thumb { background: rgba(25, 114, 225, .3); border-radius: 2px; }
