/*
 * Alfa Dashboard Installer — tema coerente con pro-theme(5).css
 * Personalizzazione esclusivamente estetica: classi e stati funzionali invariati.
 */
:root {
  color-scheme: dark;
  --afd-bg: #050505;
  --afd-panel: rgba(14,14,18,.78);
  --afd-panel-strong: rgba(20,20,26,.92);
  --afd-border: rgba(230,145,56,.22);
  --afd-border-soft: rgba(255,255,255,.08);
  --afd-text: #f7f7f5;
  --afd-muted: #c9c9c3;
  --afd-soft: #8f8f88;
  --afd-accent: #e69138;
  --afd-accent-2: #ffb15c;
  --afd-blue: #3d85c6;

  /* Alias per i componenti della web app. */
  --bg: var(--afd-bg);
  --panel: var(--afd-panel-strong);
  --card: rgba(255,255,255,.045);
  --border: var(--afd-border-soft);
  --text: var(--afd-text);
  --muted: var(--afd-muted);
  --orange: var(--afd-accent);
  --orange-soft: var(--afd-accent-2);
  --yellow: #ffd2a2;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--afd-bg); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
  color: var(--afd-text);
  background-color: #050505;
  /* Stesso sfondo/griglia/telemetria usato nel pro-theme del sito. */
  background-image:
    linear-gradient(90deg, transparent 0%, rgba(230,145,56,0) 30%, rgba(230,145,56,.70) 50%, rgba(230,145,56,0) 70%, transparent 100%),
    linear-gradient(90deg, transparent 0%, rgba(61,133,198,0) 30%, rgba(61,133,198,.52) 50%, rgba(61,133,198,0) 70%, transparent 100%),
    linear-gradient(rgba(255,255,255,.065) 1px, transparent 1px),
    linear-gradient(90deg,rgba(255,255,255,.065) 1px, transparent 1px),
    linear-gradient(rgba(230,145,56,.045) 1px, transparent 1px),
    linear-gradient(90deg,rgba(230,145,56,.045) 1px, transparent 1px),
    radial-gradient(circle at 18% 8%, rgba(230,145,56,.22), transparent 30rem),
    radial-gradient(circle at 82% 18%, rgba(61,133,198,.18), transparent 28rem),
    linear-gradient(135deg,#050505 0%,#0b0b0d 45%,#11100e 100%);
  background-size:
    38vw 2px, 32vw 1px,
    46px 46px, 46px 46px, 184px 184px, 184px 184px,
    100% 100%, 100% 100%, 100% 100%;
  background-repeat:
    no-repeat, no-repeat, repeat, repeat, repeat, repeat,
    no-repeat, no-repeat, no-repeat;
  background-position:
    -45vw 34%, 105vw 67%, 0 0, 0 0, 0 0, 0 0,
    center, center, center;
  animation: afd-background-flow 9s linear infinite, afd-bg-pulse 8s ease-in-out infinite;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body::before, body::after { content: none !important; display: none !important; }
[hidden] { display: none !important; }
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; }

@keyframes afd-background-flow {
  0% {
    background-position:
      -45vw 34%, 105vw 67%, 0 0, 0 0, 0 0, 0 0,
      center, center, center;
  }
  100% {
    background-position:
      105vw 34%, -45vw 67%, 46px 46px, 46px 46px,
      -92px 92px, -92px 92px, center, center, center;
  }
}
@keyframes afd-bg-pulse {
  0%, 100% { filter: saturate(1); }
  50% { filter: saturate(1.25); }
}

/* Struttura: dimensioni e comportamento originali mantenuti. */
.app-wrap {
  position: relative;
  z-index: 1;
  max-width: 490px;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 30px) 18px max(env(safe-area-inset-bottom), 24px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 1px 23px;
  border-bottom: 1px solid var(--afd-border);
  margin-bottom: 20px;
}
.brand-icon {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: 0 8px 18px rgba(0,0,0,.32);
}
.brand-title { min-width: 0; flex: 1; }
.brand-title h1 {
  font-size: 18px;
  letter-spacing: .035em;
  margin: 0;
  font-weight: 850;
  color: #fff;
  line-height: 1.18;
}
.brand-title p {
  margin: 5px 0 0;
  color: var(--afd-accent-2);
  letter-spacing: .12em;
  font-weight: 700;
  font-size: 10px;
}
.brand-usb { width: 20px; height: 20px; color: var(--afd-accent-2); }
.brand-usb svg { width: 100%; height: 100%; }

.panel {
  background: linear-gradient(180deg, rgba(22,22,28,.86), rgba(10,10,13,.76));
  border: 1px solid var(--afd-border-soft);
  border-radius: 22px;
  padding: 20px 19px;
  margin-bottom: 19px;
  box-shadow: 0 24px 70px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.05);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.panel-heading, .section-head { display: flex; align-items: center; gap: 10px; }
.panel-heading h2, .section-head h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
  font-weight: 750;
  color: #fff;
}
.section-head { justify-content: space-between; }
.heading-icon { width: 23px; height: 23px; flex-shrink: 0; color: var(--afd-accent); }
.support-text {
  font-size: 13px;
  color: var(--afd-muted);
  line-height: 1.6;
  margin: 12px 0 18px;
}
.subtle-note, .helper-text { font-size: 12px; line-height: 1.55; color: var(--afd-muted); margin: 12px 0; }

