/* ==========================================================================
   Ekinex Cloud Login — Premium Glassmorphism
   Override grafico di style.css. Caricato DOPO style.css → vince per ordine.
   Selettori scritti con stessa specificità dell'originale (body.theme-domoticalabs X)
   per evitare l'uso di !important.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Body: background image Ekinex a tutto schermo + flex center */
body.theme-domoticalabs {
  background: #0a0a0a url('../img/bg_ekinex.png') no-repeat center center;
  background-size: cover;
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #fff;
  overflow-x: hidden;
}

/* Overlay gradient per leggibilità (inserito in index.html come <div class="login-glow">) */
.login-glow {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(180deg,
    rgba(0,0,0,0.35) 0%,
    rgba(0,0,0,0.10) 40%,
    rgba(0,0,0,0.10) 60%,
    rgba(0,0,0,0.45) 100%);
  z-index: 0;
  pointer-events: none;
}

/* Container: da pannello absolute fullscreen a card centrata glassmorphism */
body.theme-domoticalabs .container {
  position: relative;
  top: auto; left: auto; right: auto; bottom: auto;
  width: 380px;
  max-width: 90vw;
  min-height: 0;
  margin: 0 auto;
  padding: 3rem 2.5rem;
  z-index: 2;
  background: rgba(0, 0, 0, 0.75);
  background-image: none;
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 18px;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.45),
    inset 0 0 0 1px rgba(255,255,255,0.05);
  color: #fff;
  animation: cardFadeIn 0.7s ease-out;
  box-sizing: border-box;
}

/* Wrapper esterno per centrare la card rispetto al viewport.
   min-height + padding = quando la card è più alta del viewport il body si estende e la pagina scrolla
   invece di tagliare la card fuori dallo schermo. */
body.theme-domoticalabs {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1rem;
  margin: 0;
  box-sizing: border-box;
}

/* Override gradient dei pattern (non li vogliamo sulla card) */
body.theme-domoticalabs .bg-pattern-1,
body.theme-domoticalabs .bg-pattern-2,
body.theme-domoticalabs .bg-pattern-3,
body.theme-domoticalabs .bg-pattern-4,
body.theme-domoticalabs .bg-pattern-5,
body.theme-domoticalabs .bg-pattern-6,
body.theme-domoticalabs .bg-pattern-red {
  background: rgba(0, 0, 0, 0.75);
}

/* Back-link in alto-sinistra della card, sulla stessa riga del logo.
   position:absolute → fuori dal flow normale, il logo nella header resta centrato.
   z-index 11 = sopra .header (style.css:114 imposta z-index:10) per evitare
   che metà del click area venga catturata dall'header. */
body.theme-domoticalabs .back-link {
  position: absolute;
  top: calc(3rem + 20px);
  left: 2.5rem;
  z-index: 11;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 0;
  border-radius: 50%;
  color: rgba(255,255,255,0.65);
  background: rgba(255,255,255,0.06);
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, transform 0.18s ease;
  text-decoration: none;
  flex-shrink: 0;
}
body.theme-domoticalabs .back-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.14);
  transform: translateX(-2px);
}
body.theme-domoticalabs .back-link .material-icons {
  font-size: 18px;
  line-height: 1;
  pointer-events: none;
}

/* Header: niente barra nera, solo logo centrato */
body.theme-domoticalabs .header,
body.theme-domoticalabs nav.header {
  position: relative;
  height: auto;
  background: transparent;
  border: none;
  border-bottom: none;
  padding: 0;
  margin-top: 20px;
  margin-bottom: 0.8rem;
  text-align: center;
}

body.theme-domoticalabs .header .title {
  position: static;
  left: auto; right: auto;
  line-height: normal;
  color: #fff;
}

body.theme-domoticalabs .header .title.logo {
  background: url('../img/ekinex-logo.svg') no-repeat center center;
  background-size: contain;
  width: 110px;
  height: 32px;
  margin: 0 auto;
  filter: brightness(0) invert(1);
  opacity: 0;
  animation: fadeIn 0.5s ease 0.3s forwards;
}

/* list-content: da absolute fullscreen a flow statico dentro la card */
body.theme-domoticalabs .list-content {
  position: static;
  top: auto; left: auto; right: auto; bottom: auto;
  overflow: visible;
  padding: 0;
}

body.theme-domoticalabs .list-content form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
}

/* Input field (.field-input è wrapper) */
body.theme-domoticalabs .field-input {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

body.theme-domoticalabs .field-input label {
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(255,255,255,0.75);
  margin: 0;
}
/* Capitalizzazione solo della prima lettera (normalize case dai template i18n "email"/"password" a "Email"/"Password") */
body.theme-domoticalabs .field-input label::first-letter {
  text-transform: uppercase;
}

body.theme-domoticalabs .field-input input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.88rem;
  line-height: 1.3;
  min-height: 0;
  margin: 0;
  color: #fff;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-sizing: border-box;
}

