/* ============================================================
   ACI Justice-Flow - Stile minimale ispirato al sito ACI
   Palette: blu scuro ACI + bianco + accenti rossi
   Mobile-first: tutto è verticale di default
   ============================================================ */

:root {
    --aci-blu: #002d5b;
    --aci-blu-chiaro: #014a99;
    --aci-rosso: #d51920;
    --aci-grigio-bg: #f5f5f7;
    --aci-grigio-bordo: #dcdde0;
    --aci-testo: #1a1a1a;
    --aci-testo-chiaro: #555;
    --successo: #2e7d32;
    --avviso: #ed6c02;
    --errore: #c62828;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    color: var(--aci-testo);
    background: var(--aci-grigio-bg);
    line-height: 1.5;
}

/* -------- HEADER -------- */
.aci-header {
    background: white;
    border-bottom: 1px solid var(--aci-grigio-bordo);
}
.aci-header-inner {
    max-width: 1100px; margin: 0 auto;
    padding: 1rem 1.25rem;
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 0.75rem;
}
.aci-brand { display: flex; align-items: center; gap: 0.75rem; }
.aci-logo {
    background: var(--aci-blu); color: white;
    font-weight: 800; font-size: 1.25rem;
    padding: 0.4rem 0.7rem; border-radius: 4px;
    letter-spacing: 0.05em;
}
.aci-claim {
    font-weight: 600; color: var(--aci-blu);
    font-size: 1.05rem;
}
.aci-nav { display: flex; gap: 1.25rem; }
.aci-nav a {
    color: var(--aci-blu); text-decoration: none;
    font-weight: 500; font-size: 0.95rem;
}
.aci-nav a:hover { color: var(--aci-rosso); }

/* -------- HERO -------- */
.aci-hero {
    background: linear-gradient(135deg, var(--aci-blu) 0%, var(--aci-blu-chiaro) 100%);
    color: white;
    padding: 3rem 1.25rem;
}
.aci-hero-inner { max-width: 1100px; margin: 0 auto; }
.aci-hero h1 { margin: 0 0 0.5rem; font-size: 2rem; font-weight: 700; }
.aci-hero p { margin: 0; opacity: 0.9; font-size: 1.05rem; }
.aci-badge-demo {
    display: inline-block; margin-top: 1rem;
    background: rgba(255, 200, 0, 0.95); color: #000;
    padding: 0.4rem 0.9rem; border-radius: 999px;
    font-size: 0.85rem; font-weight: 600;
}

/* -------- MAIN -------- */
.aci-main {
    max-width: 900px; margin: -2rem auto 2rem;
    padding: 0 1.25rem;
    position: relative;
}

/* -------- CARD -------- */
.card {
    background: white;
    border: 1px solid var(--aci-grigio-bordo);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 45, 91, 0.05);
}
.card h2 {
    margin: 0 0 1rem;
    color: var(--aci-blu);
    font-size: 1.4rem;
}
.card h3 { color: var(--aci-blu); display: inline; }

/* -------- FORM UPLOAD -------- */
.file-drop {
    display: block; cursor: pointer;
    border: 2px dashed var(--aci-grigio-bordo);
    border-radius: 8px;
    padding: 2rem 1rem; margin: 1rem 0;
    text-align: center;
    transition: all 0.2s;
    background: var(--aci-grigio-bg);
}
.file-drop:hover {
    border-color: var(--aci-blu);
    background: white;
}
.file-drop input[type="file"] {
    display: block; margin: 0 auto;
}
.file-drop span {
    display: block; margin-bottom: 0.75rem;
    color: var(--aci-testo-chiaro);
}

/* -------- BOTTONI -------- */
.btn-primary, .btn-secondary {
    display: inline-block; cursor: pointer;
    padding: 0.7rem 1.5rem;
    border-radius: 6px; border: 0;
    font-size: 1rem; font-weight: 600;
    transition: opacity 0.2s, transform 0.05s;
}
.btn-primary { background: var(--aci-rosso); color: white; }
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
    background: white; color: var(--aci-blu);
    border: 2px solid var(--aci-blu);
}
.btn-secondary:hover { background: var(--aci-blu); color: white; }

.oppure {
    text-align: center; margin: 1.25rem 0;
    color: var(--aci-testo-chiaro); font-style: italic;
}

