/* =========================================================================
 * AccessLoRa — Interface d'administration (maquette de démonstration)
 * Palette bleu / gris professionnelle, responsive PC + mobile.
 * ========================================================================= */

:root {
  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --surface-alt:   #f8fafc;
  --border:        #e2e8f0;
  --text:          #0f172a;
  --text-soft:     #475569;
  --text-mute:     #94a3b8;
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-soft:  #dbeafe;
  --sidebar-bg:    #0f172a;
  --sidebar-soft:  #1e293b;
  --ok:            #16a34a;
  --ok-soft:       #dcfce7;
  --warn:          #d97706;
  --warn-soft:     #fef3c7;
  --danger:        #dc2626;
  --danger-soft:   #fee2e2;
  --radius:        12px;
  --shadow:        0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-lg:     0 10px 30px rgba(15,23,42,.18);
  --sidebar-w:     256px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ---- Bandeau démo ------------------------------------------------------- */
.demo-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(90deg, #f59e0b, #f97316);
  color: #451a03;
  font-weight: 600;
  font-size: 12.5px;
  padding: 6px 12px;
  text-align: center;
}
.demo-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #451a03;
  animation: pulse 1.6s infinite;
}

/* ---- Layout ------------------------------------------------------------- */
.layout { display: flex; min-height: calc(100vh - 32px); }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 32px;
  height: calc(100vh - 32px);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--primary);
  color: #fff; font-weight: 800; font-size: 20px;
  display: grid; place-items: center;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: #fff; font-size: 16px; }
