:root { 
  --background-color: #3E4A5A;
  --card-color: #252D3A;
  --text-color: #F5F5F5;
  --muted-text: #B0BEC5;
  --accent-color: #FF8900;
  --input-border: #CCCCCC;
  --button-color: #37495F;
  --radius: 1em;
  --font-family: 'Segoe UI', Roboto, sans-serif;

  --totp-text-color: #ffffff; /* blanc par défaut (dark mode) */
}

/* Mode clair selon préférence système */
@media (prefers-color-scheme: light) {
  :root {
    --background-color: #FFFFFF;
    --card-color: #FFFFFF;
    --text-color: #1E1E1E;
    --muted-text: #555555;
    --accent-color: #FF8900;
    --input-border: #BBBBBB;
    --button-color: #E0E0E0;

    --totp-text-color: #000000; /* noir en mode clair */
  }

  #certificat_info,
  #certificat_renew {
    background-color: #FFFFFF !important;
    color: #1E1E1E !important;
  }

  .screen {
    background-color: #F4F4F4 !important;
    border: 1px solid #BBBBBB !important;
    color: #1E1E1E !important;
  }

  .key {
    background-color: #EAEAEA !important;
    color: #1E1E1E !important;
    border: 1px solid #BBBBBB !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1) !important;
  }

  .key:hover {
    background-color: var(--accent-color) !important;
    color: #fff !important;
  }
}

* {
  box-sizing: border-box;
  font-family: var(--font-family);
  margin: 0;
  padding: 0;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--background-color);
  display: block;
  overflow-x: hidden;
  overflow-y: auto; /* scroll vertical */
  transition: background-color 0.4s ease, color 0.4s ease;
  color: var(--text-color);
  min-height: 100vh;
}

/* Scrollbar discrète */
body::-webkit-scrollbar {
  width: 6px;
}
body::-webkit-scrollbar-track {
  background: transparent;
}
body::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
}
body::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.35);
}

/* --- Structure principale --- */
.site {
  position: relative;
  background-color: var(--card-color);
  border-radius: var(--radius);
  border: 2px solid var(--accent-color);
  width: 95%;
  max-width: 600px;
  padding: 2em 1.5em;
  margin: 1.5em auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1em;
  transition: background-color 0.4s ease, color 0.4s ease,
              box-shadow 0.4s ease, border 0.4s ease;
}

/* Titres */
.titre {
  font-size: 1.8em;
  font-weight: bold;
  color: var(--accent-color);
  text-align: center;
}
.sub_titre {
  font-size: 1.1em;
  color: var(--muted-text);
  text-align: center;
}

/* Contenu recentré */
.contenu {
  width: 100%;
  padding: 1em 0;
  display: flex;
  flex-direction: column;
  align-items: center; 
  justify-content: center;
  gap: 1em;
}

#loginform {
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8em;
  margin: 0 auto;
}

#loginform img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

/* Forcer l'affichage du bouton "Obtenir un nouveau code" même s'il est masqué */
#loginform input[type="button"][value="Obtenir un nouveau code"],
#loginform input[type="submit"][value="Obtenir un nouveau code"] {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  width: 100% !important;
  margin: 1em auto !important;
  padding: 0.8em;
  background-color: var(--accent-color) !important;
  color: #fff !important;
  font-weight: bold !important;
  border-radius: 0.5em !important;
  border: none !important;
  cursor: pointer !important;
}

/* Débloquer les boutons Corriger et Vérifier */
button,
input[type="button"][value="Corriger"],
input[type="submit"][value="Corriger"],
input[type="button"][value="Vérifier"],
input[type="submit"][value="Vérifier"] {
  background-color: var(--button-color) !important;
  color: var(--text-color) !important;
  border: 1px solid var(--input-border) !important;
  opacity: 1 !important;
  cursor: pointer !important;
  pointer-events: auto !important;
}

button:hover,
input[type="button"][value="Corriger"]:hover,
input[type="submit"][value="Corriger"]:hover,
input[type="button"][value="Vérifier"]:hover,
input[type="submit"][value="Vérifier"]:hover {
  background-color: var(--accent-color) !important;
  color: black !important;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.7em;
  background-color: transparent;
  border: 1px solid var(--input-border);
  border-radius: 0.4em;
  color: var(--text-color);
  text-align: center;
}
input::placeholder { color: var(--muted-text); }

.button,
input[type="submit"],
button {
  width: 100%;
  background-color: var(--button-color);
  border: none;
  padding: 0.8em;
  color: var(--text-color);
  font-weight: bold;
  border-radius: 0.4em;
  cursor: pointer;
  transition: background 0.2s ease-in-out;
}
.button:hover,
input[type="submit"]:hover,
button:hover {
  background-color: var(--accent-color);
  color: black;
}

/* Smartcard */
#smartcard {
  background-image: url('../images/smartcard.jpg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transform: scale(0.85);
  transform-origin: center;
  height: 300px;
  margin: 2em auto;
  border-radius: 0.5em;
  position: relative;
  width: 100%;
}
#smartcard span {
  position: absolute;
  bottom: 1em;
  left: 1.2em;
  color: white;
  font-size: 1.3em;
  font-weight: bold;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

