/*
  Palette e struttura basate sul design system ufficiale della PA italiana
  (Bootstrap Italia / Designers Italia): primary #0066CC "Blu Italia",
  danger #cc334d, warning #995c00, success #008055, font Titillium Web,
  header a 3 fasce (slim / brand / navbar) e footer a due fasce.
*/
:root {
  --bg: #f2f2f2;
  --surface: #ffffff;
  --text: #303031;
  --text-muted: #5c6f7a;
  --border: #c5c7c9;
  --primary: #0066cc;
  --primary-dark: #003d7a;
  --primary-darker: #17313f;
  --danger: #cc334d;
  --danger-bg: #fbe6e9;
  --warning: #995c00;
  --warning-bg: #fdf0dc;
  --success: #008055;
  --radius: 4px;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10161a;
    --surface: #182028;
    --text: #eef2f5;
    --text-muted: #a4b1ba;
    --border: #2b363e;
    --primary: #5b9bd9;
    --primary-dark: #7fb0e0;
    --primary-darker: #0d1b24;
    --danger: #ff7a70;
    --danger-bg: #2c1615;
    --warning: #f0c869;
    --warning-bg: #2a2210;
    --success: #57d17b;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Titillium Web", Geneva, Tahoma, sans-serif;
  line-height: 1.6;
  font-size: 16px;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 18px;
}

a { color: var(--primary); }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: #fff;
  color: var(--primary-darker);
  padding: 10px 16px;
  z-index: 100;
}
.skip-link:focus { left: 0; }

h1, h2, h3, h4 { font-family: "Titillium Web", Geneva, Tahoma, sans-serif; font-weight: 700; }

/* ============ HEADER (it-header-wrapper a 3 fasce) ============ */

.it-header-slim-wrapper {
  background: var(--primary-darker);
  padding: 7px 0;
}
.it-header-slim-wrapper-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.slim-label {
  color: #fff;
  font-size: 0.78rem;
  opacity: 0.9;
}
.slim-right { display: flex; gap: 18px; }
.slim-right a {
  color: #fff;
  font-size: 0.78rem;
  text-decoration: none;
}
.slim-right a:hover { text-decoration: underline; }

.it-header-center-wrapper {
  background: var(--primary-dark);
}
.it-header-center-content {
  display: flex;
  align-items: center;
  min-height: 84px;
  padding: 14px 0;
}
.it-brand-wrapper {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #fff;
  text-decoration: none;
}
.brand-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-icon svg { width: 40px; height: 40px; color: #fff; }
.it-brand-text { display: flex; flex-direction: column; }
.brand-title { font-size: 1.35rem; font-weight: 700; line-height: 1.15; }
.brand-subtitle { font-size: 0.82rem; font-weight: 400; opacity: 0.92; margin-top: 2px; }

.it-header-navbar-wrapper {
  background: var(--surface);
  border-bottom: 3px solid var(--primary);
  box-shadow: var(--shadow);
}
.navbar-content { display: flex; gap: 22px; padding: 10px 0; }
.navbar-crumb {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-darker);
  text-decoration: none;
  padding: 4px 2px;
}
.navbar-crumb:hover { text-decoration: underline; color: var(--primary); }

/* ============ MAIN ============ */

main.wrap { padding-top: 36px; padding-bottom: 48px; }

.search-section h1 { font-size: 1.7rem; margin: 0 0 8px; color: var(--primary-darker); }
.lede { color: var(--text-muted); margin: 0 0 20px; }

.search-form { position: relative; }
.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 4px 4px 14px;
  box-shadow: var(--shadow);
}
.search-box:focus-within { border-color: var(--primary); outline: 2px solid var(--primary); outline-offset: 1px; }
.search-icon { display: flex; color: var(--text-muted); flex-shrink: 0; }
.search-icon svg { width: 20px; height: 20px; }
#search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  padding: 12px 6px;
  outline: none;
}
#search-button {
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.92rem;
  padding: 11px 22px;
  border-radius: 2px;
  cursor: pointer;
}
#search-button:hover { background: var(--primary-dark); }

.suggestions {
  list-style: none;
  margin: 6px 0 0;
  padding: 6px;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 10;
  max-height: 280px;
  overflow-y: auto;
}
.suggestions li {
  padding: 10px 12px;
  border-radius: 2px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.suggestions li:hover, .suggestions li.active { background: var(--bg); }
.suggestions .s-name { font-weight: 600; }
.suggestions .s-tag {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-bg);
  padding: 1px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.result-area { margin-top: 24px; }

.result-card {
  border-radius: var(--radius);
  padding: 22px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--surface);
}
.result-card.danger { border-color: var(--danger); border-left-color: var(--danger); }
.result-card.danger h2 { color: var(--danger); }
.result-card.caution { border-color: var(--warning); border-left-color: var(--warning); }
.result-card.caution h2 { color: var(--warning); }

