/* ── 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: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%) !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: 2.4rem;
  white-space: nowrap;
}
@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; }

.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 {
  height: 210px;
  object-fit: cover;
  width: 100%;
  display: block;
}
.recipe-card .no-img {
  height: 210px;
  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;
}

/* ── Photo gallery ─────────────────────────────────── */
.gallery-wrap {
  position: relative;
  margin-bottom: 10px;
}
.gallery-main {
  border-radius: var(--radius);
  overflow: hidden;
  background: #f0e0d0;
}
.gallery-main img,
.gallery-main video {
  width: 100%;
  height: 400px;
  object-fit: cover;
  display: block;
  background: #000;
}
.gallery-main video.portrait { object-fit: contain; }

.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: #1a0a00 !important;
  color: #ccc;
  padding: 24px 0;
  margin-top: 60px;
  text-align: center;
  font-size: .87rem;
}
.footer .heart { color: var(--primary); }

/* ── 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 .search-wrap {
  flex: 1;
  max-width: none;
  margin: 0;
}

.adv-toggle-btn {
  background: rgba(255,255,255,.15);
  color: white;
  border: 2px solid rgba(255,255,255,.6);
  border-radius: 40px;
  padding: 0 14px;
  font-weight: 600;
  font-size: .82rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s, border-color .2s;
  display: flex;
  align-items: center;
  gap: 6px;
  align-self: stretch;
  animation: adv-toggle-pulse 1.6s ease-in-out infinite;
}
.adv-toggle-btn:hover,
.adv-toggle-btn.active {
  background: rgba(255,255,255,.28);
  border-color: white;
  animation: none;
  box-shadow: none;
}
@keyframes adv-toggle-pulse {
  0%, 100% {
    border-color: rgba(255,255,255,.6);
    box-shadow: 0 0 0 0 rgba(255,255,255,.55);
  }
  50% {
    border-color: #fff;
    box-shadow: 0 0 0 6px rgba(255,255,255,0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .adv-toggle-btn { animation: none; }
}
.adv-count {
  background: white;
  color: var(--primary);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: .72rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.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; }

.ingredients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 6px 16px;
}
.ing-check-item .form-check-input {
  cursor: pointer;
  border-color: #6c757d;
  border-width: 2px;
}
.ing-check-item .form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}
.ing-check-item .form-check-label {
  cursor: pointer;
  font-size: .88rem;
  color: var(--text);
}
.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; }
  .ingredients-grid { grid-template-columns: repeat(2, 1fr); }
}
