/* Flyerbox Mappe - layout mappa */
html, body { overflow: hidden; }
body { display: flex; flex-direction: column; height: 100vh; }
#main { flex: 1; display: flex; min-height: 0; position: relative; }
#mapwrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #e9e6df; }

/* ricerca */
.search { position: relative; flex: 1 1 auto; max-width: 520px; min-width: 150px; display: flex; align-items: center; background: rgba(255,255,255,.10); border-radius: 10px; padding: 0 10px; height: 38px; transition: background .15s; }
.search:focus-within { background: #fff; color: var(--fb-dark); }
.search svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; opacity: .8; flex: none; }
.search input { flex: 1; border: 0; background: transparent; color: inherit; outline: none; padding: 0 8px; font-size: 14px; min-width: 0; }
.search input::placeholder { color: rgba(255,255,255,.6); }
.search:focus-within input::placeholder { color: #aaa; }
.search .clear { border: 0; background: transparent; color: inherit; font-size: 20px; cursor: pointer; opacity: .7; padding: 0 4px; }
.results { position: absolute; top: 44px; left: 0; min-width: min(680px, 92vw); background: #fff; color: var(--fb-dark); border-radius: 12px; box-shadow: var(--fb-shadow); max-height: min(70vh, 560px); overflow: auto; z-index: 2000; padding: 6px; }
.results .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--fb-grey-2); padding: 8px 10px 4px; font-weight: 700; }
.results .it { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.results .it:hover, .results .it.focus { background: var(--fb-orange-soft); }
.results .it .t { flex: 1; min-width: 0; }
.results .it .t b { display: block; }
.results .it .t small { color: var(--fb-grey-2); }
.results .it .n { font-size: 12px; color: var(--fb-grey); white-space: nowrap; font-variant-numeric: tabular-nums; }
.results .it .btn { flex: none; }
.results .none { padding: 14px; color: var(--fb-grey-2); text-align: center; }
.results mark { background: #ffe2d2; color: inherit; border-radius: 3px; padding: 0 1px; }

/* menu a tendina */
.dd { position: relative; }
.dd .menu { display: none; position: absolute; top: 42px; right: 0; background: #fff; color: var(--fb-dark); border-radius: 12px; box-shadow: var(--fb-shadow); min-width: 260px; padding: 6px; z-index: 2500; }
.dd.open .menu { display: block; }
.dd .menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.dd .menu button:hover { background: var(--fb-orange-soft); }
.dd .menu button b { display: block; font-size: 13px; }
.dd .menu button small { color: var(--fb-grey-2); font-size: 11px; }
.dd .menu hr { border: 0; border-top: 1px solid var(--fb-line); margin: 4px 0; }
.dd .menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--fb-line); margin-bottom: 4px; font-size: 13px; }
.dd .menu .who b { display: block; font-size: 14px; }
.topbar .count { background: var(--fb-orange); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 11px; min-width: 18px; text-align: center; line-height: 18px; }
.topbar .btn.active .count { background: #fff; color: var(--fb-orange-dark); }

/* pannello */
#panel { width: 440px; background: #fff; border-right: 1px solid var(--fb-line); display: flex; flex-direction: column; box-shadow: 4px 0 18px rgba(0,0,0,.08); z-index: 1000; transition: margin-left .2s ease, width .2s ease; }
#panel.collapsed { margin-left: -440px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; }
.panel-title { font-weight: 800; font-size: 16px; }
.panel-actions { display: flex; gap: 6px; padding: 0 14px 10px; border-bottom: 1px solid var(--fb-line); flex-wrap: wrap; }
.panel-body { flex: 1; overflow: auto; }
.panel-body .empty { padding: 24px 18px; color: var(--fb-grey); line-height: 1.5; }
.panel-sub { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--fb-grey-2); font-weight: 700; padding: 12px 14px 4px; }
table.sel td, table.sel th { padding: 6px 8px; font-size: 12.5px; }
table.sel tbody tr { cursor: pointer; }
table.sel tbody tr.hover td { background: #fff1ea; }
table.sel td.x { width: 26px; text-align: center; }
table.sel td.x button { border: 0; background: transparent; color: #bbb; cursor: pointer; font-size: 16px; line-height: 1; }
table.sel td.x button:hover { color: var(--fb-red); }
table.sel tfoot td { font-weight: 800; background: #fafafa; border-top: 2px solid var(--fb-line); position: sticky; bottom: 0; }
.pt { display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-bottom: 1px solid var(--fb-line); font-size: 13px; cursor: pointer; }
.pt:hover { background: #fff8f4; }
.pt .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--fb-orange); flex: none; }
.pt .t { flex: 1; }
.pt button { border: 0; background: transparent; color: #bbb; cursor: pointer; font-size: 16px; }
.pt button:hover { color: var(--fb-red); }

/* overlay mappa */
.chip { position: absolute; z-index: 900; }
#stats { left: 12px; bottom: 62px; }
#shareBanner { left: 12px; top: 12px; background: var(--fb-dark); color: #fff; }
#noPolyNote { left: 50%; transform: translateX(-50%); top: 12px; background: #fff8e1; color: #7a4b00; }
#basemaps { position: absolute; right: 12px; bottom: 12px; z-index: 900; display: flex; background: #fff; border-radius: 8px; box-shadow: var(--fb-shadow-sm); overflow: hidden; }
#basemaps button { border: 0; background: #fff; padding: 6px 10px; cursor: pointer; font-weight: 600; font-size: 12px; color: var(--fb-grey); }
#basemaps button.on { background: var(--fb-dark); color: #fff; }
#basemaps button:hover:not(.on) { background: #f3f3f3; }
#maplogo { position: absolute; left: 12px; bottom: 12px; z-index: 900; background: rgba(255,255,255,.92); border-radius: 10px; padding: 6px 10px; box-shadow: var(--fb-shadow-sm); }
#maplogo img { height: 30px; display: block; }
#toolHint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: var(--fb-orange); color: #fff; padding: 8px 14px; border-radius: 999px; font-weight: 700; z-index: 950; box-shadow: var(--fb-shadow); display: flex; gap: 10px; align-items: center; }
#toolHint button { border: 0; background: rgba(255,255,255,.25); color: #fff; border-radius: 6px; padding: 3px 8px; cursor: pointer; font-weight: 700; }
#loading { position: absolute; top: 12px; right: 12px; background: #fff; padding: 6px 12px; border-radius: 999px; box-shadow: var(--fb-shadow-sm); z-index: 950; font-size: 12px; font-weight: 600; color: var(--fb-grey); display: flex; align-items: center; gap: 8px; }
.spin { width: 14px; height: 14px; border: 2px solid #ddd; border-top-color: var(--fb-orange); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.leaflet-container { font-family: var(--font); }
.leaflet-control-zoom { margin-bottom: 52px !important; }
.leaflet-container.tool-rect, .leaflet-container.tool-radius, .leaflet-container.tool-point { cursor: crosshair !important; }

/* etichette */
.fb-label { background: transparent; border: 0; pointer-events: none; }
.fb-label .l { text-align: center; font-weight: 700; color: #14306f; line-height: 1.15; white-space: nowrap;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff, 1px 1px 0 #fff, -1px -1px 0 #fff; transform: translate(-50%, -50%); display: inline-block; }
.fb-label .l .n { font-size: 11.5px; }
.fb-label .l .c { font-size: 10px; font-weight: 600; }
.fb-label .l .f { font-size: 10px; color: var(--fb-orange-dark); }
.fb-label.sel .l { color: #9a2e00; }

/* popup */
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: var(--fb-shadow); padding: 0; }
.leaflet-popup-content { margin: 0; min-width: 230px; }
.pp { padding: 12px 14px 10px; }
.pp h3 { margin: 0 0 6px; font-size: 15px; color: var(--fb-dark); }
.pp table { border-collapse: collapse; width: 100%; }
.pp td { padding: 2px 0; font-size: 13px; }
.pp td:first-child { color: var(--fb-grey-2); padding-right: 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.pp td:last-child { font-weight: 600; }
.pp .fam { color: var(--fb-orange-dark); font-size: 15px; }
.pp .acts { display: flex; gap: 6px; margin-top: 10px; }
.pp .acts .btn { flex: 1; justify-content: center; }
.pp .ptlabel { font-weight: 700; }

/* punto vendita */
.fb-pin { background: transparent; border: 0; }
.fb-pin .pin { width: 28px; height: 28px; border-radius: 50% 50% 50% 0; background: var(--fb-orange); transform: rotate(-45deg); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.fb-pin .pin::after { content: ""; position: absolute; width: 8px; height: 8px; background: #fff; border-radius: 50%; top: 7px; left: 7px; }
.fb-pin .cap { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); background: #fff; border-radius: 6px; padding: 1px 6px; font-size: 11px; font-weight: 700; white-space: nowrap; box-shadow: var(--fb-shadow-sm); color: var(--fb-dark); }

/* share modal */
.share-url { display: flex; gap: 6px; }
.share-url input { flex: 1; border: 1px solid var(--fb-line); border-radius: 8px; padding: 8px; font-family: var(--mono); font-size: 12px; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.links .lk { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--fb-line); font-size: 13px; }
.links .lk .t { flex: 1; min-width: 0; }
.links .lk .t b { display: block; }
.links .lk .t small { color: var(--fb-grey-2); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--fb-line); }
.proj .t { flex: 1; }
.proj .t b { display: block; }
.proj .t small { color: var(--fb-grey-2); }
.banner-pwd { background: #fff3cd; color: #7a4b00; padding: 8px 14px; font-weight: 600; text-align: center; }

/* responsive */
@media (max-width: 1180px) { .topbar .btn .lbl { display: none; } }
@media (max-width: 760px) {
  .topbar { padding: 0 8px; gap: 6px; } .topbar .title { display: none; }
  #panel { position: absolute; left: 0; top: 0; bottom: 0; width: min(92vw, 440px); }
  #panel.collapsed { margin-left: -100vw; }
  #maplogo img { height: 22px; }
}

/* stampa */
@media print {
  .topbar, #panel, #basemaps, #toolHint, #loading, .leaflet-control-zoom, #toasts, #modals { display: none !important; }
  #main, #mapwrap, #map { position: fixed !important; inset: 0 !important; width: 100vw !important; height: 100vh !important; }
  #maplogo { background: #fff; }
}

/* la scala metrica sta a destra del logo */
.leaflet-bottom.leaflet-left { left: 128px; }

/* bottoni dentro i risultati di ricerca (stanno nella topbar scura) */
.topbar .results .btn { background: #f1f1f1; color: var(--fb-dark); border-color: transparent; }
.topbar .results .btn:hover { background: var(--fb-orange); color: #fff; }
.topbar .results .btn.danger { color: var(--fb-red); background: #fdeeee; }
