/* Calcolatore Rimborso Chilometrico ACI — stile (brand Magica) */

:root {
  --bg: #F9F9F9;
  --panel: #FFFFFF;
  --text: #253342;
  --text-2: #58636F;
  --accent: #0D62E1;
  --accent-dark: #0A4AB8;
  --accent-light: #0D93E1;
  --secondary: #5FD293;
  --secondary-dark: #3DB375;
  --border: #E3E7EC;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(37, 51, 66, .08);
}

* { box-sizing: border-box; }

body {
  font-family: 'Roboto', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  margin: 0;
  line-height: 1.6;
}

h1, h2, h3, .step-head, .accordion-button {
  font-family: 'Dosis', 'Roboto', sans-serif;
  font-weight: 700;
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: underline; }

/* --- Buttons -------------------------------------------------------------- */
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 12px 24px;
}
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

.btn-outline-accent {
  border: 1px solid var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.btn-outline-accent:hover { background: var(--accent); color: #fff; }

/* --- Header --------------------------------------------------------------- */
.site-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

/* --- Hero ----------------------------------------------------------------- */
.hero { padding: 40px 0 10px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); font-weight: 800; margin: .2rem 0 .6rem; }
.hero .lead { color: var(--text-2); max-width: 720px; font-size: 1.08rem; }
.breadcrumb { margin-bottom: .5rem; }
.page-meta {
  color: var(--text-2); font-size: .9rem; margin: 0 0 .8rem;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.page-meta a { color: var(--accent); font-weight: 600; }

/* --- Calcolatore ---------------------------------------------------------- */
.calc-section { padding: 20px 0 40px; }

.calc-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 4vw, 32px);
}

.calc-step { padding: 18px 0; border-bottom: 1px dashed var(--border); }
.calc-step:last-of-type { border-bottom: 0; }

.step-head {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.25rem; margin-bottom: 16px;
}
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 1rem; font-weight: 700;
  font-family: 'Roboto', sans-serif; flex: 0 0 auto;
}

.form-label { font-weight: 600; color: var(--text); }
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 .2rem rgba(13, 98, 225, .15);
}

/* Autocomplete */
.autocomplete-list {
  position: absolute;
  left: 12px; right: 12px;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow-y: auto;
  margin-top: 4px;
}
.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f1f3f5;
}
.autocomplete-item:last-child { border-bottom: 0; }
.autocomplete-item:hover, .autocomplete-item.active { background: #EEF4FE; }
.autocomplete-item .ac-model { font-weight: 600; }
.autocomplete-item .ac-meta { color: var(--text-2); font-size: .86rem; }
.autocomplete-empty { padding: 12px 14px; color: var(--text-2); }

.selected-vehicle {
  margin-top: 14px;
  padding: 14px 16px;
  background: #EEF4FE;
  border: 1px solid #cfe0fb;
  border-radius: 10px;
}
.selected-vehicle .sv-name { font-weight: 700; }
.selected-vehicle .sv-cost { color: var(--accent-dark); font-weight: 700; }

/* Tratte */
.leg-row { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 12px; flex-wrap: wrap; }
.leg-row .leg-km { flex: 1 1 160px; }
.leg-row .leg-trip { flex: 0 0 auto; }
.leg-row .leg-remove { flex: 0 0 auto; }
.trip-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: #f1f3f5; border-radius: 8px; padding: 8px 12px;
  cursor: pointer; user-select: none; white-space: nowrap; height: 48px;
}
.add-leg { font-weight: 600; text-decoration: none; }
.add-leg:hover { text-decoration: underline; }

/* Risultato */
.result-box { min-height: 60px; }
.result-total {
  font-family: 'Dosis', sans-serif;
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}
.result-breakdown { width: 100%; margin-top: 10px; border-collapse: collapse; }
.result-breakdown th, .result-breakdown td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; font-size: .95rem; }
.result-breakdown td.num, .result-breakdown th.num { text-align: right; white-space: nowrap; }
.result-breakdown tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: 0; }

.result-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }

.disclaimer-inline {
  margin: 18px 0 0;
  font-size: .85rem;
  color: var(--text-2);
  background: #FFF8E6;
  border: 1px solid #F3E2B3;
  border-radius: 10px;
  padding: 10px 14px;
}

/* --- CTA Magica ----------------------------------------------------------- */
.cta-magica {
  margin-top: 26px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: clamp(22px, 4vw, 34px);
  display: flex; gap: 24px; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
}
.cta-magica h2 { color: #fff; font-size: 1.5rem; margin: 0 0 8px; }
.cta-magica p { margin: 0; opacity: .95; max-width: 560px; }
.cta-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.cta-magica .btn-link { color: #fff; opacity: .9; padding: 0; }
.appstore-badge img { display: block; }

/* --- Contenuto fiscale ---------------------------------------------------- */
.content-section { padding: 30px 0 50px; }
.content-article { max-width: 760px; }
.content-article h2 { font-size: 1.6rem; margin: 36px 0 12px; }
.content-article p, .content-article li { color: var(--text); }
.content-article .formula {
  font-family: 'Dosis', sans-serif; font-weight: 700; font-size: 1.2rem;
  background: #EEF4FE; border-left: 4px solid var(--accent);
  padding: 12px 16px; border-radius: 8px; color: var(--accent-dark);
}
.content-article .note { color: var(--text-2); font-size: .92rem; font-style: italic; }
.content-article .note a { font-style: normal; }
.content-article .example {
  background: #F2FBF6; border-left: 4px solid var(--secondary-dark);
  padding: 12px 16px; border-radius: 8px;
}

/* Tabella esempi tariffe ACI */
.aci-examples { width: 100%; border-collapse: collapse; margin: 6px 0 10px; }
.aci-examples th, .aci-examples td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  text-align: left; font-size: .95rem; vertical-align: top;
}
.aci-examples thead th {
  font-family: 'Dosis', sans-serif; color: var(--text-2);
  text-transform: uppercase; font-size: .8rem; letter-spacing: .03em;
}
.aci-examples td.num, .aci-examples th.num { text-align: right; white-space: nowrap; font-weight: 600; }
.aci-examples tbody tr:hover { background: #EEF4FE; }

/* Approfondimenti / link interni */
.related-links { list-style: none; padding: 0; margin: 8px 0 0; }
.related-links li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.related-links li:last-child { border-bottom: 0; }
.related-links a { font-weight: 600; }
.related-links a::before { content: "→ "; color: var(--accent-light); }

/* Accordion brand */
.accordion-button:not(.collapsed) { background: #EEF4FE; color: var(--accent-dark); box-shadow: none; }
.accordion-button:focus { box-shadow: 0 0 0 .2rem rgba(13, 98, 225, .15); }
.accordion-button { font-size: 1.05rem; }

/* --- Footer --------------------------------------------------------------- */
.site-footer { background: var(--text); color: #cdd5de; padding: 30px 0; }
.site-footer a { color: #9ec4ff; }
.site-footer .source { font-size: .9rem; margin-bottom: 8px; }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 575.98px) {
  .cta-magica { flex-direction: column; align-items: flex-start; }
  .result-actions .btn { flex: 1 1 100%; }
  /* Tratte: km a tutta larghezza, toggle A/R a capo sotto */
  .leg-row .leg-km { flex: 1 1 100%; }
  .leg-row .trip-toggle { flex: 1 1 auto; }
}
