/* ── Variabili ─────────────────────────────────────── */
:root {
  --primary:      #C0392B;
  --primary-dark: #922B21;
  --accent:       #E67E22;
  --bg:           #FFF8F2;
  --card-bg:      #FFFFFF;
  --text:         #2C1810;
  --muted:        #7D6B63;
  --shadow:       0 2px 16px rgba(44, 24, 16, .09);
  --radius:       12px;
}

/* ── Base ──────────────────────────────────────────── */
body {
  background: var(--bg);
  font-family: 'Lato', sans-serif;
  color: var(--text);
  min-height: 100vh;
}

h1, h2, h3, h4, .navbar-brand {
  font-family: 'Playfair Display', serif;
}

a { text-decoration: none; }
a:hover { text-decoration: none; }

/* ── Navbar ────────────────────────────────────────── */
.navbar {
  background: var(--primary) !important;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.navbar-brand { font-size: 1.4rem; font-weight: 700; letter-spacing: .5px; }
.navbar-brand-center {
  font-size: 1.7rem;
  white-space: nowrap;
}
.navbar-logo {
  height: 4.6rem;
  width: 4.6rem;
  object-fit: contain;
  padding: 5px;
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 50%;
}
@media (max-width: 991px) {
  .navbar-logo { height: 3.4rem; width: 3.4rem; padding: 3px; }
}

/* ── Carosello cover ricette (sotto la navbar) ───────── */
.cover-carousel {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #f7efe9;
  border-bottom: 2px solid #f0e0d0;
  padding: 12px 0;
}
.cover-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: rgba(192,57,43,.92);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.28);
  transition: background .2s;
}
.cover-nav:hover { background: var(--primary-dark); }
.cover-prev { left: 14px; }
.cover-next { right: 14px; }
@media (max-width: 575px) {
  .cover-nav { width: 48px; height: 48px; font-size: 1.2rem; }
  .cover-prev { left: 8px; }
  .cover-next { right: 8px; }
}
.cover-track {
  display: flex;
  width: max-content;
  will-change: transform;
  /* lo spostamento (pausa + slittamento accelerato) è gestito via JS */
}
/* Dimensione e margine delle slide sono impostati in JS (px) sulla larghezza
   reale del carosello: 1 cover su mobile, 3 su desktop. Qui solo un fallback. */
.cover-slide { flex: 0 0 auto; margin-right: 16px; display: block; text-decoration: none; }
.cover-img-wrap { position: relative; display: block; line-height: 0; }
.cover-slide img {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: 0 3px 10px rgba(0,0,0,.2);
  display: block;
  transition: transform .2s;
}
.cover-slide:hover img { transform: scale(1.03); }
.cover-name {
  display: block;
  max-width: 200px;
  margin-top: 8px;
  text-align: center;
  font-family: 'Playfair Display', serif;
  font-weight: 600;
  font-size: .98rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (prefers-reduced-motion: reduce) {
  .cover-carousel { overflow-x: auto; }  /* niente auto-scroll: scorrevole a mano */
}
@media (max-width: 575px) {
  .cover-slide img { height: 220px; width: 220px; }
}

/* ── Cassetto categorie (menu a sinistra, drill-down) ─── */
.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1.6rem;
  line-height: 1;
  padding: 4px 10px;
  cursor: pointer;
}
.menu-toggle:hover { background: rgba(255,255,255,.15); }

.menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease;
  z-index: 1040;
}
.menu-backdrop.show { opacity: 1; visibility: visible; }

.cat-menu {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 300px;
  max-width: 84vw;
  background: #fff;
  box-shadow: 2px 0 18px rgba(0,0,0,.25);
  transform: translateX(-100%);
  transition: transform .28s ease;
  z-index: 1050;
  display: flex;
  flex-direction: column;
}
.cat-menu.open { transform: translateX(0); }

