:root {
  /* iOS System Colors Modificati per Brand */
  --bg: #F2F2F7;
  --surface: #FFFFFF;
  --text: #000000;
  --muted: #8E8E93;
  --border: rgba(60, 60, 67, 0.18);
  
  --accent: #009EE0; /* Nuovo Blu Brand */
  --accent-2: #34C759;
  
  --nav-bg: #FFFFFF; /* Sfondo header solido bianco */
  
  --subcat-bg: #E3E3E8; 
  --subcat-text: #1C1C1E;

  --radius-lg: 16px;
  --content: 860px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 90px;
}

a { color: inherit; text-decoration: none; }

.shell {
  width: min(var(--content), calc(100% - 32px));
  margin: 0 auto;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0 10px;
}

.brand-logo {
  height: 68px;
  width: auto;
  display: block;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.8px;
}

.brand .tagline {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Navigazione Categorie */
.category-nav-wrap {
  width: 100%;
  position: relative;
  background: var(--nav-bg);
}

.category-nav {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 16px 16px 20px 16px; 
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-mask-image: linear-gradient(to right, rgba(0,0,0,1) 88%, rgba(0,0,0,0) 100%);
  mask-image: linear-gradient(to right, rgba(0,0,0,1) 88%, rgba(0,0,0,0) 100%);
}

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

.category-nav::after {
  content: '';
  display: block;
  min-width: 24px;
}

.category-chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  height: 80px;
  padding: 12px;
  border-radius: 12px;
  background-color: var(--accent);
  background-size: cover;
  background-position: center;
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
  text-align: center;
  white-space: normal;
  line-height: 1.2;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  overflow: hidden;
}

.category-chip:active { 
  transform: scale(0.96); 
  opacity: 0.9;
}

/* Main Menu */
.menu { padding: 24px 0 40px; }

.menu-section {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.category-hero {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  background: #E5E5EA;
}
.hero-placeholder {
  width: 100%;
  height: 120px;
  background: #E5E5EA;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}

.section-head {
  padding: 20px 20px 14px;
}
.section-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.section-desc {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

/* Sottocategorie */
.subsection {
  margin-top: 4px;
}

.subsection-title {
  margin: 0;
  padding: 10px 20px;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--subcat-text);
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--subcat-bg);
  border-top: 1px solid rgba(60, 60, 67, 0.12);
  border-bottom: 1px solid rgba(60, 60, 67, 0.12);
  display: flex;
  align-items: center;
}

.menu-list {
  display: flex;
  flex-direction: column;
}

.menu-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease, transform 0.1s ease;
}
.menu-item:active {
  background: #F2F2F7;
}
.menu-item:last-child {
  border-bottom: none;
}

.menu-item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.menu-item-name {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.menu-item-chevron {
  font-size: 18px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 4px;
}

.menu-item-price {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.menu-item-format {
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
}

.menu-item-desc {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.35;
  margin-top: 2px;
}

.menu-item-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.menu-item-note {
  font-size: 12px;
  color: var(--text);
  background: #F2F2F7;
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 500;
}

.allergen-badge-mini {
  font-size: 11px;
  color: #777;
  background: #fafafa;
  border: 1px solid #dbdbdb;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.pairing-badge-mini {
  font-size: 11px;
  color: #0284C7;
  background: #E0F2FE;
  border: 1px solid #BAE6FD;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
}

/* Bottom Bar */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  gap: 12px;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
}

.bottom-btn {
  flex: 1;
  background: var(--accent);
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
  box-shadow: 0 4px 12px rgba(0, 158, 224, 0.25);
  transition: transform 0.1s;
}
.bottom-btn:active { transform: scale(0.96); }

.bottom-btn.alt {
  background: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.emoji-icon {
  font-size: 22px;
  line-height: 1;
}

/* =========================================================
   iOS MODAL BOTTOM SHEET (Dettaglio Prodotto, Allergeni, Abbinamenti)
   ========================================================= */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-sheet {
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  background: var(--surface);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.modal-overlay.active .modal-sheet {
  transform: translateY(0);
}

.modal-handle-bar {
  width: 100%;
  padding: 12px 0 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--surface);
}

.modal-handle {
  width: 36px;
  height: 5px;
  background: #D1D1D6;
  border-radius: 3px;
}

.modal-close-btn {
  position: absolute;
  top: 12px;
  right: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #E5E5EA;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
}

.modal-body {
  padding: 32px 24px 36px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-header-group {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.modal-product-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.modal-product-price {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.modal-product-format {
  font-size: 15px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
}

.modal-product-desc {
  font-size: 16px;
  color: #3A3A3C;
  line-height: 1.5;
  background: var(--bg);
  padding: 14px 16px;
  border-radius: 12px;
}

/* Modal Sections */
.modal-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-section-title {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.allergen-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FCD34D;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}

.pairing-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #F0F9FF;
  border: 1px solid #BAE6FD;
  color: #0369A1;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
}

.pairing-icon {
  font-size: 24px;
}

/* Messaggi di stato */
.loading, .error, .empty {
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--muted);
}
.error { color: #FF3B30; }

.footer-note {
  margin-top: 32px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* =========================================================
   ANALYTICS DASHBOARD MODAL
   ========================================================= */
.analytics-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.analytics-overlay.active {
  opacity: 1;
  visibility: visible;
}

.analytics-modal {
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  background: var(--surface);
  border-radius: 24px;
  padding: 24px;
  position: relative;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.analytics-modal h2 {
  margin-top: 0;
  font-size: 22px;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  padding-bottom: 12px;
}

.analytics-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
}

.analytics-item-name {
  font-weight: 600;
  color: var(--text);
}

.analytics-item-count {
  font-weight: 700;
  color: var(--accent);
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: 12px;
}