/* 3U Vision partner map (versione sito web)
   Layout: pannello a sinistra (filtri, elenco, scheda partner) e mappa vettoriale a destra.
   Sotto i 760px la mappa va in alto e il pannello sotto.
   Colori dalla 3U Vision Logo Guide 2026: Pure Orange #de5307 (RAL 2004), Slate Grey #4f5358 (RAL 7015).
   Tema unico chiaro, scelto perché la mappa verrà incorporata nel sito aziendale. */
:root {
  color-scheme: light;
  /* brand */
  --orange: #de5307;
  --orange-dark: #b84405;
  --orange-soft: #fbe6da;
  --slate: #4f5358;
  /* superfici e testo */
  --bg: #f4f5f6;
  --panel: #ffffff;
  --ink: #2c3034;
  --muted: #6a6f75;
  --line: #e0e2e5;
  --soft: #f0f1f3;
  /* mappa */
  --ocean: #f3f4f6;
  --land: #e1e4e7;
  --land-covered: #b2b8be;
  --land-hover: #9ea5ac;
  --land-edge: #fbfbfc;
  /* tipi di partner */
  --hq: #de5307;
  --branch: #de5307;
  --dealer: #4f5358;
  --agent: #ffffff;
  /* stati */
  --ok: #2f7a4f;
  --ok-bg: #e4f1e9;
  --wait: #8a5200;
  --wait-bg: #fdf0dc;
  /* testo */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.9375rem;
  --fs-lg: 1.25rem;
  --radius: 8px;
}

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.45;
}

.pm-app { display: flex; flex-direction: column; height: 100%; min-height: 520px; }

/* intestazione */
.pm-head {
  display: flex; align-items: center; gap: 12px;
  padding-block: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--panel);
  border-bottom: 3px solid var(--orange);
}
.pm-chev { width: 14px; height: 22px; flex: none; }
.pm-head h1 { margin: 0; font-size: var(--fs-lg); line-height: 1.2; font-weight: 700; color: var(--slate); text-wrap: balance; }
.pm-head p { margin: 2px 0 0; color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }

/* corpo */
.pm-main { flex: 1; display: grid; grid-template-columns: minmax(300px, 390px) 1fr; min-height: 0; }
.pm-panel { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; min-width: 0; }
.pm-mapwrap { position: relative; min-width: 0; }
#pm-map { position: absolute; inset: 0; background: var(--ocean); }

/* filtri */
.pm-filters {
  display: grid; gap: 12px; padding: 16px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--panel); z-index: 2;
}
.pm-search { position: relative; }
.pm-search input {
  width: 100%; box-sizing: border-box; font: inherit; color: var(--ink);
  padding: 9px 12px 9px 34px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--soft);
}
.pm-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--muted); }
.pm-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pm-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: var(--fs-sm); color: var(--ink);
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 4px 10px 4px 5px; cursor: pointer;
}
.pm-chip.pm-plain { padding-left: 10px; }
.pm-chip[aria-pressed="false"] { color: var(--muted); background: var(--soft); }
.pm-chip[aria-pressed="false"] .pm-dot { filter: grayscale(1); opacity: .45; }
.pm-chip[aria-pressed="true"].pm-plain { border-color: var(--slate); background: var(--slate); color: #fff; }
.pm-chip .pm-n { color: var(--muted); font-variant-numeric: tabular-nums; }
.pm-dot {
  width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  box-sizing: border-box;
}
.pm-dot svg { width: 14px; height: 14px; }
.pm-dot.agent { border: 1.5px solid var(--slate); }
.pm-select {
  width: 100%; font: inherit; color: var(--ink); padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
}
.pm-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin: 0 0 6px; display: block; }
.pm-meta { display: flex; justify-content: space-between; align-items: center; font-size: var(--fs-sm); color: var(--muted); }
.pm-link { font: inherit; font-size: var(--fs-sm); color: var(--orange-dark); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.pm-country {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--orange-soft); border-radius: var(--radius); padding: 8px 10px; font-size: var(--fs-sm);
}
.pm-country strong { font-weight: 700; }

