/* =========================================================
   DDT Scan - design system (famiglia FuturaLine / App Pianali)
   ---------------------------------------------------------
     0. Token          4. Pulsanti        8. Chip e badge
     1. Reset          5. Campi           9. Stati vuoti, spinner
     2. Tipografia     6. Pannelli       10. Blazor (errori, reconnect)
     3. Icone          7. Avvisi         11. Movimento ridotto
   Regole: azione primaria sempre verde con testo navy, input mai
   sotto 16px (zoom iOS), stati mai affidati al solo colore.
   ========================================================= */

/* 0. Token */
:root {
    --c-bg: #eef1f5;
    --c-surface: #ffffff;
    --c-surface-2: #f6f8fb;
    --c-ink: #0f1f33;
    --c-muted: #536273;
    --c-line: #d5dce6;
    --c-line-soft: #e6ebf1;

    --c-navy: #0e2a4a;
    --c-navy-700: #163a63;
    --c-navy-900: #0a1f38;
    --c-navy-tint: #e6edf5;
    --c-green: #7fb539;
    --c-green-600: #6aa02c;
    --c-green-text: #3f6d12;
    --c-green-tint: #e6f2d5;

    --c-blue-text: #123e86;
    --c-blue-tint: #e3ecfb;
    --c-amber: #e0a400;
    --c-amber-text: #7a4e00;
    --c-amber-tint: #fff0c9;
    --c-red: #c4291f;
    --c-red-text: #9b1c14;
    --c-red-tint: #fbe7e5;

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 14px;
    --r-pill: 999px;

    --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;

    --topbar-h: 60px;
    --content-max: 1560px;
    --gutter: 24px;

    --shadow-card: 0 1px 2px rgba(14, 34, 56, .04), 0 6px 18px rgba(14, 34, 56, .05);
    --shadow-modal: 0 18px 40px rgba(14, 34, 56, .22);
    --ease: cubic-bezier(.2, .8, .2, 1);
    --focus: #6aa02c;
}

@media (max-width: 640px) {
    :root { --gutter: 16px; --topbar-h: 56px; }
}

/* 1. Reset (sostituisce Bootstrap) */
*, *::before, *::after { box-sizing: border-box; }

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

