/* =====================================================================================
   Helpdesk — design system (SaaS moderno, accento blu).
   Stile applicato sugli ELEMENTI semantici così migliora tutte le pagine via cascata,
   senza toccare il markup dei componenti. Tema chiaro + scuro (prefers-color-scheme).
   ===================================================================================== */

/* ---- Design tokens ---------------------------------------------------------------- */
:root {
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-contrast: #ffffff;
    --accent-weak: #eff6ff;
    --accent-ring: rgba(37, 99, 235, 0.35);

    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --border-strong: #d1d5db;

    --ok: #16a34a;
    --ok-weak: #dcfce7;
    --warn: #d97706;
    --warn-weak: #fef3c7;
    --danger: #dc2626;
    --danger-weak: #fee2e2;
    --info: #0891b2;
    --info-weak: #cffafe;

    --radius: 10px;
    --radius-sm: 7px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --content-max: 1180px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --accent: #3b82f6;
        --accent-hover: #60a5fa;
        --accent-contrast: #0b1220;
        --accent-weak: rgba(59, 130, 246, 0.14);
        --accent-ring: rgba(59, 130, 246, 0.45);

        --bg: #0d1117;
        --surface: #161b26;
        --surface-2: #1c2331;
        --text: #e6e9ef;
        --text-muted: #9aa4b2;
        --border: #2a3346;
        --border-strong: #3a4560;

        --ok-weak: rgba(22, 163, 74, 0.18);
        --warn-weak: rgba(217, 119, 6, 0.18);
        --danger-weak: rgba(220, 38, 38, 0.20);
        --info-weak: rgba(8, 145, 178, 0.18);
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
    }
}

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

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { color: var(--text); line-height: 1.25; font-weight: 650; margin: 0 0 0.6em; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
h1:focus { outline: none; }

p { margin: 0 0 0.8em; }

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

hr { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

small { color: var(--text-muted); }

code {
    font-family: ui-monospace, "Cascadia Code", "Fira Code", monospace;
    font-size: 0.9em;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.1em 0.35em;
}

/* ---- App shell (MainLayout) ------------------------------------------------------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    padding: 0.55rem 1.25rem;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid var(--border);
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 750;
    font-size: 1.05rem;
    color: var(--text);
    letter-spacing: -0.01em;
    margin-right: 0.75rem;
}
.app-brand:hover { text-decoration: none; }
.app-brand .dot {
    width: 0.7rem; height: 0.7rem; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    box-shadow: 0 0 0 3px var(--accent-weak);
}

.app-nav { display: inline-flex; align-items: center; gap: 0.15rem; flex-wrap: wrap; }
.app-nav a {
    color: var(--text-muted);
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
    font-weight: 550;
    font-size: 0.92rem;
    line-height: 1;
    transition: background 0.12s, color 0.12s;
}
.app-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.app-nav a.active { background: var(--accent-weak); color: var(--accent); }

.app-spacer { margin-left: auto; }

.app-user { display: inline-flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; }
.app-user .who { color: var(--text-muted); font-weight: 550; }

main {
    display: block;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 1.6rem 1.25rem 3rem;
}

/* ---- Tables (card-like) ----------------------------------------------------------- */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin: 0 0 1.25rem;
    font-size: 0.93rem;
}
thead th {
    text-align: left;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 650;
    background: var(--surface-2);
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td { padding: 0.65rem 0.85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }

/* ---- Forms & controls ------------------------------------------------------------- */
label { display: inline-block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; color: var(--text); }

input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),
select,
textarea {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.65rem;
    max-width: 100%;
    transition: border-color 0.12s, box-shadow 0.12s;
}
textarea { width: 100%; min-height: 7rem; resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }

fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.15rem; margin: 0 0 1.25rem; }
legend { font-weight: 650; padding: 0 0.4rem; }

/* ---- Buttons ---------------------------------------------------------------------- */
button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    line-height: 1.1;
    padding: 0.5rem 0.95rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--accent-contrast);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.04s;
}
button:hover, .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Varianti (aggiungibili sui bottoni chiave) */
button.secondary, .btn.secondary {
    background: var(--surface); color: var(--text); border-color: var(--border-strong);
}
button.secondary:hover, .btn.secondary:hover { background: var(--surface-2); border-color: var(--border-strong); }

