/* ==========================================================
   ScanMAP Preferences UI V2
   Solo grafica: non modifica logica IDIM
   ========================================================== */

body[data-page="preferences"]{
  min-height:100vh;
  margin:0;
  background:
    radial-gradient(circle at 12% 4%, rgba(52,181,229,.18), transparent 34%),
    linear-gradient(180deg, #061c31 0%, #09223b 220px, #eef6fb 221px, #f5f9fc 100%) !important;
  color:#153047;
  font-family:Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* TOPBAR */
body[data-page="preferences"] .scanmap-topbar{
  position:sticky;
  top:0;
  z-index:3000;
  height:74px;
  min-height:74px;
  padding:8px 14px;
  box-sizing:border-box;
  background:
    radial-gradient(circle at 0% 0%, rgba(33,150,243,.18), transparent 34%),
    linear-gradient(180deg, rgba(3,22,40,.98), rgba(2,14,28,.98));
  border-bottom:1px solid rgba(255,255,255,.10);
  box-shadow:0 8px 24px rgba(0,0,0,.26);
  display:flex;
  align-items:center;
  justify-content:space-between;
}

body[data-page="preferences"] .scanmap-topbar-left,
body[data-page="preferences"] .scanmap-topbar-left a{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
  color:inherit;
  text-decoration:none;
}

body[data-page="preferences"] .scanmap-logo-shell{
  width:50px;
  height:50px;
  min-width:50px;
  border-radius:50%;
  overflow:hidden;
  box-shadow:0 0 0 1px rgba(255,255,255,.14), 0 6px 16px rgba(0,0,0,.25);
  background:transparent;
}

body[data-page="preferences"] .scanmap-logo-shell img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

body[data-page="preferences"] .scanmap-brand strong{
  display:block;
  color:#fff;
  font-size:19px;
  font-weight:850;
  line-height:1.05;
  letter-spacing:-.03em;
}

body[data-page="preferences"] .scanmap-brand span,
body[data-page="preferences"] #pageTitleSubShell{
  display:block;
  color:rgba(255,255,255,.76);
  font-size:13px;
  line-height:1.15;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:48vw;
}

body[data-page="preferences"] .scanmap-topbar-right{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
}

body[data-page="preferences"] .scanmap-icon-btn{
  min-height:44px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:0 14px;
  border-radius:999px;
  background:rgba(255,255,255,.08);
  border:1px solid rgba(255,255,255,.16);
  color:#fff;
  text-decoration:none;
  font-weight:750;
  box-shadow:0 8px 18px rgba(0,0,0,.22);
}

body[data-page="preferences"] .lang-switcher{
  position:relative;
}

body[data-page="preferences"] #currentFlag{
  width:28px;
  height:20px;
  object-fit:cover;
  border-radius:4px;
}

body[data-page="preferences"] #currentLangLabel{
  color:#fff;
  font-size:15px;
  font-weight:850;
}

body[data-page="preferences"] .lang-switcher__menu{
  display:none;
  position:fixed;
  top:72px;
  right:12px;
  width:210px;
  max-height:55vh;
  overflow-y:auto;
  padding:8px;
  border-radius:18px;
  background:rgba(5,22,38,.98);
  border:1px solid rgba(90,180,255,.22);
  box-shadow:0 18px 38px rgba(0,0,0,.38);
  z-index:99999;
}

body[data-page="preferences"] .lang-switcher__menu.is-open{
  display:flex;
  flex-direction:column;
}

body[data-page="preferences"] .lang-option{
  width:100%;
  display:flex;
  align-items:center;
  border:none;
  border-radius:12px;
  background:transparent;
  color:#fff;
  padding:9px 10px;
  cursor:pointer;
  text-align:left;
}

body[data-page="preferences"] .lang-option:hover,
body[data-page="preferences"] .lang-option.is-active{
  background:rgba(255,255,255,.08);
}

/* MAIN */
body[data-page="preferences"] .idim-page{
  padding:0;
}

body[data-page="preferences"] .container.preferences-shell{
  width:min(1120px, calc(100% - 28px));
  margin:0 auto;
  padding:28px 0 120px;
}

/* HERO */
body[data-page="preferences"] .preferences-header{
  position:relative;
  margin:0 0 22px;
  padding:26px 26px 28px;
  border-radius:30px;
  overflow:hidden;
  color:#fff;
  background:
    radial-gradient(circle at top right, rgba(52,181,229,.30), transparent 38%),
    linear-gradient(135deg, rgba(5,28,51,.96), rgba(6,61,98,.94));
  border:1px solid rgba(255,255,255,.13);
  box-shadow:0 22px 48px rgba(0,0,0,.22);
}