/* elenco */
.pm-list { list-style: none; margin: 0; padding: 8px; display: grid; gap: 2px; }
.pm-item button {
  width: 100%; text-align: left; font: inherit; color: inherit; background: none; border: 0; cursor: pointer;
  display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start;
  padding: 10px 8px; border-radius: var(--radius);
}
.pm-item button:hover { background: var(--soft); }
.pm-item .pm-dot { margin-top: 1px; }
.pm-item-name { font-weight: 600; display: flex; align-items: baseline; gap: 7px; }
.pm-item-name span { min-width: 0; }
.pm-flag { width: 18px; height: 12px; flex: none; border-radius: 2px; box-shadow: 0 0 0 1px rgba(44,48,52,.15); display: inline-block; position: relative; top: 1px; }
.pm-item-sub { display: block; color: var(--muted); font-size: var(--fs-sm); }
.pm-item-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.pm-empty { padding: 24px 16px; color: var(--muted); }

.pm-tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 600;
  border-radius: 4px; padding: 1px 6px; background: var(--soft); color: var(--muted);
}
.pm-tag.ok { background: var(--ok-bg); color: var(--ok); }
.pm-tag.wait { background: var(--wait-bg); color: var(--wait); }
.pm-tag.hq { background: var(--orange-soft); color: var(--orange-dark); }

