/* ---- Theme Variables ---- */
:root {
  --bg: #faf8f5;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-content: #faf8f5;
  --text: #2c2420;
  --text-secondary: #6b5e54;
  --text-muted: #a89a8e;
  --accent: #e07a3a;
  --accent-hover: #d06828;
  --accent-glow: rgba(224, 122, 58, 0.15);
  --accent-subtle: #fdf0e6;
  --border: #ece5dd;
  --tag-bg: #f5f0ea;
  --tag-text: #7a6b5d;
  --tag-active-bg: #e07a3a;
  --tag-active-text: #fff;
  --search-bg: #f5f0ea;
  --search-border: #ece5dd;
  --card-hover-border: #e07a3a;
  --badge-bg: #e07a3a;
  --badge-text: #fff;
  --hero-gradient: linear-gradient(135deg, #fdf0e6 0%, #faf8f5 100%);
  --shadow-sm: 0 1px 2px rgba(44,36,32,0.04);
  --shadow: 0 2px 8px rgba(44,36,32,0.06), 0 1px 2px rgba(44,36,32,0.04);
  --shadow-hover: 0 8px 30px rgba(224,122,58,0.12), 0 2px 8px rgba(44,36,32,0.06);
  --shadow-glow: 0 0 0 3px rgba(224,122,58,0.1);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-width: 270px;
  --header-height: 56px;
  --bottom-tab-height: 64px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #18140f;
  --bg-sidebar: #211c16;
  --bg-card: #261f18;
  --bg-content: #18140f;
  --text: #f0ebe4;
  --text-secondary: #b5a99a;
  --text-muted: #6d6158;
  --accent: #f0923a;
  --accent-hover: #f5a55a;
  --accent-glow: rgba(240, 146, 58, 0.2);
  --accent-subtle: #332618;
  --border: #352d24;
  --tag-bg: #2e2720;
  --tag-text: #b5a99a;
  --tag-active-bg: #f0923a;
  --tag-active-text: #18140f;
  --search-bg: #2e2720;
  --search-border: #352d24;
  --card-hover-border: #f0923a;
  --badge-bg: #f0923a;
  --badge-text: #18140f;
  --hero-gradient: linear-gradient(135deg, #2a2118 0%, #18140f 100%);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-hover: 0 8px 30px rgba(240,146,58,0.15), 0 2px 8px rgba(0,0,0,0.3);
  --shadow-glow: 0 0 0 3px rgba(240,146,58,0.15);
}

/* ---- Reset ---- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-content);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
}

/* ---- Layout ---- */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---- Sidebar (desktop) ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  overflow: hidden;
}

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

.logo {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.theme-toggle {
  background: var(--tag-bg);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.theme-toggle:hover {
  color: var(--accent);
  background: var(--accent-subtle);
  transform: rotate(15deg);
}

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

.sidebar-search {
  padding: 0 18px 14px;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--search-border);
  border-radius: var(--radius-sm);
  background: var(--search-bg);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: all var(--transition);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
  background: var(--bg-card);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px;
}

.nav-section {
  margin-bottom: 16px;
}

.nav-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 0 10px 10px;
}

.nav-tag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-secondary);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: all var(--transition);
  font-weight: 450;
}

.nav-tag:hover {
  background: var(--tag-bg);
  color: var(--text);
  transform: translateX(3px);
}

.nav-tag.active {
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-tag-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--tag-bg);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  min-width: 24px;
  text-align: center;
}

.nav-tag.active .nav-tag-count {
  color: var(--accent);
  background: var(--accent-glow);
}

.sidebar-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.recipe-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---- Mobile Header ---- */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
  backdrop-filter: blur(10px);
}

/* ---- Main Content ---- */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 36px 44px;
  min-width: 0;
  scroll-behavior: smooth;
}

.loading {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ---- Hero / Content Header ---- */
.content-hero {
  background: var(--hero-gradient);
  border-radius: var(--radius);
  padding: 32px 36px;
  margin-bottom: 28px;
  border: 1px solid var(--border);
}

.content-hero h1 {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.15;
  margin-bottom: 4px;
}

.content-hero .hero-accent {
  color: var(--accent);
}

.content-hero .subtitle {
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 450;
}

/* ---- Recipe Grid ---- */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.recipe-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 22px 24px;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.recipe-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition);
}

.recipe-card:hover {
  border-color: var(--card-hover-border);
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

.recipe-card:hover::before {
  transform: scaleX(1);
}

.recipe-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
  line-height: 1.3;
  letter-spacing: -0.2px;
}

.card-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.card-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.card-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--tag-bg);
  color: var(--tag-text);
  letter-spacing: 0.2px;
}

.card-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--accent-subtle);
  color: var(--accent);
  white-space: nowrap;
}

.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ---- Recipe Detail ---- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 24px;
  transition: all var(--transition);
  padding: 6px 12px 6px 8px;
  border-radius: var(--radius-sm);
}

.back-link:hover {
  background: var(--accent-subtle);
  transform: translateX(-3px);
}

.recipe-detail-header {
  margin-bottom: 32px;
}

.recipe-detail-header h1 {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 16px;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.meta-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.88rem;
  color: var(--text);
  font-weight: 500;
}

