/* =========================================================================
   LumiCity - Supervision
   Styles complémentaires (au-delà des utilitaires Tailwind)
   ========================================================================= */

/* --- Panneaux génériques --------------------------------------------------- */
.panel {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #eef2f6;
  background: #fbfcfd;
}

.panel-title {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #173c5c;
}

/* Variante sombre du bandeau (console terminal) */
.panel-head-dark {
  background: #102b41;
  border-bottom-color: #102b41;
}
.panel-title-light {
  color: #ffffff;
}
.panel-head-note {
  font-size: 0.6875rem;
  font-family: 'Consolas', 'Cascadia Mono', 'Menlo', 'Courier New', monospace;
  color: #9fb6cc;
}

/* --- Légende de la carte --------------------------------------------------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.85rem;
  font-size: 0.6875rem;
  color: #64748b;
}
.legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.lg-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 9999px;
  display: inline-block;
}
.lg-ring {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 9999px;
  border: 2px solid #1f4e79;
  display: inline-block;
}

/* --- Cartes KPI ------------------------------------------------------------ */
.kpi-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.kpi-badge {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  padding: 0.1rem 0.5rem;
  border-radius: 9999px;
  box-shadow: inset 0 0 0 1px currentColor;
  --tw-ring-offset-width: 0;
}
.kpi-value {
  margin-top: 0.5rem;
  font-size: 1.85rem;
  line-height: 1.1;
  font-weight: 700;
  color: #102b41;
  font-variant-numeric: tabular-nums;
}
.kpi-foot {
  margin-top: 0.35rem;
  font-size: 0.6875rem;
}

/* --- Carte Leaflet --------------------------------------------------------- */
.map-frame {
  height: 340px;
  width: 100%;
}
.map-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.4rem 0.9rem;
  border-top: 1px solid #eef2f6;
  background: #fbfcfd;
  font-size: 10px;
  color: #64748b;
}
@media (min-width: 1024px) {
  .map-frame {
    height: 400px;
  }
}
.leaflet-container {
  font-family: inherit;
  background: #e8edf2;
}

/* Message affiché lorsque aucun fond de carte ne peut être chargé */
.map-notice {
  position: absolute;
  z-index: 900;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  max-width: 90%;
  text-align: center;
  background: #fff;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 0.375rem;
  padding: 0.4rem 0.7rem;
  font-size: 11px;
  line-height: 1.35;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.15);
}

/* Marqueur personnalisé (pastille colorée) */
.led {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 9999px;
  background: var(--led, #10b981);
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.25), 0 1px 3px rgba(15, 23, 42, 0.35);
}

/* Pastille en détection : clignotement sobre */
.led-blink {
  animation: ledBlink 1.1s ease-in-out infinite;
}
@keyframes ledBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(1.25); }
}

/* Poteau maître : pastille plus grande, anneau bleu institutionnel */
.led-master {
  width: 22px;
  height: 22px;
  border-width: 3px;
  box-shadow: 0 0 0 2px #1f4e79, 0 1px 4px rgba(15, 23, 42, 0.4);
}

/* Étiquette du mât */
.mast-label {
  font-size: 10px;
  font-weight: 600;
  color: #334155;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #dbe3ea;
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
  transform: translateY(-14px);
}

/* --- Console LoRa ---------------------------------------------------------- */
.terminal {
  height: 220px;
  overflow-y: auto;
  background: #0f172a;
  color: #cbd5e1;
  font-family: 'Consolas', 'Cascadia Mono', 'Menlo', 'Courier New', monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 0.75rem 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.terminal .log-line {
  display: block;
  padding: 1px 0;
  animation: logIn 0.25s ease-out;
}
@keyframes logIn {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}
.terminal .t-time   { color: #64748b; }
.terminal .t-gw     { color: #7dd3fc; }
.terminal .t-mast   { color: #e2e8f0; }
.terminal .t-id     { color: #fbbf24; }
.terminal .t-role   { color: #a78bfa; }
.terminal .t-geo    { color: #5eead4; }
.terminal .t-info   { color: #94a3b8; }
.terminal .t-ok     { color: #6ee7b7; }
.terminal .t-warn   { color: #fcd34d; }
.terminal .t-err    { color: #f87171; }

/* Barre de défilement sobre */
.terminal::-webkit-scrollbar { width: 8px; }
.terminal::-webkit-scrollbar-track { background: #0f172a; }
.terminal::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
.terminal::-webkit-scrollbar-thumb:hover { background: #475569; }

/* --- Puces d'état ---------------------------------------------------------- */
.live-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  animation: pulseDot 2s infinite;
}
@keyframes pulseDot {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* --- Boutons d'action ------------------------------------------------------ */
.btn-action {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  background: #ffffff;
  color: #1e293b;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  cursor: pointer;
}
.btn-action:hover {
  background: #f4f7fb;
  border-color: #c7d5e4;
}
.btn-action:active {
  transform: translateY(1px);
}
.btn-action:focus-visible {
  outline: 2px solid #1f4e79;
  outline-offset: 2px;
}
.btn-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 0.4rem;
  background: #eef4fa;
  color: #1f4e79;
}
.btn-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.btn-label {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
}
.btn-sub {
  font-size: 0.6875rem;
  color: #64748b;
  line-height: 1.3;
}

/* --- Lignes d'information -------------------------------------------------- */
.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: #64748b;
  padding: 0.25rem 0;
}

/* --- Tableau de statistiques par poteau ----------------------------------- */
.stats-scroll {
  max-height: 440px;
  overflow: auto;
}
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.stats-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  text-align: left;
  font-weight: 600;
  color: #475569;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.stats-table tbody td {
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid #eef2f6;
  color: #334155;
  white-space: nowrap;
}
.stats-table tbody tr:hover {
  background: #f8fafc;
}
.stats-table tbody tr.is-master {
  background: #f1f6fb;
}
.stats-table tbody tr.is-master:hover {
  background: #e9f1f9;
}
.stats-table th.num,
.stats-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.mono {
  font-family: 'Consolas', 'Cascadia Mono', 'Menlo', 'Courier New', monospace;
  color: #1f4e79;
  font-weight: 600;
}

/* Badges d'état */
.state-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 9999px;
  line-height: 1.5;
}
.state-nominal     { background: #ecfdf5; color: #047857; }
.state-detect      { background: #fffbeb; color: #b45309; }
.state-veille      { background: #f1f5f9; color: #475569; }
.state-maintenance { background: #fef2f2; color: #b91c1c; }

/* Badges de rôle */
.role-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 9999px;
  line-height: 1.5;
}
.role-master { background: #eef4fa; color: #1f4e79; }
.role-slave  { background: #f8fafc; color: #64748b; }