/* scheda partner */
.pm-detail { padding: 16px; display: grid; gap: 18px; }
.pm-back { justify-self: start; }
.pm-dhead { display: grid; gap: 6px; padding-left: 12px; border-left: 4px solid var(--orange); }
.pm-type { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--slate); }
.pm-dhead h2 { margin: 0; font-size: 1.3rem; line-height: 1.25; text-wrap: balance; color: var(--ink); }
.pm-dhead h2 .pm-flag { width: 24px; height: 16px; margin-right: 8px; top: 1px; }
.pm-sec h3 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; font-weight: 700; }
.pm-addr { font-style: normal; }
.pm-gmaps { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; font-size: var(--fs-sm); color: var(--orange-dark); font-weight: 600; }
.pm-gmaps svg { width: 14px; height: 14px; }
.pm-contact { display: grid; gap: 4px; }
.pm-contact + .pm-contact { margin-top: 10px; }
.pm-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pm-line .pm-k { color: var(--muted); font-size: var(--fs-sm); min-width: 54px; }
.pm-detail a { color: var(--orange-dark); overflow-wrap: anywhere; }
.pm-copy {
  font: inherit; font-size: var(--fs-xs); border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  border-radius: 4px; padding: 1px 8px; cursor: pointer;
}
.pm-services { display: flex; flex-wrap: wrap; gap: 8px; }
.pm-service {
  display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 600;
  border-radius: 6px; padding: 6px 10px; background: var(--ok-bg); color: var(--ok);
}
.pm-service.wait { background: var(--wait-bg); color: var(--wait); }
.pm-service svg { width: 15px; height: 15px; }
.pm-terr { display: flex; flex-wrap: wrap; gap: 6px; }
.pm-terr span { font-size: var(--fs-sm); border-radius: 4px; padding: 2px 8px; background: var(--soft); }
.pm-terr span.pm-global { background: var(--orange); color: #fff; }
.pm-sgroup + .pm-sgroup { margin-top: 12px; }
.pm-sgroup h4 { margin: 0 0 6px; font-size: var(--fs-sm); font-weight: 600; }
.pm-sectors { display: flex; flex-wrap: wrap; gap: 6px; }
.pm-s {
  font-size: var(--fs-sm); border-radius: 999px; padding: 2px 10px;
  border: 1.5px solid var(--slate); color: var(--slate); background: var(--panel);
}
.pm-s.excl { background: var(--slate); color: #fff; }
.pm-legend-s { display: flex; gap: 14px; font-size: var(--fs-xs); color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.pm-legend-s i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -2px; margin-right: 4px; border: 1.5px solid var(--slate); }
.pm-legend-s i.excl { background: var(--slate); }

/* legenda sulla mappa */
.pm-maplegend {
  position: absolute; left: 12px; bottom: 12px; z-index: 500;
  background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px; display: grid; gap: 4px; font-size: var(--fs-xs); box-shadow: 0 2px 8px rgba(44,48,52,.08);
}
.pm-maplegend div { display: flex; align-items: center; gap: 6px; }
.pm-maplegend .pm-dot { width: 18px; height: 18px; }
.pm-maplegend .pm-dot svg { width: 11px; height: 11px; }
.pm-swatch { width: 18px; height: 12px; border-radius: 2px; background: var(--land-covered); display: inline-block; }
.pm-swatch.sel { background: #eb9a6c; }

/* pin */
.pm-pin { background: none; border: 0; }
.pm-pin svg { display: block; overflow: visible; filter: drop-shadow(0 2px 2px rgba(44,48,52,.35)); transition: transform .18s ease, opacity .18s ease; transform-origin: 50% 100%; }
.pm-pin.pm-sel svg { transform: scale(1.45); }
.pm-pin.pm-dim svg { opacity: .4; }
.pm-halo { transform-origin: center; transform-box: fill-box; animation: pm-pulse 1.6s ease-out infinite; }
@keyframes pm-pulse { 0% { transform: scale(.6); opacity: .7; } 100% { transform: scale(1.6); opacity: 0; } }

.leaflet-container { font-family: var(--font); background: var(--ocean); }
.leaflet-container:focus { outline: none; }
.leaflet-container:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }
.leaflet-tooltip.pm-tip { font-family: var(--font); font-size: var(--fs-sm); border-radius: 6px; border-color: var(--line); color: var(--ink); box-shadow: 0 2px 6px rgba(44,48,52,.12); }
.leaflet-control-attribution { font-size: 10px; }
.pm-home { width: 34px; height: 34px; display: grid; place-items: center; background: var(--panel); border: 0; cursor: pointer; color: var(--slate); }
.pm-home svg { width: 16px; height: 16px; }

button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.leaflet-marker-icon:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; border-radius: 50%; }

@media (max-width: 760px) {
  html, body { height: auto; }
  .pm-app { height: auto; }
  .pm-main { display: flex; flex-direction: column; }
  .pm-mapwrap { order: -1; height: 58vh; min-height: 320px; }
  .pm-panel { border-right: 0; overflow: visible; }
  .pm-filters { position: static; }
  .pm-head h1 { font-size: 1.0625rem; }
  .pm-maplegend { left: 8px; bottom: 8px; right: 60px; grid-auto-flow: column; grid-template-rows: auto auto auto; gap: 2px 10px; padding: 6px 8px; justify-content: start; }
  .pm-maplegend .pm-dot { width: 16px; height: 16px; }
  .pm-maplegend .pm-dot svg { width: 10px; height: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .pm-pin svg { transition: none; }
  .pm-halo { animation: none; opacity: .35; }
}
.pm-halo { transform-box: fill-box; }
.leaflet-tooltip.pm-seltip { border: 2px solid var(--orange); font-weight: 700; color: var(--ink); }
.pm-labelrow { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pm-labelrow .pm-label { margin-bottom: 6px; }
.pm-mailnote { flex-basis: 100%; font-size: var(--fs-xs); color: var(--muted); padding-left: 62px; }
@media (max-width: 760px) { .pm-mailnote { padding-left: 0; } }
.pm-row .pm-chip#pm-showall { padding-left: 10px; }
.pm-tiplist { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 2px; }
.pm-tiplist li { position: relative; padding-left: 14px; }
.pm-tiplist li::before { content: ""; position: absolute; left: 0; top: .55em; width: 7px; height: 7px; border-radius: 50%; background: var(--orange); }
.pm-tipnote { color: var(--muted); }

/* incorporata nella pagina Network (iframe): sotto i 760px la mappa ha un'altezza fissa,
   la pagina adatta l'altezza dell'iframe al contenuto */
html.pm-embedded body { background: var(--panel); }
@media (max-width: 760px) {
  html.pm-embedded .pm-mapwrap { height: 440px; min-height: 0; }
  /* elenco e scheda scorrono all'interno, così la pagina non diventa troppo lunga */
  html.pm-embedded .pm-panel { max-height: 640px; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--line); }
}