.meta-chip-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.recipe-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.recipe-tag {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--tag-bg);
  color: var(--tag-text);
  transition: all var(--transition);
}

.recipe-tag:hover {
  background: var(--accent-subtle);
  color: var(--accent);
}

/* Detail sections */
.recipe-body {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 44px;
  align-items: start;
}

.recipe-section {
  margin-bottom: 28px;
}

.section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

/* Ingredient list with checkboxes */
.ingredient-list {
  list-style: none;
}

.ingredient-list li {
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  transition: all var(--transition);
}

.ingredient-list li:hover {
  padding-left: 4px;
}

.ingredient-list li:last-child {
  border-bottom: none;
}

.ingredient-list li.checked {
  color: var(--text-muted);
  text-decoration: line-through;
}

.ingredient-check {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 7px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  transition: all var(--transition);
}

.ingredient-list li:hover .ingredient-check {
  border-color: var(--accent);
}

.ingredient-list li.checked .ingredient-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: scale(1.1);
}

/* Instructions */
.instruction-list {
  list-style: none;
  counter-reset: step;
}

.instruction-list li {
  counter-increment: step;
  padding: 16px 0 16px 48px;
  position: relative;
  font-size: 1rem;
  line-height: 1.65;
  border-bottom: 1px solid var(--border);
  transition: all var(--transition);
}

.instruction-list li:last-child {
  border-bottom: none;
}

.instruction-list li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 16px;
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.instruction-subheading {
  font-size: 1rem;
  font-weight: 700;
  margin: 24px 0 10px;
  color: var(--text);
  letter-spacing: -0.2px;
}

.instruction-subheading:first-child {
  margin-top: 0;
}

/* Notes */
.recipe-notes {
  background: var(--accent-subtle);
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.7;
  border-left: 3px solid var(--accent);
}

.recipe-notes ul {
  margin: 0;
  padding-left: 18px;
}

.recipe-notes li {
  margin-bottom: 4px;
}

/* Variations */
.variations-list {
  list-style: none;
}

.variations-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.5;
}

.variations-list li:last-child {
  border-bottom: none;
}

.variations-list strong {
  color: var(--accent);
}

/* ---- Bottom Tabs (mobile) ---- */
.bottom-tabs {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-tab-height);
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
  backdrop-filter: blur(10px);
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 20px;
  border-radius: 12px;
  transition: all var(--transition);
}

.tab-item.active {
  color: var(--accent);
  background: var(--accent-subtle);
}

/* ---- Filter Drawer (mobile) ---- */
.filter-drawer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
}

.filter-drawer.open {
  display: block;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}

.drawer-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-sidebar);
  border-radius: 20px 20px 0 0;
  max-height: 75vh;
  overflow-y: auto;
  padding: 0 22px 22px;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 14px;
  position: sticky;
  top: 0;
  background: var(--bg-sidebar);
}

.drawer-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.drawer-close {
  background: var(--tag-bg);
  border: none;
  font-size: 1.3rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 10px;
  transition: all var(--transition);
}

.drawer-close:hover {
  background: var(--accent-subtle);
  color: var(--accent);
}

.drawer-search {
  margin-bottom: 16px;
}

.drawer-tags {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drawer-tags .nav-tag {
  padding: 14px 14px;
  font-size: 0.98rem;
  border-radius: 12px;
}

/* ---- Mobile Responsive ---- */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .mobile-header {
    display: flex;
  }

  .bottom-tabs {
    display: flex;
  }

  .content {
    padding: 20px 18px;
    padding-top: calc(var(--header-height) + 16px);
    padding-bottom: calc(var(--bottom-tab-height) + 16px);
  }

  .recipe-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .content-hero {
    padding: 24px 22px;
    margin-bottom: 20px;
  }

  .content-hero h1 {
    font-size: 1.4rem;
  }

  .recipe-detail-header h1 {
    font-size: 1.7rem;
  }

  .recipe-body {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media (min-width: 769px) {
  .mobile-header {
    display: none !important;
  }

  .bottom-tabs {
    display: none !important;
  }

  .filter-drawer {
    display: none !important;
  }
}

/* ---- Scrollbar ---- */
.sidebar-nav::-webkit-scrollbar,
.content::-webkit-scrollbar {
  width: 5px;
}

.sidebar-nav::-webkit-scrollbar-track,
.content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb,
.content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover,
.content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ---- Animations ---- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.recipe-card {
  animation: fadeIn 0.3s ease both;
}

.recipe-card:nth-child(2) { animation-delay: 0.03s; }
.recipe-card:nth-child(3) { animation-delay: 0.06s; }
.recipe-card:nth-child(4) { animation-delay: 0.09s; }
.recipe-card:nth-child(5) { animation-delay: 0.12s; }
.recipe-card:nth-child(6) { animation-delay: 0.15s; }
.recipe-card:nth-child(7) { animation-delay: 0.18s; }
.recipe-card:nth-child(8) { animation-delay: 0.21s; }
.recipe-card:nth-child(9) { animation-delay: 0.24s; }
.recipe-card:nth-child(10) { animation-delay: 0.27s; }