body.theme-domoticalabs .field-input input::placeholder { color: rgba(255,255,255,0.4); }
body.theme-domoticalabs .field-input input:focus {
  background: rgba(255,255,255,0.1);
  border-color: #009DE0;
  box-shadow: 0 0 0 2px rgba(0,157,224,0.15);
  outline: none;
}

/* Chrome autofill: evita il giallo di default mantenendo dark theme */
body.theme-domoticalabs .field-input input:-webkit-autofill,
body.theme-domoticalabs .field-input input:-webkit-autofill:hover,
body.theme-domoticalabs .field-input input:-webkit-autofill:focus {
  -webkit-box-shadow: inset 0 0 0 1000px rgba(255,255,255,0.08);
  -webkit-text-fill-color: #fff;
  caret-color: #fff;
  transition: background-color 9999s ease;
}

/* Bottoni CTA — display:block per evitare quirks di flex su <button>:
   con flex il box browser-default può collassare il padding e ridurre l'area
   davvero cliccabile. Block + text-align:center + padding alto = tutta l'area è hit-target. */
body.theme-domoticalabs .list-content button,
body.theme-domoticalabs .list-content input[type="submit"] {
  display: block;
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-align: center;
  border: none;
  cursor: pointer;
  margin: 0.4rem 0 0;
  appearance: none;
  -webkit-appearance: none;
  transition: transform 0.2s ease, box-shadow 0.25s ease;
  font-family: inherit;
  background: linear-gradient(135deg, #009DE0 0%, #0077B6 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(0,157,224,0.35);
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}

body.theme-domoticalabs .list-content button:hover,
body.theme-domoticalabs .list-content input[type="submit"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(0,157,224,0.5);
  color: #fff;
}

body.theme-domoticalabs .list-content button.yellow { /* override gialli template */
  background: linear-gradient(135deg, #009DE0 0%, #0077B6 100%);
  color: #fff;
}

/* Testi link secondari */
body.theme-domoticalabs .list-content p,
body.theme-domoticalabs .list-content label.checkbox-row {
  text-align: left;
  font-size: 0.82rem;
  font-weight: 400;
  color: rgba(255,255,255,0.88);
  margin: 0.2rem 0 0;
  transition: color 0.2s ease;
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}
body.theme-domoticalabs .list-content label.checkbox-row::first-letter {
  text-transform: none;
}
body.theme-domoticalabs .list-content p:hover { color: #009DE0; }

body.theme-domoticalabs a { color: #009DE0; }

/* Link colorati alla OAuth login */
body.theme-domoticalabs .list-content a { color: #009DE0; text-decoration: none; }
body.theme-domoticalabs .list-content a:hover { text-decoration: underline; }

/* Checkbox custom — root cause: style.css:883 impone width/height 22px,
   float:left, border #555, background trasparente. Sovrascrivo con appearance:none +
   pseudo-element check, mantenendo specificità equivalente. */
body.theme-domoticalabs form input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  border: 1.5px solid rgba(255,255,255,0.35);
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  cursor: pointer;
  position: relative;
  float: none;
  margin: 0;
  padding: 0;
  line-height: normal;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}
body.theme-domoticalabs form input[type="checkbox"]:hover {
  border-color: rgba(255,255,255,0.55);
}
body.theme-domoticalabs form input[type="checkbox"]:checked {
  background: #009DE0;
  border-color: #009DE0;
}
body.theme-domoticalabs form input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
body.theme-domoticalabs form input[type="checkbox"]:focus-visible {
  outline: 2px solid rgba(0,157,224,0.5);
  outline-offset: 2px;
}

/* Animazioni */
@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn { to { opacity: 1; } }

/* Responsive */
@media (max-width: 480px) {
  body.theme-domoticalabs .container {
    padding: 2.2rem 1.6rem;
    border-radius: 18px;
  }
  body.theme-domoticalabs .header .title.logo { width: 120px; height: 38px; }
}

/* Toast scuro premium */
body.theme-domoticalabs toastmessage {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  backdrop-filter: blur(12px);
}

/* Footer fisso in basso (replica TechAgent auth.css:304) */
body.theme-domoticalabs .login-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 14px 20px;
  text-align: center;
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 0.5px;
  line-height: 1.6;
  z-index: 1;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
  border: none;
  box-sizing: border-box;
  opacity: 0;
  animation: fadeIn 0.6s ease 1.6s forwards;
}

body.theme-domoticalabs .login-footer strong {
  color: #fff;
}

body.theme-domoticalabs .login-footer small {
  color: rgba(255, 255, 255, 0.6);
}