button.ghost, .btn.ghost { background: transparent; color: var(--accent); border-color: transparent; }
button.ghost:hover, .btn.ghost:hover { background: var(--accent-weak); }

button.danger, .btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger:hover, .btn.danger:hover { background: #b91c1c; border-color: #b91c1c; }

button.sm, .btn.sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; }

/* ---- Cards & utilities ------------------------------------------------------------ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.35rem;
    margin: 0 0 1.25rem;
}

.muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.stack > * + * { margin-top: 0.85rem; }
.row-actions { display: inline-flex; gap: 0.4rem; flex-wrap: wrap; }

/* Campo di form verticale (label sopra, controllo a piena larghezza, allineati) */
.field { margin-bottom: 0.95rem; }
.field > label { display: block; margin-bottom: 0.3rem; }
.field > input:not([type=checkbox]):not([type=radio]),
.field > select,
.field > textarea { width: 100%; }

/* Card di autenticazione centrata (login / registrazione / reset password) */
.auth-card {
    max-width: 400px;
    margin: 2.5rem auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 1.75rem 1.85rem;
}
.auth-card h1 { font-size: 1.4rem; margin-bottom: 1.1rem; }
.auth-card button[type=submit], .auth-card .btn-block { width: 100%; margin-top: 0.25rem; }
.auth-links { margin-top: 1.1rem; font-size: 0.9rem; }
.auth-links p { margin: 0.35rem 0; }

/* Hero / benvenuto (home) */
.hero { padding: 2rem 2.25rem; }
.hero h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.lead { font-size: 1.08rem; color: var(--text-muted); max-width: 62ch; margin-bottom: 1.3rem; }

/* Contenitore form a larghezza contenuta (nuovo ticket ecc.) */
.form-narrow { max-width: 640px; }

/* Callout informativo (es. suggerimenti KB in fase di apertura ticket) */
.callout {
    background: var(--accent-weak);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    margin: 0.25rem 0 0.5rem;
}
.callout ul { margin: 0.4rem 0 0; padding-left: 1.1rem; line-height: 1.8; }

/* ---- Badges (stato / priorità) ---------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: 0.3rem;
    font-size: 0.76rem; font-weight: 650; line-height: 1;
    padding: 0.28rem 0.55rem; border-radius: var(--radius-pill);
    background: var(--surface-2); color: var(--text-muted);
    border: 1px solid var(--border);
}
.badge.ok { background: var(--ok-weak); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-weak); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-weak); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-weak); color: var(--info); border-color: transparent; }
.badge.accent { background: var(--accent-weak); color: var(--accent); border-color: transparent; }

/* ---- Timeline (dettaglio ticket) -------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--border); }
.timeline > li { position: relative; padding: 0 0 1rem 0.9rem; }
.timeline > li::before {
    content: ""; position: absolute; left: -1.52rem; top: 0.35rem;
    width: 0.7rem; height: 0.7rem; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--accent);
}

/* ---- Validazione (ASP.NET Core) --------------------------------------------------- */
.valid.modified:not([type=checkbox]) { outline: none; border-color: var(--ok) !important; }
.invalid { border-color: var(--danger) !important; }
.validation-message { color: var(--danger); font-size: 0.85rem; margin-top: 0.25rem; }

/* ---- Blazor error UI -------------------------------------------------------------- */
.blazor-error-boundary {
    background: var(--danger); color: #fff;
    border-radius: var(--radius); padding: 1rem 1.15rem; margin: 0 0 1rem;
}
.blazor-error-boundary::after { content: "Si è verificato un errore."; }

/* ---- Responsive ------------------------------------------------------------------- */
@media (max-width: 720px) {
    .app-header { padding: 0.5rem 0.85rem; }
    .app-nav a { padding: 0.35rem 0.55rem; }
    main { padding: 1.1rem 0.85rem 2.5rem; }
    table { font-size: 0.88rem; }
    thead th, tbody td { padding: 0.5rem 0.6rem; }
}
