:root {
    --bg-body: #111;
    --text-body: #fff;
    --bg-header: #222;
    --border-header: #333;
    --text-nav: #ccc;
    --text-nav-hover: #fff;
    --accent: #ffc107;
    --accent-allergens: #ffc107;
    --accent-sticky:  #ffc107;
    --text-desc: #aaa;
    --border-item: #333;
    --bg-allergeni: #1a1a1a;
    --text-allergeni: #ccc;
    --bg-fab: #222;
    --border-fab: #444;
}

html[data-theme="light"] {
    --bg-body: #f4f4f4;
    --text-body: #222;
    --bg-header: #fff;
    --border-header: #e0e0e0;
    --text-nav: #555;
    --text-nav-hover: #111;
    --accent: #e08e00;
    --accent-allergens: #ffc107;
     --accent-sticky: #ffc107;
    --text-desc: #666;
    --border-item: #e0e0e0;
    --bg-allergeni: #f0f0f0;
    --text-allergeni: #555;
    --bg-fab: #fff;
    --border-fab: #ccc;
}

@media (prefers-color-scheme: light) {
    html:not([data-theme]) {
        --bg-body: #f4f4f4;
        --text-body: #222;
        --bg-header: #fff;
        --border-header: #e0e0e0;
        --text-nav: #555;
        --text-nav-hover: #111;
        --accent: #e08e00;
        --accent-allergens: #ffc107;
         --accent-sticky: #ffc107;
        --text-desc: #666;
        --border-item: #e0e0e0;
        --bg-allergeni: #f0f0f0;
        --text-allergeni: #555;
        --bg-fab: #fff;
        --border-fab: #ccc;
    }
}

/* BASE MOBILE-FIRST CSS */
body { font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: var(--bg-body); color: var(--text-body); transition: background-color .2s ease, color .2s ease; }

/* 1. HEADER STICKY (logo + nav insieme) */
.sticky-header {
    position: sticky;
    top: 0;
    z-index: 999;
    background-color: var(--bg-header);
    
}

.menu-logo {
    display: flex;
    justify-content: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-header);
}

.menu-logo img {
    max-height: 100px;
    
    width: auto;
}


/* ============================= */
/* STICKY NAV CATEGORIE MENU */
/* ============================= */

.sticky-nav {
    display: flex;
    align-items: center;
    gap: 8px;

    overflow-x: auto;
    overflow-y: hidden;

    white-space: nowrap;

    padding: 10px 12px;

    -webkit-overflow-scrolling: touch;

    /* Nasconde scrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sticky-nav::-webkit-scrollbar {
    display: none;
}


/* BOTTONI CATEGORIE */

.sticky-nav a {
    flex-shrink: 0;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 9px 18px;

    color: var(--text-nav);
    text-decoration: none;

    font-size: 14px;
    font-weight: bold;

    background: var(--bg-body);

    border: 1px solid var(--border-item);
    border-radius: 999px;

    transition:
        background-color .2s ease,
        color .2s ease,
        border-color .2s ease,
        transform .1s ease;
}


/* HOVER SOLO CON MOUSE */
@media (hover: hover) {

    .sticky-nav a:hover {
        color: var(--text-nav-hover);
        border-color: var(--accent-sticky);
    }

}


/* CATEGORIA ATTIVA DOPO CLICK */

.sticky-nav a.attiva {
    background: var(--accent-sticky);
    border-color: var(--accent-sticky);
    color: #000;
    transform: scale(1.05);
}


/* FEEDBACK TOUCH MOBILE */

.sticky-nav a:active {
    transform: scale(0.96);
}


/* DESKTOP */

@media (min-width: 769px) {

    .sticky-nav {
        justify-content: center;
    }

}


/* 2. STRUTTURA DEL LAYOUT DEI PIATTI */
.menu-container { padding: 20px; max-width: 600px; margin: 0 auto; }

.category-section { margin-bottom: 40px; scroll-margin-top: calc(var(--header-height, 90px) + 15px); 
    
}

.category-title { font-size: 24px; color: var(--accent); border-bottom: 2px solid var(--accent); padding-bottom: 5px; margin-bottom: 20px; }

/* ===== Banner immagine categoria (modalità piatta, facoltativo) ===== */
.category-banner {
    width: 100%;
    max-height: 180px;
    overflow: hidden;
    border-radius: 12px;
    margin-bottom: 16px;
}

.category-banner img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.category-description {
    font-size: 14px;
    color: var(--text-desc);
    margin: -12px 0 20px 0;
}

/* ===== Categoria ad accordion (impostazione globale attiva) ===== */
.category-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    border: 1px solid var(--border-item);
    background: var(--bg-header);
}

