/* ================================================================
   GESTIONALE FNA — CSS PRINCIPALE
   Bootstrap 5 + personalizzazioni
   ================================================================ */

:root {
    --fna-primary:     #1A3C6E;
    --fna-accent:      #2E75B6;
    --fna-accent-light:#D5E8F0;
    --fna-sidebar-w:   260px;
    --fna-sidebar-bg:  #1A3C6E;
    --fna-sidebar-text:#E8EDF5;
    --fna-sidebar-hover: rgba(255,255,255,0.1);
    --fna-sidebar-active: rgba(255,255,255,0.18);
    --fna-header-h:    56px;
}

/* ── RESET & BASE ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #F0F2F5;
    color: #1A1A1A;
    overflow-x: hidden;
}

/* ── NAVBAR TOP (mobile) ─────────────────────────────────── */
.fna-navbar {
    background: var(--fna-primary);
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--fna-header-h);
    z-index: 1040;
}

/* ── SIDEBAR ──────────────────────────────────────────────── */
.fna-sidebar {
    width: var(--fna-sidebar-w);
    height: 100vh;
    background: var(--fna-sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 1030;
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    overflow-y: auto;
    overflow-x: hidden;
}

.fna-sidebar-header {
    padding: 20px 18px 16px;
    color: #fff;
    font-size: 1.15rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    letter-spacing: .3px;
}

/* Box utente */
.fna-user-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.fna-user-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem;
    flex-shrink: 0;
}
.fna-user-info { overflow: hidden; }
.fna-user-info > div:first-child {
    color: #fff; font-size: .88rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fna-user-role {
    color: rgba(255,255,255,0.6);
    font-size: .75rem;
}

/* Navigazione */
.fna-nav {
    padding: 10px 0;
}
.fna-nav-link {
    display: flex;
    align-items: center;
    padding: 9px 18px;
    color: var(--fna-sidebar-text);
    text-decoration: none;
    font-size: .9rem;
    border-radius: 0;
    transition: background .15s;
}
.fna-nav-link:hover {
    background: var(--fna-sidebar-hover);
    color: #fff;
}
.fna-nav-link.active {
    background: var(--fna-sidebar-active);
    color: #fff;
    font-weight: 600;
    border-left: 3px solid #63B3ED;
}
.fna-nav-link i { width: 20px; flex-shrink: 0; }
.fna-sep {
    border-color: rgba(255,255,255,0.1);
    margin: 6px 18px;
}
.fna-nav-gruppo {
    padding: 14px 18px 4px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255,255,255,.45) !important;
    user-select: none;
}
.fna-sidebar-footer {
    padding: 10px 0 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
}

/* ── LAYOUT PRINCIPALE ────────────────────────────────────── */
#wrapper {
    min-height: 100vh;
}
.fna-main {
    margin-left: var(--fna-sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── PAGE HEADER ──────────────────────────────────────────── */
.fna-page-header {
    background: #fff;
    padding: 18px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #E2E8F0;
    gap: 12px;
    flex-wrap: wrap;
}
.fna-page-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--fna-primary);
    margin: 0 0 2px;
}
.breadcrumb { font-size: .82rem; }
.breadcrumb-item a { color: var(--fna-accent); text-decoration: none; }

/* ── CONTENUTO ────────────────────────────────────────────── */
.fna-content {
    padding: 24px 28px;
    flex: 1;
}

/* ── FOOTER ───────────────────────────────────────────────── */
.fna-footer {
    background: #fff;
    border-top: 1px solid #E2E8F0;
    padding: 12px 28px;
    text-align: center;
    color: #718096;
}

/* ── CARDS DASHBOARD ──────────────────────────────────────── */
.fna-stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid #E2E8F0;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.fna-stat-card .stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--fna-primary);
    line-height: 1;
}
.fna-stat-card .stat-label {
    font-size: .82rem;
    color: #718096;
    margin-top: 4px;
}
.fna-stat-card .stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