/* Menu */
.menu {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
  justify-content: center;
  margin-top: 1em;
}
.menu_item, .menu_item_g {
  width: 8em;
  height: 8em;
  background-color: var(--card-color);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 60%;
  border-radius: 0.6em;
  box-shadow: 0 0 6px rgba(0,0,0,0.2);
  transition: transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.menu_item:hover, .menu_item_g:hover {
  transform: scale(1.05);
  border: 2px solid var(--accent-color);
}
.menu_item a, .menu_item_g a {
  position: absolute;
  inset: 0;
  text-indent: -9999px;
}

/* Messages & liens */
#login_message,
#login_retry,
.info,
.lost_password {
  text-align: center;
  color: var(--text-color);
}

.lost_password {
  order: 3;
  margin-top: 0.4em;
  text-align: center;
  width: 100%;
}

.lost_password a {
  color: var(--muted-text);
  font-size: 0.9em;
  text-decoration: underline;
}

.info.msg {
  color: #FF6666;
  font-style: italic;
  padding-top: 4px;
}

/* Images simples */
.img_simple {
  margin: 1em auto;
  min-height: 140px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 200px;
}
.img_simple img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5em;
}
.img_simple.newcert,
.img_simple.otp,
.img_simple.error,
.img_simple.maintenance,
.img_simple.ok {
  width: 128px;
  height: 128px;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: contain;
  margin: 1em auto;
  border-radius: 0.5em;
}

.img_simple.newcert { background-image: url("../images/authentification.gif"); }
.img_simple.otp { background-image: url("../images/otp.gif"); }
.img_simple.error { background-image: url("../images/erreur.gif"); }
.img_simple.maintenance { background-image: url("../images/maintenance.gif"); }
.img_simple.ok { background-image: url("../images/ok.gif"); }
.img_simple.disconnect,
.img_simple.connect {
  height: 140px;
  width: auto;
}

/* Footer */
.footer {
  font-size: 0.85em;
  color: var(--muted-text);
  text-align: center;
  padding-top: 1em;
}
.copyright {
  font-size: 0.75em;
  color: var(--muted-text);
  text-align: center;
  padding-top: 1em;
  border-top: 1px solid #2E3744;
  margin-top: 2em;
}

/* Clavier PIN */
.keyboard {
  background-color: var(--card-color);
  border: 1px solid var(--input-border);
  padding: 1em;
  margin: 2em auto;
  border-radius: 1em;
  max-width: 260px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: var(--shadow);
}
.screen {
  background-color: #1F2731;
  border: 1px solid #666;
  width: 100%;
  height: 3em;
  border-radius: 0.5em;
  margin-bottom: 1em;
  display: flex;
  align-items: center;
  justify-content: center;
}
#codepin {
  width: 90%;
  background-color: transparent;
  border: none;
  color: var(--accent-color);
  font-size: 1.5em;
  text-align: center;
  letter-spacing: 0.4em;
}
.pave {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}
.line {
  display: flex;
  justify-content: center;
  gap: 0.5em;
}
.key {
  background-color: #1E2633;
  color: var(--text-color);
  border: 1px solid #555;
  border-radius: 0.5em;
  width: 3em;
  height: 3em;
  text-align: center;
  font-size: 1.2em;
  line-height: 3em;
  font-weight: bold;
  cursor: pointer;
}
.key:hover {
  background-color: var(--accent-color);
  color: black;
}

/* Popup OTP */
#otp_choice {
  background-color: var(--card-color);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  width: 320px;
  margin: 1em auto;
  border-radius: 0.8em;
  padding: 1em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1em;
  border: 1px solid var(--input-border);

  text-align: center;
}

#otp_choice img {
  display: inline-block;
  vertical-align: middle;
  background-color: transparent;
  padding: 8px;
  cursor: pointer;
  border-radius: 0.5em;
  width: 50px;
  height: 50px;
  object-fit: contain;
  transition: background 0.3s, transform 0.3s, border-color 0.3s;
  margin: 0 8px;
  border: 2px solid #EC7900; /* bordure orange visible */
}

#otp_choice img:hover {
  background-color: rgba(236, 121, 0, 0.3); /* orange très clair */
  border-color: #FFAD42; /* orange plus clair au hover */
  transform: scale(1.05); /* légère augmentation */
}

/* Champs de texte en lecture seule ou désactivés grisées */
input[type="text"][readonly],
input[type="text"][disabled],
input[type="password"][readonly],
input[type="password"][disabled],
textarea[readonly],
textarea[disabled],
select[disabled] {
  background-color: #55595f !important;  /* gris foncé */
  color: #a0a5aa !important;             /* texte gris clair */
  border-color: #444c56 !important;
  cursor: not-allowed;
  pointer-events: none; /* bloque interaction */
  user-select: none;    /* empêche sélection */
}

