/* ==========================================================================
   LAYOUT & STRUCTURE RESPONSIVE
   ========================================================================== */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 850px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 1.2rem;
  }
  .sidebar {
    position: static !important;
    flex-direction: row !important;
    overflow-x: auto;
    scrollbar-width: thin;
  }
  .side-item {
    flex: 0 0 auto;
    width: auto !important;
  }
}

/* ==========================================================================
   SIDEBAR (LISTE DES MACHINES)
   ========================================================================== */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  background: rgba(34, 34, 61, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: .75rem;
  position: sticky;
  top: 1rem;
}

.side-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: .65rem .8rem;
  color: #fff;
  cursor: pointer;
  min-width: 0; /* Important pour le troncage de texte */
  transition: background .2s ease, transform .1s ease;
}

.side-item:hover { 
  background: rgba(255, 255, 255, 0.08); 
}

.side-item:active {
  transform: scale(0.98);
}

.side-item.active { 
  background: linear-gradient(90deg, rgba(93, 80, 254, 0.25), rgba(255, 165, 0, 0.1)); 
  border-left: 3px solid #5d50fe;
  padding-left: calc(.8rem - 3px);
}

/* Évite que les noms longs cassent la structure */
.side-name { 
  flex: 1; 
  font-weight: 600; 
  font-size: .95rem; 
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-type { 
  font-size: .78rem; 
  opacity: .6; 
  background: rgba(255, 255, 255, 0.1);
  padding: .15rem .4rem;
  border-radius: 4px;
  white-space: nowrap;
}

/* ==========================================================================
   PANNEAU DE DÉTAIL & GRILLES
   ========================================================================== */
.detail {
  background: rgba(34, 34, 61, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 1.5rem;
  min-height: 240px;
}

.detail-head { 
  display: flex; 
  align-items: center; 
  justify-content: space-between;
  gap: 1rem; 
  margin-bottom: .5rem; 
  flex-wrap: wrap;
}

.detail-head h2 { 
  margin: 0; 
  font-size: 1.6rem; 
  font-weight: 700;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-head h2 a { color: #FFA500; text-decoration: none; }
.detail-head h2 a:hover { text-decoration: underline; }

.empty-hint { opacity: .6; text-align: center; padding: 2rem 0; font-style: italic; }
.last { font-size: .88rem; opacity: .7; margin: .2rem 0 1.2rem; }
.detail .wake { width: auto; padding: .6rem 1.8rem; margin-bottom: 1.5rem; }

/* ==========================================================================
   BANNEURS DES APPLICATIONS (ROBUSTE AUX TEXTES LONGS)
   ========================================================================== */
.banners { display: flex; flex-direction: column; gap: 1rem; }

.banner {
  background: rgba(20, 20, 40, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 1rem;
  transition: border-color .2s;
}
.banner:hover {
  border-color: rgba(93, 80, 254, 0.3);
}

.banner-head { 
  display: flex; 
  align-items: center; 
  gap: .8rem; 
  min-width: 0; /* Permet aux enfants flex de se squeezer proprement */
}

.app-icon { font-size: 1.5rem; line-height: 1; flex-shrink: 0; }
.app-icon-img { width: 32px; height: 32px; object-fit: contain; border-radius: 6px; flex-shrink: 0; }

.banner-titles { 
  display: flex; 
  flex-direction: column; 
  line-height: 1.3; 
  flex: 1; 
  min-width: 0; 
}
.banner-titles strong {
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.banner-titles small { 
  opacity: .6; 
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.banner-dot { flex-shrink: 0; margin-left: 0.5rem; }
.banner-status { font-size: .9rem; font-weight: 500; white-space: nowrap; margin-left: auto; text-align: right; }

.banner-info { 
  font-size: .88rem; 
  opacity: .75; 
  margin: .5rem 0 0; 
  white-space: pre-line; 
  padding: .5rem .75rem;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 6px;
}
.chart-wrap { position: relative; height: 130px; margin-top: .8rem; }

/* ==========================================================================
   INDICATEURS DE STATUT (DOTS)
   ========================================================================== */
.dot { 
  display: inline-block; 
  width: .75rem; 
  height: .75rem; 
  border-radius: 50%; 
  vertical-align: middle; 
  flex-shrink: 0;
}
.dot.on   { background: #2ecc71; box-shadow: 0 0 8px rgba(46, 204, 113, 0.6); }
.dot.off  { background: #e74c3c; box-shadow: 0 0 8px rgba(231, 76, 60, 0.6); }
.dot.wake { background: #FFA500; box-shadow: 0 0 8px rgba(255, 165, 0, 0.6); animation: pulse 1.2s infinite ease-in-out; }
.dot.idle { background: #7f8c8d; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .85rem;
  font-weight: 600;
  padding: .25rem .6rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
}

@keyframes pulse { 
  0%, 100% { opacity: 1; transform: scale(1); } 
  50% { opacity: .4; transform: scale(0.9); } 
}

/* ==========================================================================
   COMPOSANTS UTILITAIRES & ADMIN
   ========================================================================== */
.toast {
  position: fixed; left: 50%; bottom: 2rem; transform: translateX(-50%);
  background: #23245b; color: #fff; padding: .8rem 1.5rem; border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4); z-index: 1000;
  font-weight: 500;
  transition: all 0.3s ease;
}
.toast.err { background: #e74c3c; }

.flash { padding: .75rem 1.2rem; border-radius: 8px; margin-bottom: 1rem; }
.flash.ok  { background: #27ae60; color: #fff; }
.flash.err { background: #c0392b; color: #fff; }

.login-box { max-width: 400px; margin: 4rem auto; padding: 2rem; background: rgba(34, 34, 61, 0.4); border-radius: 12px; }
form.inline { display: inline; margin: 0; }
button.small { padding: .3rem .8rem; font-size: .85rem; margin: 0; width: auto; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
.checks label { display: inline-flex; align-items: center; gap: .3rem; margin-right: 1.2rem; margin-bottom: .4rem; }
.creds { font-family: monospace; font-size: 1.1rem; user-select: all; background: rgba(0,0,0,0.2); padding: .75rem; border-radius: 6px; }

table { font-size: .92rem; width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .75rem .5rem; }
tr:not(:last-child) { border-bottom: 1px solid rgba(255,255,255,0.05); }

.admin-tabs {
  display: flex;
  gap: .25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-wrap: wrap;
}
.tab-btn {
  background: transparent; border: none; color: #fff; opacity: .6;
  padding: .75rem 1.2rem; cursor: pointer; border-bottom: 2px solid transparent;
  margin: 0; width: auto; font-size: .95rem; transition: all .2s;
}
.tab-btn:hover { opacity: 1; background: rgba(255,255,255,0.02); }
.tab-btn.active { opacity: 1; border-bottom-color: #FFA500; font-weight: 600; }

.group-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.app-icon-table { width: 24px; height: 24px; object-fit: contain; vertical-align: middle; margin-right: .4rem; border-radius: 4px; }
.chart-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: .85rem; opacity: .7; background: rgba(20,20,40,0.4); border-radius: 8px;
}

/* ==========================================================================
   NAVIGATION BAR REDESIGN (MATCHING SIDEBAR & CARDS)
   ========================================================================== */
header.container {
  margin-top: 1rem;
  margin-bottom: 2rem;
}

header nav {
  background: rgba(34, 34, 61, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: .5rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Alignement des listes de navigation */
header nav ul {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

header nav ul:first-child strong {
  font-size: 1.15rem;
  letter-spacing: 0.5px;
  color: #fff;
}

/* Liens de navigation */
header nav ul li a {
  display: inline-block;
  color: #fff;
  opacity: .7;
  text-decoration: none;
  font-size: .95rem;
  font-weight: 500;
  padding: .5rem .8rem;
  border-radius: 8px;
  border-bottom: 2px solid transparent;
  transition: all .2s ease;
}

header nav ul li a:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

/* État actif (Si vous ajoutez une classe .active sur vos liens php) */
header nav ul li a.active {
  opacity: 1;
  font-weight: 600;
  background: linear-gradient(90deg, rgba(93, 80, 254, 0.15), rgba(255, 165, 0, 0.05));
  border-bottom-color: #FFA500;
  border-radius: 8px 8px 0 0; /* Optionnel : garde l'esprit de l'onglet admin */
}

/* Bouton de déconnexion personnalisé */
header nav button.secondary.outline.small {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
  padding: .4rem .8rem;
  border-radius: 8px;
  margin: 0;
  cursor: pointer;
  transition: all .2s ease;
}

header nav button.secondary.outline.small:hover {
  background: rgba(231, 76, 60, 0.15);
  border-color: rgba(231, 76, 60, 0.4);
  color: #e74c3c;
}

header nav button.secondary.outline.small:active {
  transform: scale(0.98);
}

/* Adaptabilité Mobile (Responsive) */
@media (max-width: 768px) {
  header nav {
    flex-direction: column;
    align-items: stretch;
    padding: .75rem;
    gap: .75rem;
  }
  
  header nav ul {
    justify-content: center;
    flex-wrap: wrap;
    gap: .25rem;
  }
  
  header nav ul:first-child {
    text-align: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: .5rem;
  }
  
  header nav ul li a {
    font-size: .9rem;
    padding: .4rem .6rem;
  }
}
/* ==========================================================================
   ADMIN PANELS & FORMS REDESIGN
   ========================================================================== */

/* Structure des blocs de contenu de l'admin */
.admin-pane article {
  background: rgba(34, 34, 61, 0.4) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* En-têtes des blocs formulaires */
.admin-pane article header {
  background: rgba(0, 0, 0, 0.2) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  margin: -1.5rem -1.5rem 1.5rem -1.5rem;
  padding: .75rem 1.5rem;
  font-weight: 600;
  color: #FFA500; /* Rappel de la couleur d'accentuation */
  font-size: 1.1rem;
}

/* Champs de saisie, sélections et listes déroulantes */
.admin-pane input[type="text"],
.admin-pane input[type="password"],
.admin-pane input[type="number"],
.admin-pane input[type="datetime-local"],
.admin-pane select {
  background: rgba(20, 20, 40, 0.5) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
  border-radius: 8px;
  transition: border-color .2s;
}

.admin-pane input:focus,
.admin-pane select:focus {
  border-color: rgba(93, 80, 254, 0.6) !important;
  box-shadow: 0 0 8px rgba(93, 80, 254, 0.3) !important;
}

/* Fieldset et légendes (Gestion des groupes/cases à cocher) */
.admin-pane fieldset {
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.15);
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.2rem;
}

.admin-pane fieldset legend {
  font-size: .88rem;
  font-weight: 600;
  opacity: .8;
  padding: 0 .5rem;
}

/* Boutons principaux de l'administration */
.admin-pane button[type="submit"] {
  background: #5d50fe;
  border: none;
  color: #fff;
  font-weight: 600;
  border-radius: 8px;
  transition: background .2s, transform .1s;
}

.admin-pane button[type="submit"]:hover {
  background: #4b3ee3;
}

.admin-pane button[type="submit"]:active {
  transform: scale(0.98);
}

/* Tableaux de données administratifs */
.admin-pane table {
  background: rgba(34, 34, 61, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  overflow: hidden;
}

.admin-pane th {
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-weight: 600;
  text-transform: uppercase;
  font-size: .8rem;
  letter-spacing: 0.5px;
  padding: 1rem .75rem;
}

.admin-pane td {
  padding: 1rem .75rem;
  vertical-align: middle;
}

.admin-pane tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Liens d'action (Modifier, gérer) */
.admin-pane td a {
  color: #FFA500;
  text-decoration: none;
  font-weight: 500;
  margin-right: .5rem;
}

.admin-pane td a:hover {
  text-decoration: underline;
}

/* Ajustement pour les puces/chips des groupes */
.group-chips button.secondary.outline.small {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 20px;
  padding: .3rem .7rem;
  transition: all .2s;
}

.group-chips button.secondary.outline.small:hover {
  background: rgba(231, 76, 60, 0.2);
  border-color: #e74c3c;
  color: #e74c3c;
}
/* ==========================================================================
   CORRECTIONS RESPONSIVE & TRONCAGE (PANNEAU ADMIN)
   ========================================================================== */

/* 1. Rendre les colonnes adaptatives sur mobile (Passage en bloc si l'écran est trop petit) */
@media (max-width: 992px) {
  .admin-pane .cols {
    grid-template-columns: 1fr !important;
    gap: 1.5rem;
  }
}

/* 2. Rendre les conteneurs de tableaux robustes au débordement */
.admin-pane div[style*="overflow-x:auto"] {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(34, 34, 61, 0.2);
  margin-bottom: 1.5rem;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.2);
}

.admin-pane table {
  border: none !important; /* On laisse le conteneur gérer la bordure */
  margin: 0;
  width: 100%;
}

/* 3. Gestion du texte tronqué / Masquage propre ou retour à la ligne */
.admin-pane td, 
.admin-pane th {
  white-space: normal; /* Autorise le retour à la ligne pour éviter de casser la table */
  word-break: break-word; /* Coupe les longs mots (comme des URLs ou clés sans espace) s'ils manquent de place */
  max-width: 220px; /* Limite la largeur maximale d'une cellule pour forcer le retour à la ligne */
  vertical-align: top;
}

/* Permet aux adresses MAC et URLs sous le nom de ne pas casser la mise en page */
.admin-pane td small {
  display: block;
  opacity: .5;
  font-family: monospace;
  word-break: break-all; /* Idéal pour couper proprement les adresses MAC ou les longues URLs */
  line-height: 1.2;
  margin-top: 0.2rem;
}

/* Pour la colonne "Actions" (Modifier / Supprimer), on force le non-cumul pour éviter les sauts de ligne laids */
.admin-pane td:last-child {
  white-space: nowrap;
  max-width: none;
}

/* 4. Optimisation des formulaires sur Mobile */
@media (max-width: 576px) {
  .admin-pane article {
    padding: 1rem;
  }
  .admin-pane article header {
    margin: -1rem -1rem 1rem -1rem;
    padding: .75rem 1rem;
  }
  /* Les cases à cocher des groupes s'empilent proprement sur mobile */
  .checks label {
    display: flex !important;
    width: 100%;
    margin-right: 0;
    margin-bottom: .6rem;
  }
}
