/*
 * Filet de sécurité pour les navigateurs Smart TV anciens.
 * Chargé avant la feuille principale : Tailwind garde donc la priorité quand
 * il est pris en charge, tandis que la connexion reste utilisable sinon.
 */
html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

.kgb-auth-page {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: #f7fbfe;
  color: #07121e;
  font-family: Arial, Helvetica, sans-serif;
}

.kgb-auth-shell {
  width: 100%;
  max-width: 448px;
  margin: 0 auto;
}

.kgb-auth-brand {
  margin-bottom: 32px;
  text-align: center;
}

.kgb-auth-logo {
  width: 220px;
  height: 96px;
  margin: 0 auto 16px;
}

.kgb-auth-card {
  overflow: hidden;
  border: 1px solid #e0e5ea;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(0, 40, 83, 0.16);
}

.kgb-auth-card input,
.kgb-auth-card button {
  min-height: 44px;
}

@media (min-width: 1200px) and (min-height: 650px) {
  .kgb-auth-shell {
    max-width: 520px;
  }

  .kgb-auth-logo {
    width: 270px;
    height: 118px;
  }

  .kgb-auth-card {
    font-size: 18px;
  }

  .kgb-auth-card input,
  .kgb-auth-card button {
    min-height: 52px;
    font-size: 18px;
  }
}

@media (min-width: 2400px) and (min-height: 1200px) {
  .kgb-auth-shell {
    max-width: 720px;
  }

  .kgb-auth-logo {
    width: 380px;
    height: 166px;
  }

  .kgb-auth-card {
    font-size: 24px;
  }

  .kgb-auth-card input,
  .kgb-auth-card button {
    min-height: 68px;
    font-size: 24px;
  }
}

/* --------------------------------------------------------------
   Règles sûres appliquées partout : elles n'altèrent pas le design
   moderne (Tailwind reste prioritaire) mais évitent qu'une image
   déborde de son conteneur sur les navigateurs anciens.
   -------------------------------------------------------------- */
img,
svg,
video,
canvas {
  max-width: 100%;
}

/* Les cartes Leaflet positionnent leurs calques en absolu : la contrainte
   ci-dessus réduirait leur largeur à zéro et rendrait le tracé invisible. */
.leaflet-container img,
.leaflet-container svg,
.leaflet-container canvas {
  max-width: none;
  max-height: none;
}

.kgb-auth-logo img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* --------------------------------------------------------------
   Mise en page de secours : activée UNIQUEMENT quand le navigateur
   n'applique pas la feuille principale (classe posée en JS après
   détection). Aucun impact sur PC, mobile, tablette ou TV modernes.
   -------------------------------------------------------------- */
html.kgb-css-fallback,
html.kgb-css-fallback body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: #f7fbfe;
  color: #07121e;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

html.kgb-css-fallback * {
  max-width: 100%;
}

/* Connexion : le logo garde son ratio et le formulaire reste centré. */
html.kgb-css-fallback .kgb-auth-page {
  display: block;
  padding: 4vh 4vw;
}

html.kgb-css-fallback .kgb-auth-shell {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

html.kgb-css-fallback .kgb-auth-logo {
  display: block;
  width: 220px;
  max-width: 60%;
  height: auto;
  margin: 0 auto 16px;
  overflow: hidden;
}

html.kgb-css-fallback .kgb-auth-logo img {
  height: auto;
}

html.kgb-css-fallback .kgb-auth-card {
  padding: 16px;
}

html.kgb-css-fallback .kgb-auth-card input,
html.kgb-css-fallback .kgb-auth-card select {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #c8d3de;
  border-radius: 8px;
  background: #ffffff;
  font-size: 16px;
}

html.kgb-css-fallback .kgb-auth-card button {
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: #0089ca;
  color: #ffffff;
  font-size: 16px;
}

html.kgb-css-fallback .kgb-password-field {
  position: relative;
}

html.kgb-css-fallback .kgb-password-toggle {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  color: #5b6a78;
}

/* Supervision : lisible sur grand écran, sans débordement horizontal. */
html.kgb-css-fallback .screen-board-root {
  width: 100%;
  padding: 2vh 2vw;
  background: #030c17;
  color: #ecf3f8;
}

html.kgb-css-fallback .screen-board-content {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
}

html.kgb-css-fallback .screen-surface {
  display: block;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: #071727;
}

html.kgb-css-fallback .screen-activity-map,
html.kgb-css-fallback .leaflet-container {
  width: 100%;
  min-height: 320px;
}

/* Très grands écrans en mode de secours : agrandissement proportionnel. */
@media (min-width: 2200px) {
  html.kgb-css-fallback,
  html.kgb-css-fallback body {
    font-size: 22px;
  }

  html.kgb-css-fallback .kgb-auth-shell {
    max-width: 720px;
  }
}