.category-card:active {
    transform: scale(0.99);
}

/* Variante CON immagine: card grande, foto a piena larghezza,
   nome e descrizione sovrapposti in basso su un gradiente scuro
   (leggibili indipendentemente da quanto è chiara la foto) */
.category-card.has-media {
    min-height: 190px;
    display: flex;
    align-items: flex-end;
}

.category-card-media {
    position: absolute;
    inset: 0;
}

.category-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.category-card.has-media .category-card-info {
    position: relative;
    z-index: 2;
    width: 100%;
    padding: 18px 54px 18px 18px;
    background: linear-gradient(to top, rgba(0,0,0,0.80) 15%, rgba(0,0,0,0.35) 55%, rgba(0,0,0,0) 100%);
}

.category-card.has-media .category-card-name {
    color: #fff;
    font-size: 21px;
}

.category-card.has-media .category-card-desc {
    color: rgba(255,255,255,0.88);
}

/* Variante SENZA immagine: card più compatta, colori del tema normali */
.category-card.no-media .category-card-info {
    padding: 18px 54px 18px 18px;
}

.category-card.no-media .category-card-name {
    font-size: 18px;
    color: var(--accent);
}

.category-card.no-media .category-card-desc {
    color: var(--text-desc);
}

.category-card-name {
    font-weight: bold;
    line-height: 1.3;
}

.category-card-desc {
    font-size: 13px;
    margin-top: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.category-card-chevron {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: transform .2s ease;
}

.category-card.has-media .category-card-chevron {
    background: rgba(0,0,0,0.45);
    color: #fff;
}

.category-card.no-media .category-card-chevron {
    background: var(--bg-allergeni);
    color: var(--text-nav);
}

.category-card.aperto .category-card-chevron {
    transform: rotate(180deg);
}

@media (min-width: 600px) {
    .category-card.has-media {
        min-height: 220px;
    }
}

/* Corpo della categoria: si apre/chiude con la stessa tecnica
   già usata nell'admin per i pannelli a comparsa (grid-template-rows) */
.category-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .3s ease, margin-top .3s ease;
    margin-top: 0;
    overflow: hidden;
}

.category-body.aperto {
    grid-template-rows: 1fr;
    margin-top: 14px;
}

.category-body-inner {
    min-height: 0;
}

/* 3. IL SINGOLO PIATTO (layout a lista, default) */
.menu-item { margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px dashed var(--border-item); }
.item-main { display: flex; justify-content: space-between; align-items: center; font-size: 18px; font-weight: bold; }
.item-price { color: var(--accent); margin-left: 10px; }
.item-description { font-size: 14px; color: var(--text-desc); margin: 5px 0 0 0; font-weight: normal; }

/* Contenitore immagine + prezzo, allineato a destra */
.item-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Thumbnail immagine piatto (opzionale) */
.item-image-thumb {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid var(--border-item);
    flex-shrink: 0;
    transition: transform .15s ease, border-color .15s ease;
}

.item-image-thumb:hover {
    transform: scale(1.08);
    border-color: var(--accent);
}

.item-image-thumb:active {
    transform: scale(0.96);
}

/* ===== 3b. I PIATTI COME GRIGLIA DI CARD (impostazione globale attiva) ===== */
.piatti-grid-card {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}

@media (min-width: 600px) {
    .piatti-grid-card {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    }
}

.menu-item-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-item);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-header);
}

.menu-item-card-img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
    cursor: pointer;
    border: none;
    border-radius: 0;
}

