﻿/* ===== Token (colori dal logo Moovix) ===== */
:root {
    --teal: #00d8b4;
    --ocean: #0b80b0;
    --indigo: #5a4ff6;
    --violet: #8a3ee6;
    --brand-gradient: linear-gradient(90deg, var(--teal) 0%, var(--ocean) 100%);
    --accent-gradient: linear-gradient(135deg, var(--indigo) 0%, var(--violet) 100%);

    --sidebar-bg: #12142a;
    --sidebar-bg-2: #1a1d38;
    --sidebar-text: #a4a8c7;
    --sidebar-text-strong: #ffffff;

    --page-bg: #f5f6fa;
    --surface: #ffffff;
    --border: #e6e8f0;
    --text: #1b1d33;
    --text-muted: #6b6f8a;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(18, 20, 42, .04), 0 4px 16px rgba(18, 20, 42, .05);
    --sidebar-width: 264px;
    --topbar-height: 68px;

    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-title: "Plus Jakarta Sans", var(--font-body);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--page-bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3 { font-family: var(--font-title); color: var(--text); margin: 0; }
h1:focus { outline: none; }

/* ===== Struttura ===== */
.shell { display: flex; min-height: 100vh; }

.nav-toggle { display: none; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    color: var(--sidebar-text);
    z-index: 30;
    transition: transform .25s ease;
}

.brand {
    display: flex;
    align-items: center;
    height: var(--topbar-height);
    padding: 0 26px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

    .brand img { height: 30px; width: auto; display: block; }

.nav { padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; }

.nav-label {
    padding: 0 12px 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #6a6e93;
}

.nav-item + .nav-label { margin-top: 18px; }

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    color: var(--sidebar-text);
    transition: background .15s ease, color .15s ease;
}

    .nav-item svg { flex-shrink: 0; opacity: .85; }

    .nav-item:hover { background: rgba(255, 255, 255, .05); color: var(--sidebar-text-strong); }

    .nav-item.active {
        background: linear-gradient(90deg, rgba(0, 216, 180, .16) 0%, rgba(11, 128, 176, .10) 100%);
        color: var(--sidebar-text-strong);
    }

        .nav-item.active svg { color: var(--teal); opacity: 1; }

        .nav-item.active::before {
            content: "";
            position: absolute;
            left: -14px;
            top: 8px;
            bottom: 8px;
            width: 3px;
            border-radius: 0 3px 3px 0;
            background: var(--brand-gradient);
        }

.sidebar-footer {
    margin-top: auto;
    padding: 18px 26px;
    font-size: 12px;
    color: #5d6187;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.backdrop { display: none; }

.main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

/* ===== Barra in alto ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 32px;
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.topbar-spacer { flex: 1; }

.menu-button {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
}

    .menu-button:hover { background: var(--page-bg); }

.user { display: flex; align-items: center; gap: 11px; padding-right: 16px; border-right: 1px solid var(--border); }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 0 0 3px rgba(90, 79, 246, .12);
}

.user-text { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 14px; }
.user-role { font-size: 12px; color: var(--text-muted); }

.logout {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 38px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--surface);
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}

    .logout:hover { color: #c0283d; border-color: #f3c6cd; background: #fff5f6; }

/* ===== Contenuto ===== */
.content { padding: 32px; max-width: 1280px; width: 100%; }

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

    .page-header h1 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
    .page-header p { margin: 4px 0 0; color: var(--text-muted); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.empty-state { padding: 64px 24px; text-align: center; }

    .empty-state h2 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
    .empty-state p { margin: 0 auto 20px; max-width: 420px; color: var(--text-muted); }
    .empty-state p:last-child { margin-bottom: 0; }

.empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: 18px;
    border-radius: 18px;
    color: var(--ocean);
    background: linear-gradient(135deg, rgba(0, 216, 180, .14) 0%, rgba(11, 128, 176, .14) 100%);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: var(--radius-sm);
    font: 600 14px var(--font-body);
    cursor: pointer;
    white-space: nowrap;
    transition: filter .15s ease, box-shadow .15s ease;
}

.btn-primary {
    color: #fff;
    background: var(--brand-gradient);
    box-shadow: 0 4px 14px rgba(11, 128, 176, .25);
}

    .btn-primary:hover:not(:disabled) { filter: brightness(1.06); box-shadow: 0 6px 18px rgba(11, 128, 176, .32); }
    .btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

.muted { color: var(--text-muted); margin: 0; }

/* ===== Dashboard ===== */
.shortcut-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }

.shortcut {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

    .shortcut:hover { border-color: rgba(11, 128, 176, .35); box-shadow: 0 8px 24px rgba(18, 20, 42, .08); transform: translateY(-1px); }

.shortcut-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    color: var(--ocean);
    background: linear-gradient(135deg, rgba(0, 216, 180, .14) 0%, rgba(11, 128, 176, .14) 100%);
}

.shortcut-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.shortcut-title { font-family: var(--font-title); font-weight: 700; font-size: 16px; }
.shortcut-desc { font-size: 13.5px; color: var(--text-muted); }
.shortcut-arrow { flex-shrink: 0; color: #b4b8cf; transition: color .15s ease, transform .15s ease; }
.shortcut:hover .shortcut-arrow { color: var(--ocean); transform: translateX(2px); }

/* ===== Elenco e dettaglio ===== */
.master-detail { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }

.list-panel { overflow: hidden; }

.list-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.count {
    min-width: 22px;
    padding: 1px 7px;
    border-radius: 11px;
    background: var(--page-bg);
    text-align: center;
    letter-spacing: 0;
}

.list { list-style: none; margin: 0; padding: 8px; display: flex; flex-direction: column; gap: 2px; }

.list-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    transition: background .15s ease;
}

    .list-item:hover { background: var(--page-bg); }

    .list-item.selected { background: linear-gradient(90deg, rgba(0, 216, 180, .12) 0%, rgba(11, 128, 176, .08) 100%); }

        .list-item.selected::before {
            content: "";
            position: absolute;
            left: 0;
            top: 10px;
            bottom: 10px;
            width: 3px;
            border-radius: 0 3px 3px 0;
            background: var(--brand-gradient);
        }

.list-item-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: var(--text-muted);
    background: var(--page-bg);
}

