/* --- VARIABILI E DESIGN SYSTEM --- */
:root {
  --primary-color: #97494d;
  --bg-color: #f8f9fa;
  --text-main: #1a1a1a;
  --text-muted: #889497;
  --white: #ffffff;
  --border-radius: 18px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* --- RESET E BASE --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family:
    -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  line-height: 1.5;
  padding-bottom: 50px;
}

/* --- HEADER --- */
header {
  background-color: var(--white);
  text-align: center;
  padding: 50px 15px 25px; /* Spazio extra per i tasti in alto */
  border-bottom-left-radius: 30px;
  border-bottom-right-radius: 30px;
  box-shadow: var(--shadow);
  position: relative; /* Necessario per i tasti assoluti */
}

/* Tasto Home (Sinistra) */
.back-home-header {
  position: absolute;
  top: 20px;
  left: 20px;
  text-decoration: none;
  color: var(--text-main);
  background-color: var(--bg-color);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: bold;
  font-size: 1.2rem;
  box-shadow: var(--shadow);
  z-index: 10;
}

/* --- NUOVO SELETTORE LINGUA A TENDINA (Destra) --- */
.custom-dropdown {
  position: absolute;
  top: 20px;
  right: 20px;
  display: inline-block;
  z-index: 1100;
}

/* Il bottone principale sempre visibile */
.dropdown-trigger {
  background-color: var(--bg-color);
  color: var(--text-main);
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 8px 14px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.dropdown-trigger:active {
  transform: scale(0.95);
}

/* La tendina con le opzioni (nascosta di base) */
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  background-color: var(--white);
  min-width: 140px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.05);
  overflow: hidden;
  padding: 4px 0;
}

/* Classe aggiunta via JavaScript per mostrare la tendina */
.dropdown-menu.show {
  display: block;
}

/* Le singole righe delle lingue dentro la tendina */
.dropdown-item {
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.15s ease;
}

.dropdown-item:hover,
.dropdown-item:active {
  background-color: var(--bg-color);
  color: var(--primary-color);
}

/* Titolo e Logo Cliccabile */
.title-link {
  text-decoration: none;
  color: inherit;
  display: inline-block;
}

.title-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-bottom: 8px;
}

.header-icon {
  width: 100px;
  height: 100px;
  object-fit: contain;
}

header h1 {
  color: var(--primary-color);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -1px;
}

header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