.menu-item-card-img.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-allergeni);
    color: var(--text-desc);
    font-size: 30px;
    cursor: default;
}

.menu-item-card-body {
    padding: 10px 12px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.menu-item-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 6px;
    font-size: 15px;
    font-weight: bold;
}

.menu-item-card .item-name {
    line-height: 1.3;
}

.menu-item-card .item-price {
    white-space: nowrap;
    margin-left: 0;
}

.menu-item-card .icona-allergeni {
    margin-left: 0;
    margin-top: 6px;
    align-self: flex-start;
}

.menu-item-card .item-description {
    margin-top: 6px;
}

.menu-item-card .dettaglio-allergeni {
    margin-top: 0;
}

.menu-item-card .dettaglio-allergeni.aperto {
    margin-top: 8px;
}

/* Lightbox immagine piatto a comparsa */
.img-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.img-lightbox.aperta {
    display: flex;
}

.img-lightbox img {
    max-width: min(500px, 90vw);
    max-height: min(500px, 80vh);
    width: auto;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.img-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.img-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.22);
}


.icona-allergeni {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 12px;
    background: var(--bg-allergeni);
    color: var(--accent-allergens);
    cursor: pointer;
    vertical-align: middle;
    transition: background-color .15s ease;
}

.icona-allergeni:hover {
    background: var(--border-item);
}

.freccia-allergeni {
    font-size: 9px;
    transition: transform .1s ease;
    display: inline-block;
}

.icona-allergeni.attivo .freccia-allergeni {
    transform: rotate(180deg);
}

.dettaglio-allergeni {
    max-height: 0;
    overflow: hidden;
    transition: max-height .1s ease;
    font-size: 13px;
    color: var(--text-allergeni);
    background: var(--bg-allergeni);
    border-radius: 4px;
}

.dettaglio-allergeni-inner {
    padding: 8px 10px;
}

.dettaglio-allergeni.aperto {
    margin-top: 8px;
}


/* ── FAB comuni (lingua + tema) ── */
.lang-fab, .theme-fab {
    position: fixed;
    right: 20px;
    z-index: 1000;
}

.lang-fab { bottom: 20px; }
.theme-fab { bottom: 80px; }



.lang-fab input[type="checkbox"],
.theme-fab input[type="checkbox"] { display: none !important; }

.lang-selected-menu, .theme-selected-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-fab);
    border: 2px solid var(--border-fab);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    font-size: 20px;
}

.lang-selected-menu img {
    width: 26px;
    height: 20px;
    object-fit: cover;
    border-radius: 3px;
}

.lang-options-menu, .theme-options-menu {
    display: none;
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    background: var(--bg-header);
    border: 1px solid var(--border-fab);
    border-radius: 8px;
    overflow: hidden;
    min-width: 60px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.lang-fab input[type="checkbox"]:checked ~ .lang-options-menu { display: block; }
.theme-fab input[type="checkbox"]:checked ~ .theme-options-menu { display: block; }

.lang-options-menu a, .theme-options-menu a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    color: var(--text-nav);
    text-decoration: none;
    font-size: 13px;
}

.lang-options-menu a:hover, .theme-options-menu a:hover { background: var(--border-header); color: var(--text-nav-hover); }
.lang-options-menu a.attiva, .theme-options-menu a.attiva { color: var(--accent); font-weight: bold; }
.lang-options-menu a img { width: 20px; height: 15px; object-fit: cover; border-radius: 2px; }


.menu-footer {
    margin-top: 0px;
    padding: 40px 20px 120px;
    text-align: center;
    border-top: 1px solid var(--border-item);
    color: var(--text-desc);
}

.menu-footer-content {
    max-width: 600px;
    margin: 0 auto;
}

.footer-dev,
.footer-piva {
    margin: 8px 0;
    font-size: 14px;
}

.footer-social {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.footer-social a {
    text-decoration: none;
    color: var(--text-main);
    font-size: 28px;
    transition: transform .2s ease;
}


.footer-social a:visited {
    color: var(--text-main);
    text-decoration: none;
}



.footer-social a:hover {
    transform: scale(1.1);
    
}
