/* ==========================================
   شيف رانيا محمود - Chef Rania Mahmoud
   Instagram-Style Recipe Website
   ========================================== */

:root {
  --primary: #e1306c;
  --primary-dark: #c13584;
  --primary-light: #fce4ec;
  --secondary: #833ab4;
  --accent: #fd1d1d;
  --gradient: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  --bg: #fafafa;
  --bg-dark: #121212;
  --surface: #ffffff;
  --text: #262626;
  --text-light: #8e8e8e;
  --text-lighter: #c7c7c7;
  --border: #dbdbdb;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-primary: 'Tajawal', 'Cairo', sans-serif;
  --font-secondary: 'Cairo', 'Tajawal', sans-serif;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-top: env(safe-area-inset-top, 0px);
  --bottom-nav-height: 56px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  direction: rtl;
  padding-bottom: 70px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

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

ul { list-style: none; }

img {
  max-width: 100%;
  display: block;
}

.highlight-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ==========================================
   HEADER
   ========================================== */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-secondary);
  font-weight: 700;
  font-size: 1.2rem;
}

.logo i {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 1.4rem;
}

.nav {
  display: none;
  align-items: center;
  gap: 4px;
}

.nav a {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav a:hover,
.nav a.active {
  background: var(--gradient);
  color: #fff;
}

/* Dropdown menus */
.nav-dropdown {
  position: relative;
}

.nav-dropdown > a {
  cursor: pointer;
}

.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--surface);
  min-width: 200px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  z-index: 100;
  padding: 6px;
  margin-top: 4px;
}

.nav-dropdown:hover .dropdown-content {
  display: flex;
}

/* Nav backdrop */
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 998;
}
.nav-backdrop.active {
  display: block;
}

.dropdown-content a {
  display: flex !important;
  padding: 8px 14px !important;
  font-size: 0.85rem !important;
  border-radius: 6px !important;
  color: var(--text) !important;
  background: transparent !important;
}

.dropdown-content a:hover {
  background: #f5f5f5 !important;
  color: var(--primary) !important;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-toggle,
.menu-toggle {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: var(--transition);
}

.search-toggle:hover,
.menu-toggle:hover {
  background: #f0f0f0;
}

/* Mobile Nav Overlay */
@media (max-width: 767px) {
  .nav {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 999;
    gap: 2px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }
  .nav.active {
    display: flex;
  }
  .nav.active a {
    padding: 12px 16px;
    border-radius: 8px;
  }
  .nav-backdrop {
    display: none; /* base style inherited, only override sibling selector */
  }
  .nav.active ~ .nav-backdrop,
  .nav-backdrop.active {
    display: block;
  }
  .nav-dropdown .dropdown-content {
    position: static;
    box-shadow: none;
    border: none;
    padding-right: 16px;
  }
  .nav-dropdown:hover .dropdown-content {
    display: none;
  }
  .nav-dropdown.open .dropdown-content {
    display: block;
  }
}

/* Desktop Nav */
@media (min-width: 768px) {
  .nav { display: flex; }
  .menu-toggle { display: none; }
}

/* Search Bar */
.search-bar {
  display: none;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.search-bar.active {
  display: block;
}

.search-wrapper {
  display: flex;
  align-items: center;
  background: #efefef;
  border-radius: 8px;
  padding: 0 12px;
  gap: 8px;
}

.search-wrapper i {
  color: var(--text-light);
}

.search-wrapper input {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: transparent;
  font-family: var(--font-primary);
  font-size: 0.95rem;
  outline: none;
  color: var(--text);
}

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

.search-close {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
}

.search-results {
  display: none;
  margin-top: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.search-results.active {
  display: block;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.search-result-item:hover {
  background: #f0f0f0;
}

.search-result-item .result-img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.search-result-item .result-info h4 {
  font-size: 0.9rem;
  font-weight: 600;
}

.search-result-item .result-info span {
  font-size: 0.8rem;
  color: var(--text-light);
}

/* ==========================================
   Search Filters
   ========================================== */
.search-filters {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.search-filters select {
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-primary);
  font-size: 0.78rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  outline: none;
  min-width: 120px;
}

.search-filters select:focus {
  border-color: var(--primary);
}

.filter-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 4px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  background: var(--surface);
  color: var(--text);
  user-select: none;
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ==========================================
   Related Recipes
   ========================================== */
.related-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.related-card {
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border);
  background: var(--surface);
}

.related-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.related-card-img {
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: rgba(255,255,255,0.5);
}

.related-card-info {
  padding: 8px 10px;
}

.related-card-info h4 {
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.related-card-info span {
  font-size: 0.7rem;
  color: var(--text-light);
}

/* ==========================================
   BOTTOM NAV (Mobile)
   ========================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 6px 0;
  z-index: 999;
  height: 56px;
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.65rem;
  color: var(--text-light);
  transition: var(--transition);
  padding: 4px 12px;
  border-radius: 8px;
}

.bottom-nav a i {
  font-size: 1.2rem;
}

.bottom-nav a.active {
  color: var(--primary);
}

.bottom-nav a:hover {
  color: var(--primary);
}

@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .bottom-nav { display: none; }
}

/* ==========================================
   STORIES / CATEGORIES
   ========================================== */
/* ==========================================
   DAILY STORIES BAR
   ========================================== */
.daily-stories-section {
  padding: 10px 0 5px;
  overflow: hidden;
}

.daily-stories-header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.daily-stories-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 6px;
}

.daily-stories-title i {
  color: var(--primary);
}

.daily-stories-wrapper {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 0 8px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.daily-stories-wrapper::-webkit-scrollbar {
  display: none;
}

.daily-stories-loader {
  text-align: center;
  padding: 10px;
  color: var(--text-light);
  width: 100%;
}

.daily-story-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  min-width: 68px;
  transition: var(--transition);
  flex-shrink: 0;
}

.daily-story-item:hover {
  transform: translateY(-2px);
}

.daily-story-ring {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  padding: 3px;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.daily-story-ring img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--surface);
}

.daily-story-ring .no-image {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--primary);
  border: 2px solid var(--surface);
}

.daily-story-item .daily-story-title {
  font-size: 0.65rem;
  color: var(--text-light);
  text-align: center;
  max-width: 68px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daily-story-item.seen .daily-story-ring {
  background: var(--border);
}

/* ==========================================
   STORY VIEWER MODAL
   ========================================== */
#storyViewer {
  z-index: 10000;
}

#storyViewer.active {
  display: flex;
}