.list-item.selected .list-item-icon { color: var(--ocean); background: #fff; }

.list-item-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.list-item-title { font-weight: 600; font-size: 14px; }
.list-item-desc { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.detail-panel { min-height: 320px; }
.detail { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.detail-head { padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
    .detail-head h2 { font-size: 20px; font-weight: 800; }
    .detail-head p { margin: 4px 0 0; color: var(--text-muted); }

/* ===== Sezioni ===== */
.section-card { overflow: hidden; }

.section-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    transition: background .15s ease;
}

    .section-head:hover { background: #fafbfd; }

.section-chevron { flex-shrink: 0; color: var(--text-muted); transition: transform .2s ease; }
.section-card.open .section-chevron { transform: rotate(90deg); color: var(--ocean); }

.section-title { flex: 1; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
    .section-title h3 { font-size: 16px; font-weight: 700; }

.tag {
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--page-bg);
    color: var(--text-muted);
    font: 500 12px ui-monospace, "Cascadia Code", Consolas, monospace;
}

.dirty {
    padding: 2px 9px;
    border-radius: 11px;
    background: #fff4e0;
    color: #a2620a;
    font-size: 12px;
    font-weight: 600;
}

.section-visibility { font-size: 13px; font-weight: 600; color: #0f7a64; }
    .section-visibility .off { color: var(--text-muted); }

.section-body { padding: 4px 20px 22px 50px; border-top: 1px solid var(--border); padding-top: 20px; }

.section-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: #fafbfd;
}

    .section-foot .muted { margin-right: auto; font-size: 13px; }

.error { margin: 0; padding: 12px 14px; border-radius: var(--radius-sm); background: #fdecee; color: #b3243a; }

/* ===== Campi ===== */
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px 18px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
    .field > label { font-size: 13px; font-weight: 600; color: #3b3e58; }

.field-wide, .field-group { grid-column: 1 / -1; }

.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dcdfea;
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text);
    font: 400 14px var(--font-body);
    transition: border-color .15s ease, box-shadow .15s ease;
}

    .input::placeholder { color: #a6aac2; }
    .input:hover { border-color: #c5c9da; }
    .input:focus { outline: none; border-color: var(--ocean); box-shadow: 0 0 0 3px rgba(11, 128, 176, .15); }

textarea.input { resize: vertical; min-height: 96px; line-height: 1.5; }

.field-group {
    margin: 0;
    padding: 16px 18px 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fbfbfd;
    min-width: 0;
}

    .field-group > legend {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 0 6px;
        font-family: var(--font-title);
        font-size: 13.5px;
        font-weight: 700;
    }

    .field-group .field-group { background: #fff; }

/* Array: un pulsante meno per elemento, un pulsante più in fondo */
.array-item { position: relative; }
    .array-item > .array-remove { position: absolute; top: 8px; right: 10px; }

.array-row { display: flex; align-items: flex-end; gap: 8px; grid-column: 1 / -1; }
    .array-row > .field { flex: 1; }
    .array-row > .array-remove { margin-bottom: 7px; }

.array-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text-muted);
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}

    .array-remove:hover { color: #b3243a; border-color: #f1c2ca; background: #fdecee; }
    .array-remove:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(179, 36, 58, .2); }

.array-add {
    grid-column: 1 / -1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px dashed #c5c9da;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ocean);
    font: 600 13.5px var(--font-body);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}

    .array-add:hover { border-color: var(--ocean); background: #f3f9fc; }
    .array-add:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(11, 128, 176, .25); }

/* Interruttore: checkbox restilizzato */
.field-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }

.switch {
    appearance: none;
    flex-shrink: 0;
    position: relative;
    width: 40px;
    height: 22px;
    margin: 0;
    border-radius: 11px;
    background: #d5d8e4;
    cursor: pointer;
    transition: background .2s ease;
}

    .switch::after {
        content: "";
        position: absolute;
        top: 3px;
        left: 3px;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        background: #fff;
        box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
        transition: transform .2s ease;
    }

    .switch:checked { background: linear-gradient(90deg, var(--teal), var(--ocean)); }
        .switch:checked::after { transform: translateX(18px); }
    .switch:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(11, 128, 176, .25); }

.btn-secondary { color: var(--text); background: #fff; border: 1px solid var(--border); }
    .btn-secondary:hover:not(:disabled) { background: var(--page-bg); }

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ===== Menu a rotellina ===== */
.menu-azioni { position: relative; flex-shrink: 0; }

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}

    .icon-button svg { transition: transform .3s ease; }
    .icon-button:hover, .icon-button.active { color: var(--ocean); border-color: rgba(11, 128, 176, .35); background: #f3f9fc; }
    .icon-button.active svg { transform: rotate(60deg); }
    .icon-button:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(11, 128, 176, .25); }

.menu-overlay { position: fixed; inset: 0; z-index: 40; }

.menu-popup {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 41;
    min-width: 220px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 12px 32px rgba(18, 20, 42, .14);
    animation: menu-in .12s ease-out;
}

@keyframes menu-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text);
    font: 500 14px var(--font-body);
    text-align: left;
    cursor: pointer;
}

    .menu-item svg { flex-shrink: 0; color: var(--text-muted); }
    .menu-item:hover:not(:disabled) { background: var(--page-bg); }
    .menu-item:hover:not(:disabled) svg { color: var(--ocean); }
    .menu-item:disabled { color: #a6aac2; cursor: not-allowed; }
        .menu-item:disabled svg { color: #c5c9da; }

.menu-sep { height: 1px; margin: 6px 4px; background: var(--border); }

/* ===== Avvisi ===== */
.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding: 12px 14px 12px 16px;
    border: 1px solid;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

    .alert span { flex: 1; }

.alert-success { color: #0f6b58; background: #e8f8f3; border-color: #bfe9dc; }
.alert-error { color: #b3243a; background: #fdecee; border-color: #f5c6cd; }

.alert-close {
    border: 0;
    background: none;
    color: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    opacity: .7;
}

    .alert-close:hover { opacity: 1; }

/* ===== Finestra di conferma ===== */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(18, 20, 42, .45); }

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 51;
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 24px;
    transform: translate(-50%, -50%);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 24px 64px rgba(18, 20, 42, .25);
}

    .modal h2 { font-size: 19px; font-weight: 800; }
    .modal p { margin: 12px 0 0; color: #45485f; }

.modal-file { font: 500 13px ui-monospace, "Cascadia Code", Consolas, monospace; color: var(--text-muted) !important; margin-top: 4px !important; word-break: break-all; }
.modal-subtitle { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted) !important; margin-top: 18px !important; }

.import-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

    .import-list li {
        display: flex;
        flex-wrap: wrap;
        gap: 4px 10px;
        padding: 10px 12px;
        border-radius: var(--radius-sm);
        background: var(--page-bg);
        font-size: 14px;
    }

        .import-list li span { color: var(--text-muted); }

.import-list-skipped li { background: #fff8eb; color: #8a5a10; }

.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ===== Schermi stretti: sidebar a scomparsa ===== */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .main { margin-left: 0; }
    .menu-button { display: inline-flex; }
    .topbar { padding: 0 16px; }
    .content { padding: 24px 16px; }

    .nav-toggle:checked ~ .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
    .nav-toggle:checked ~ .backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 25;
        background: rgba(18, 20, 42, .45);
    }
}

@media (max-width: 560px) {
    .user-text { display: none; }
    .user { padding-right: 10px; }
    .logout span { display: none; }
    .logout { padding: 0 11px; }
    .page-header { align-items: flex-start; }
}

@media (max-width: 1100px) {
    .master-detail { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
    .section-body { padding: 18px 16px; }
    .section-head, .section-foot { padding-left: 16px; padding-right: 16px; }
    .section-foot { flex-wrap: wrap; }
    .field-group { padding: 14px 12px; }
}

/* ===== Blazor ===== */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1.25rem;
    color: white;
    border-radius: var(--radius-sm);
}

    .blazor-error-boundary::after { content: "Si è verificato un errore."; }
