/* ------------------------------------------------------------------
   Skillmatrix — tema applicativo sopra Bootstrap 5
   Palette: grafite per la navigazione, ambra "tiger" come accento.
   ------------------------------------------------------------------ */
:root {
    --sm-bg: #f4f5f7;
    --sm-surface: #ffffff;
    --sm-ink: #1c1f26;
    --sm-ink-muted: #6b7280;
    --sm-line: #e5e7eb;
    --sm-sidebar: #15181f;
    --sm-sidebar-ink: #c9ced6;
    --sm-sidebar-active: #262b35;
    --sm-accent: #f59e0b;
    --sm-accent-ink: #1c1f26;
    --sm-accent-soft: #fef3c7;
    --sm-radius: 12px;
    --bs-primary: #f59e0b;
    --bs-primary-rgb: 245, 158, 11;
    --bs-link-color: #b45309;
    --bs-link-hover-color: #92400e;
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-bg: var(--sm-bg);
    --bs-body-color: var(--sm-ink);
}

html, body { height: 100%; }
body { background: var(--sm-bg); color: var(--sm-ink); -webkit-font-smoothing: antialiased; }

/* ---- struttura: sidebar fissa + contenuto ---- */
.sm-shell { display: flex; min-height: 100vh; }
.sm-sidebar {
    width: 248px; flex: 0 0 248px; background: var(--sm-sidebar); color: var(--sm-sidebar-ink);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sm-brand {
    display: flex; align-items: center; gap: .65rem; padding: 1.1rem 1.25rem; color: #fff; text-decoration: none;
    font-weight: 700; letter-spacing: .01em; border-bottom: 1px solid rgba(255,255,255,.06);
}
.sm-brand .mark {
    width: 34px; height: 34px; border-radius: 9px; background: var(--sm-accent); color: var(--sm-accent-ink);
    display: grid; place-items: center; font-weight: 800; font-size: .95rem;
}
.sm-brand small { display: block; font-weight: 400; font-size: .72rem; color: var(--sm-sidebar-ink); letter-spacing: .06em; text-transform: uppercase; }
.sm-nav { padding: .75rem .75rem; flex: 1; overflow-y: auto; }
.sm-nav .label { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: #6f7684; padding: .9rem .75rem .35rem; }
.sm-nav a {
    display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 8px;
    color: var(--sm-sidebar-ink); text-decoration: none; font-size: .92rem;
}
.sm-nav a i { width: 1.1rem; text-align: center; font-size: 1.05rem; opacity: .85; }
.sm-nav a:hover { background: var(--sm-sidebar-active); color: #fff; }
.sm-nav a.active { background: var(--sm-sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--sm-accent); }
.sm-nav a.disabled { opacity: .4; pointer-events: none; }
.sm-nav a .badge { margin-left: auto; font-weight: 500; }
.sm-user {
    padding: .9rem 1rem; border-top: 1px solid rgba(255,255,255,.06); display: flex; align-items: center; gap: .7rem;
}
.sm-user .avatar {
    width: 34px; height: 34px; border-radius: 50%; background: #2d3340; color: #fff; display: grid; place-items: center;
    font-weight: 600; font-size: .85rem; flex: 0 0 auto;
}
.sm-user .who { min-width: 0; flex: 1; line-height: 1.2; }
.sm-user .who strong { display: block; color: #fff; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-user .who span { font-size: .75rem; color: #8b93a1; }
.sm-user .btn { color: #8b93a1; padding: .25rem .4rem; }
.sm-user .btn:hover { color: #fff; }

.sm-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sm-topbar {
    display: flex; align-items: center; gap: 1rem; padding: .85rem 1.75rem; background: var(--sm-surface);
    border-bottom: 1px solid var(--sm-line); position: sticky; top: 0; z-index: 10;
}
.sm-topbar h1 { font-size: 1.15rem; font-weight: 600; margin: 0; }
.sm-topbar .spacer { flex: 1; }
.sm-content { padding: 1.5rem 1.75rem 2.5rem; flex: 1; }
.sm-footer { padding: .9rem 1.75rem; color: var(--sm-ink-muted); font-size: .78rem; border-top: 1px solid var(--sm-line); }

/* ---- componenti ---- */
.card { border: 1px solid var(--sm-line); border-radius: var(--sm-radius); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: transparent; border-bottom: 1px solid var(--sm-line); font-weight: 600; padding: .9rem 1.25rem; }
.card-body { padding: 1.25rem; }
.table { --bs-table-hover-bg: #fafafa; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--sm-ink-muted); font-weight: 600; border-bottom-width: 1px; }
.table td { vertical-align: middle; }
.btn { border-radius: 8px; font-weight: 500; }
.btn-primary { --bs-btn-bg: var(--sm-accent); --bs-btn-border-color: var(--sm-accent); --bs-btn-color: var(--sm-accent-ink);
    --bs-btn-hover-bg: #d97706; --bs-btn-hover-border-color: #d97706; --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: #b45309; --bs-btn-active-border-color: #b45309; }
.btn-outline-primary { --bs-btn-color: #b45309; --bs-btn-border-color: #f3c66c; --bs-btn-hover-bg: var(--sm-accent-soft); --bs-btn-hover-color: #92400e; --bs-btn-hover-border-color: #f3c66c; --bs-btn-active-bg: var(--sm-accent-soft); --bs-btn-active-color: #92400e; }
.form-control, .form-select { border-radius: 8px; border-color: #d6d9df; }
.form-control:focus, .form-select:focus { border-color: var(--sm-accent); box-shadow: 0 0 0 .2rem rgba(245,158,11,.2); }
.form-check-input:checked { background-color: var(--sm-accent); border-color: var(--sm-accent); }
.badge.role-admin { background: #1c1f26; }
.badge.role-gestore { background: #2563eb; }
.badge.role-operatore { background: #059669; }
.text-accent { color: #b45309; }

/* ---- statistiche in home ---- */
.stat { display: flex; flex-direction: column; gap: .2rem; }
.stat .value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; }
.stat .label { font-size: .78rem; color: var(--sm-ink-muted); text-transform: uppercase; letter-spacing: .06em; }
.line-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .7rem; border: 1px solid var(--sm-line); border-radius: 999px; background: #fff; font-size: .85rem; }
.line-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sm-accent); }

/* ---- pagine di accesso (layout auth) ---- */
.auth-bg { min-height: 100vh; display: grid; place-items: center; background:
    radial-gradient(1200px 500px at 10% -10%, #fde68a33, transparent 60%),
    radial-gradient(900px 500px at 100% 110%, #1c1f2611, transparent 60%), var(--sm-bg); padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card.wide { max-width: 760px; }
.auth-brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.5rem; justify-content: center; }
.auth-brand .mark { width: 42px; height: 42px; border-radius: 11px; background: var(--sm-accent); color: var(--sm-accent-ink); display: grid; place-items: center; font-weight: 800; }
.auth-brand .name { font-weight: 700; font-size: 1.1rem; }
.auth-brand .name small { display: block; font-weight: 400; font-size: .72rem; color: var(--sm-ink-muted); text-transform: uppercase; letter-spacing: .08em; }

/* ---- responsive ---- */
@media (max-width: 991.98px) {
    .sm-shell { flex-direction: column; }
    .sm-sidebar { width: 100%; flex: none; height: auto; position: static; }
    .sm-nav { display: flex; flex-wrap: wrap; gap: .25rem; padding: .5rem; }
    .sm-nav .label { display: none; }
    .sm-content, .sm-topbar, .sm-footer { padding-left: 1rem; padding-right: 1rem; }
}

/* ---- pesi di competenza (0..4) ---- */
.weight-0 { background: #f1f3f5 !important; color: #9aa1ab !important; border-color: #e5e7eb !important; }
.weight-1 { background: #fee2e2 !important; color: #991b1b !important; border-color: #fecaca !important; }
.weight-2 { background: #fef3c7 !important; color: #92400e !important; border-color: #fde68a !important; }
.weight-3 { background: #d1fae5 !important; color: #065f46 !important; border-color: #a7f3d0 !important; }
.weight-4 { background: #059669 !important; color: #fff !important; border-color: #047857 !important; }
.badge.weight-0, .badge.weight-1, .badge.weight-2, .badge.weight-3, .badge.weight-4 { min-width: 1.6em; }
.cell-sample { display: inline-grid; place-items: center; width: 1.5rem; height: 1.25rem; border-radius: 4px; font-size: .72rem; font-weight: 600; }
.avatar-lg { width: 52px; height: 52px; border-radius: 50%; background: #1c1f26; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; flex: 0 0 auto; }
.skill-list .list-group-item.saved { background: #fffbeb; transition: background .6s; }
.skill-list .weight-btn.active { font-weight: 700; }
@media (max-width: 575.98px) { .skill-list .weight-picker { width: 100%; } .skill-list .weight-picker .btn { flex: 1; } }

/* ---- matrice competenze ---- */
.matrix-wrap { overflow: auto; max-height: calc(100vh - 290px); }
table.matrix { border-collapse: separate; border-spacing: 0; font-size: .78rem; }
table.matrix th, table.matrix td { border-bottom: 1px solid var(--sm-line); border-right: 1px solid var(--sm-line); }
table.matrix thead th { position: sticky; top: 0; background: #fff; z-index: 2; vertical-align: bottom; }
table.matrix th.corner { position: sticky; left: 0; top: 0; z-index: 4; background: #fff; min-width: 220px; padding: .5rem .75rem; vertical-align: top; }
table.matrix th.row-head { position: sticky; left: 0; background: #fff; z-index: 1; white-space: nowrap; padding: 0 .75rem; font-weight: 500; text-align: left; min-width: 220px; }
table.matrix th.col-head { width: 30px; min-width: 30px; padding: 0; }
table.matrix th.col-head .rot { height: 150px; display: flex; align-items: flex-end; justify-content: center; overflow: hidden; }
table.matrix th.col-head .rot span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-weight: 500; color: #4b5563; line-height: 1; padding-top: 6px; }
table.matrix th.col-head:hover .rot span { color: var(--sm-ink); }
.sm-tooltip { position: fixed; z-index: 1000; pointer-events: none; background: #1c1f26; color: #fff; font-size: .78rem; line-height: 1.3; padding: .4rem .6rem; border-radius: 6px; max-width: 320px; box-shadow: 0 4px 14px rgba(0,0,0,.2); display: none; }
.sm-tooltip.show { display: block; }
table.matrix th.col-head .cov { font-size: .68rem; text-align: center; color: var(--sm-ink-muted); padding: 2px 0; border-top: 1px solid var(--sm-line); }
table.matrix td.cell { width: 30px; height: 28px; text-align: center; font-weight: 600; cursor: pointer; user-select: none; }
table.matrix td.cell:hover { outline: 2px solid var(--sm-accent); outline-offset: -2px; }
table.matrix td.cell.busy { opacity: .5; cursor: progress; }
table.matrix[data-can-edit="0"] td.cell { cursor: default; }

/* nessuna competenza (riga assente) vs 0 = assegnata per necessità */
.weight-none { background: #fff !important; color: #c3c8d0 !important; border-color: #e5e7eb !important; }
table.matrix td.cell.weight-0 { background: repeating-linear-gradient(45deg, #fff1f2, #fff1f2 3px, #ffe4e6 3px, #ffe4e6 6px) !important; color: #be123c !important; font-size: 1rem; }
.badge.weight-0, .cell-sample.weight-0, .weight-btn.weight-0 { background: #ffe4e6 !important; color: #be123c !important; border-color: #fecdd3 !important; }

/* ---- piazzamenti ---- */
table.placements tr.row-empty td { background: #fff7ed; }
.offcanvas .cell-sample { width: 1.35rem; height: 1.2rem; font-size: .7rem; }
.line-chip.border-danger { border-color: #dc3545 !important; }

/* ---- calendario assenze ---- */
table.abs-cal { border-collapse: separate; border-spacing: 0; font-size: .78rem; width: 100%; }
table.abs-cal th, table.abs-cal td { border-bottom: 1px solid var(--sm-line); border-right: 1px solid var(--sm-line); }
table.abs-cal thead th { position: sticky; top: 0; background: #fff; z-index: 2; text-align: center; padding: .35rem 0; }
table.abs-cal th.corner { position: sticky; left: 0; z-index: 4; text-align: left; padding-left: .75rem; min-width: 200px; }
table.abs-cal th.row-head { position: sticky; left: 0; background: #fff; z-index: 1; white-space: nowrap; padding: 0 .75rem; font-weight: 500; text-align: left; min-width: 200px; }
table.abs-cal th.day .dn { display: block; font-size: .62rem; color: var(--sm-ink-muted); font-weight: 500; }
table.abs-cal th.day .dd { display: block; font-weight: 600; }
table.abs-cal th.day.we, table.abs-cal td.we { background: #f8f9fa; }
table.abs-cal th.day.today { box-shadow: inset 0 -3px 0 var(--sm-accent); }
table.abs-cal td.c { width: 28px; min-width: 28px; height: 28px; text-align: center; font-weight: 600; cursor: pointer; user-select: none; }
table.abs-cal td.c:hover { outline: 2px solid var(--sm-accent); outline-offset: -2px; }
table.abs-cal td.c.sel { outline: 2px solid #1c1f26; outline-offset: -2px; background: #fde68a !important; }
table.abs-cal td.pl { color: #9aa1ab; font-weight: 400; }
table.abs-cal td.tot, table.abs-cal th.tot { text-align: center; min-width: 40px; }
table.abs-cal td.abs { color: #fff; }
.abs-dot { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; vertical-align: -2px; }
.t1 { background: #dc3545 !important; } .t2 { background: #0d6efd !important; } .t3 { background: #6f42c1 !important; }
.t4 { background: #fd7e14 !important; } .t5 { background: #20c997 !important; } .t6 { background: #6c757d !important; }

/* ---- cruscotti ---- */
.chart-wrap { position: relative; width: 100%; }
.nav-tabs .nav-link { color: var(--sm-ink-muted); }
.nav-tabs .nav-link.active { color: var(--sm-ink); font-weight: 600; border-bottom-color: #fff; }

/* ---- area personale (ruolo risorsa): layout mobile-first con barra in basso ---- */
.me-body { background: var(--sm-bg); padding-bottom: 72px; }
.me-top { background: var(--sm-sidebar); color: #fff; padding: .6rem 0; }
.me-wrap { max-width: 720px; margin: 0 auto; padding: 0 1rem; }
.me-nav { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--sm-line); display: flex; justify-content: space-around; padding: .35rem 0 calc(.35rem + env(safe-area-inset-bottom)); z-index: 20; }
.me-nav a { display: flex; flex-direction: column; align-items: center; gap: .1rem; color: var(--sm-ink-muted); text-decoration: none; font-size: .7rem; padding: .25rem 1rem; border-radius: 10px; }
.me-nav a i { font-size: 1.35rem; }
.me-nav a.active { color: #b45309; background: var(--sm-accent-soft); }
.me-today { border-left: 5px solid var(--sm-line); }
.me-today.is-placed { border-left-color: var(--sm-accent); }
.me-today.is-absent { border-left-color: #6c757d; }
.me-cal-head, .me-cal-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.me-cal-head span { text-align: center; font-size: .68rem; color: var(--sm-ink-muted); padding: .2rem 0; }
.me-cal-day { aspect-ratio: 1; border-radius: 8px; background: #f4f5f7; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .8rem; line-height: 1.1; }
.me-cal-day.out { opacity: .3; }
.me-cal-day.today { outline: 2px solid var(--sm-accent); outline-offset: -2px; }
.me-cal-day.pl { background: var(--sm-accent-soft); color: #92400e; font-weight: 600; }
.me-cal-day.abs { background: #e5e7eb; color: #374151; font-weight: 600; }
.me-cal-day .t { font-size: .62rem; font-weight: 500; margin-top: 2px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }

.badge.role-risorsa { background: #7c3aed; }

/* ---- contestazioni ---- */
.search-pop { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; background: #fff; border: 1px solid var(--sm-line); border-radius: 8px; box-shadow: 0 8px 24px rgba(16,24,40,.12); max-height: 360px; overflow: auto; display: none; margin-top: 2px; }
.search-pop.show { display: block; }
.pop-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--sm-line); padding: .5rem .75rem; font-size: .85rem; }
.pop-item:hover { background: var(--sm-accent-soft); }
.timeline .tl-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; background: #f1f3f5; color: var(--sm-ink-muted); }
.timeline .tl-stato { background: #dbeafe; color: #1d4ed8; } .timeline .tl-assegnazione { background: #ede9fe; color: #6d28d9; }
.timeline .tl-allegato { background: #fef3c7; color: #92400e; } .timeline .tl-esito { background: #d1fae5; color: #047857; }
