/* ===== Modulo Property Intelligence — pannello ricerca (Fonti · sub-tab) =====
   Redesign ottanio v2 (palette/typografia portale). Riusa le var globali di
   variables.css (--ott-*, --ink, --paper, --ff-display, --ff-mono). Tutto lo
   wiring JS (id + classi generate runtime) è preservato. La legenda resta sui
   colori REALI dei poligoni mappa (rosso #890103/#B4595A) — vedi arricchimento.js
   FILL_COLOR/CL_COLOR — NON i colori illustrativi del mockup. */

#fonti-panel-arricchimento .arric-panel { padding: 0; }

/* chevron riusabile per i select */
#fonti-panel-arricchimento {
  --arric-chev: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%230E3B45' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  --arric-chev-sm: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}

/* ---------- Dataset attivo ---------- */
.arric-dshead {
  padding: 14px 16px;
  background: linear-gradient(180deg, #F8FAFB, #FFFFFF);
  border-bottom: 1px solid var(--ott-200, #E4E9EF);
}
.arric-dshead-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.arric-dshead-icon {
  width: 30px; height: 30px; border-radius: 7px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--ott-soft, #2a525c), var(--ott-base, #0E3B45));
  color: #fff; display: flex; align-items: center; justify-content: center;
}
.arric-dshead-icon svg { width: 15px; height: 15px; }
.arric-dshead-lbl {
  font-size: 10px; font-weight: 700; color: var(--ott-500, #64748B);
  letter-spacing: .16em; text-transform: uppercase;
}
.arric-dshead-t {
  font-family: var(--ff-display, 'Archivo', sans-serif); font-weight: 800;
  font-size: 14px; color: var(--ott-deep, #031C23); letter-spacing: -.005em; margin-top: 1px;
}

/* ---------- Select stile portale ---------- */
.arric-sel {
  width: 100%; height: 38px; padding: 0 34px 0 14px;
  background-color: #fff; border: 1px solid var(--ott-200, #E4E9EF); border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--ink, #0F172A);
  outline: none; appearance: none; cursor: pointer; box-sizing: border-box;
  background-image: var(--arric-chev); background-repeat: no-repeat; background-position: right 14px center;
  transition: border-color 100ms, box-shadow 100ms;
}
.arric-sel:hover { border-color: var(--ott-300, #CBD5E0); }
.arric-sel:focus { border-color: var(--ott-base, #0E3B45); box-shadow: var(--rd-focus-ring, 0 0 0 3px rgba(14,59,69,.10)); }
.arric-sel--sm {
  height: 34px; font-size: 12.5px; font-weight: 500; padding: 0 30px 0 12px;
  background-color: var(--ott-50, #F4F6F9);
  background-image: var(--arric-chev-sm); background-position: right 10px center;
}
#arric-layer-select { margin: 0; }

/* ---------- Barra azioni mappa ---------- */
.arric-actbar {
  padding: 12px 16px; border-bottom: 1px solid var(--ott-200, #E4E9EF);
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; background: #fff;
}
.arric-tbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 10px; border-radius: 7px; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; cursor: pointer; transition: background 100ms, border-color 100ms, filter 100ms;
  background: #fff; border: 1px solid var(--ott-200, #E4E9EF); color: var(--ink, #0F172A);
}
.arric-tbtn svg { width: 13px; height: 13px; flex-shrink: 0; }
.arric-tbtn:hover:not(:disabled) { background: var(--ott-50, #F4F6F9); border-color: var(--ott-300, #CBD5E0); }
.arric-tbtn.active {
  background: linear-gradient(180deg, var(--ott-soft, #2a525c), var(--ott-base, #0E3B45));
  border-color: var(--ott-base, #0E3B45); color: #fff;
}
.arric-tbtn.active:hover:not(:disabled) { filter: brightness(1.06); background: linear-gradient(180deg, var(--ott-soft, #2a525c), var(--ott-base, #0E3B45)); }
.arric-tbtn:disabled { color: #b8c2c4; border-color: #e2e8ec; background: #f7f9fa; cursor: not-allowed; }

.arric-controls { margin: 0; }

/* ---------- Pills tipologia soggetto ---------- */
.arric-subcluster {
  padding: 12px 16px; display: flex; gap: 6px; border-bottom: 1px solid var(--ott-200, #E4E9EF);
  overflow-x: auto; scrollbar-width: none; margin: 0;
}
.arric-subcluster::-webkit-scrollbar { display: none; }
.arric-chip {
  flex-shrink: 0; padding: 6px 12px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  color: var(--ott-500, #64748B); border: 1px solid var(--ott-200, #E4E9EF); background: #fff;
  cursor: pointer; transition: all 100ms;
}
.arric-chip:hover { border-color: var(--ott-300, #CBD5E0); color: var(--ink, #0F172A); }
.arric-chip.active { background: var(--ott-base, #0E3B45); color: #fff; border-color: var(--ott-base, #0E3B45); }

/* ---------- Sezioni con label + icona ---------- */
.arric-sect { padding: 13px 16px; border-bottom: 1px solid var(--ott-100, #E8EDF1); }
.arric-sect-lbl {
  font-size: 10.5px; font-weight: 700; color: var(--ott-500, #64748B); letter-spacing: .14em;
  text-transform: uppercase; margin-bottom: 6px; display: flex; align-items: center; gap: 6px;
}
.arric-sect-lbl svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ---------- Veicoli / denominazioni (multi-select come lista: 4+ righe con scroll) ----------
   Selettore scoped al pannello (specificità 1,1,0) per BATTERE
   _redesign-foundation.css `.rd-scope select{height:32px}` (0,1,1) che altrimenti
   schiaccia la multiselect a 1 riga. height:auto lascia che size="4" mostri 4 righe. */
#fonti-panel-arricchimento .arric-vlist {
  width: 100%; box-sizing: border-box;
  height: auto; min-height: 124px; max-height: 168px; overflow-y: auto;
  padding: 4px;
  appearance: auto; -webkit-appearance: listbox; background-image: none;
  background-color: #fff; border: 1px solid var(--ott-200, #E4E9EF); border-radius: 8px;
  font-family: var(--ff-mono, monospace); font-size: 11.5px; color: var(--ink, #0F172A);
}
#fonti-panel-arricchimento .arric-vlist:focus { outline: none; border-color: var(--ott-base, #0E3B45); box-shadow: var(--rd-focus-ring, 0 0 0 3px rgba(14,59,69,.10)); }
.arric-vlist option { padding: 7px 9px; border-radius: 5px; line-height: 1.2; margin-bottom: 1px; }
.arric-vlist option:checked {
  background: rgba(14,59,69,.08) linear-gradient(0deg, rgba(14,59,69,.08), rgba(14,59,69,.08));
  color: var(--ott-base, #0E3B45); font-weight: 600;
}

/* ---------- Localizzazione (triplet) ---------- */
.arric-geo { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.arric-geo-col { min-width: 0; }
.arric-geo-lbl {
  display: block; font-size: 9.5px; font-weight: 600; color: var(--ott-500, #64748B);
  letter-spacing: .10em; text-transform: uppercase; margin-bottom: 3px;
}

/* ---------- Reset ---------- */
.arric-reset { padding: 12px 16px; border-bottom: 1px solid var(--ott-200, #E4E9EF); }
.arric-btn-reset {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; height: 34px; border-radius: 7px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  background: #fff; border: 1px solid var(--ott-200, #E4E9EF); color: var(--ott-700, #0F2A33);
  transition: background 100ms, border-color 100ms, color 100ms;
}
.arric-btn-reset svg { width: 13px; height: 13px; }
.arric-btn-reset:hover { background: var(--ott-50, #F4F6F9); border-color: #890103; color: #890103; }

/* ---------- KPI grid 2×3 (Rendita = card accent full-width, nth-child 3) ---------- */
.arric-kpi {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--ott-200, #E4E9EF);
  background: linear-gradient(180deg, #F8FAFB, #FFFFFF);
}
.arric-kpi-card { background: #fff; border: 1px solid var(--ott-200, #E4E9EF); border-radius: 8px; padding: 11px 13px; text-align: left; }
.arric-kpi-lbl { font-size: 9.5px; font-weight: 700; color: var(--ott-500, #64748B); text-transform: uppercase; letter-spacing: .14em; margin-bottom: 4px; }
.arric-kpi-val { font-family: var(--ff-mono, monospace); font-weight: 600; font-size: 20px; color: var(--ott-deep, #031C23); line-height: 1.1; }
.arric-kpi-val--pos { color: #15803d; }
.arric-kpi-val--neg { color: #b91c1c; }
.arric-kpi-sub { font-size: 10.5px; color: var(--ott-500, #64748B); margin-top: 3px; }
.arric-kpi-sub b, .arric-kpi-card .arric-kpi-sub b { color: var(--ott-base, #0E3B45); font-weight: 600; font-family: var(--ff-mono, monospace); }
#arric-kpi .arric-kpi-card:nth-child(3) {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--ott-base, #0E3B45), var(--ott-deep, #031C23));
  border-color: var(--ott-deep, #031C23);
}
#arric-kpi .arric-kpi-card:nth-child(3) .arric-kpi-lbl { color: rgba(255,255,255,.62); }
#arric-kpi .arric-kpi-card:nth-child(3) .arric-kpi-val { color: #fff; }
#arric-kpi .arric-kpi-card:nth-child(3) .arric-kpi-sub { color: rgba(255,255,255,.70); }
#arric-kpi .arric-kpi-card:nth-child(3) .arric-kpi-sub b { color: #FBD3D4; }
.arric-kpi-empty {
  grid-column: 1 / -1; padding: 16px 12px; text-align: center; font-size: 12px;
  color: var(--ott-500, #64748B); background: #fff; border: 1px dashed var(--ott-300, #CBD5E0);
  border-radius: 8px; line-height: 1.4;
}

/* ---------- Apri dashboard (link row) ---------- */
.arric-actions { margin: 0; }
.arric-dashlink {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--ott-200, #E4E9EF); background: #fff;
  cursor: pointer; transition: background 100ms; text-align: left;
}
.arric-dashlink:hover:not(:disabled) { background: var(--ott-50, #F4F6F9); }
.arric-dashlink:disabled { opacity: .5; cursor: not-allowed; }
.arric-dashlink-t { display: flex; align-items: center; gap: 10px; min-width: 0; }
.arric-dashlink-t > svg { width: 14px; height: 14px; color: var(--ott-base, #0E3B45); flex-shrink: 0; }
.arric-dashlink-tx { min-width: 0; }
.arric-dashlink-tx b { display: block; font-size: 12.5px; font-weight: 600; color: var(--ott-base, #0E3B45); }
.arric-dashlink-tx small { display: block; font-size: 10.5px; color: var(--ott-500, #64748B); font-weight: 500; }
.arric-dashlink-arrow { color: var(--ott-base, #0E3B45); flex-shrink: 0; }
.arric-dashlink-arrow svg { width: 12px; height: 12px; }

/* ---------- Input (Cerca / Cluster) ---------- */
.arric-search { position: relative; }
.arric-input-wrap { position: relative; }
.arric-input-lead {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 13px; height: 13px; color: var(--ott-500, #64748B); pointer-events: none;
}
.arric-input {
  width: 100%; height: 34px; padding: 0 12px 0 34px; box-sizing: border-box;
  background: var(--ott-50, #F4F6F9); border: 1px solid var(--ott-200, #E4E9EF); border-radius: 7px;
  font-size: 12.5px; color: var(--ink, #0F172A); outline: none; transition: all 100ms;
}
.arric-input:hover { background: #fff; }
.arric-input:focus { border-color: var(--ott-base, #0E3B45); background: #fff; box-shadow: var(--rd-focus-ring, 0 0 0 3px rgba(14,59,69,.10)); }

#arric-search-results {
  list-style: none; padding: 0; margin: 4px 0 0 0; max-height: 180px; overflow: auto;
  background: #fff; border: 1px solid var(--ott-200, #E4E9EF); border-radius: 7px;
}
#arric-search-results:empty { display: none; }
#arric-search-results li {
  padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--ott-100, #E8EDF1); font-size: 12px;
}
#arric-search-results li:last-child { border-bottom: 0; }
#arric-search-results li:hover { background: var(--ott-50, #F4F6F9); }

/* ---------- Summary card ---------- */
.arric-summary { padding: 14px 16px; background: linear-gradient(180deg, #fff, var(--ott-50, #F4F6F9)); border-bottom: 1px solid var(--ott-200, #E4E9EF); }
.arric-stats {
  background: #fff; border-left: 3px solid var(--ott-base, #0E3B45); border-radius: 0 8px 8px 0;
  padding: 12px 14px; box-shadow: 0 1px 2px rgba(15,23,42,.06); font-size: 12px; color: var(--ink, #0F172A);
}
.arric-stats:empty { display: none; }
.arric-stats b { color: var(--ott-base, #0E3B45); font-weight: 700; }
.arric-bbox-info { color: var(--ott-500, #64748B); font-size: 11px; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--ott-200, #E4E9EF); }

/* ---------- Legenda (colori REALI poligoni mappa — rosso) ---------- */
.arric-legend { padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.arric-legend > div { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ott-700, #0F2A33); margin: 0; }
.arric-legend strong { font-weight: 600; color: var(--ink, #0F172A); }
.arric-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; border: 1px solid rgba(15,23,42,.10); margin: 0; }
.arric-swatch-nct { background: #B4595A; }
.arric-swatch-nceu { background: #890103; }
.arric-swatch-unknown { background: #C9B0B0; }

/* Popup proprietario */
.arric-popup { font-size: 12px; min-width: 230px; max-width: 300px; }
.arric-popup strong { font-size: 13px; color: var(--brand-base, #0E3B45); }
.arric-popup hr { margin: 6px 0; border: 0; border-top: 1px solid #e3e9ea; }
.arric-popup .row { margin: 2px 0; }
.arric-popup .row b { color: #34474c; font-weight: 600; }
.arric-popup-fonte { color: #8a979a; font-size: 10px; margin-top: 6px; font-style: italic; }

/* Dashboard modale (legacy — PI usa finestra propria pi-dashboard.html) */
.arric-dash-overlay {
  position: fixed; inset: 0; z-index: 10001;
  background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center;
}
.arric-dash-box {
  background: #fff; border-radius: 10px; width: 92vw; max-width: 1200px; height: 86vh;
  display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.3); overflow: hidden;
}
.arric-dash-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid #eee;
}
.arric-dash-head h3 { margin: 0; font-size: 15px; color: var(--brand-base, #0E3B45); }
.arric-dash-x { border: 0; background: none; font-size: 24px; line-height: 1; cursor: pointer; color: #888; }
.arric-dash-x:hover { color: var(--brand-base, #0E3B45); }
.arric-dash-kpi { display: flex; gap: 10px; padding: 12px 18px; flex-wrap: wrap; }
.arric-dash-kpi .arric-kpi-card { min-width: 140px; }
.arric-dash-grid {
  flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
  gap: 10px; padding: 0 18px 18px; overflow: auto;
}
.arric-dash-chart { min-height: 240px; border: 1px solid #f0f0f0; border-radius: 6px; }
.arric-dash-loading { padding: 30px; text-align: center; color: #888; font-size: 13px; }

/* ===== Popup particella + subalterni (stile Mappatura) ===== */
.arric-popup-pi { min-width: 270px; max-width: 340px; }
.arric-pi-cf { font-size: 11px; color: #64748b; margin-top: 2px; }
.arric-units-wrap { max-height: 210px; overflow: auto; margin-top: 4px; }
.arric-units { width: 100%; border-collapse: collapse; font-size: 11px; }
.arric-units th {
  position: sticky; top: 0; background: #f8fafc; text-align: left; color: #64748b;
  font-weight: 600; font-size: 9.5px; text-transform: uppercase; letter-spacing: .3px;
  border-bottom: 1px solid #e3e9ea; padding: 3px 5px;
}
.arric-units td { padding: 3px 5px; border-bottom: 1px solid #f0f3f4; vertical-align: top; }
.arric-units tbody tr:last-child td { border-bottom: 0; }
.arric-units .arric-u-sub { font-weight: 600; color: var(--brand-base, #0E3B45); white-space: nowrap; }
.arric-units .arric-u-cons { color: #94a3b8; }
.arric-units .arric-u-r { text-align: right; white-space: nowrap; color: #475569; }

/* ===== Modalità Property Intelligence: spegne il pannello "Gestione perizie" ===== */
body.arric-pi-active #surfaceGroupNavWindow { display: none !important; }