body[data-page="preferences"] .preferences-header::after{
  content:"";
  position:absolute;
  right:-60px;
  bottom:-80px;
  width:260px;
  height:260px;
  border-radius:999px;
  background:rgba(255,255,255,.055);
}

body[data-page="preferences"] .preferences-header .eyebrow{
  position:relative;
  z-index:1;
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-height:30px;
  padding:0 12px;
  border-radius:999px;
  background:rgba(255,255,255,.10);
  border:1px solid rgba(255,255,255,.14);
  color:#bdeaff;
  font-size:13px;
  font-weight:850;
  letter-spacing:.08em;
  text-transform:uppercase;
  margin-bottom:14px;
}

body[data-page="preferences"] .preferences-header h1{
  position:relative;
  z-index:1;
  max-width:780px;
  margin:0 0 10px;
  color:#fff;
  font-family:Montserrat, Inter, sans-serif;
  font-size:clamp(2rem, 5vw, 3.3rem);
  line-height:1.02;
  letter-spacing:-.05em;
}

body[data-page="preferences"] .preferences-header p{
  position:relative;
  z-index:1;
  max-width:760px;
  margin:0;
  color:rgba(255,255,255,.78);
  font-size:1.05rem;
  line-height:1.55;
}

/* FORM CARD */
body[data-page="preferences"] .preferences-form-card{
  border-radius:30px;
  padding:24px;
  background:rgba(255,255,255,.90);
  border:1px solid rgba(13,94,175,.12);
  box-shadow:0 24px 54px rgba(16,59,102,.13);
  backdrop-filter:blur(14px);
  -webkit-backdrop-filter:blur(14px);
}

body[data-page="preferences"] .preferences-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:16px;
}

body[data-page="preferences"] .field-card{
  padding:18px;
  border-radius:24px;
  background:linear-gradient(180deg, #fff, #f8fbff);
  border:1px solid rgba(13,94,175,.10);
  box-shadow:0 10px 24px rgba(16,59,102,.06);
}

body[data-page="preferences"] .field-card--full{
  grid-column:1 / -1;
}

body[data-page="preferences"] .field-card label,
body[data-page="preferences"] .chip-label{
  color:#112f49;
  font-size:1rem;
  font-weight:850;
}

body[data-page="preferences"] .field-caption{
  color:#647d93;
  font-size:.93rem;
}

/* SCELTE */
body[data-page="preferences"] .choice-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:10px;
  margin-top:8px;
}

body[data-page="preferences"] .choice-card span,
body[data-page="preferences"] .chip span{
  min-height:48px;
  border-radius:18px;
  background:#fff;
  border:1px solid rgba(13,94,175,.14);
  color:#17324d;
  font-weight:800;
  box-shadow:0 6px 14px rgba(16,59,102,.045);
}

body[data-page="preferences"] .choice-card input:checked + span,
body[data-page="preferences"] .chip input:checked + span{
  background:linear-gradient(135deg, rgba(13,94,175,.13), rgba(52,181,229,.14));
  border-color:rgba(13,94,175,.36);
  color:#0d5eaf;
  box-shadow:0 10px 22px rgba(13,94,175,.10);
}

body[data-page="preferences"] .chip-grid{
  gap:10px;
  margin-top:10px;
}

body[data-page="preferences"] .idim-form input,
body[data-page="preferences"] .idim-form textarea,
body[data-page="preferences"] .idim-form select{
  border-radius:18px;
  border:1px solid rgba(13,94,175,.14);
  background:#fff;
  color:#17324d;
  font-weight:600;
}

/* POSIZIONE */
body[data-page="preferences"] #detectLocationButton{
  min-height:52px;
  border-radius:18px;
  border:1px solid rgba(13,94,175,.16);
  background:#fff;
  color:#0d5eaf;
  font-weight:850;
  box-shadow:0 8px 18px rgba(16,59,102,.08);
}

/* SUMMARY */
body[data-page="preferences"] .preferences-summary{
  margin-top:20px;
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:12px;
}