.story-viewer-container {
  width: 100%;
  height: 100%;
  max-width: 420px;
  max-height: 90vh;
  background: #111;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.story-viewer-header {
  display: flex;
  align-items: center;
  padding: 12px 12px 8px;
  gap: 8px;
  z-index: 2;
}

.story-progress {
  flex: 1;
  display: flex;
  gap: 4px;
}

.story-progress-segment {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  overflow: hidden;
}

.story-progress-segment .story-progress-fill {
  height: 100%;
  background: #fff;
  width: 0%;
  transition: width 0.1s linear;
}

.story-progress-segment.active .story-progress-fill {
  width: 100%;
}

.story-progress-segment.viewed .story-progress-fill {
  width: 100%;
  background: rgba(255,255,255,0.5);
}

.story-viewer-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 50%;
  transition: background 0.2s;
  flex-shrink: 0;
}

.story-viewer-close:hover {
  background: rgba(255,255,255,0.15);
}

.story-viewer-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.story-viewer-image-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}

.story-viewer-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.story-viewer-content {
  padding: 16px 20px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1;
}

.story-viewer-content h2 {
  color: #fff;
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.story-viewer-content p {
  color: rgba(255,255,255,0.85);
  font-size: 0.85rem;
  line-height: 1.5;
}

.story-viewer-nav {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  z-index: 0;
}

.story-nav-btn {
  width: 45%;
  background: none;
  border: none;
  color: rgba(255,255,255,0.3);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  outline: none;
}

.story-nav-btn:hover {
  color: rgba(255,255,255,0.7);
}

.story-nav-btn:first-child {
  justify-content: flex-start;
  padding-left: 12px;
}

.story-nav-btn:last-child {
  justify-content: flex-end;
  padding-right: 12px;
}

.story-viewer-link {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  background: var(--primary);
  color: #fff;
  padding: 8px 20px;
  border-radius: 24px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  transition: var(--transition);
}

.story-viewer-link:hover {
  transform: translateX(-50%) scale(1.05);
}

@media (max-width: 480px) {
  .story-viewer-container {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  #storyViewer.active .modal-overlay {
    padding: 0;
  }

  .daily-story-ring {
    width: 52px;
    height: 52px;
  }

  .daily-story-item {
    min-width: 60px;
  }

  .daily-story-item .daily-story-title {
    max-width: 60px;
    font-size: 0.6rem;
  }
}

/* ==========================================
   STORIES SECTION (Categories)
   ========================================== */
.stories-section {
  padding: 20px 0;
  overflow-x: auto;
}

.stories-wrapper {
  display: flex;
  gap: 16px;
  padding: 4px 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.stories-wrapper::-webkit-scrollbar {
  display: none;
}

.story-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  min-width: 72px;
  transition: var(--transition);
}

.story-item:hover {
  transform: translateY(-2px);
}

.story-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--surface);
  border: 2.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--text-light);
  transition: var(--transition);
}

