/* ============================================================
   AVM Gestionale — Stile principale
   ============================================================ */
:root {
    --color-primary:   #0055A5;
    --color-secondary: #6c757d;
    --color-success:   #198754;
    --color-danger:    #dc3545;
    --color-warning:   #ffc107;
    --color-bg:        #f4f6f9;
    --color-sidebar:   #1a2a4a;
    --color-navbar:    #0055A5;
    --color-text:      #212529;
    --sidebar-width:   220px;
    --navbar-height:   56px;
    --font:            'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--color-bg); color: var(--color-text); }
a    { color: var(--color-primary); text-decoration: none; }

/* --- Navbar --- */
.avm-navbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--navbar-height);
    background: var(--color-navbar);
    color: #fff;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.25rem;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.avm-navbar-brand { display: flex; align-items: center; gap: .5rem; font-size: 1.1rem; font-weight: 700; }
/* "Bus" del nome SICURBus: sulla barra blu un rosso chiaro, altrimenti poco leggibile */
.avm-navbar-brand { --brand-bus: #ff5a5f; }
.avm-navbar-right { display: flex; align-items: center; gap: 1rem; font-size: .875rem; }
.avm-user small   { opacity: .75; }
.avm-btn-logout   { color: #fff; opacity: .85; }
.avm-btn-logout:hover { opacity: 1; }

/* --- Layout wrapper --- */
.avm-wrapper {
    display: flex;
    margin-top: var(--navbar-height);
    min-height: calc(100vh - var(--navbar-height));
}

/* --- Sidebar --- */
.avm-sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    flex-shrink: 0;
    padding-top: .5rem;
    position: fixed;
    top: var(--navbar-height);
    bottom: 0;
    overflow-y: auto;
}
.avm-sidebar-item {
    display: flex; align-items: center; gap: .65rem;
    padding: .65rem 1.25rem;
    color: rgba(255,255,255,.75);
    font-size: .875rem;
    transition: background .15s, color .15s;
}
.avm-sidebar-item:hover, .avm-sidebar-item.active {
    background: rgba(255,255,255,.12);
    color: #fff;
}
.avm-sidebar-item i { font-size: 1.1rem; }

/* Sezioni richiudibili del menu (config/menu_groups.php) */
.avm-sidebar-group-title {
    cursor: pointer;
    list-style: none;              /* niente triangolino nativo di <summary> */
    user-select: none;
    font-weight: 600;
}
.avm-sidebar-group-title::-webkit-details-marker { display: none; }
.avm-sidebar-caret {
    margin-left: auto;
    font-size: .8rem !important;
    opacity: .6;
    transition: transform .15s;
}
.avm-sidebar-group[open] > summary .avm-sidebar-caret { transform: rotate(180deg); }
.avm-sidebar-group[open] { background: rgba(0,0,0,.15); }
/* Sezione chiusa che contiene la pagina corrente: titolo evidenziato */
.avm-sidebar-group.has-active:not([open]) > summary { color: #fff; }
.avm-sidebar-subitem { padding-left: 2.25rem; font-size: .84rem; }
.avm-sidebar-subitem i { font-size: 1rem; }
/* Modulo disattivato ma lasciato visibile (Service → Moduli): grigio, non cliccabile */
.avm-sidebar-off,
.avm-sidebar-off:hover {
    color: rgba(255,255,255,.3);
    background: none;
    cursor: not-allowed;
}

/* --- Content area --- */
.avm-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 1.5rem;
}
.avm-page-header {
    margin-bottom: 1.25rem;
    padding-bottom: .75rem;
    border-bottom: 2px solid var(--color-primary);
}
.avm-page-header h1 { font-size: 1.4rem; font-weight: 700; color: var(--color-primary); }

/* --- Buttons --- */
.avm-btn {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .4rem .9rem; border-radius: .35rem;
    font-size: .875rem; font-weight: 500; cursor: pointer;
    border: 1px solid transparent; transition: opacity .15s;
}
.avm-btn:hover { opacity: .85; }
.avm-btn-primary   { background: var(--color-primary);   color: #fff; }
.avm-btn-secondary { background: var(--color-secondary); color: #fff; }
.avm-btn-danger    { background: var(--color-danger);    color: #fff; }
.avm-btn-sm        { padding: .25rem .55rem; font-size: .8rem; }
.avm-btn-full      { width: 100%; justify-content: center; }

/* --- Toolbar --- */
.avm-toolbar { display: flex; gap: .5rem; margin-bottom: 1rem; }

/* --- Table --- */
.avm-table-container { overflow-x: auto; }
.avm-table {
    width: 100%; border-collapse: collapse;
    background: #fff; border-radius: .5rem; overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.avm-table th {
    background: var(--color-primary); color: #fff;
    padding: .65rem .85rem; text-align: left; font-size: .8rem;
    white-space: nowrap;
}
.avm-table td {
    padding: .55rem .85rem; border-bottom: 1px solid #e9ecef;
    font-size: .875rem;
}
.avm-table tr:last-child td { border-bottom: none; }
.avm-table tr:hover td { background: #f0f4ff; }
.avm-col-actions { width: 90px; text-align: center; }
.avm-empty { text-align: center; color: var(--color-secondary); padding: 2rem; }

/* --- Forms --- */
.avm-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.avm-fieldset {
    border: 1px solid #dee2e6; border-radius: .4rem;
    padding: 1rem; margin-bottom: 1.25rem;
}
.avm-fieldset legend {
    font-weight: 600; font-size: .875rem;
    color: var(--color-primary); padding: 0 .4rem;
}
.avm-form-group { display: flex; flex-direction: column; gap: .3rem; }
.avm-form-group label { font-size: .8rem; font-weight: 600; color: #495057; }
.req { color: var(--color-danger); }
.avm-input {
    border: 1px solid #ced4da; border-radius: .35rem;
    padding: .4rem .65rem; font-size: .875rem;
    transition: border-color .15s;
}
.avm-input:focus { border-color: var(--color-primary); outline: none; box-shadow: 0 0 0 2px rgba(0,85,165,.15); }
.avm-input:disabled { background: #f8f9fa; color: #6c757d; }
.avm-form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; }

/* Toggle boolean */
.avm-toggle { display: flex; align-items: center; gap: .5rem; }
.avm-toggle input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--color-primary); }

/* --- Alert --- */
.avm-alert { padding: .75rem 1rem; border-radius: .35rem; margin-bottom: 1rem; font-size: .875rem; }
.avm-alert-danger { background: #f8d7da; color: #842029; border: 1px solid #f5c2c7; }
.avm-alert-success { background: #d1e7dd; color: #0f5132; border: 1px solid #badbcc; }
.avm-alert-warning { background: #fff3cd; color: #664d03; border: 1px solid #ffecb5; }
.avm-alert-info { background: #cff4fc; color: #055160; border: 1px solid #b6effb; }

/* --- Login page --- */
.avm-login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: var(--color-bg);
}
.avm-login-box {
    background: #fff; border-radius: .6rem;
    padding: 2.5rem 2rem; width: 100%; max-width: 380px;
    box-shadow: 0 4px 24px rgba(0,0,0,.12);
}
.avm-login-logo {
    text-align: center; margin-bottom: 1.5rem;
    color: var(--color-primary);
}
.avm-login-logo h2 { font-size: 1.2rem; margin-top: .4rem; }
.avm-login-box .avm-form-group { margin-bottom: 1rem; }
.avm-login-box .avm-btn { margin-top: .5rem; }

/* --- Dashboard KPI cards --- */
.avm-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.avm-kpi-card {
    background: #fff; border-radius: .5rem;
    padding: 1rem; text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    border-top: 3px solid var(--color-primary);
}
.avm-kpi-card .kpi-value { font-size: 2rem; font-weight: 700; color: var(--color-primary); }
.avm-kpi-card .kpi-label { font-size: .75rem; color: var(--color-secondary); margin-top: .25rem; }

/* ── Gravità degli alert (badge di lista e configurazione) ───────────────── */
.avm-badge { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .5rem; border-radius: 999px; font-weight: 600; }
.avm-badge-danger    { background: #f8d7da; color: #842029; }
.avm-badge-warning   { background: #fff3cd; color: #664d03; }
.avm-badge-info      { background: #cff4fc; color: #055160; }
.avm-badge-secondary { background: #e2e3e5; color: #41464b; }
.avm-badge-success   { background: #d1e7dd; color: #0f5132; }

/* ── Campanella degli alert nella barra in alto ──────────────────────────── */
.avm-bell { position: relative; }
.avm-bell-btn {
    position: relative; background: none; border: none; color: #fff; cursor: pointer;
    font-size: 1.2rem; line-height: 1; padding: .35rem .45rem; border-radius: 6px;
}
.avm-bell-btn:hover, .avm-bell-btn[aria-expanded="true"] { background: rgba(255,255,255,.15); }
.avm-bell-count {
    position: absolute; top: -.1rem; right: -.2rem; min-width: 1.1rem; padding: 0 .25rem;
    background: var(--color-warning); color: #212529; border-radius: 999px;
    font-size: .68rem; font-weight: 700; line-height: 1.1rem; text-align: center;
}
.avm-bell-count.critico { background: var(--color-danger); color: #fff; }
.avm-bell-menu {
    position: absolute; top: calc(100% + .4rem); right: 0; z-index: 1100; width: 360px;
    max-width: calc(100vw - 2rem); background: #fff; color: var(--color-text); border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,.22); overflow: hidden;
}
.avm-bell-head {
    display: flex; justify-content: space-between; align-items: center; padding: .6rem .8rem;
    font-weight: 700; border-bottom: 1px solid #e9ecef;
}
.avm-bell-item { display: flex; gap: .55rem; align-items: flex-start; padding: .55rem .8rem; border-bottom: 1px solid #f1f3f5; }
.avm-bell-item:hover { background: #f8f9fa; }
.avm-bell-item > i { margin-top: .15rem; }
.avm-bell-item.danger  > i { color: var(--color-danger); }
.avm-bell-item.warning > i { color: #b58100; }
.avm-bell-item.info    > i { color: #0aa2c0; }
.avm-bell-text { flex: 1; min-width: 0; color: inherit; font-size: .84rem; overflow-wrap: anywhere; }
.avm-bell-text small { display: block; color: var(--color-secondary); margin-top: .1rem; }
.avm-bell-close { background: none; border: none; cursor: pointer; color: var(--color-secondary); padding: .1rem .25rem; }
.avm-bell-empty { padding: 1.25rem; text-align: center; color: var(--color-secondary); font-size: .875rem; }
.avm-bell-foot { display: flex; justify-content: space-between; padding: .55rem .8rem; font-size: .82rem; background: #f8f9fa; }