/* ── TABELLE ──────────────────────────────────────────────── */
.fna-table {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #E2E8F0;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.fna-table .table { margin: 0; }
.fna-table .table thead th {
    background: var(--fna-primary);
    color: #fff;
    font-weight: 600;
    font-size: .83rem;
    letter-spacing: .3px;
    border: none;
    padding: 12px 14px;
    white-space: nowrap;
}
.fna-table .table tbody tr:hover { background: #F8FAFC; }
.fna-table .table td { vertical-align: middle; font-size: .88rem; padding: 10px 14px; }
.fna-table-toolbar {
    padding: 14px 18px;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── FORM CARD ────────────────────────────────────────────── */
.fna-card {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #E2E8F0;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.fna-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #E2E8F0;
    font-weight: 700;
    color: var(--fna-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.fna-card-body { padding: 20px; }

/* ── BADGE STATO ──────────────────────────────────────────── */
.badge-attivo    { background:#DCFCE7; color:#166534; }
.badge-sospeso   { background:#FEF9C3; color:#713F12; }
.badge-chiuso    { background:#F1F5F9; color:#475569; }
.badge-disabile  { background:#EFF6FF; color:#1E40AF; }
.badge-anziano   { background:#FFF7ED; color:#9A3412; }
.badge-alta      { background:#FEE2E2; color:#991B1B; }
.badge-media     { background:#FEF3C7; color:#92400E; }
.badge-bassa     { background:#DCFCE7; color:#166534; }
.badge-spontaneo { background:#F0FDF4; color:#166534; }
.badge-invio     { background:#EFF6FF; color:#1E40AF; }

/* ── BOTTONI PRINCIPALI ───────────────────────────────────── */
.btn-fna-primary {
    background: var(--fna-primary);
    border-color: var(--fna-primary);
    color: #fff;
}
.btn-fna-primary:hover {
    background: #142d52;
    border-color: #142d52;
    color: #fff;
}
.btn-fna-outline {
    border-color: var(--fna-primary);
    color: var(--fna-primary);
}
.btn-fna-outline:hover {
    background: var(--fna-primary);
    color: #fff;
}

/* ── ALERT ORE ────────────────────────────────────────────── */
.ore-ok     { color: #166534; }
.ore-warning{ color: #92400E; }
.ore-danger { color: #991B1B; font-weight: 700; }

/* ── TARGET 50/50 ─────────────────────────────────────────── */
.target-bar { height: 10px; border-radius: 99px; overflow: hidden; background: #E2E8F0; }
.target-bar-fill { height: 100%; border-radius: 99px; transition: width .4s; }

/* ── LOGIN PAGE ───────────────────────────────────────────── */
.fna-login-wrap {
    min-height: 100vh;
    background: linear-gradient(135deg, #1A3C6E 0%, #2E75B6 100%);
    display: flex; align-items: center; justify-content: center;
}
.fna-login-card {
    background: #fff;
    border-radius: 14px;
    padding: 40px 36px;
    width: 100%; max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.fna-login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.fna-login-logo i { font-size: 2.8rem; color: var(--fna-primary); }
.fna-login-logo h2 { font-weight: 800; color: var(--fna-primary); margin: 8px 0 2px; }
.fna-login-logo p { color: #718096; font-size: .88rem; margin: 0; }

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .fna-sidebar {
        transform: translateX(-100%);
        top: var(--fna-header-h);
        min-height: calc(100vh - var(--fna-header-h));
    }
    .fna-sidebar.open {
        transform: translateX(0);
    }
    .fna-main {
        margin-left: 0;
        padding-top: var(--fna-header-h);
    }
    .fna-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 1025;
        top: var(--fna-header-h);
    }
    .fna-overlay.open { display: block; }
    .fna-content { padding: 16px; }
    .fna-page-header { padding: 14px 16px; }
}

@media (max-width: 575.98px) {
    .fna-stat-card .stat-number { font-size: 1.6rem; }
    .fna-table .table thead th { font-size: .78rem; }
    .fna-table .table td { font-size: .82rem; }
}

/* ── UTILITIES ────────────────────────────────────────────── */
.text-fna-primary { color: var(--fna-primary) !important; }
.bg-fna-light     { background: var(--fna-accent-light) !important; }
.cursor-pointer   { cursor: pointer; }

/* ── SCROLLBAR SIDEBAR ────────────────────────────────────── */
.fna-sidebar::-webkit-scrollbar {
    width: 4px;
}
.fna-sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.fna-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}
.fna-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.4);
}

/* ── MESSAGGI: sidebar cartelle ──────────────────────────── */
.list-group-item-action {
    color: var(--fna-primary);
    font-weight: 500;
}
.list-group-item-action:hover {
    background: var(--fna-accent-light);
    color: var(--fna-primary);
}
.list-group-item-action.active {
    background: var(--fna-primary) !important;
    border-color: var(--fna-primary) !important;
    color: #fff !important;
    font-weight: 600;
}