/* =============================================================================
   Adozioni Testi Scolastici - Foglio di stile istituzionale
   Stile Pubblica Amministrazione italiana: blu istituzionale, bianco, grigio.
   ============================================================================= */

:root {
    --pa-blue:       #0059B3;   /* Blu istituzionale */
    --pa-blue-dark:  #003d80;
    --pa-blue-700:   #004a99;
    --pa-blue-light: #e8f0fb;
    --pa-cyan:       #0d8aed;
    --pa-grey-bg:    #f2f4f8;
    --pa-grey-100:   #e9edf3;
    --pa-grey-200:   #d7dde6;
    --pa-grey-500:   #6b7684;
    --pa-ink:        #1b2733;
    --pa-green:      #1a8a4b;
    --pa-yellow:     #b8860b;
    --pa-red:        #c62828;
    --sidebar-w:     264px;
    --topbar-h:      68px;
    --radius:        12px;
    --font: 'Titillium Web', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Font istituzionale Titillium Web (standard PA italiana) via bundling opzionale */
@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@300;400;600;700;900&display=swap');

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    color: var(--pa-ink);
    background: var(--pa-grey-bg);
    font-size: 15px;
    line-height: 1.5;
}
a { color: var(--pa-blue); text-decoration: none; }
a:hover { color: var(--pa-blue-dark); }

/* ============================== LOGIN ==================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(1200px 600px at 90% -10%, rgba(13,138,237,.25), transparent),
        linear-gradient(135deg, #003d80 0%, #0059B3 55%, #0d6efd 100%);
    padding: 24px;
}
.login-wrapper {
    width: 100%;
    max-width: 960px;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 30, 70, .35);
}
.login-brand {
    background: linear-gradient(160deg, var(--pa-blue-dark), var(--pa-blue));
    color: #fff;
    padding: 48px 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.login-emblem {
    width: 64px; height: 64px; border-radius: 16px;
    background: rgba(255,255,255,.15);
    display: flex; align-items: center; justify-content: center;
    font-size: 32px; margin-bottom: 22px;
    border: 1px solid rgba(255,255,255,.25);
}
.login-brand h1 { font-size: 28px; font-weight: 700; margin: 0 0 8px; }
.login-brand p { opacity: .85; margin: 0 0 28px; }
.login-features { list-style: none; padding: 0; margin: 0; }
.login-features li { padding: 7px 0; opacity: .92; font-size: 14px; }
.login-features i { color: #7dd3fc; margin-right: 8px; }
.login-card { display: flex; align-items: center; }
.login-card-inner { padding: 48px 44px; width: 100%; }
.login-card-inner h2 { font-size: 22px; font-weight: 700; color: var(--pa-blue-dark); }
.login-note { font-size: 12px; color: var(--pa-grey-500); }

/* ============================== APP SHELL =============================== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--pa-blue-dark), var(--pa-blue));
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex; flex-direction: column;
    z-index: 1030;
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,.12);
    min-height: var(--topbar-h);
}
.brand-logo {
    width: 40px; height: 40px; border-radius: 10px;
    background: rgba(255,255,255,.16);
    display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title { font-weight: 700; font-size: 18px; }
.brand-sub { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .7; }
.sidebar-nav { padding: 14px 12px; overflow-y: auto; flex: 1; }
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: 12px;
    color: rgba(255,255,255,.82);
    padding: 11px 14px; border-radius: 10px;
    font-size: 14.5px; font-weight: 600;
    margin-bottom: 3px;
    transition: background-color .18s ease, color .18s ease;
}
.sidebar-nav .nav-link i { font-size: 18px; width: 22px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-nav .nav-link.active {
    background: #fff; color: var(--pa-blue-dark);
    box-shadow: 0 6px 18px rgba(0,0,0,.18);
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex; flex-direction: column;
    min-width: 0;
}
.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--pa-grey-200);
    display: flex; align-items: center; gap: 16px;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 1020;
}
.btn-hamburger {
    display: none; border: none; background: transparent;
    font-size: 24px; color: var(--pa-blue-dark); cursor: pointer;
}
.topbar-title { flex: 1; display: flex; align-items: baseline; gap: 12px; }
.topbar-title h1 { font-size: 20px; font-weight: 700; margin: 0; color: var(--pa-ink); }
.topbar-anno {
    font-size: 12px; font-weight: 700; color: var(--pa-blue-dark);
    background: var(--pa-blue-light); padding: 3px 10px; border-radius: 20px;
}
.user-chip {
    display: flex; align-items: center; gap: 10px;
    border: 1px solid var(--pa-grey-200); background: #fff;
    padding: 6px 12px 6px 6px; border-radius: 40px; cursor: pointer;
}
.user-chip:hover { background: var(--pa-grey-100); }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--pa-blue); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
}
.user-info { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.user-name { font-weight: 600; font-size: 13.5px; }
.user-role { font-size: 11px; color: var(--pa-grey-500); }

.content { padding: 26px 28px; flex: 1; }
.app-footer {
    padding: 14px 28px; border-top: 1px solid var(--pa-grey-200);
    background: #fff; display: flex; justify-content: space-between;
    font-size: 12.5px; color: var(--pa-grey-500);
}

/* ============================== COMPONENTI ============================== */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-head .lead-sub { color: var(--pa-grey-500); margin: 4px 0 0; font-size: 14px; }