.cat-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}
.menu-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.cat-menu-body { overflow-y: auto; padding: 6px 0 20px; }

.cat-menu-all {
  display: block;
  padding: 13px 18px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid #f0e6df;
}
.cat-menu-macro {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  background: transparent;
  border: none;
  border-bottom: 1px solid #f5ece6;
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}
.cat-menu-macro .chev {
  font-size: .8rem;
  color: var(--muted);
  transition: transform .2s ease;
}
.cat-menu-group.open .cat-menu-macro .chev { transform: rotate(180deg); }

.cat-menu-sub {
  max-height: 0;
  overflow: hidden;
  transition: max-height .28s ease;
  background: #faf6f3;
}
.cat-menu-group.open .cat-menu-sub { max-height: 640px; }

.cat-menu-sub-link {
  display: block;
  padding: 11px 18px 11px 36px;
  color: var(--text);
  text-decoration: none;
  font-size: .92rem;
  border-bottom: 1px solid #f1e8e2;
}
.cat-menu-all:hover,
.cat-menu-macro:hover,
.cat-menu-sub-link:hover { background: #fbeee8; color: var(--primary); }
.cat-menu-all.active,
.cat-menu-sub-link.active { color: var(--primary); background: #fbeee8; }
@media (max-width: 991px) {
  .navbar-brand-center {
    font-size: 1.3rem;
  }
}

/* ── Hero ──────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  padding: 24px 0 20px;
}
.hero h1 { font-size: clamp(1.8rem, 3.5vw, 2.4rem); font-weight: 700; }
.hero p  { font-size: 1.1rem; opacity: .9; }

.search-wrap {
  background: white;
  border-radius: 50px;
  padding: 4px 4px 4px 14px;
  display: flex;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  max-width: 360px;
  margin: 0 auto;
}
.search-wrap input {
  border: none;
  outline: none;
  flex: 1;
  font-size: .85rem;
  background: transparent;
  color: var(--text);
}
.search-wrap button {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border: none;
  border-radius: 40px;
  padding: 6px 16px;
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
  white-space: nowrap;
}
.search-wrap button:hover { opacity: .9; }

/* ── Category filter ───────────────────────────────── */
.cat-filters { gap: 8px; flex-wrap: wrap; }
.cat-filters .btn {
  border-radius: 20px;
  font-size: .83rem;
  padding: 5px 14px;
  font-weight: 600;
  border-color: var(--primary);
  color: var(--primary);
}
.cat-filters .btn:hover,
.cat-filters .btn.active {
  background: var(--primary);
  color: white;
}
.cat-filters .btn-all.active {
  background: var(--primary);
  color: white;
}
.cat-filters .btn-all:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: white; }

/* ── Recipe cards ──────────────────────────────────── */
.recipe-card {
  border: none;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  height: 100%;
  color: inherit;
  position: relative;
}
.recipe-card .card-body { flex: 1; }

/* Colore difficoltà per livello: 1 verde, 2 giallo, 3 rosso */
.diff-lvl-1 { --hat-color: #2e9e44; }
.diff-lvl-2 { --hat-color: #e0a800; }
.diff-lvl-3 { --hat-color: #C0392B; }

.difficulty-hats {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.difficulty-hats .chef-hat {
  width: 18px;
  height: 18px;
  fill: var(--hat-color, #fff);
}
.difficulty-hats .chef-hat.dim {
  opacity: 0.3;
}

.recipe-difficulty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 12px;
  background: #fff;
  border: 1px solid #000;
  border-radius: 20px;
  color: var(--hat-color, var(--primary, #C0392B));
  font-size: .85rem;
  font-weight: 600;
}
.recipe-difficulty .rd-label {
  text-transform: uppercase;
  letter-spacing: .4px;
  font-size: .72rem;
  margin-right: 2px;
}
.recipe-difficulty .chef-hat {
  width: 20px;
  height: 20px;
  fill: currentColor;
}
.recipe-difficulty .chef-hat.dim {
  color: #d4cfce;
}

.badge-new {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: #27AE60;
  color: white;
  font-size: .68rem;
  font-weight: 800;
  padding: 4px 11px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .8px;
  z-index: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.recipe-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 32px rgba(44,24,16,.14);
  color: inherit;
}
.recipe-card .card-img {
  aspect-ratio: 1 / 1;
  object-fit: cover;
  width: 100%;
  display: block;
}
.recipe-card .no-img {
  aspect-ratio: 1 / 1;
  width: 100%;
  background: linear-gradient(135deg, #f5e6d3, #e8c9a0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}
.recipe-card .card-body { padding: 16px 18px 18px; }
.recipe-card .card-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.recipe-card .card-text  { font-size: .85rem; color: var(--muted); }

.badge-cat {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.badge-sub {
  display: inline-block;
  background: #6c757d;
  color: white;
  font-size: .70rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  margin-bottom: 8px;
  margin-left: 4px;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.subcat-link.active {
  background: #6c757d !important;
  color: white !important;
  border-color: #6c757d !important;
}

.subcat-divider {
  border: none;
  border-top: 2px solid #a0604a;
  margin: 12px 0 4px;
}

/* ── Empty state ───────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .icon { font-size: 4rem; margin-bottom: 16px; opacity: .4; }

/* ── Recipe detail ─────────────────────────────────── */
.recipe-header {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.recipe-header h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin-bottom: 8px; }

.recipe-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.recipe-section h3 {
  font-size: 1.2rem;
  color: var(--primary);
  border-bottom: 2px solid #f5e6d3;
  padding-bottom: 8px;
  margin-bottom: 16px;
}
.content {
  white-space: pre-wrap;
  line-height: 1.8;
  font-size: .95rem;
}
.content a.recipe-link,
a.recipe-link {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.content a.recipe-link:hover,
a.recipe-link:hover {
  color: var(--primary-dark, #8e2a1f);
  text-decoration-thickness: 2px;
}

/* ── Photo gallery ─────────────────────────────────── */
.gallery-wrap {
  position: relative;
  margin-bottom: 10px;
}
/* Box quadrato 1:1 (riferimento di altezza/larghezza max, come le foto);
   centra il contenuto per i video che non riempiono il quadrato. */
.gallery-main {
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Foto: riempiono il quadrato, ritagliate (invariato) */
.gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}
/* Video: dimensione naturale, MAI ingranditi se piccoli; capati al quadrato.
   Orizzontale grande = larghezza max come le foto, altezza ridotta.
   Verticale grande = altezza max come le foto, larghezza ridotta. Sempre centrato. */
.gallery-main video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  background: #000;
}

.gallery-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, .45);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background .15s;
  padding: 0;
}
.gallery-btn:hover { background: rgba(0, 0, 0, .72); }
.gallery-btn.prev { left: 10px; }
.gallery-btn.next { right: 10px; }
.gallery-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.gallery-thumbs > img,
.gallery-thumbs > .thumb-video {
  width: 76px;
  height: 76px;
  border-radius: 8px;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color .15s, opacity .15s;
  opacity: .7;
  overflow: hidden;
  background: #000;
  flex-shrink: 0;
  box-sizing: border-box;
}
.gallery-thumbs > img {
  object-fit: cover;
  display: block;
}
.gallery-thumbs > .thumb-video {
  position: relative;
}
.gallery-thumbs > .thumb-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.gallery-thumbs > .thumb-video .thumb-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
  background: rgba(0,0,0,.18);
  pointer-events: none;
}
.gallery-thumbs > img.active,
.gallery-thumbs > img:hover,
.gallery-thumbs > .thumb-video.active,
.gallery-thumbs > .thumb-video:hover { border-color: var(--primary); opacity: 1; }

/* ── Admin ─────────────────────────────────────────── */
.admin-wrap {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.admin-wrap .table th { background: #fdf0e8; color: var(--text); font-weight: 700; }
.admin-wrap .table td { vertical-align: middle; }

.login-card {
  max-width: 400px;
  margin: 80px auto;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card .logo { font-size: 2.5rem; margin-bottom: 8px; }

/* Drag & drop handle */
.drag-handle {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 20px;
  cursor: grab;
  color: #bbb;
  font-size: .75rem;
  user-select: none;
  border-radius: 6px 6px 0 0;
  background: #f4f4f4;
  margin-bottom: 4px;
  transition: color .15s, background .15s;
}
.drag-handle:hover { color: #888; background: #e8e8e8; }
.drag-handle:active { cursor: grabbing; }
.photo-item.dragging,
.video-admin-item.dragging {
  opacity: .35;
  outline: 2px dashed var(--primary);
  outline-offset: 2px;
}

/* Admin photo grid */
.photo-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.photo-item {
  position: relative;
  width: 120px;
}
.photo-item img {
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  border: 3px solid transparent;
}
.photo-item.is-cover img { border-color: var(--primary); }
.photo-item .cover-badge {
  position: absolute;
  top: 28px; left: 4px;
  background: var(--primary);
  color: white;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  text-transform: uppercase;
}
.photo-item .photo-actions {
  display: flex;
  gap: 4px;
  margin-top: 5px;
  justify-content: center;
}
.photo-item .photo-actions button {
  font-size: .72rem;
  padding: 2px 8px;
  border-radius: 10px;
}
.photo-item.is-video video {
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  border: 3px solid transparent;
  background: #000;
  display: block;
  pointer-events: none;
}
.photo-item.is-video .video-badge {
  position: absolute;
  top: 28px; right: 4px;
  background: rgba(0,0,0,.6);
  color: #fff;
  font-size: .65rem;
  padding: 2px 6px;
  border-radius: 10px;
  pointer-events: none;
}
.photo-item.is-video .video-pending {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 90px;
  background: #f8f9fa;
  border-radius: 8px;
  gap: .4rem;
}

/* Category checkbox grid */
.category-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 6px 12px;
  padding: 12px;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  margin-bottom: 6px;
  transition: border-color .2s, box-shadow .2s;
}
.category-check-grid.cat-error {
  border-color: #dc3545;
  box-shadow: 0 0 0 3px rgba(220,53,69,.15);
}
.category-check-item .form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

/* Upload preview */
#preview-wrap { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
#preview-wrap img {
  width: 100px;
  height: 75px;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid #ddd;
}

/* Video gallery (pagina pubblica) */
.video-gallery { display: flex; flex-direction: row; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.video-gallery video {
  flex: 1 1 320px;
  max-width: 560px;
  width: 100%;
  border-radius: var(--radius);
  background: #000;
  display: block;
}
.video-gallery video.portrait {
  flex-basis: 200px;
  max-width: 320px;
  max-height: 560px;
}
@media (max-width: 575px) {
  .video-gallery { flex-direction: column; }
  .video-gallery video { max-width: 100%; }
  .video-gallery video.portrait { max-width: 100%; max-height: 480px; }
}

/* Video admin grid */
.video-admin-grid { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; }
.video-admin-item { width: 280px; }
.video-admin-item .drag-handle { border-radius: 6px; margin-bottom: 6px; }
.video-admin-item video {
  width: 100%;
  height: 158px;
  border-radius: 8px;
  background: #000;
  display: block;
}

/* Video upload preview */
#video-preview-wrap { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
#video-preview-wrap video {
  width: 200px;
  height: 113px;
  border-radius: 6px;
  border: 2px solid #ddd;
  background: #000;
}

/* ── Footer ────────────────────────────────────────── */
.footer {
  background: var(--primary) !important;
  color: #fff;
  padding: 24px;
  margin-top: 60px;
  font-size: .87rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}
.footer .heart { color: #fff; }
.footer-text {
  text-align: center;
  grid-column: 2;
}
.footer-social {
  display: flex;
  gap: 32px;
  justify-self: start;
  grid-column: 1;
}
.footer-social a {
  font-size: 2.6rem;
  line-height: 1;
  display: inline-block;
  transition: transform .2s ease, filter .2s ease;
}
.footer-social a:hover {
  transform: scale(1.45);
  filter: brightness(1.2);
}
.footer-social .fa-instagram {
  background: linear-gradient(45deg, #feda75 0%, #fa7e1e 25%, #d62976 50%, #962fbf 75%, #4f5bd5 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;
}
.footer-social .fa-tiktok {
  color: #fff;
  text-shadow: 2px 2px 0 #fe2c55, -2px -2px 0 #25f4ee;
}
.navbar-social {
  display: flex;
  gap: 10px;
  align-items: center;
}
.navbar-social a {
  font-size: 1.5rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: #000;
  border-radius: 6px;
  transition: transform .2s ease, filter .2s ease, box-shadow .2s ease;
}
.navbar-social a:hover {
  transform: scale(1.18);
  filter: brightness(1.2);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.25);
}
.navbar-social .ns-ig {
  background: radial-gradient(circle at 30% 110%, #feda75 0%, #fa7e1e 20%, #d62976 45%, #962fbf 65%, #4f5bd5 90%);
}
.navbar-social .ns-ig .fa-instagram { color: #fff; }
.navbar-social .ns-tt { background: #000; }
.navbar-social .ns-tt .fa-tiktok {
  color: #fff;
  text-shadow: 1.5px 1.5px 0 #fe2c55, -1.5px -1.5px 0 #25f4ee;
}
@media (max-width: 575px) {
  .navbar-social { gap: 8px; }
  .navbar-social a {
    font-size: 1.2rem;
    width: 34px;
    height: 34px;
  }
}
@media (max-width: 575px) {
  .footer {
    padding: 18px 14px;
    gap: 8px;
  }
  .footer-social { gap: 16px; }
  .footer-social a { font-size: 1.8rem; }
}

/* ── Utilities ─────────────────────────────────────── */
.btn-primary-custom {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-weight: 600;
}
.btn-primary-custom:hover { opacity: .9; color: white; }

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.count-label { color: var(--muted); font-size: .9rem; }

/* ── Advanced search ─────────────────────────────── */
.search-area {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 560px;
  margin: 0 auto;
}

/* Search-area dentro la navbar (solo home): riempie lo spazio tra titolo e social */
.navbar-search { flex: 1 1 320px; min-width: 0; }
.navbar-search .search-area { max-width: none; margin: 0; }
.search-area .search-wrap {
  flex: 1;
  max-width: none;
  margin: 0;
}
/* Barra di ricerca nella navbar: larga la metà (era ~360px piena) e allineata a destra */
.navbar-search .search-wrap { max-width: 290px; margin-left: auto; }
/* a 180px lo spazio è stretto: l'input si restringe, il pulsante Cerca resta leggibile */
.navbar-search .search-wrap input { min-width: 0; }
.navbar-search .search-wrap button { flex-shrink: 0; }

.adv-toggle-btn {
  background: #fff;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: 30px;
  padding: 8px 18px;
  font-weight: 700;
  font-size: .95rem;
  line-height: 1;
  cursor: pointer;
  transition: background .2s, color .2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.adv-toggle-btn:hover,
.adv-toggle-btn.active {
  background: var(--primary);
  color: #fff;
}

/* Pulsante categorie (3 barre) accanto al toggle ingredienti: stessa pillola,
   ma icona-only e larghezza fissa (non si allarga mai a tutta riga). */
.cat-toggle-pill {
  flex: 0 0 auto;
  padding-left: 15px;
  padding-right: 15px;
  font-size: 1.15rem;
}

/* Pannello filtri categoria collassabile (nascosto di default) */
.cat-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s ease;
}
.cat-panel.open { max-height: 800px; }
.adv-count {
  background: var(--primary);
  color: #fff;
  border: 1.5px solid #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: .72rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* sul pulsante attivo (rosso) il badge si inverte per restare leggibile */
.adv-toggle-btn.active .adv-count { background: #fff; color: var(--primary); }

.adv-panel {
  background: #fff8f2;
  border-top: 1px solid #f0e0d0;
  border-bottom: 2px solid #f0e0d0;
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s ease;
}
.adv-panel.open { max-height: 1600px; }

.adv-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.adv-panel-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
}
.adv-panel-cat {
  font-weight: 400;
  color: var(--muted);
  font-size: .9rem;
}
.adv-clear-link {
  font-size: .82rem;
  color: var(--primary);
}
.adv-clear-link:hover { color: var(--primary-dark); text-decoration: underline; }

/* Scelta ingredienti compatta: chip in area scrollabile */
.ing-search-wrap {
  position: relative;
  max-width: 360px;
}
.ing-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9a8e86;
  pointer-events: none;
  font-size: .9rem;
}
.ing-search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid #e0cdbf;
  border-radius: 20px;
  font-size: .95rem;
  background: #fff;
  outline: none;
}
.ing-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(192,57,43,.18);
}
.ing-suggestions {
  display: none;
  margin-top: 4px;
  background: #fff;
  border: 1px solid #e0cdbf;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
  max-height: 260px;
  overflow-y: auto;
  padding: 4px;
}
.ing-suggestions.show { display: block; }
.ing-sugg-item {
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .95rem;
  color: var(--text);
}
.ing-sugg-item:hover { background: #f4e7df; }
.ing-sugg-empty {
  padding: 8px 12px;
  color: #9a8e86;
  font-size: .9rem;
}
.ingredients-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 190px;
  overflow-y: auto;
  padding: 2px;
}
.ing-chip { cursor: pointer; margin: 0; }
.ing-chip .ing-cb {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.ing-chip span {
  display: inline-block;
  padding: 5px 12px;
  border: 1.5px solid #d9c7bd;
  border-radius: 20px;
  background: #fff;
  color: var(--text);
  font-size: .85rem;
  line-height: 1.2;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.ing-chip:hover span { border-color: var(--primary); }
.ing-chip .ing-cb:checked + span {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.ing-chip .ing-cb:focus-visible + span { box-shadow: 0 0 0 3px rgba(192,57,43,.35); }
.ing-chip.hidden { display: none; }

/* Chip dei filtri attivi (categoria/macro selezionata), rimovibili con la × */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 14px;
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  font-size: .85rem;
  line-height: 1.2;
  white-space: nowrap;
}
.filter-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  text-decoration: none;
}
.filter-chip-x:hover { background: rgba(255,255,255,.5); color: #fff; }
/* Categoria/macro = rosso (default .filter-chip); ingredienti = verde, per distinguerli */
.filter-chip-ing { background: #2e9e44; }
.adv-panel-note {
  font-size: .82rem;
  color: var(--muted);
}

@media (max-width: 575px) {
  .search-area { flex-direction: column; gap: 8px; }
  .search-area .search-wrap { width: 100%; }
  .adv-toggle-btn { width: 100%; justify-content: center; padding: 10px 14px; }
  /* Categorie + ingredienti restano affiancati: l'icona resta compatta,
     il toggle ingredienti riempie lo spazio rimanente. */
  .catalog-buttons .adv-toggle-btn { width: auto; }
  .catalog-buttons #adv-toggle-btn { flex: 1 1 auto; justify-content: center; }
  .catalog-buttons .cat-toggle-pill { flex: 0 0 auto; }
  .ingredients-grid { grid-template-columns: repeat(2, 1fr); }
}