.story-item.active .story-circle,
.story-item:hover .story-circle {
  border-color: transparent;
  background: var(--gradient);
  color: #fff;
}

.story-item span {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-light);
  text-align: center;
  white-space: nowrap;
}

.story-item.active span {
  color: var(--text);
  font-weight: 700;
}

/* ==========================================
   RECIPE GRID
   ========================================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 16px 0;
}

.section-header h2 {
  font-family: var(--font-secondary);
  font-size: 1.5rem;
  font-weight: 800;
}

.section-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.recipes-count {
  font-size: 0.85rem;
  color: var(--text-light);
}

.view-toggle {
  background: none;
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 1rem;
  transition: var(--transition);
}

.view-toggle:hover {
  background: #f0f0f0;
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.recipe-grid.list-view {
  grid-template-columns: 1fr;
}

@media (min-width: 600px) {
  .recipe-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}

@media (min-width: 900px) {
  .recipe-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }
}

/* Recipe Card */
.recipe-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border);
}

.recipe-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.recipe-card-img {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.recipe-card-img .card-img-icon {
  font-size: 3rem;
  color: rgba(255,255,255,0.6);
}

.recipe-card-img .card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 500;
  backdrop-filter: blur(4px);
}

.recipe-card-img .card-badge.tip {
  background: var(--gradient);
}

.card-badges-row {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 2;
}

.recipe-card-img .card-badge.badge-new {
  background: #22c55e;
}

.recipe-card-img .card-badge.badge-top {
  background: #f59e0b;
}

.recipe-card-img .card-badge.badge-popular {
  background: #ef4444;
}

.recipe-card-img .card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition);
}

.recipe-card:hover .card-overlay {
  opacity: 1;
}

.recipe-card-info {
  padding: 10px 12px 14px;
}

.recipe-card-info h3 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.recipe-card-info .card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-light);
}

.recipe-card-info .card-meta i {
  font-size: 0.65rem;
}

/* List View */
.recipe-grid.list-view .recipe-card {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.recipe-grid.list-view .recipe-card-img {
  width: 120px;
  min-height: 120px;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
}

.recipe-grid.list-view .recipe-card-info {
  flex: 1;
  padding: 12px 16px;
}

.recipe-grid.list-view .recipe-card-info h3 {
  font-size: 1rem;
}

/* ==========================================
   VIDEOS SECTION
   ========================================== */
.videos-section {
  padding: 8px 0 20px;
}

.videos-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 600px) {
  .videos-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .videos-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.video-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
}

.video-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.video-card-embed {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
}

.video-card-embed iframe,
.video-card-embed video,
.video-card-embed .insta-embed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.video-card-embed .insta-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f09433, #dc2743, #bc1888);
  color: #fff;
  text-decoration: none;
  gap: 8px;
}

.video-card-embed .insta-fallback i {
  font-size: 3rem;
}

.video-card-embed .insta-fallback span {
  font-size: 0.85rem;
  font-weight: 600;
}

.video-card-info {
  padding: 12px 14px;
}

