/* Stili specifici della pagina Alimenti */

.alimenti-grid,
.elenco {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== Categorie ===== */
.categorie-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px 6px;
}
.btn-link {
    border: none;
    background: none;
    color: var(--brand);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    min-height: 36px;
}
/* Telefono: categorie come chip scorrevoli */
.categorie-lista {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}
.cat {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 6px 0 14px;
    border-radius: 19px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
.cat .n {
    font-size: 12px;
    color: var(--text-muted);
    padding-right: 8px;
}
.cat.active {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--brand-contrast);
}
.cat.active .n {
    color: var(--brand-soft);
}
.cat-edit {
    display: none;
}

/* ===== Elenco ===== */
.search .small {
    flex-shrink: 0;
}
.tabella-box {
    display: none;
    padding: 0;
    overflow-x: auto;
}
.tabella {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.tabella th {
    position: sticky;
    top: 0;
    background: var(--surface);
    text-align: right;
    padding: 0;
    border-bottom: 1px solid var(--border);
}
.tabella th:first-child,
.tabella th:nth-child(2) {
    text-align: left;
}
.tabella th button {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: none;
    background: none;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    text-align: inherit;
    cursor: pointer;
    white-space: nowrap;
}
.tabella th button.ordinato {
    color: var(--brand);
}
.tabella td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.tabella td:first-child {
    text-align: left;
    font-weight: 700;
}
.tabella td:nth-child(2) {
    text-align: left;
}
.tabella tbody tr {
    cursor: pointer;
}
/* solo con il mouse: sul telefono l'evidenziazione resterebbe dopo il tocco */
@media (hover: hover) {
    .tabella tbody tr:hover {
        background: var(--surface-2);
    }
}
.tabella tbody tr:last-child td {
    border-bottom: none;
}
.vuoto {
    color: var(--border-strong);
}
.badge-cat {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
    background: var(--surface-2);
    margin: 2px 4px 2px 0;
    white-space: nowrap;
}

/* Schede su telefono */
.alimento-scheda .entry-food {
    white-space: normal;
}
.kcal {
    font-size: 15px;
    font-weight: 800;
    white-space: nowrap;
}

@media (min-width: 1100px) {
    .alimenti-grid {
        display: grid;
        grid-template-columns: 260px minmax(0, 1fr);
        gap: 24px;
        align-items: start;
    }
    .categorie {
        position: sticky;
        top: 28px;
        background: var(--surface);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        padding: 16px 12px;
    }
    .categorie-lista {
        flex-direction: column;
        gap: 2px;
        overflow: visible;
    }
    .cat {
        border: none;
        border-radius: 12px;
        min-height: 42px;
        padding: 0 4px 0 12px;
        background: transparent;
    }
    .cat:hover {
        background: var(--surface-2);
    }
    .cat.active,
    .cat.active:hover {
        background: var(--brand);
    }
    .cat .nome {
        flex-grow: 1;
        text-align: left;
    }
    .cat .n {
        padding-right: 0;
    }
    .cat-edit {
        display: inline-flex;
        width: 32px;
        height: 32px;
        visibility: hidden;
    }
    .cat:hover .cat-edit {
        visibility: visible;
    }
    .cat.active .cat-edit {
        visibility: visible;
        color: var(--brand-contrast);
    }
    .tabella-box {
        display: block;
    }
    .schede {
        display: none;
    }
}

/* Ogni categoria: pulsante per filtrare + pulsante per modificarla (non annidati) */
.cat-sel {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-grow: 1;
    min-height: inherit;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    padding: 0;
}

/* La matita appare sulla categoria selezionata (anche su telefono, dove non c'è il passaggio del mouse)
   e quando la si raggiunge con la tastiera */
.cat.active .cat-edit {
    display: inline-flex;
    width: 32px;
    height: 32px;
    color: var(--brand-contrast);
}
.cat:focus-within .cat-edit {
    visibility: visible;
}

.azioni-header {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
