/* ══════════════════════════════════════════════════════════════
 *  HOME PORTALE AOC — stili specifici della home (Layout C)
 *  Tutto il resto (token, .card, .badge, .section, .search-box,
 *  .stats-grid, .btn, ...) arriva da aoc-assets/aoc-style.css.
 *  Qui solo ciò che il Design System non copre.
 * ══════════════════════════════════════════════════════════════ */

/* ── Shell a due colonne: sidebar-albero + pannello centrale ── */
.home-shell {
    display: flex;
    min-height: 100vh;
}

/* ════════ SIDEBAR AD ALBERO (variante C) ════════ */
.tree-side {
    width: 290px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s, background 0.3s, border-color 0.3s;
}

.tree-logo {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.tree-logo img {
    height: 38px;
    width: auto;
    filter: var(--logo-filter);
}

.tree-logo h1 {
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.2;
}

.tree-logo h1 span {
    display: block;
    font-size: 0.66rem;
    color: var(--text-muted);
    font-weight: 400;
}

.tree-search {
    padding: 12px 14px;
    flex-shrink: 0;
}

.tree-nav {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0 12px;
}

/* Voce fissa "⭐ Le tue App" in cima */
.tree-fav {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 18px;
    margin-bottom: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
    border-left: 3px solid transparent;
    user-select: none;
    transition: all 0.15s;
}

.tree-fav:hover { color: var(--text); background: var(--bg-hover); }

.tree-fav.active {
    color: var(--warning);
    border-left-color: var(--warning);
    background: var(--warning-dim);
}

.tree-fav .tf-count {
    margin-left: auto;
    font-size: 0.62rem;
    color: var(--text-muted);
}

.tree-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 14px 8px;
}

/* Categoria espandibile */
.tree-cat-head {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 18px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
    user-select: none;
    border-left: 3px solid transparent;
    transition: color 0.15s, background 0.15s;
}

.tree-cat-head:hover { color: var(--text); background: var(--bg-hover); }
.tree-cat.open  > .tree-cat-head,
.tree-cat.active > .tree-cat-head { color: var(--text); }
.tree-cat.active > .tree-cat-head { border-left-color: var(--accent); }

.tree-cat-ico { font-size: 1rem; flex-shrink: 0; }
.tree-cat-label { flex: 1; min-width: 0; }

.tree-cnt {
    font-size: 0.62rem;
    color: var(--text-muted);
}

.tree-chev {
    font-size: 0.7rem;
    color: var(--text-dim);
    transition: transform 0.2s;
}

.tree-cat.open > .tree-cat-head .tree-chev { transform: rotate(90deg); }

.tree-apps { display: none; padding: 2px 0 6px; }
.tree-cat.open .tree-apps { display: block; }

.tree-app {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 18px 7px 42px;
    font-size: 0.8rem;
    color: var(--text-dim);
    text-decoration: none;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: all 0.12s;
}

.tree-app:hover {
    background: var(--bg-hover);
    color: var(--text);
    border-left-color: var(--accent);
}