body[data-page="preferences"] .summary-pill{
  min-width:0;
  border-radius:20px;
  padding:14px;
  background:linear-gradient(180deg, #f7fbff, #eef7ff);
  border:1px solid rgba(13,94,175,.10);
}

body[data-page="preferences"] .summary-pill-label{
  color:#6c8195;
  font-size:.78rem;
  font-weight:750;
  text-transform:uppercase;
  letter-spacing:.04em;
}

body[data-page="preferences"] .summary-pill-value{
  color:#17324d;
  font-size:.96rem;
  font-weight:850;
}

/* FOOTER */
body[data-page="preferences"] .form-footer{
  margin-top:22px;
  padding-top:18px;
  border-top:1px solid rgba(13,94,175,.08);
}

body[data-page="preferences"] .form-footer-note{
  color:#60788e;
}

body[data-page="preferences"] #submitPreferences{
  min-height:58px;
  min-width:260px;
  border-radius:999px;
  background:linear-gradient(135deg, #ff5a36, #d92323);
  color:#fff;
  border:none;
  font-weight:900;
  font-size:1rem;
  box-shadow:0 18px 30px rgba(217,35,35,.26);
}

/* STATUS */
body[data-page="preferences"] .status-box{
  border-radius:18px;
  font-weight:700;
}

/* BOTTOM NAV */
body[data-page="preferences"] .scanmap-bottom-nav{
  position:fixed;
  left:0;
  right:0;
  bottom:0;
  height:82px;
  z-index:2800;
  background:
    radial-gradient(circle at top left, rgba(52,181,229,.18), transparent 38%),
    linear-gradient(180deg, rgba(7,38,70,.98), rgba(3,20,38,.98));
  border-top:1px solid rgba(255,255,255,.12);
  box-shadow:0 -10px 28px rgba(0,0,0,.28);
}

body[data-page="preferences"] .scanmap-bottom-nav__track{
  height:100%;
  display:flex;
  align-items:center;
  justify-content:space-around;
  gap:0;
  padding:7px 8px 8px;
  box-sizing:border-box;
}

body[data-page="preferences"] .scanmap-bottom-link{
  flex:1 1 0;
  min-width:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:5px;
  color:rgba(255,255,255,.94);
  text-decoration:none;
  font-size:11px;
  font-weight:700;
}

body[data-page="preferences"] .scanmap-bottom-link img{
  width:26px;
  height:26px;
  object-fit:contain;
  filter:grayscale(1) brightness(2.4) contrast(.9);
  opacity:.95;
}

/* RESPONSIVE */
@media(max-width:840px){
  body[data-page="preferences"] .container.preferences-shell{
    width:min(100% - 20px, 720px);
    padding-top:16px;
  }

  body[data-page="preferences"] .preferences-header{
    padding:22px 18px 24px;
    border-radius:26px;
  }

  body[data-page="preferences"] .preferences-form-card{
    padding:14px;
    border-radius:26px;
  }

  body[data-page="preferences"] .preferences-grid{
    grid-template-columns:1fr;
  }

  body[data-page="preferences"] .preferences-summary{
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }
}

@media(max-width:560px){
  body[data-page="preferences"] .scanmap-topbar{
    height:74px;
    min-height:74px;
    padding:8px 10px;
  }

  body[data-page="preferences"] .scanmap-logo-shell{
    width:46px;
    height:46px;
    min-width:46px;
  }

  body[data-page="preferences"] .scanmap-brand strong{
    font-size:18px;
  }

  body[data-page="preferences"] .scanmap-brand span{
    font-size:12px;
    max-width:42vw;
  }

  body[data-page="preferences"] #mapsLink{
    display:none;
  }

  body[data-page="preferences"] .preferences-header h1{
    font-size:2rem;
  }

  body[data-page="preferences"] .choice-grid{
    grid-template-columns:1fr;
  }

  body[data-page="preferences"] .preferences-summary{
    grid-template-columns:1fr;
  }

  body[data-page="preferences"] #submitPreferences{
    width:100%;
    min-width:0;
  }
}

/* ==========================================================
   PREFERENCES SELECTED STATES
   tasti selezionati blu con testo bianco
   ========================================================== */

body[data-page="preferences"] .choice-card input:checked + span,
body[data-page="preferences"] .chip input:checked + span{
  background:linear-gradient(135deg, #0d5eaf, #1287d4) !important;
  border-color:rgba(255,255,255,.22) !important;
  color:#ffffff !important;
  box-shadow:0 14px 26px rgba(13,94,175,.28) !important;
}

body[data-page="preferences"] .choice-card input:checked + span::after,
body[data-page="preferences"] .chip input:checked + span::after{
  content:" ✓";
  font-weight:900;
  color:#ffffff;
  margin-left:6px;
}

body[data-page="preferences"] .choice-card input:checked + span,
body[data-page="preferences"] .chip input:checked + span,
body[data-page="preferences"] .choice-card input:checked + span *,
body[data-page="preferences"] .chip input:checked + span *{
  color:#ffffff !important;
}