html, body {
    min-height: 100%;
    margin: 0;
    background: var(--c-bg);
    color: var(--c-ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, figure, dl, dd { margin: 0; }
h1, h2, h3, h4 { color: var(--c-navy); font-weight: 800; letter-spacing: -.01em; line-height: 1.2; }
ol, ul { margin: 0; padding: 0; list-style: none; }
a { color: var(--c-blue-text); }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; margin: 0; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; }
code { font-family: var(--font-mono); }
[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1:focus, h1:focus-visible { outline: none; }

/* 2. Tipografia e utility */
.muted { color: var(--c-muted); }
.tnum { font-variant-numeric: tabular-nums; }
.truncate { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}
.eyebrow {
    color: var(--c-green-text);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

/* 3. Icone (SVG inline, dimensione da --icon-size) */
.icon {
    width: var(--icon-size, 20px);
    height: var(--icon-size, 20px);
    flex: 0 0 var(--icon-size, 20px);
    fill: none;
    stroke: currentColor;
    stroke-width: var(--icon-stroke, 2);
    stroke-linecap: round;
    stroke-linejoin: round;
}
.brand-mark { width: var(--mark-size, 36px); height: var(--mark-size, 36px); flex: 0 0 var(--mark-size, 36px); border-radius: 22%; }

/* 4. Pulsanti */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 1.5px solid transparent;
    border-radius: var(--r-md);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
    -webkit-user-select: none;
    user-select: none;
}
.btn:disabled { opacity: .5; }
.btn-primary { background: var(--c-green); color: var(--c-navy); }
.btn-primary:hover:not(:disabled) { background: var(--c-green-600); }
.btn-secondary { background: var(--c-surface); color: var(--c-navy); border-color: var(--c-line); }
.btn-secondary:hover:not(:disabled) { background: var(--c-navy-tint); border-color: #c3cedb; }
.btn-lg { min-height: 52px; font-size: 16px; padding: 0 22px; }
.btn-block { width: 100%; }

.btn-icon {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: var(--r-sm);
    color: var(--c-muted);
    transition: background-color .15s var(--ease), color .15s var(--ease);
    --icon-size: 18px;
}
.btn-icon:hover:not(:disabled) { background: var(--c-red-tint); color: var(--c-red-text); }
.btn-icon:disabled { opacity: .4; }

/* 5. Campi */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: 14px; font-weight: 700; color: var(--c-navy); }
.input {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border: 1.5px solid var(--c-line);
    border-radius: var(--r-md);
    background: var(--c-surface);
    color: var(--c-ink);
    font-size: 16px;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
    -webkit-appearance: none;
    appearance: none;
}
.input::placeholder { color: #7d8a99; }
.input:hover { border-color: #b9c5d3; }
.input:focus, .input:focus-visible { outline: none; border-color: var(--c-green-600); box-shadow: 0 0 0 3px rgba(127, 181, 57, .35); }

/* 6. Pannelli */
.panel {
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-card);
    min-width: 0;
}
.panel__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 16px;
    padding: 20px 22px 0;
}
.panel__title { font-size: 17px; }
.panel__subtitle { color: var(--c-muted); font-size: 14px; margin-top: 3px; }
.panel__body { padding: 16px 22px 22px; }
@media (max-width: 640px) {
    .panel__head { padding: 16px 16px 0; }
    .panel__body { padding: 14px 16px 16px; }
}

/* 7. Avvisi */
.notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    font-size: 14.5px;
    line-height: 1.4;
    --icon-size: 20px;
}
.notice > .icon { margin-top: 1px; }
.notice strong { font-weight: 700; }
.notice--error { background: var(--c-red-tint); color: var(--c-red-text); }
.notice--warning { background: var(--c-amber-tint); color: var(--c-amber-text); }
.notice--info { background: var(--c-blue-tint); color: var(--c-blue-text); }
.notice--ok { background: var(--c-green-tint); color: var(--c-green-text); }

/* 8. Chip e badge */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 26px;
    padding: 0 9px;
    border-radius: var(--r-sm);
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
    --icon-size: 14px;
    --icon-stroke: 2.6;
}
.badge--ok { background: var(--c-green-tint); color: var(--c-green-text); }
.badge--warning { background: var(--c-amber-tint); color: var(--c-amber-text); }
.badge--error { background: var(--c-red-tint); color: var(--c-red-text); }
.badge--muted { background: var(--c-navy-tint); color: var(--c-navy); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 24px;
    padding: 2px 9px;
    border-radius: var(--r-pill);
    background: var(--c-navy-tint);
    color: var(--c-navy);
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    --icon-size: 14px;
    --icon-stroke: 2.4;
}
.chip--ok { background: var(--c-green-tint); color: var(--c-green-text); }
.chip--warning { background: var(--c-amber-tint); color: var(--c-amber-text); }
.chip--error { background: var(--c-red-tint); color: var(--c-red-text); }
.chip--info { background: var(--c-blue-tint); color: var(--c-blue-text); }

/* 9. Spinner */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border-radius: 50%;
    border: 2.5px solid rgba(14, 42, 74, .2);
    border-top-color: var(--c-navy);
    animation: ddt-spin .8s linear infinite;
}
.spinner--sm { width: 14px; height: 14px; flex-basis: 14px; border-width: 2px; }
@keyframes ddt-spin { to { transform: rotate(360deg); } }

/* Pagine di servizio (errore, non trovata) */
.status-page {
    max-width: 560px;
    margin: 32px auto;
    padding: 32px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}
.status-page h1 { font-size: 22px; }
.status-page p { color: var(--c-muted); }
.status-page .btn { margin-top: 6px; }
.status-page__icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--c-navy-tint);
    color: var(--c-navy);
    --icon-size: 28px;
}
.status-page__icon--error { background: var(--c-red-tint); color: var(--c-red-text); }
.status-page__code code { padding: 2px 6px; border-radius: 6px; background: var(--c-surface-2); font-size: 13px; color: var(--c-ink); }

/* 10. Blazor: errore circuito e riconnessione */
.blazor-error-boundary {
    background: var(--c-red-tint);
    color: var(--c-red-text);
    border-radius: var(--r-md);
    padding: 12px 14px;
}
.blazor-error-boundary::after { content: "Si è verificato un errore in questa sezione."; }

/* 11. Movimento ridotto */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; scroll-behavior: auto !important; }
    .spinner { animation-duration: 1.6s; }
}