.video-card-info h4 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-card-info .video-meta {
  font-size: 0.75rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.video-card-info .video-meta i {
  font-size: 0.65rem;
}

/* Load More */
.load-more {
  text-align: center;
  padding: 24px 0 40px;
}

.btn-load-more {
  background: var(--surface);
  border: 1.5px solid var(--border);
  padding: 10px 32px;
  border-radius: 8px;
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-load-more:hover {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
}

/* ==========================================
   MODAL (Recipe Detail)
   ========================================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: var(--transition);
}

.modal-close:hover {
  background: rgba(0,0,0,0.7);
}

.modal-body {
  padding: 0;
}

.modal-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: rgba(255,255,255,0.4);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px 12px;
}

.modal-header h2 {
  font-family: var(--font-secondary);
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.modal-header .modal-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-header .modal-badges span {
  background: #f0f0f0;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-light);
}

.modal-section {
  padding: 16px 24px;
  border-top: 1px solid #f0f0f0;
}

.modal-section h3 {
  font-family: var(--font-secondary);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-section h3 i {
  color: var(--primary);
}

.modal-section ul {
  padding-right: 20px;
}

.modal-section ul li {
  margin-bottom: 6px;
  font-size: 0.95rem;
  position: relative;
  padding-right: 8px;
}

.ingredients-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

@media (min-width: 500px) {
  .ingredients-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

.ingredients-list li {
  background: #f9f9f9;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ingredients-list li::before {
  content: '•';
  color: var(--primary);
  font-size: 1.2rem;
}

.steps-list li {
  padding: 8px 0;
  counter-increment: step;
  display: flex;
  gap: 10px;
}

.steps-list li::before {
  content: counter(step);
  background: var(--gradient);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-left: 8px;
}

.steps-list {
  counter-reset: step;
  list-style: none;
  padding-right: 0;
}

/* Tips Box */
.tip-box {
  background: linear-gradient(135deg, #fff5f5, #fff0f8);
  border-right: 4px solid var(--primary);
  padding: 16px;
  border-radius: 8px;
  margin: 12px 0;
}

.tip-box h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--primary);
}

.tip-box h4 i {
  font-size: 1.1rem;
}

.tip-box p {
  font-size: 0.9rem;
  color: #555;
}

/* Share Section */
.share-section {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px 24px 24px;
  border-top: 1px solid #f0f0f0;
}

.share-btn {
  flex: 1;
  min-width: 100px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  color: #fff;
}

.share-btn:hover {
  transform: translateY(-2px);
}

.share-btn.facebook-btn { background: #1877f2; }
.share-btn.twitter-btn { background: #000; }
.share-btn.pinterest-btn { background: #e60023; }
.share-btn.whatsapp-btn { background: #25d366; }
.share-btn.copy-btn { background: var(--text); }
.share-btn.print-btn { background: #2c3e50; }
.share-btn.pdf-btn { background: #d32f2f; }

/* Video Modal */
.video-modal-content {
  max-width: 500px;
  background: #000;
  border-radius: var(--radius-lg);
}

.video-modal-content .modal-close {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

.video-modal-body {
  padding: 0;
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.video-modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.video-modal-body .insta-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f09433, #dc2743, #bc1888);
  color: #fff;
  text-decoration: none;
  gap: 12px;
  font-size: 1.1rem;
}

.video-modal-body .insta-fallback i {
  font-size: 4rem;
}

.video-card {
  cursor: pointer;
}

.video-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition);
  z-index: 2;
  cursor: pointer;
}

.video-card-embed:hover .video-card-overlay {
  opacity: 1;
}

.video-card-overlay i {
  color: #fff;
  font-size: 2rem;
  background: rgba(0,0,0,0.5);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================
   ABOUT PAGE
   ========================================== */
.about-hero {
  padding: 40px 0;
  background: linear-gradient(180deg, #fff5f5 0%, var(--bg) 100%);
}

.about-hero-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  text-align: center;
}

.about-image-wrapper {
  position: relative;
}

.about-image {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: #fff;
  box-shadow: 0 8px 30px rgba(225, 48, 108, 0.3);
}

.about-text h1 {
  font-family: var(--font-secondary);
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 8px;
}

.about-subtitle {
  color: var(--text-light);
  font-size: 1.05rem;
  font-weight: 500;
}

.about-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 24px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-number {
  font-size: 1.8rem;
  font-weight: 900;
  font-family: var(--font-secondary);
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-light);
}

.about-story {
  padding: 40px 0;
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 768px) {
  .about-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.about-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  transition: var(--transition);
}

.about-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.about-card-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 1.4rem;
  color: #fff;
}

.about-card h3 {
  font-family: var(--font-secondary);
  font-weight: 700;
  margin-bottom: 8px;
}

.about-card p {
  font-size: 0.9rem;
  color: #666;
  line-height: 1.7;
}

/* Instagram CTA */
.instagram-cta {
  padding: 40px 0;
  background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  color: #fff;
  text-align: center;
}

.cta-content {
  max-width: 500px;
  margin: 0 auto;
}

.cta-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.cta-content h2 {
  font-family: var(--font-secondary);
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.cta-content .highlight-text {
  -webkit-text-fill-color: #fff;
}

.cta-content p {
  font-size: 1rem;
  margin-bottom: 20px;
  opacity: 0.9;
}

.btn-instagram {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  color: #dc2743;
  padding: 12px 28px;
  border-radius: 8px;
  font-weight: 700;
  font-family: var(--font-primary);
  font-size: 1rem;
  transition: var(--transition);
}

.btn-instagram:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

/* ==========================================
   FOOTER
   ========================================== */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 32px 0 16px;
  margin-top: 20px;
}

.footer-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 768px) {
  .footer-content {
    grid-template-columns: 2fr 1fr 1fr;
  }
}

.footer-brand .logo {
  font-size: 1.2rem;
  margin-bottom: 8px;
  display: inline-flex;
}

.footer-brand p {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 8px;
}

.footer-links h4,
.footer-social h4 {
  font-family: var(--font-secondary);
  font-weight: 700;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.footer-links a {
  display: block;
  padding: 4px 0;
  font-size: 0.85rem;
  color: var(--text-light);
  transition: var(--transition);
}

.footer-links a:hover {
  color: var(--primary);
}

.social-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.social-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  transition: var(--transition);
}

.social-icon:hover {
  transform: translateY(-2px);
}

.social-icon.instagram { background: var(--gradient); }
.social-icon.tiktok { background: #000; }
.social-icon.facebook { background: #1877f2; }
.social-icon.youtube { background: #ff0000; }
.social-icon.snapchat { background: #fffc00; color: #000; }
.social-icon.whatsapp { background: #25d366; }

.footer-bottom {
  text-align: center;
  padding-top: 20px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-light);
}

/* ==========================================
   FLOATING INSTAGRAM BUTTON
   ========================================== */
.float-instagram {
  position: fixed;
  bottom: 76px;
  left: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 16px rgba(225, 48, 108, 0.4);
  z-index: 100;
  transition: var(--transition);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(225, 48, 108, 0.4); }
  50% { box-shadow: 0 4px 24px rgba(225, 48, 108, 0.7); }
}

.float-instagram:hover {
  transform: scale(1.1);
}

@media (min-width: 768px) {
  .float-instagram {
    bottom: 24px;
  }
}

/* ==========================================
   SCROLL TO TOP
   ========================================== */
.scroll-top {
  position: fixed;
  bottom: 76px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
  z-index: 100;
  transition: var(--transition);
  box-shadow: var(--shadow);
}

.scroll-top.visible {
  display: flex;
}

.scroll-top:hover {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
}

@media (min-width: 768px) {
  .scroll-top {
    bottom: 24px;
  }
}

/* ==========================================
   TOAST
   ========================================== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 3000;
  opacity: 0;
  transition: var(--transition);
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 768px) {
  .toast {
    bottom: 24px;
  }
}

/* ==========================================
   NO RESULTS
   ========================================== */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
}

.no-results i {
  font-size: 3rem;
  color: var(--text-lighter);
  margin-bottom: 12px;
}

.no-results h3 {
  font-family: var(--font-secondary);
  font-weight: 700;
  margin-bottom: 4px;
}

.no-results p {
  color: var(--text-light);
  font-size: 0.9rem;
}

/* ==========================================
   SCROLLBAR
   ========================================== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-lighter);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}

/* ==========================================
   PWA INSTALL PROMPT
   ========================================== */
.pwa-prompt {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 8px);
  left: 8px;
  right: 8px;
  z-index: 500;
  animation: slideUp 0.4s ease;
}

@keyframes slideUp {
  from { transform: translateY(100px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.pwa-prompt-content {
  background: var(--surface);
  border-radius: 16px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  border: 1px solid var(--border);
  position: relative;
}

.pwa-prompt-icon {
  font-size: 2rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient);
  border-radius: 12px;
  flex-shrink: 0;
}

.pwa-prompt-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.pwa-prompt-text strong {
  font-size: 0.9rem;
  font-weight: 700;
}

.pwa-prompt-text span {
  font-size: 0.78rem;
  color: var(--text-light);
}

.pwa-prompt-install {
  background: var(--gradient);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.pwa-prompt-install:hover {
  transform: scale(1.05);
}

.pwa-prompt-close {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  border: 2px solid var(--surface);
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 768px) {
  .pwa-prompt { display: none !important; }
}

/* ==========================================
   APP-LIKE MOBILE ENHANCEMENTS
   ========================================== */
@media (max-width: 767px) {
  body {
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
    background: var(--bg);
  }

  .header {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: rgba(255,255,255,0.92);
  }

  .story-item {
    -webkit-tap-highlight-color: transparent;
  }

  .story-item:active .story-circle {
    transform: scale(0.9);
  }

  .recipe-card {
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease;
  }

  .recipe-card:active {
    transform: scale(0.97) !important;
  }

  .bottom-nav {
    padding-bottom: var(--safe-area-bottom);
    height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: rgba(255,255,255,0.95);
  }

  .bottom-nav a:active {
    transform: scale(0.9);
  }

  .modal-content {
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    margin-top: auto;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 100%;
    animation: modalSlideUp 0.35s ease;
  }

  .modal-overlay.active {
    align-items: flex-end;
  }

  @keyframes modalSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .float-instagram {
    bottom: calc(var(--bottom-nav-height) + 16px);
  }

  .scroll-top {
    bottom: calc(var(--bottom-nav-height) + 16px);
  }

  .search-bar {
    padding-bottom: calc(8px + var(--safe-area-bottom));
  }

  .stories-wrapper {
    scroll-snap-type: x mandatory;
  }

  .story-item {
    scroll-snap-align: start;
  }

  /* Smooth page transitions */
  .recipe-grid .recipe-card {
    animation: fadeInUp 0.4s ease backwards;
  }

  .recipe-grid .recipe-card:nth-child(1) { animation-delay: 0s; }
  .recipe-grid .recipe-card:nth-child(2) { animation-delay: 0.05s; }
  .recipe-grid .recipe-card:nth-child(3) { animation-delay: 0.1s; }
  .recipe-grid .recipe-card:nth-child(4) { animation-delay: 0.15s; }

  @keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* ==========================================
   MODAL DRAG INDICATOR (mobile)
   ========================================== */
.modal-content::before {
  content: '';
  display: none;
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
}

@media (max-width: 767px) {
  .modal-content::before {
    display: block;
  }
}

/* ==========================================
   PULL TO REFRESH INDICATOR (simulated)
   ========================================== */
.pull-indicator {
  text-align: center;
  padding: 12px;
  color: var(--text-light);
  font-size: 0.8rem;
  display: none;
}

/* ==========================================
   SKELETON LOADING
   ========================================== */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 400px) {
  .recipe-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .recipe-card-info {
    padding: 8px 10px 10px;
  }

  .recipe-card-info h3 {
    font-size: 0.78rem;
  }
}

/* ==========================================
   Favorites Button
   ========================================== */
.fav-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(255,255,255,0.9);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  font-size: 1rem;
  color: #ddd;
  transition: var(--transition);
  box-shadow: var(--shadow);
}

.fav-btn:hover {
  transform: scale(1.1);
}

.fav-btn.active {
  color: var(--primary);
  background: rgba(255,255,255,0.95);
}

.fav-btn.active i {
  animation: heartPop 0.3s ease;
}

@keyframes heartPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ==========================================
   Servings Control
   ========================================== */
.servings-section {
  background: #f8f9fa;
  border-radius: var(--radius);
  margin: 0 16px 12px;
  padding: 12px 16px;
}

.servings-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.servings-control label {
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.servings-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.serving-btn {
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--primary);
  background: #fff;
  color: var(--primary);
  border-radius: 50%;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.serving-btn:hover {
  background: var(--primary);
  color: #fff;
}

.serving-count {
  font-weight: 700;
  font-size: 1.2rem;
  min-width: 30px;
  text-align: center;
  color: var(--primary);
}

/* ==========================================
   Star Rating
   ========================================== */
.star-input .star-btn:hover,
.star-input .star-btn:hover ~ .star-btn {
  color: #f5a623 !important;
}

.star-input {
  unicode-bidi: bidi-override;
  direction: rtl;
}

.star-input .star-btn {
  font-size: 1.6rem;
  padding: 0 2px;
}

/* ==========================================
   Reviews
   ========================================== */
#reviewsSection {
  scroll-margin-top: 16px;
}

.review-form textarea,
.review-form input {
  font-size: 0.85rem;
  background: var(--bg);
}

.review-form textarea:focus,
.review-form input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ==========================================
   Nutrition
   ========================================== */
.nutrition-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nutrition-item {
  flex: 1;
  min-width: 80px;
  background: #f8f9fa;
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  border: 1px solid var(--border);
}

.nutrition-value {
  display: block;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

.nutrition-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-light);
  margin-top: 2px;
}

.calories-badge {
  background: rgba(225, 48, 108, 0.85) !important;
  color: #fff !important;
  left: auto !important;
  right: 8px;
  font-size: 0.65rem;
}

.calories-badge i {
  margin-left: 3px;
}

/* ==========================================
   AI Assistant Floating Panel
   ========================================== */
.ai-fab {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 80px);
  left: 16px;
  z-index: 999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  box-shadow: 0 4px 16px rgba(225,48,108,0.4);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(225,48,108,0.5);
}

.ai-fab .fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent);
  color: #fff;
  font-size: 0.55rem;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.ai-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: 0.3s;
}

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

.ai-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 380px;
  max-width: 88vw;
  background: var(--surface);
  z-index: 1001;
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  border-left: 1px solid var(--border);
}

.ai-panel.open {
  transform: translateX(0);
}

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--gradient);
  color: #fff;
  flex-shrink: 0;
}