/* Totp progress bar intégrée */
#totp_progress {
  background-color: transparent !important; /* Fond transparent */
  border-radius: 0.4em;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  width: 180px;
  height: 24px;
  margin-top: 0.5em;
  z-index: 10;
  flex-shrink: 0;
}

#totp_bar {
  background-color: rgba(50, 205, 50, 0.6) !important; /* Vert clair semi-transparent */
  opacity: 0.8;
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  transition: width 0.4s linear;
}

#totp_sec {
  position: relative;
  z-index: 20;
  width: 100%;
  text-align: center;
  color: var(--totp-text-color);
  font-weight: bold;
  line-height: 24px;
  user-select: none;
}

/* Responsive */
@media (max-width: 768px) {
  .site { max-width: 90%; padding: 1.5em 1em; }
  .menu_item, .menu_item_g { width: 7em; height: 7em; }
  .key { width: 2.7em; height: 2.7em; font-size: 1.1em; line-height: 2.7em; }
  .img_simple.newcert,
  .img_simple.otp,
  .img_simple.error,
  .img_simple.maintenance,
  .img_simple.ok { width: 112px; height: 112px; }
}
@media (max-width: 480px) {
  .site { padding: 1em 0.8em; max-width: 100%; margin: 0.5em; }
  .titre { font-size: 1.4em; }
  .sub_titre { font-size: 0.95em; }
  .menu_item, .menu_item_g { width: 6em; height: 6em; }
  .key { width: 2.4em; height: 2.4em; font-size: 1em; line-height: 2.4em; }
  .img_simple.newcert,
  .img_simple.otp,
  .img_simple.error,
  .img_simple.maintenance,
  .img_simple.ok { width: 96px; height: 96px; }
}

/* Images menu */
.menu_item.m1 { background-image: url('../images/tiers.gif'); }
.menu_item.m2 { background-image: url('../images/cps.gif'); }
.menu_item.m3 { background-image: url('../images/cp.gif'); }
.menu_item.m4 { background-image: url('../images/nominatif.gif'); }
.menu_item.m5 { background-image: url('../images/collectif.gif'); }
.menu_item.m6 { background-image: url('../images/automate.gif'); }
.menu_item.m7 { background-image: url('../images/anonymous.gif'); }
.menu_item.m8 { background-image: url('../images/contrappel.gif'); }
.menu_item.m9 { background-image: url('../images/simple.gif'); }

.erreur {
  padding: 2em 0 2em;
  text-align: center;
  color: #ff0000;
}

/* Clavier PIN */
.keyboard {
  background-color: var(--card-color);
  border: 1px solid var(--input-border);
  padding: 1em;
  margin: 2em auto;
  border-radius: 1em;
  max-width: 260px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: var(--shadow);
}
.screen {
  background-color: #1F2731;
  border: 1px solid #666;
  width: 100%;
  height: 3em;
  border-radius: 0.5em;
  margin-bottom: 1em;
  display: flex;
  align-items: center;
  justify-content: center;
}
#codepin {
  width: 90%;
  background-color: transparent;
  border: none;
  color: var(--accent-color);
  font-size: 1.5em;
  text-align: center;
  letter-spacing: 0.4em;
}
.pave {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}
.line {
  display: flex;
  justify-content: center;
  gap: 0.5em;
}
.key {
  background-color: #1E2633;
  color: var(--text-color);
  border: 1px solid #555;
  border-radius: 0.5em;
  width: 3em;
  height: 3em;
  text-align: center;
  font-size: 1.2em;
  line-height: 3em;
  font-weight: bold;
  cursor: pointer;
}
.key:hover {
  background-color: var(--accent-color);
  color: black;
}

/* Popup OTP */
#otp_choice {
  background-color: var(--card-color);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  width: 320px;
  margin: 1em auto;
  border-radius: 0.8em;
  padding: 1em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1em;
  border: 1px solid var(--input-border);

  text-align: center;
}

#otp_choice img {
  display: inline-block;
  vertical-align: middle;
  background-color: transparent;
  padding: 8px;
  cursor: pointer;
  border-radius: 0.5em;
  width: 50px;
  height: 50px;
  object-fit: contain;
  transition: background 0.3s, transform 0.3s, border-color 0.3s;
  margin: 0 8px;
  border: 2px solid #EC7900; /* bordure orange visible */
}

#otp_choice img:hover {
  background-color: rgba(236, 121, 0, 0.3); /* orange très clair */
  border-color: #FFAD42; /* orange plus clair au hover */
  transform: scale(1.05); /* légère augmentation */
}

/* Champs de texte en lecture seule ou désactivés grisées */
input[type="text"][readonly],
input[type="text"][disabled],
input[type="password"][readonly],
input[type="password"][disabled],
textarea[readonly],
textarea[disabled],
select[disabled] {
  background-color: #55595f !important;  /* gris foncé */
  color: #a0a5aa !important;             /* texte gris clair */
  border-color: #444c56 !important;
  cursor: not-allowed;
  pointer-events: none; /* bloque interaction */
  user-select: none;    /* empêche sélection */
}