.result-card h2 { margin: 0 0 10px; font-size: 1.2rem; display: flex; align-items: center; gap: 10px; }
.result-card h2 svg { width: 24px; height: 24px; flex-shrink: 0; }
.result-card p { margin: 0 0 10px; }
.result-card ul { margin: 0 0 10px; padding-left: 20px; }
.result-meta {
  font-size: 0.86rem;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}
.result-meta div { margin-bottom: 4px; }

.result-card.multi .broker-item { padding: 14px 0; border-top: 1px solid var(--border); }
.result-card.multi .broker-item:first-of-type { padding-top: 0; border-top: none; }
.broker-item.unconfirmed h2 { color: var(--warning); }

.loading { color: var(--text-muted); padding: 14px 0; }

.report-section { margin-top: 48px; }
.report-section h2 { font-size: 1.25rem; margin-bottom: 12px; color: var(--primary-darker); }
.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.contact-list { list-style: none; padding: 0; margin: 16px 0; }
.contact-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.li-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  color: var(--primary);
  margin-top: 1px;
}
.li-icon svg { width: 100%; height: 100%; }
.muted { color: var(--text-muted); font-size: 0.9rem; }

.result-cta {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.assist-cta-btn {
  display: inline-block;
  border: none;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 13px 28px;
  border-radius: 2px;
  cursor: pointer;
}
.assist-cta-btn:hover { background: var(--primary-dark); }

.assist-broker-banner {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 0.92rem;
}

.assist-callout {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.92rem;
}

/* ============ Autorità estera (nel risultato di ricerca) ============ */
.foreign-authority {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}
.foreign-authority-title { font-weight: 700; margin-bottom: 6px; }
.foreign-authority-note { color: var(--text-muted); font-size: 0.82rem; margin-top: 4px; }

/* ============ Modulo assistenza ============ */
.assist-section { margin-top: 48px; }
.assist-section h2 { font-size: 1.25rem; margin-bottom: 8px; color: var(--primary-darker); }

.assist-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-top: 16px;
}
.assist-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}
.assist-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 14px;
}
.assist-grid label { margin-top: 0; }
.assist-full { grid-column: 1 / -1; }
.assist-form input[type="text"],
.assist-form input[type="tel"],
.assist-form input[type="email"],
.assist-form input[type="file"],
.assist-form textarea {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.assist-form textarea { resize: vertical; }
.assist-form input:focus, .assist-form textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}
.assist-hint { font-weight: 400; color: var(--text-muted); font-size: 0.8rem; }

.assist-consent {
  flex-direction: row !important;
  align-items: flex-start;
  gap: 10px !important;
  font-weight: 400 !important;
  font-size: 0.85rem !important;
  color: var(--text) !important;
}
.assist-consent input[type="checkbox"] { margin-top: 3px; flex-shrink: 0; width: 16px; height: 16px; }

.assist-form .form-actions { margin-top: 20px; padding-top: 0; border-top: none; }
.assist-form button[type="submit"] {
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.92rem;
  padding: 11px 26px;
  border-radius: 2px;
  cursor: pointer;
}
.assist-form button[type="submit"]:hover { background: var(--primary-dark); }
.assist-form button[type="submit"]:disabled { opacity: 0.6; cursor: default; }

#assist-result { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius); font-size: 0.9rem; }
#assist-result.ok { background: var(--danger-bg); background: #e5f5ec; color: #1f7a34; border: 1px solid #b7e0c6; }
#assist-result.error { background: var(--danger-bg); color: #8a1f1a; border: 1px solid #f0b8bf; }

@media (max-width: 640px) {
  .assist-grid { grid-template-columns: 1fr; }
}

/* ============ FOOTER (it-footer a due fasce) ============ */

.it-footer { margin-top: 48px; }
.it-footer-main {
  background: var(--primary-darker);
  color: #fff;
  padding: 32px 0;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 26px;
}
.footer-grid h4 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 8px;
  color: #fff;
}
.footer-grid p { margin: 0; font-size: 0.88rem; opacity: 0.92; }
.footer-grid a { color: #fff; }

.it-footer-small-prints {
  background: var(--primary-dark);
  padding: 12px 0;
}
.small-prints-content {
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  padding-top: 12px;
  font-size: 0.78rem;
  color: #fff;
  opacity: 0.85;
}