.card {
    border: 1px solid var(--pa-grey-200);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(16,40,70,.05);
}
.card-header {
    background: #fff; border-bottom: 1px solid var(--pa-grey-100);
    font-weight: 700; color: var(--pa-blue-dark);
    border-radius: var(--radius) var(--radius) 0 0 !important;
}

/* Card statistiche dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; margin-bottom: 26px; }
.stat-card {
    background: #fff; border: 1px solid var(--pa-grey-200); border-radius: var(--radius);
    padding: 20px; display: flex; align-items: center; gap: 16px;
    transition: transform .18s ease, box-shadow .18s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(16,40,70,.10); }
.stat-icon {
    width: 52px; height: 52px; border-radius: 13px; flex: none;
    display: flex; align-items: center; justify-content: center; font-size: 24px;
    background: var(--pa-blue-light); color: var(--pa-blue);
}
.stat-icon.green  { background: #e4f6ea; color: var(--pa-green); }
.stat-icon.yellow { background: #fdf3dc; color: var(--pa-yellow); }
.stat-icon.red    { background: #fdeaea; color: var(--pa-red); }
.stat-icon.cyan   { background: #e2f3fd; color: var(--pa-cyan); }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; color: var(--pa-ink); }
.stat-label { font-size: 13px; color: var(--pa-grey-500); margin-top: 4px; }

.btn-primary { background: var(--pa-blue); border-color: var(--pa-blue); font-weight: 600; }
.btn-primary:hover { background: var(--pa-blue-dark); border-color: var(--pa-blue-dark); }
.btn-outline-primary { color: var(--pa-blue); border-color: var(--pa-blue); font-weight: 600; }
.btn-outline-primary:hover { background: var(--pa-blue); border-color: var(--pa-blue); }
.text-pa { color: var(--pa-blue-dark) !important; }

/* Tabelle */
.table thead th { background: var(--pa-blue-light); color: var(--pa-blue-dark); border-bottom: 2px solid var(--pa-blue); font-size: 13px; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; }
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--pa-blue-light); }
.table-toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }

/* Semafori tetto di spesa */
.tetto-badge { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; padding: 5px 12px; border-radius: 30px; font-size: 13px; }
.tetto-green  { background: #e4f6ea; color: var(--pa-green); }
.tetto-yellow { background: #fdf3dc; color: var(--pa-yellow); }
.tetto-red    { background: #fdeaea; color: var(--pa-red); }
.tetto-grey   { background: var(--pa-grey-100); color: var(--pa-grey-500); }
.tetto-dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--pa-grey-500); }
.empty-state i { font-size: 46px; opacity: .35; display: block; margin-bottom: 12px; }

/* ============================== RESPONSIVE ============================== */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .btn-hamburger { display: block; }
    .login-wrapper { grid-template-columns: 1fr; max-width: 460px; }
    .login-brand { display: none; }
}
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,20,50,.4); z-index: 1025; }
.sidebar-backdrop.show { display: block; }
