/* =====================================================================
   Gestionale Percorsi — Tema brand (palette colori.JPG) + layout sidebar
   ===================================================================== */
:root {
    /* Palette brand Percorsi */
    --brand:        #1c74c0;   /* blu primario (hero) */
    --brand-dark:   #13548f;
    --brand-light:  #2a86d8;
    --brand-tint:   #eaf2fb;

    /* Accenti (aree di intervento) */
    --c-teal:   #4f97ac;
    --c-green:  #16b582;
    --c-orange: #f07e16;
    --c-purple: #b56ca8;
    --c-olive:  #8f9b4f;
    --c-brick:  #a8443b;

    /* Sidebar scura (logo bianco) */
    --sb-bg:     #15293f;
    --sb-bg-2:   #102032;
    --sb-hover:  #1e3c5c;
    --sb-text:   #c4d3e3;
    --sb-muted:  #7d93ab;
    --sb-active: var(--c-green);

    --ink: #2b3a4a;
    --content-bg: #eef1f5;

    /* Alias retro-compatibilità (le viste usano ancora coral) */
    --coral:      var(--brand);
    --coral-dark: var(--brand-dark);
    --coral-tint: var(--brand-tint);

    --sb-w: 256px;
    --sb-w-collapsed: 68px;
}

html, body { height: 100%; }
body {
    background: var(--content-bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { color: var(--brand); }

/* =====================================================================
   Layout a due colonne: sidebar fissa + contenuto
   ===================================================================== */
.app-layout { min-height: 100vh; }

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sb-w);
    background: linear-gradient(180deg, var(--sb-bg) 0%, var(--sb-bg-2) 100%);
    color: var(--sb-text);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: width .2s ease, transform .2s ease;
    overflow: hidden;
}

/* Header con logo bianco */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 72px;
    padding: 0 1rem;
    background: rgba(0,0,0,.18);
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}
.sidebar-brand img { height: 34px; width: auto; }

/* Blocco utente */
.sidebar-user {
    display: flex; align-items: center; gap: .7rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}
