/* ==========================================================================
   MAPPA CONSORZI STABILI 2D/3D — CSS DEDICATO (ex blocco <style> inline)
   Estratto verbatim da mappa-consorzi.php. Deve essere caricato DOPO
   assets/style.css per preservare la priorita' della cascata
   (es. .hero-map deve sovrascrivere .hero).
   ========================================================================== */

  /* STILI MAPPA INTEGRATA NELLA PAGINA OPERAGEST */
  .hero-map {
    padding: 48px 0 20px;
  }

  .map-embed-wrapper {
    position: relative;
    width: 100%;
    height: 760px;
    background: var(--paper);
    border: 1px solid var(--line);
    margin: 16px 0 40px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(28, 25, 21, 0.06);
    transition: all 0.3s ease;
  }

  .map-embed-wrapper.is-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    margin: 0 !important;
    border: none !important;
  }

  /* BARRA STRUMENTI DELLA MAPPA */
  .map-subbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 900;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(246, 243, 238, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
    padding: 9px 16px;
    gap: 12px;
  }

  .subbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
  }

  .kicker-subbar {
    letter-spacing: 0.16em;
    font-size: 11px;
    color: var(--bronze);
    font-weight: 700;
    text-transform: uppercase;
  }

  .metrics-summary {
    display: flex;
    gap: 10px;
    font-size: 13px;
    color: var(--muted);
  }

  .metrics-summary b {
    color: var(--ink);
    font-family: Georgia, serif;
  }

  .subbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }

  .view-switch-btn {
    background: var(--travertine);
    border: 1px solid var(--line);
    color: var(--ink);
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    font-family: inherit;
  }

  .view-switch-btn:hover {
    background: var(--bronze);
    border-color: var(--bronze);
    color: #fff;
  }

  .view-switch-btn.active {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--paper);
  }

  .select-basemap {
    background: #ffffff;
    border: 1px solid var(--line);
    color: var(--ink);
    padding: 6px 10px;
    font-size: 13px;
    font-family: inherit;
    border-radius: 2px;
    cursor: pointer;
    outline: none;
  }

  /* VIEWPORT STACK */
  #viewport-container {
    position: absolute;
    top: 50px;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    perspective: 1200px;
  }

  #map2d-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: var(--paper);
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: 50% 60%;
  }

  #map2d-container.tilted-25d {
    transform: rotateX(36deg) scale(1.08);
  }

  #map3d-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    display: none;
    background: radial-gradient(circle at 50% 40%, #e2dad0 0%, #c4b8a8 100%);
    cursor: grab;
  }

  #map3d-container:active { cursor: grabbing; }

  /* SIDEBAR DRAWER */
  .sidebar-drawer {
    position: absolute;
    top: 62px;
    left: 14px;
    bottom: 14px;
    width: 360px;
    z-index: 850;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--line);
    border-radius: 2px;
    padding: 14px;
    box-shadow: 0 4px 18px rgba(28, 25, 21, 0.08);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar-drawer.collapsed {
    transform: translateX(-385px);
  }

  .sidebar-toggle-tab {
    position: absolute;
    top: 10px;
    right: -30px;
    width: 30px;
    height: 40px;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid var(--line);
    border-left: none;
    border-radius: 0 3px 3px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--bronze);
    font-size: 13px;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.06);
  }

  .search-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    background: #ffffff;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--ink);
    border-radius: 2px;
    outline: none;
  }

  .search-input:focus { border-color: var(--bronze); }

  .filters-row {
    display: flex;
    gap: 6px;
  }

  .filter-select {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--line);
    background: #ffffff;
    font-family: inherit;
    font-size: 12.5px;
    color: var(--ink);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
  }

  .chips-wire-row {
    display: flex;
    gap: 6px;
  }

  .chip-wire {
    flex: 1;
    padding: 5px 6px;
    background: var(--travertine);
    border: 1px solid var(--line);
    border-radius: 2px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    text-align: center;
    user-select: none;
    transition: all 0.2s;
  }

  .chip-wire.active {
    background: var(--bronze);
    border-color: var(--bronze);
    color: #fff;
  }

  .consorzi-list-wrap {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding-right: 2px;
  }

  .consorzi-list-wrap::-webkit-scrollbar { width: 4px; }
  .consorzi-list-wrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }

  .consorzio-card-item {
    background: #ffffff;
    border: 1px solid var(--line);
    padding: 10px 12px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
  }

  .consorzio-card-item:hover {
    border-color: var(--bronze);
    background: #faf8f5;
    transform: translateX(2px);
  }

  .consorzio-card-item.is-target {
    border: 2px solid var(--bronze);
    background: #fdfaf6;
  }

  .item-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 3px;
  }

  .item-title {
    font-family: Georgia, serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.25;
  }

  .badge-modello {
    font-size: 9.5px;
    padding: 2px 5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
    border-radius: 2px;
    white-space: nowrap;
  }

  .badge-target { background: var(--bronze); color: #fff; }
  .badge-gigante { background: var(--ink); color: var(--paper); }
  .badge-verticale { background: var(--travertine); color: var(--bronze); border: 1px solid var(--line); }
  .badge-pmi { background: #eef2ed; color: var(--accent-green); border: 1px solid #c9d8cd; }

  .item-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 5px;
  }

  .item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 11px;
  }

  .item-tag {
    background: var(--travertine);
    padding: 1px 5px;
    border-radius: 2px;
    color: var(--ink);
  }

  /* SCHEDA DETTAGLIO MODALE (DOSSIER ISTITUZIONALE) */
  .detail-dossier {
    position: absolute;
    top: 62px;
    right: 14px;
    bottom: 14px;
    width: 420px;
    max-height: calc(100% - 76px);
    z-index: 850;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 2px;
    padding: 20px;
    box-shadow: 0 16px 40px rgba(28, 25, 21, 0.16);
    display: none;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    animation: fadeIn 0.25s ease;
  }

  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .close-dossier-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
  }

  .close-dossier-btn:hover { color: var(--ink); }

  .dossier-kicker {
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--bronze);
    font-weight: 700;
    margin-bottom: 3px;
  }

  .dossier-title {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 21px;
    font-weight: 500;
    color: var(--ink);
    line-height: 1.2;
    margin-bottom: 2px;
  }

  .dossier-subtitle {
    font-size: 12.5px;
    color: var(--muted);
    margin-bottom: 6px;
  }

  .dossier-desc {
    background: var(--paper);
    border-left: 3px solid var(--bronze);
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--ink);
  }

  .dossier-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
  }

  .dossier-table th, .dossier-table td {
    border-bottom: 1px solid var(--line);
    padding: 6px 4px;
    vertical-align: top;
  }

  .dossier-table th {
    width: 44%;
    color: var(--muted);
    font-weight: 500;
  }

  .dossier-table td {
    font-weight: 600;
    color: var(--ink);
    word-break: break-all;
  }

  .dossier-table td a {
    color: var(--bronze);
    text-decoration: underline;
  }

  .chips-soa-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
  }

  .soa-pill {
    background: var(--travertine);
    border: 1px solid var(--line);
    padding: 2px 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--ink);
  }

  .btn-candida-dossier {
    background: var(--ink);
    color: var(--paper);
    border: none;
    padding: 10px;
    font-size: 13.5px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    border-radius: 2px;
    transition: background 0.2s;
    margin-top: 4px;
    text-decoration: none;
    display: block;
  }

  .btn-candida-dossier:hover {
    background: var(--bronze);
    color: #fff;
  }

  /* CONTROLLI 3D FLUTTUANTI */
  .controls-3d-box {
    position: absolute;
    bottom: 18px;
    right: 18px;
    z-index: 850;
    display: none;
    flex-direction: column;
    gap: 6px;
  }

  .btn-ctrl-3d {
    background: #ffffff;
    border: 1px solid var(--line);
    color: var(--ink);
    width: 38px;
    height: 38px;
    border-radius: 2px;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.2s;
  }

  .btn-ctrl-3d:hover {
    background: var(--bronze);
    color: #fff;
    border-color: var(--bronze);
  }

  .hud-3d-banner {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 850;
    display: none;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 6px 18px;
    font-size: 12px;
    color: var(--muted);
    pointer-events: none;
    font-family: Georgia, serif;
    white-space: nowrap;
  }

  /* MARKER PERSONALIZZATO A SIGILLO OPERAGEST */
  .custom-seal-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
  }
  .custom-seal-marker:hover {
    transform: scale(1.22);
  }

  @media (max-width: 900px) {
    .map-embed-wrapper { height: 600px; }
    .map-subbar { flex-direction: column; gap: 8px; align-items: flex-start; }
    .sidebar-drawer { width: 300px; top: 110px; }
    .detail-dossier { width: calc(100% - 28px); left: 14px; right: 14px; top: 110px; }
  }