/* Login e campi: stessa tonalità arancione delle interazioni del sito. */
.auth-form { display: grid; gap: 8px; }
.auth-form label { font-size: 12px; color: var(--afd-muted); font-weight: 650; }
.auth-form input {
  min-height: 44px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(10,10,13,.84);
  color: #fff;
  border-radius: 14px;
  padding: 0 12px;
  margin-bottom: 5px;
  outline: none;
  width: 100%;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.auth-form input:focus {
  border-color: var(--afd-accent);
  box-shadow: 0 0 0 3px rgba(230,145,56,.20);
}
.auth-form input::placeholder { color: var(--afd-soft); }
.main-button {
  min-height: 45px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--afd-accent), #c9711e);
  color: #111;
  font-weight: 800;
  letter-spacing: .02em;
  padding: 10px 16px;
  box-shadow: 0 14px 36px rgba(230,145,56,.25);
  transition: transform .18s ease, filter .18s ease, box-shadow .18s ease;
}
.main-button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: 0 18px 48px rgba(230,145,56,.34);
}
.main-button:active:not(:disabled) { transform: translateY(1px); }
.main-button:disabled { opacity: .65; }
.main-button:focus-visible, .text-button:focus-visible {
  outline: 3px solid rgba(230,145,56,.55);
  outline-offset: 2px;
}