.sidebar-user .avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: var(--brand); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.05rem; flex-shrink: 0;
}
.sidebar-user .u-name { color: #fff; font-weight: 600; font-size: .92rem; line-height: 1.1; }
.sidebar-user .u-role { color: var(--sb-muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .4px; }

/* Etichetta sezione */
.sidebar-label {
    color: var(--sb-muted);
    font-size: .7rem; text-transform: uppercase; letter-spacing: 1px;
    padding: 1rem 1.3rem .4rem;
}

/* Navigazione */
.sidebar-nav { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding-bottom: 1rem; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }

.sb-link {
    display: flex; align-items: center; gap: .8rem;
    padding: .72rem 1.3rem;
    color: var(--sb-text);
    font-size: .92rem;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
    white-space: nowrap;
}
.sb-link:hover { background: var(--sb-hover); color: #fff; }
.sb-link .sb-icon { font-size: 1.1rem; width: 22px; text-align: center; flex-shrink: 0; }
.sb-link.active {
    background: var(--sb-hover);
    color: #fff;
    border-left-color: var(--sb-active);
}
.sb-link.active .sb-icon { color: var(--sb-active); }

/* Gruppo a tendina */
.sb-caret { margin-left: auto; font-size: .8rem; transition: transform .2s ease; }
.sb-link[aria-expanded="true"] .sb-caret { transform: rotate(90deg); }
.sb-submenu { background: rgba(0,0,0,.22); }
.sb-sublink {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem 1.3rem .55rem 3.2rem;
    color: var(--sb-muted);
    font-size: .86rem;
    white-space: nowrap;
}
.sb-sublink::before { content: "\2022"; color: var(--sb-active); }
.sb-sublink:hover { color: #fff; background: var(--sb-hover); }
.sb-sublink.active { color: #fff; }

/* Footer sidebar (collassa) */
.sidebar-foot { flex-shrink: 0; padding: .5rem; border-top: 1px solid rgba(255,255,255,.06); text-align: center; }
.sidebar-foot button {
    background: rgba(255,255,255,.06); border: none; color: var(--sb-text);
    width: 38px; height: 34px; border-radius: 6px; cursor: pointer;
}
.sidebar-foot button:hover { background: var(--sb-hover); color: #fff; }

/* Contenuto */
.app-main { margin-left: var(--sb-w); transition: margin-left .2s ease; min-height: 100vh; display: flex; flex-direction: column; }

/* Topbar */
.app-topbar {
    height: 60px; background: #fff;
    border-bottom: 1px solid #e3e8ee;
    display: flex; align-items: center; gap: 1rem;
    padding: 0 1.3rem;
    position: sticky; top: 0; z-index: 1030;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.app-topbar .burger {
    background: none; border: none; font-size: 1.4rem; color: var(--ink); cursor: pointer; line-height: 1;
}
.app-topbar .tb-title { font-weight: 600; color: var(--ink); }
.app-topbar .tb-right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.app-topbar .tb-user { display: flex; align-items: center; gap: .5rem; color: var(--ink); }
.app-topbar .tb-user .avatar-sm {
    width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem;
}

.app-content { flex: 1 1 auto; padding: 1.5rem 1.6rem 2.5rem; }

.app-footer {
    background: #fff; border-top: 1px solid #e3e8ee;
    padding: .8rem 1.6rem; color: #8a98a8; font-size: .82rem;
    display: flex; justify-content: space-between;
}

/* Collasso desktop (solo icone) */
body.sidebar-collapsed .sidebar { width: var(--sb-w-collapsed); }
body.sidebar-collapsed .app-main { margin-left: var(--sb-w-collapsed); }
body.sidebar-collapsed .sidebar .u-info,
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .sb-link .sb-text,
body.sidebar-collapsed .sb-link .sb-caret,
body.sidebar-collapsed .sb-submenu { display: none !important; }
body.sidebar-collapsed .sidebar-user { justify-content: center; }
body.sidebar-collapsed .sb-link { justify-content: center; padding: .72rem 0; }
body.sidebar-collapsed .sidebar-brand img { height: 28px; }

/* Backdrop mobile */
.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.4);
    z-index: 1035; display: none;
}

/* Responsive: sidebar off-canvas */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .app-main { margin-left: 0; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; }
}

/* =====================================================================
   Componenti rebrandizzati
   ===================================================================== */
.btn-coral, .btn-brand {
    background: var(--brand); border-color: var(--brand); color: #fff;
}
.btn-coral:hover, .btn-brand:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-outline-coral, .btn-outline-brand { color: var(--brand); border: 1px solid var(--brand); background: #fff; }
.btn-outline-coral:hover, .btn-outline-brand:hover { background: var(--brand); color: #fff; }
.text-coral, .text-brand { color: var(--brand) !important; }

.page-title { border-left: 4px solid var(--brand); padding-left: .6rem; margin-bottom: 1.2rem; }
.card-soft { border: none; box-shadow: 0 1px 6px rgba(0,0,0,.07); border-radius: .6rem; }

/* Breadcrumb */
.breadcrumb { background: transparent; padding: 0; margin-bottom: .8rem; font-size: .85rem; }
.breadcrumb a { color: var(--brand); }

/* =====================================================================
   Dashboard
   ===================================================================== */
.stat-card {
    border-radius: .55rem; padding: 1.2rem 1.3rem; color: #fff;
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,.10); text-decoration: none; min-height: 104px;
    transition: transform .08s ease, box-shadow .08s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.16); color: #fff; }
.stat-card .sc-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .6px; opacity: .92; }
.stat-card .sc-value { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat-card .sc-icon { font-size: 2.6rem; opacity: .35; }
.bg-teal   { background: var(--c-teal); }
.bg-brandc { background: var(--brand-light); }
.bg-purple { background: var(--c-purple); }
.bg-olive  { background: var(--c-olive); }
.bg-greenc { background: var(--c-green); }
.bg-orange { background: var(--c-orange); }
.bg-brick  { background: var(--c-brick); }
.bg-dark2  { background: #2b2f38; }

.tile { display:block; border-radius:.6rem; padding:1.3rem; background:#fff; box-shadow:0 1px 6px rgba(0,0,0,.07); text-decoration:none; color:var(--ink); transition:transform .08s ease, box-shadow .08s ease; }
.tile:hover { transform: translateY(-2px); box-shadow:0 4px 14px rgba(0,0,0,.12); color:var(--brand-dark); }
.tile .tile-icon { font-size: 1.8rem; color: var(--brand); }

.action-card { background:#fff; border-radius:.6rem; box-shadow:0 1px 6px rgba(0,0,0,.07); padding:2rem 1.5rem; text-align:center; }
.action-card h2 { font-size: 1.5rem; color: var(--ink); margin-bottom: 1.2rem; }

/* =====================================================================
   Protocollo / calendario / form (invariati nella logica)
   ===================================================================== */
.stato-dot { display:inline-block; width:14px; height:14px; border-radius:50%; cursor:pointer; border:1px solid rgba(0,0,0,.15); }
.stato-valido { background:#28a745; }
.stato-nonvalido { background:#dc3545; }

.cal-weekend { background: var(--brand-tint); }
.cal-festivo { background: #fff3cd; }
.cal-attivo { background: #e8f5e9; }
.ore-grid input { width: 56px; text-align:center; padding:2px; }
.ore-grid th, .ore-grid td { text-align:center; vertical-align:middle; font-size:.85rem; }
.qualifica-row { background: var(--brand-tint); font-weight:600; }

/* Selettore stato giorno (radio: servizio / festivo / escluso) */
.cal-stato { margin-top: 2px; }
.cal-stato label {
    display: block;
    font-size: .75rem;
    line-height: 1.35;
    cursor: pointer;
    white-space: nowrap;
}
.cal-stato input[type="radio"] { margin-right: 3px; vertical-align: middle; }

.required label::after { content:" *"; color: var(--brand); }

/* =====================================================================
   Tab di navigazione progetto (barra orizzontale "pill")
   ===================================================================== */
.proj-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .3rem;
    padding: .4rem;
    background: #fff;
    border-radius: .7rem;
    box-shadow: 0 1px 6px rgba(0,0,0,.07);
}
.proj-tab {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .9rem;
    border-radius: .5rem;
    color: #5b6b7c;
    font-size: .9rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: background .14s ease, color .14s ease, box-shadow .14s ease;
}
.proj-tab .bi { font-size: 1.05rem; opacity: .85; }
.proj-tab:hover {
    background: var(--brand-tint);
    color: var(--brand-dark);
}
.proj-tab.active {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 2px 8px rgba(28,116,192,.30);
}
.proj-tab.active .bi { opacity: 1; }

/* Voce Export Excel: spinta a destra, accento verde */
.proj-tab-export { color: var(--c-green); }
.proj-tab-export:hover { background: rgba(22,181,130,.12); color: #0f8d65; }

/* Schermi stretti: scroll orizzontale invece dell'a-capo */
@media (max-width: 991.98px) {
    .proj-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .proj-tabs::-webkit-scrollbar { height: 5px; }
    .proj-tabs::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 3px; }
    .proj-tab-export.ms-auto { margin-left: .3rem !important; }
}