.ai-panel-header h3 {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-panel-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  transition: 0.2s;
}

.ai-panel-close:hover {
  background: rgba(255,255,255,0.35);
}

.ai-panel-tabs {
  display: flex;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
}

.ai-panel-tab {
  flex: 1;
  min-width: 0;
  padding: 10px 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-light);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border-bottom: 2px solid transparent;
  font-family: inherit;
}

.ai-panel-tab i {
  font-size: 1rem;
}

.ai-panel-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.ai-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.ai-panel-tab-content {
  display: none;
}

.ai-panel-tab-content.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

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

/* Ingredient Search */
.ai-ingredient-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.2s;
}

.ai-ingredient-input:focus {
  outline: none;
  border-color: var(--primary);
}

.ai-ingredient-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.ai-ingredient-tag {
  background: #f0f0f0;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
}

.ai-ingredient-tag .remove-tag {
  cursor: pointer;
  color: var(--text-light);
  font-size: 0.65rem;
}

.ai-ingredient-tag .remove-tag:hover {
  color: var(--danger);
}

/* Pantry */
.ai-pantry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.ai-pantry-item {
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: 0.2s;
  background: var(--surface);
  text-align: center;
  user-select: none;
}

.ai-pantry-item:hover {
  border-color: var(--primary);
}