/* -------- SPINNER HTMX -------- */
.htmx-indicator {
    display: none;
    text-align: center;
    padding: 2rem;
}
.htmx-indicator.htmx-request { display: block; }
.spinner {
    width: 48px; height: 48px;
    border: 4px solid var(--aci-grigio-bordo);
    border-top-color: var(--aci-blu);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: rot 0.8s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* -------- RISULTATO -------- */
.risultato-header {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 1rem;
    margin-bottom: 1rem;
}
.prob-badge {
    padding: 0.6rem 1rem; border-radius: 8px;
    text-align: center; min-width: 130px;
    background: var(--aci-grigio-bg);
}
.prob-badge strong { display: block; font-size: 1.6rem; }
.prob-badge span { font-size: 0.78rem; color: var(--aci-testo-chiaro); }
.prob-1, .prob-2, .prob-3, .prob-4 { background: #ffebee; }
.prob-5, .prob-6, .prob-7 { background: #fff3e0; }
.prob-8, .prob-9, .prob-10 { background: #e8f5e9; }

.risultato details {
    border-top: 1px solid var(--aci-grigio-bordo);
    padding: 1rem 0;
}
.risultato details summary {
    cursor: pointer; list-style: none;
    user-select: none;
}
.risultato details summary::-webkit-details-marker { display: none; }
.risultato details summary::before {
    content: "▶"; display: inline-block;
    margin-right: 0.5rem; transition: transform 0.2s;
    color: var(--aci-blu);
}
.risultato details[open] summary::before {
    transform: rotate(90deg);
}

/* -------- TABELLA DATI -------- */
.tab-dati {
    width: 100%; border-collapse: collapse;
    margin-top: 0.5rem;
}
.tab-dati th, .tab-dati td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--aci-grigio-bordo);
    text-align: left;
    vertical-align: top;
}
.tab-dati th {
    color: var(--aci-testo-chiaro); font-weight: 500;
    width: 35%;
}

.azioni-testo-estratto {
    margin-top: 0.75rem;
}

.dialog-testo-estratto {
    width: min(920px, calc(100% - 2rem));
    border: 1px solid var(--aci-grigio-bordo);
    border-radius: 10px;
    padding: 0;
}

.dialog-testo-estratto::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid var(--aci-grigio-bordo);
    margin: 0;
}

.testo-estratto-pre {
    margin: 0;
    padding: 1rem;
    max-height: min(70vh, 620px);
    overflow: auto;
    white-space: pre-wrap;
    background: var(--aci-grigio-bg);
}

/* -------- VIZI -------- */
.vizi { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.vizio {
    padding: 1rem; border-radius: 6px;
    margin-bottom: 0.75rem;
    border-left: 4px solid var(--aci-grigio-bordo);
    background: var(--aci-grigio-bg);
}
.vizio-nullita { border-left-color: var(--errore); }
.vizio-annullabilita { border-left-color: var(--avviso); }
.vizio-irregolarita { border-left-color: #888; }
.vizio-potenziale { border-left-color: var(--aci-blu-chiaro); }
.vizio-titolo { margin-bottom: 0.5rem; }
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem; border-radius: 999px;
    font-size: 0.7rem; font-weight: 700;
    margin-right: 0.5rem;
}
.badge-nullita { background: var(--errore); color: white; }
.badge-annullabilita { background: var(--avviso); color: white; }
.badge-irregolarita { background: #888; color: white; }
.badge-potenziale { background: var(--aci-blu-chiaro); color: white; }
.norma { font-size: 0.9rem; color: var(--aci-testo-chiaro); margin: 0.4rem 0; }
.difesa { font-size: 0.92rem; margin: 0.4rem 0 0; }

/* -------- ALERT -------- */
.alert {
    padding: 0.75rem 1rem; border-radius: 6px; margin: 0.75rem 0;
}
.alert-success { background: #e8f5e9; color: var(--successo); }
.alert-info { background: #e3f2fd; color: #0d47a1; }

/* -------- CONTROLLI -------- */
.controlli { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.5rem; }
.controllo {
    flex: 1 1 220px;
    background: var(--aci-grigio-bg);
    padding: 0.75rem 1rem; border-radius: 6px;
}
.controllo h4 { margin: 0 0 0.4rem; color: var(--aci-blu); }
.controllo p { margin: 0.2rem 0; font-size: 0.92rem; }

/* -------- FORM RICORSO -------- */
.form-ricorso .grid-2 {
    display: grid; gap: 0.75rem;
    grid-template-columns: 1fr;
}
@media (min-width: 640px) {
    .form-ricorso .grid-2 { grid-template-columns: 1fr 1fr; }
}
.form-ricorso label {
    display: block; font-size: 0.9rem; font-weight: 500;
    color: var(--aci-testo-chiaro);
}
.form-ricorso input[type="text"],
.form-ricorso input[type="email"],
.form-ricorso input[type="tel"],
.form-ricorso input[type="date"] {
    width: 100%; margin-top: 0.25rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--aci-grigio-bordo);
    border-radius: 4px; font: inherit;
}
.form-ricorso input:focus {
    outline: none; border-color: var(--aci-blu);
    box-shadow: 0 0 0 3px rgba(0, 45, 91, 0.1);
}
.form-ricorso .autorita {
    margin-top: 1rem; padding: 1rem;
    border: 1px solid var(--aci-grigio-bordo);
    border-radius: 6px;
}
.form-ricorso .autorita legend { font-weight: 600; color: var(--aci-blu); }
.form-ricorso .autorita label {
    display: block; padding: 0.3rem 0; cursor: pointer;
    color: var(--aci-testo); font-weight: 400;
}
.form-ricorso button { margin-top: 1rem; }

/* -------- INFO -------- */
.aci-info ol { padding-left: 1.4rem; }
.aci-info li { margin-bottom: 0.6rem; }

/* -------- FOOTER -------- */
.aci-footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--aci-testo-chiaro);
    font-size: 0.9rem;
}