/* Gli stati funzionali (autorizzato / errore) mantengono colori leggibili. */
.signed-in {
  padding: 11px 12px;
  background: rgba(255,255,255,.045);
  border: 1px solid var(--afd-border);
  border-radius: 14px;
}
.signed-in-top { display: flex; align-items: center; gap: 8px; color: #b6edd1; font-size: 12px; font-weight: 750; }
.green-dot { width: 8px; height: 8px; background: #52d4a1; border-radius: 50%; display: inline-block; }
.signed-email { font-size: 12px; color: var(--afd-muted); overflow-wrap: anywhere; margin: 8px 0; }
.text-button {
  background: none;
  color: var(--afd-accent-2);
  border: 0;
  padding: 4px 0;
  font-size: 12px;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.error-message {
  background: rgba(104,35,44,.32);
  border: 1px solid rgba(183,82,101,.70);
  border-radius: 12px;
  color: #ffd2db;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  margin: 12px 0 0;
}

/* Selezione firmware V1/V2: stessa estetica delle card del sito. */

.firmware-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 16px; margin: 15px 0; }
.firmware-group {
  border-radius: 20px;
  border: 1px solid var(--afd-border-soft);
  background: rgba(255,255,255,.035);
  padding: 14px 12px 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.firmware-group-head { text-align: center; margin-bottom: 10px; }
.firmware-group-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
  font-weight: 800;
  color: #fff;
  letter-spacing: .04em;
}
.firmware-group-sub {
  margin: 5px 0 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--afd-muted);
}
.firmware-group-image {
  display: block;
  width: min(100%, 180px);
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  margin: 0 auto 12px;
  padding: 8px;
  border-radius: 16px;
  background: rgba(255,255,255,.0);
  border: 1px solid rgba(230,145,56,.0);
  box-shadow: 0 10px 24px rgba(0,0,0,.0);
}
.firmware-group-actions { display: grid; grid-template-columns: minmax(0,1fr); gap: 10px; }

.firmware-panel { padding-bottom: 17px; }
.connect-panel { margin: 16px 0 14px; }
.connect-hint { color: var(--afd-muted); font-size: 12px; line-height: 1.5; }
.connect-panel .main-button { width: 100%; margin: 2px 0 4px; }
.authorized {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  color: #b6edd1;
  border: 1px solid rgba(82,212,161,.30);
  background: rgba(30,92,72,.24);
  margin: 13px 0;
}
.authorized span { font-weight: 900; margin-right: 6px; }

.fw-card {
  border-radius: 18px;
  border: 1px solid var(--afd-border-soft);
  background: rgba(255,255,255,.045);
  overflow: hidden;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}


.fw-card.selected {
  border-color: rgba(230,145,56,.65);
  background: linear-gradient(180deg, rgba(230,145,56,.13), rgba(255,255,255,.045));
  box-shadow: 0 0 0 2px rgba(230,145,56,.16);
  grid-column: auto;
}
.fw-choice {
  background: transparent;
  border: 0;
  width: 100%;
  min-height: 70px;
  color: var(--afd-text);
  padding: 12px 7px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 7px;
}
.fw-choice:not(:disabled) { cursor: pointer; }
.fw-choice:disabled { opacity: .6; }
.fw-choice:focus-visible { outline: 2px solid var(--afd-accent); outline-offset: -3px; }
.fw-label { font-weight: 750; font-size: 13px; line-height: 1.2; }
.fw-sub { font-size: 10px; color: var(--afd-muted); line-height: 1.3; }
.fw-card[data-key$='beta'] .fw-label { color: #ffd2a2; }
.fw-card.unavailable { opacity: .7; }
.fw-card.unavailable .fw-choice:disabled { cursor: not-allowed; }
.fw-installer {
  border-top: 1px solid var(--afd-border-soft);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 57px;
  padding: 10px 4px;
}
.fw-installer esp-web-install-button { max-width: 100%; }
.fw-card.selected .fw-choice { min-height: 64px; }
.fw-action-panel {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--afd-border);
  background: linear-gradient(180deg, rgba(230,145,56,.055), rgba(5,5,5,.30));
}
.fw-action-panel .fw-verify-btn, .fw-action-panel .fw-flash-btn {
  width: 100%; min-height: 46px; font-size: 13px; letter-spacing: .025em;
}
.fw-action-panel .fw-installer { border: 0; min-height: 0; padding: 0; display: block; }
.fw-action-panel esp-web-install-button { display: block; width: 100%; max-width: 100%; }
/* Il canale beta resta distinguibile senza introdurre pulsanti giallo acceso. */
.fw-card[data-key$='beta'] .fw-action-panel .fw-flash-btn {
  background: linear-gradient(135deg, var(--afd-accent), #c9711e);
  border-color: rgba(255,255,255,.12);
  color: #111;
}
.fw-card-message { margin: 8px 0 0; color: #ffd2a2; font-size: 11px; line-height: 1.5; }
.fw-action-panel .main-button:disabled { opacity: .60; }

/* Pulsante esposto dal web component, quando la sua parte è personalizzabile. */
esp-web-install-button::part(button) {
  border-radius: 999px;
  background: linear-gradient(135deg, var(--afd-accent), #c9711e);
  color: #111;
  font-weight: 800;
  border: 1px solid rgba(255,255,255,.12);
}
.small-note { font-size: 11px; line-height: 1.55; color: var(--afd-soft); margin: 11px 0 0; }
.footer-note { text-align: center; font-size: 10px; color: var(--afd-soft); margin: 16px 0; }

@media (max-width: 360px) {
  .app-wrap { padding-left: 12px; padding-right: 12px; }
  .panel { padding: 16px 14px; }
  .fw-label { font-size: 12px; }
  .brand-title h1 { font-size: 16px; }
}
@media (min-width: 780px) {
  .app-wrap { padding-top: 48px; padding-bottom: 45px; }
}
@media (max-width: 767px) {
  body { background-attachment: fixed; }
}
@media (prefers-reduced-motion: reduce) {
  body { animation: none; }
  * { transition: none !important; }
}

/* Selettore bilingue IT/EN: solo estetica, nessuna interazione USB. */
.lang-switch { display: inline-flex; flex-shrink: 0; gap: 3px; padding: 3px; border-radius: 999px;
  border: 1px solid rgba(230,145,56,.30); background: rgba(0,0,0,.32); }
.lang-option { padding: 6px 8px; min-height: 30px; min-width: 33px; border: 0; border-radius: 999px;
  background: transparent; color: #c9c9c3; font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.lang-option[aria-pressed="true"] { background: #e69138; color: #111; }
.lang-option:focus-visible { outline: 2px solid #ffb15c; outline-offset: 2px; }
@media (max-width: 360px) { .brand {gap: 7px;} .brand-usb {display:none;} .lang-option {padding:5px 6px; min-width:29px;} }