.tree-app-ico { flex-shrink: 0; }
.tree-app-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Footer sidebar: temi */
.tree-foot {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.theme-btn {
    flex: 1;
    padding: 7px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.theme-btn:hover { border-color: var(--border-light); color: var(--text); }
.theme-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ════════ PANNELLO CENTRALE ════════ */
.home-main {
    flex: 1;
    min-width: 0;
    min-height: 100vh;
}

.home-head {
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 14px;
}

.home-greeting h2 { font-size: 1.25rem; font-weight: 700; }
.home-greeting .date { font-size: 0.76rem; color: var(--text-muted); margin-top: 2px; }

/* Avatar */
.home-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent);
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.home-avatar:hover { transform: scale(1.08); box-shadow: 0 0 12px var(--accent-glow); }

.home-avatar-fallback {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.95rem; font-weight: 700;
    flex-shrink: 0; cursor: pointer;
}

.home-content { padding: 26px 28px 60px; }

/* ════════ RISULTATI / SEZIONE CORRENTE ════════ */
.row-label {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 4px 0 14px;
}
.row-label .rl-ico { font-size: 1.05rem; }
.row-label .rl-txt { font-size: 1rem; font-weight: 600; }
.row-label .rl-cnt {
    font-size: 0.66rem; color: var(--text-muted);
    background: var(--surface2); padding: 3px 9px; border-radius: 10px;
}

/* Colori pastello per icona sezione (parità con la vecchia home) */
.section-icon.cat-checklist                { background: rgba(34,197,94,0.15); }
.section-icon.cat-analisi                  { background: rgba(168,85,247,0.15); }
.section-icon.cat-docs                     { background: rgba(59,130,246,0.15); }
.section-icon.cat-prodotti                 { background: rgba(249,115,22,0.15); }
.section-icon.cat-magazzino-spedizioni     { background: rgba(234,179,8,0.15); }
.section-icon.cat-marketing                { background: rgba(37,211,102,0.15); }
.section-icon.cat-marketplace-fatturazione { background: rgba(99,102,241,0.15); }
.section-icon.cat-microfix                 { background: rgba(59,130,246,0.15); }
.section-icon.cat-trade-in                 { background: var(--trade-in-glow); }
.section-icon.cat-utility                  { background: rgba(156,163,175,0.15); }
.section-icon.cat-favorites                { background: var(--accent-glow); }

/* ════════ CARD: stella preferiti + etichetta contenitore + highlight ════════ */
.card-fav {
    position: absolute;
    top: 8px; right: 8px;
    background: none; border: none;
    cursor: pointer;
    font-size: 0.95rem;
    opacity: 0;
    transition: all 0.2s;
    padding: 4px; line-height: 1; z-index: 2;
}
.card:hover .card-fav { opacity: 0.4; }
.card-fav:hover { opacity: 1 !important; transform: scale(1.2); }
.card-fav.active { opacity: 1 !important; color: var(--warning); }

/* etichetta "↳ in [Contenitore]" sui risultati delle sotto-app */
.card-parent {
    font-size: 0.66rem;
    color: var(--accent);
    font-weight: 600;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* evidenziazione sottostringa che ha fatto match */
mark {
    background: var(--warning-dim);
    color: var(--text);
    border-radius: 3px;
    padding: 0 1px;
}

/* ════════ TENDINA SUGGERIMENTI (typeahead) ════════ */
.sb-wrap { position: relative; }

.suggest {
    position: absolute;
    left: 0; right: 0;
    top: calc(100% + 6px);
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 60;
    overflow: hidden;
    max-height: 380px;
    overflow-y: auto;
}

.suggest-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover, .suggest-item.active { background: var(--bg-hover); }

.si-ico {
    width: 28px; height: 28px;
    border-radius: 6px;
    background: var(--surface2);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; flex-shrink: 0;
}
.si-txt { flex: 1; min-width: 0; }
.si-title { font-size: 0.85rem; font-weight: 600; }
.si-parent { font-size: 0.68rem; color: var(--accent); }
.si-cat { font-size: 0.66rem; color: var(--text-muted); }
.si-hint {
    font-size: 0.62rem; color: var(--text-muted);
    border: 1px solid var(--border-light); border-radius: 5px; padding: 1px 6px;
}
.suggest-empty { padding: 14px; color: var(--text-muted); font-size: 0.82rem; }

/* ════════ AVATAR POPUP ════════ */
.avatar-popup-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 500;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s;
}
.avatar-popup-overlay.show { opacity: 1; }

.avatar-popup {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px; text-align: center;
    box-shadow: var(--shadow);
    transform: scale(0.9); transition: transform 0.2s;
}
.avatar-popup-overlay.show .avatar-popup { transform: scale(1); }

.avatar-popup img {
    width: 200px; height: 200px;
    border-radius: 50%; object-fit: cover;
    border: 3px solid var(--accent);
    margin-bottom: 16px;
}
.avatar-popup-fallback {
    width: 200px; height: 200px;
    border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 4rem; font-weight: 700;
    margin: 0 auto 16px;
}
.avatar-popup-name { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.avatar-popup-role { font-size: 0.82rem; color: var(--text-dim); text-transform: capitalize; }

/* ════════ HAMBURGER + OVERLAY (mobile) ════════ */
.hamburger {
    display: none;
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    background: var(--surface2);
    border: 1px solid var(--border);
    cursor: pointer;
    align-items: center; justify-content: center;
    font-size: 1.2rem; color: var(--text);
    flex-shrink: 0;
}

.tree-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
}

/* ════════ RESPONSIVE ════════ */
@media (max-width: 900px) {
    .tree-side {
        position: fixed;
        left: 0; top: 0;
        transform: translateX(-100%);
    }
    .tree-side.open { transform: translateX(0); }
    .tree-overlay.open { display: block; }
    .hamburger { display: flex; }
    .home-content { padding: 20px 16px 50px; }
    .home-head { padding: 12px 16px; }
}
