/* Portale ticket – foglio di stile unico, nessuna risorsa esterna */

:root {
    --paper:   #F3F5F8;
    --surface: #FFFFFF;
    --ink:     #17213A;
    --muted:   #5B6579;
    --line:    #D9DFE7;
    --brand:   #1E4D8C;
    --brand-ink: #FFFFFF;

    --open:    #0B7A72;
    --open-bg: #E3F4F2;
    --wait:    #A35A00;
    --wait-bg: #FCEFD9;
    --closed:  #69717F;
    --closed-bg: #ECEEF1;
    --danger:  #A3332B;
    --danger-bg: #FBE7E5;

    --radius-s: 4px;
    --radius-m: 8px;
    --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper:   #0F151E;
        --surface: #17202C;
        --ink:     #E5E9EF;
        --muted:   #9AA4B3;
        --line:    #2A3545;
        --brand:   #7DB0EC;
        --brand-ink: #0F151E;

        --open:    #43C6BA;
        --open-bg: #12302E;
        --wait:    #F0AC4B;
        --wait-bg: #36290F;
        --closed:  #9199A6;
        --closed-bg: #232B37;
        --danger:  #F08A80;
        --danger-bg: #3A1D1B;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 16px/1.55 var(--font);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--brand); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 2px; }

h1, h2 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 650; margin-bottom: .6rem; }

.wrap { width: 100%; max-width: 920px; margin: 0 auto; padding: 0 20px; }
.main { flex: 1; padding-top: 32px; padding-bottom: 48px; }
.muted { color: var(--muted); }

/* ---------- Barra superiore ---------- */

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }

.brand { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); line-height: 1.2; padding: 10px 0; }
.brand__name { font-weight: 700; font-size: 1.05rem; }
.brand__app { color: var(--muted); font-size: .85rem; }

.who { display: flex; align-items: center; gap: 14px; }
.who form { margin: 0; }
.who__name { text-align: right; font-size: .92rem; line-height: 1.3; }
.who__org { display: block; color: var(--muted); font-size: .82rem; }

/* ---------- Pulsanti ---------- */

.btn {
    display: inline-block;
    font: inherit; font-weight: 600;
    border: 1px solid var(--brand);
    background: var(--brand); color: var(--brand-ink);
    padding: 9px 18px; border-radius: var(--radius-s);
    cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn--quiet { background: transparent; color: var(--brand); border-color: var(--line); font-weight: 500; padding: 6px 12px; }
.btn--quiet:hover { border-color: var(--brand); filter: none; }

/* ---------- Login ---------- */

.login { max-width: 400px; margin: 24px auto 0; }
.login .lead { color: var(--muted); margin: .4rem 0 1.5rem; }
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; }
.field input {
    font: inherit; font-weight: 400;
    padding: 10px 12px;
    border: 1px solid var(--line); border-radius: var(--radius-s);
    background: var(--surface); color: var(--ink);
}
.field input:focus-visible { border-color: var(--brand); }
.form .btn { justify-self: start; }
.hint { color: var(--muted); font-size: .9rem; margin-top: 1.5rem; }

.alert {
    background: var(--danger-bg); color: var(--danger);
    border-left: 4px solid var(--danger);
    padding: 10px 14px; border-radius: var(--radius-s);
    margin: 0 0 16px;
}

/* ---------- Elenco ticket ---------- */

.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; background: var(--surface); }
.seg__item { padding: 7px 16px; text-decoration: none; color: var(--muted); font-size: .92rem; font-weight: 500; }
.seg__item + .seg__item { border-left: 1px solid var(--line); }
.seg__item:hover { color: var(--ink); }
.seg__item[aria-current="page"] { background: var(--ink); color: var(--paper); }

.tlist { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.tlist li + li { border-top: 1px solid var(--line); }

/* La riga del ticket: binario colorato a sinistra = stato, numero grande in cifre tabellari */
.trow {
    display: grid;
    grid-template-columns: 5.5rem 1fr auto;
    align-items: center; gap: 16px;
    padding: 14px 18px 14px 14px;
    text-decoration: none; color: var(--ink);
    border-left: 5px solid var(--open);
}
.trow:hover { background: var(--paper); }
.trow--waiting { border-left-color: var(--wait); }
.trow--closed  { border-left-color: var(--closed); }

.trow__num { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; color: var(--ink); }
.trow--closed .trow__num { color: var(--muted); }
.trow__main { display: grid; gap: 2px; min-width: 0; }
.trow__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow__meta { color: var(--muted); font-size: .85rem; }

.pill { display: inline-block; font-size: .8rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill--open    { color: var(--open);   background: var(--open-bg); }
.pill--waiting { color: var(--wait);   background: var(--wait-bg); }
.pill--closed  { color: var(--closed); background: var(--closed-bg); }

.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius-m); padding: 28px; }
.empty p { margin: 0 0 .4rem; }
.empty p:first-child { font-weight: 600; }

.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 20px; flex-wrap: wrap; }
.pager__info { color: var(--muted); font-size: .9rem; }

/* ---------- Dettaglio ticket ---------- */

.back { display: inline-block; margin-bottom: 18px; font-size: .92rem; }

.case-head { border-left: 5px solid var(--open); padding: 2px 0 2px 16px; margin-bottom: 20px; }
.case-head--waiting { border-left-color: var(--wait); }
.case-head--closed  { border-left-color: var(--closed); }
.case-head__num { margin: 0 0 4px; font-size: 1rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.case-head h1 { margin-bottom: 10px; max-width: 60ch; overflow-wrap: anywhere; }

.callout { background: var(--wait-bg); color: var(--ink); border-left: 4px solid var(--wait); padding: 12px 16px; border-radius: var(--radius-s); margin: 0 0 20px; }

.facts {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1px; background: var(--line);
    border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden;
    margin: 0 0 28px;
}
.facts div { background: var(--surface); padding: 12px 14px; }
.facts dt { color: var(--muted); font-size: .82rem; }
.facts dd { margin: 2px 0 0; font-weight: 600; }

.block { margin-bottom: 28px; }
.prose { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px 18px; max-width: 75ch; overflow-wrap: anywhere; }
.prose p { margin: 0; }
.block--resolution .prose { border-left: 4px solid var(--open); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); display: grid; gap: 16px; }
.timeline__item { position: relative; }
.timeline__item::before {
    content: ""; position: absolute; left: -25px; top: 6px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--brand); border: 2px solid var(--paper);
}
.timeline__item--client::before { background: var(--muted); }
.timeline__head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.timeline__head time { color: var(--muted); font-size: .85rem; }
.timeline__item--client .prose { background: var(--paper); }

/* ---------- Errori e piè di pagina ---------- */

.errorpage { max-width: 560px; }
.errorpage p { margin: .8rem 0; }

.foot { padding-top: 18px; padding-bottom: 28px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }

/* ---------- Mobile ---------- */

@media (max-width: 600px) {
    h1 { font-size: 1.35rem; }
    .trow { grid-template-columns: 1fr auto; grid-template-areas: "num pill" "main main"; gap: 6px 12px; }
    .trow__num { grid-area: num; font-size: 1.15rem; }
    .trow .pill { grid-area: pill; justify-self: end; }
    .trow__main { grid-area: main; }
    .trow__title { white-space: normal; }
    .who__name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