.ai-pantry-item.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* AI Chat */
.ai-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px 0;
}

.ai-chat-msg {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.82rem;
  line-height: 1.6;
  max-width: 88%;
  word-wrap: break-word;
}

.ai-chat-msg.user {
  background: var(--primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-left-radius: 4px;
}

.ai-chat-msg.assistant {
  background: var(--bg);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-right-radius: 4px;
}

.ai-chat-msg .msg-sender {
  font-size: 0.65rem;
  font-weight: 600;
  margin-bottom: 4px;
  opacity: 0.7;
}

.ai-chat-input-wrap {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.ai-chat-input-wrap input {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  font-family: inherit;
  font-size: 0.85rem;
}

.ai-chat-input-wrap input:focus {
  outline: none;
  border-color: var(--primary);
}

.ai-chat-input-wrap button {
  background: var(--primary);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: 0.2s;
}

.ai-chat-input-wrap button:hover {
  transform: scale(1.05);
}

/* Recipe results cards */
.ai-recipe-result {
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: 0.2s;
}

.ai-recipe-result:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.ai-recipe-result h4 {
  font-size: 0.85rem;
  margin-bottom: 4px;
  color: var(--primary);
}

.ai-recipe-result p {
  font-size: 0.75rem;
  color: var(--text-light);
}

.ai-recipe-result .recipe-match-badge {
  display: inline-block;
  background: var(--success);
  color: #fff;
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 4px;
}

/* Generated recipe display */
.ai-generated-recipe {
  background: #f0faf4;
  border: 1px solid #d4edda;
  border-radius: 10px;
  padding: 14px;
  font-size: 0.85rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

.ai-loading {
  text-align: center;
  padding: 20px;
  color: var(--text-light);
}

.ai-error {
  color: var(--danger);
  padding: 12px;
  background: #fde8e8;
  border-radius: 8px;
  font-size: 0.85rem;
}

@media (max-width: 480px) {
  .ai-panel {
    width: 100vw;
    max-width: 100vw;
  }
  .ai-fab {
    bottom: calc(var(--bottom-nav-height) + 16px);
    left: 12px;
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }
  .ai-pantry-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}