.brand-text span { color: #64748b; font-size: 11.5px; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-soft); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-ico { width: 20px; text-align: center; opacity: .9; }

.sidebar-footer { margin-top: auto; padding: 12px 10px 2px; color: #64748b; font-size: 11px; }
.live-indicator { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: #94a3b8; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(22,163,74,.6); animation: pulse 1.8s infinite; }

/* ---- Main --------------------------------------------------------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 22px;
  position: sticky; top: 32px; z-index: 20;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.clock { font-variant-numeric: tabular-nums; color: var(--text-soft); font-weight: 600; font-size: 13px; }
.burger { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text); }

.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary-dark);
  font-weight: 700; display: grid; place-items: center; font-size: 13px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta strong { font-size: 13px; }
.user-meta span { font-size: 11px; color: var(--text-mute); }

.content { padding: 22px; max-width: 1280px; width: 100%; }

/* ---- Cartes de synthèse ------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
}
.stat-card .stat-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 20px; margin-bottom: 4px; }
.stat-value { font-size: 30px; font-weight: 800; line-height: 1; }
.stat-label { color: var(--text-soft); font-size: 12.5px; font-weight: 500; }
.stat-sub { font-size: 11.5px; color: var(--text-mute); }
.ico-blue   { background: var(--primary-soft); color: var(--primary-dark); }
.ico-green  { background: var(--ok-soft);      color: var(--ok); }
.ico-amber  { background: var(--warn-soft);    color: var(--warn); }
.ico-red    { background: var(--danger-soft);  color: var(--danger); }

/* ---- Panneaux / cartes -------------------------------------------------- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.panel-head .sub { color: var(--text-mute); font-size: 12px; }
.panel-body { padding: 4px 0; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; align-items: start; }

/* ---- Tables ------------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 18px; white-space: nowrap; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-mute); font-weight: 600; border-bottom: 1px solid var(--border); }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-alt); }
td .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; color: var(--text-soft); }

/* ---- Badges de statut --------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1.6;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge-ok     { background: var(--ok-soft);     color: #15803d; }
.badge-ok .dot     { background: var(--ok); }
.badge-warn   { background: var(--warn-soft);   color: #b45309; }
.badge-warn .dot   { background: var(--warn); }
.badge-danger { background: var(--danger-soft); color: #b91c1c; }
.badge-danger .dot { background: var(--danger); }
.badge-info   { background: var(--primary-soft); color: var(--primary-dark); }
.badge-info .dot   { background: var(--primary); }
.badge-mute   { background: #f1f5f9; color: #64748b; }
.badge-mute .dot   { background: #94a3b8; }

.group-tag { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; }
.group-tag .swatch { width: 9px; height: 9px; border-radius: 3px; }

/* ---- Signal / batterie -------------------------------------------------- */
.meter { display: inline-flex; align-items: center; gap: 8px; }
.bar { width: 90px; height: 7px; border-radius: 99px; background: #e2e8f0; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; }
.meter small { color: var(--text-soft); font-variant-numeric: tabular-nums; min-width: 44px; }

.signal { display: inline-flex; align-items: flex-end; gap: 2px; height: 16px; }
.signal i { width: 4px; background: #cbd5e1; border-radius: 1px; }
.signal i.on { background: var(--ok); }
.signal i.warn.on { background: var(--warn); }
.signal i.bad.on { background: var(--danger); }

/* ---- Flux temps réel ---------------------------------------------------- */
.feed { list-style: none; margin: 0; padding: 0; max-height: 430px; overflow-y: auto; }
.feed li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px; border-bottom: 1px solid var(--border);
}
.feed li:last-child { border-bottom: none; }
.feed .f-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 15px; flex: 0 0 auto; }
.feed .f-main { flex: 1; min-width: 0; }
.feed .f-main strong { font-size: 13px; }
.feed .f-main .f-sub { color: var(--text-mute); font-size: 11.5px; }
.feed .f-time { color: var(--text-mute); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.feed li.flash { animation: flashRow 1s ease; }

/* ---- Filtres / contrôles ------------------------------------------------ */
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 11px; color: var(--text-mute); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
select, input[type="search"] {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: 13px; background: var(--surface); color: var(--text); min-width: 150px;
}
select:focus, input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-alt); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.count-pill { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 99px; padding: 3px 10px; font-size: 12px; color: var(--text-soft); font-weight: 600; }

/* ---- Drawer (édition droits) ------------------------------------------- */
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 400px; max-width: 92vw;
  background: var(--surface); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .25s ease;
  z-index: 120; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-scrim { position: fixed; inset: 0; background: rgba(15,23,42,.45); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 110; }
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
.drawer-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; }
.drawer-head h3 { margin: 0 0 3px; font-size: 16px; }
.drawer-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.drawer .close-x { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-mute); line-height: 1; }

.right-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px;
}
.right-row .r-info { display: flex; flex-direction: column; }
.right-row .r-info strong { font-size: 13.5px; }
.right-row .r-info span { font-size: 11.5px; color: var(--text-mute); }

/* Interrupteur */
.switch { position: relative; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: #cbd5e1; border-radius: 99px; transition: background .2s; }
.switch .track::before { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: var(--shadow); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::before { transform: translateX(18px); }

.field-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.field-row .lbl { font-size: 11.5px; color: var(--text-mute); font-weight: 600; text-transform: uppercase; }

.empty { padding: 40px; text-align: center; color: var(--text-mute); }
.section-note { font-size: 12px; color: var(--text-mute); margin: 4px 18px 12px; }

.scrim { display: none; }

/* ---- Animations --------------------------------------------------------- */
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.5); } 70% { box-shadow: 0 0 0 8px rgba(22,163,74,0); } 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); } }
@keyframes flashRow { 0% { background: var(--primary-soft); } 100% { background: transparent; } }

/* ---- Responsive --------------------------------------------------------- */
@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } }

@media (max-width: 760px) {
  .burger { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
    transform: translateX(-100%); transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 90; }
  .scrim.open { opacity: 1; pointer-events: auto; }
  .topbar { top: 0; }
  .sidebar { top: 0; }
  .user-meta { display: none; }
  .content { padding: 16px; }
  .stat-value { font-size: 26px; }
}