/* --- NAVIGAZIONE CATEGORIE --- */
.category-nav {
  position: sticky;
  top: 0;
  background-color: rgba(248, 249, 250, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  justify-content: flex-start;
  align-items: center;
  overflow-x: auto;
  padding: 15px 10px;
  gap: 12px;
  z-index: 1000;
  scrollbar-width: none;
}

.category-nav::-webkit-scrollbar {
  display: none;
}

.category-nav a {
  text-decoration: none;
  color: var(--text-main);
  background-color: var(--white);
  padding: 10px 24px;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* --- HOME PAGE (index.html) --- */
.home-container {
  max-width: 600px;
  margin: 40px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.home-card {
  background-color: var(--white);
  padding: 45px 20px;
  border-radius: var(--border-radius);
  text-align: center;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.home-card:active {
  transform: scale(0.96);
}

.card-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary-color);
  text-transform: uppercase;
}

/* --- MENU ITEMS --- */
.menu-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 25px 15px;
}

.menu-section {
  margin-bottom: 45px;
  scroll-margin-top: 100px;
}

.menu-section h2 {
  font-size: 1.5rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-section h2::after {
  content: "";
  height: 2px;
  flex: 1;
  background: linear-gradient(to right, var(--primary-color), transparent);
  opacity: 0.2;
}

.menu-item {
  background-color: var(--white);
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 15px;
  display: flex !important;
  flex-direction: row !important; /* Blinda la struttura su una singola riga */
  justify-content: space-between;
  align-items: center; /* Centra tutto verticalmente */
  box-shadow: var(--shadow);
  width: 100%;
}

.item-main-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start !important; /* Forza nome e bollini a sinistra */
  text-align: left !important;
  flex: 1; /* Prende tutto lo spazio a sinistra */
  margin-right: 15px; /* Spazio di sicurezza dal prezzo */
}

.item-name {
  font-weight: 700;
  font-size: 1.15rem;
  color: #000;
}

.item-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.item-price {
  font-weight: 800;
  color: var(--primary-color);
  background: #fff0f0;
  padding: 6px 14px;
  border-radius: 12px;
  height: fit-content;
  align-self: center; /* Assicura la centratura del blocco */
  white-space: nowrap !important; /* Impedisce che la valuta vada a capo spezzando il layout */
}

/* --- ALLERGEN BADGES --- */
.allergen-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.allergen-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-glutine {
  background: #fac775;
  border-color: #ef9f27;
  color: #412402;
}
.badge-latte {
  background: #b5d4f4;
  border-color: #378add;
  color: #042c53;
}
.badge-uova {
  background: #c0dd97;
  border-color: #639922;
  color: #173404;
}
.badge-pesce {
  background: #9fe1cb;
  border-color: #1d9e75;
  color: #04342c;
}
.badge-crostacei {
  background: #f5c4b3;
  border-color: #d85a30;
  color: #4a1b0c;
}
.badge-molluschi {
  background: #cecbf6;
  border-color: #7f77dd;
  color: #26215c;
}
.badge-soia {
  background: #eaf3de;
  border-color: #639922;
  color: #173404;
}
.badge-arachidi {
  background: #fac775;
  border-color: #ef9f27;
  color: #412402;
}
.badge-frutta-guscio {
  background: #f4c0d1;
  border-color: #d4537e;
  color: #4b1528;
}
.badge-sedano {
  background: #c0dd97;
  border-color: #639922;
  color: #173404;
}
.badge-senape {
  background: #fac775;
  border-color: #ef9f27;
  color: #412402;
}
.badge-sesamo {
  background: #d3d1c7;
  border-color: #888780;
  color: #2c2c2a;
}
.badge-lupino {
  background: #cecbf6;
  border-color: #7f77dd;
  color: #26215c;
}
.badge-so2 {
  background: #f7c1c1;
  border-color: #e24b4a;
  color: #501313;
}

/* --- FOOTER --- */
footer {
  text-align: center;
  padding: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --- RESPONSIVE --- */
@media (max-width: 600px) {
  .header-icon {
    width: 45px;
    height: 45px;
  }
  header h1 {
    font-size: 1.5rem;
  }
  .back-home-header {
    top: 10px;
    left: 10px;
    width: 35px;
    height: 35px;
  }
  .custom-dropdown {
    top: 10px;
    right: 10px;
  }
  .dropdown-trigger {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
  .menu-item {
    flex-direction: column;
  }
  .item-price {
    margin-top: 10px;
    align-self: flex-end;
  }
}

/* --- ALLERGEN BADGES AS LINKS --- */
a.allergen-badge {
  text-decoration: none;
  cursor: pointer;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}

a.allergen-badge:hover,
a.allergen-badge:active {
  opacity: 0.75;
  transform: scale(0.96);
}

/* --- PAGINA ALLERGENI --- */
.allergen-page-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 25px 15px;
}

.allergen-intro {
  background-color: #fff8e1;
  border-left: 4px solid #f5a623;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 28px;
  font-size: 0.88rem;
  color: #6b4d00;
  line-height: 1.6;
}

.allergen-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.allergen-card {
  background-color: var(--white);
  border-radius: var(--border-radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.allergen-card-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.allergen-card-body {
  flex: 1;
}

.allergen-card-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 4px;
}

.allergen-card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.allergen-card-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.section-title {
  font-size: 1.5rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::after {
  content: "";
  height: 2px;
  flex: 1;
  background: linear-gradient(to right, var(--primary-color), transparent);
  opacity: 0.2;
}

@media (max-width: 500px) {
  .allergen-grid {
    grid-template-columns: 1fr;
  }
}