/* ============================================
   🚀 KILLER MOBILE-FIRST PROFESSIONAL LAYOUT
   Modern UX Design System for Recipe Platform
   ============================================ */

/* ============================================
   📱 MOBILE BASE (320px+) - Design for smallest first
   ============================================ */

/* Core mobile-first container */
.container-mobile-first {
  width: 100%;
  max-width: 100%;
  padding: 1rem;
  margin: 0 auto;
}

/* Safe area for notched devices (iPhone X+) */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 16px);
  --safe-bottom: env(safe-area-inset-bottom, 16px);
  --safe-left: env(safe-area-inset-left, 16px);
}

/* ============================================
   🎨 MOBILE-FIRST HEADER
   ============================================ */

.mobile-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: linear-gradient(
    135deg,
    var(--jamaica-green, #008744) 0%,
    var(--jamaica-green-dark, #006b3c) 100%
  );
  padding: var(--safe-top) var(--safe-right) 0.75rem var(--safe-left);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.mobile-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 100%;
}

.mobile-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: white;
  text-decoration: none;
}

.mobile-logo-icon {
  font-size: 1.75rem;
  animation: pulse 2s ease-in-out infinite;
}

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

/* Menu toggle button */
.mobile-menu-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 8px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-menu-toggle:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   🧭 BOTTOM NAVIGATION BAR
   Thumb-friendly, always accessible
   ============================================ */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.98);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding: 0.5rem var(--safe-right) var(--safe-bottom) var(--safe-left);
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.08);
}

.bottom-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  min-width: 64px;
  color: #757575;
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s ease;
  border-radius: 12px;
  position: relative;
}

.bottom-nav-item:active {
  transform: scale(0.95);
  background: rgba(0, 135, 68, 0.05);
}

.bottom-nav-item.active {
  color: var(--jamaica-green, #008744);
  font-weight: 700;
}

.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 3px;
  background: var(--jamaica-green, #008744);
  border-radius: 0 0 3px 3px;
}

.bottom-nav-icon {
  font-size: 1.5rem;
  transition: transform 0.2s ease;
}

.bottom-nav-item.active .bottom-nav-icon {
  transform: translateY(-2px);
}

.bottom-nav-label {
  font-size: 0.6875rem;
  line-height: 1;
}

/* Badge for notifications/favorites */
.nav-badge {
  position: absolute;
  top: 0.25rem;
  right: 0.75rem;
  background: #ff3d00;
  color: white;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 0.125rem 0.375rem;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ============================================
   📋 MOBILE CARD DESIGN
   Swipeable, digestible content cards
   ============================================ */

.mobile-card-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 5rem 1rem 5rem 1rem; /* Account for fixed header/bottom nav */
}

.mobile-recipe-card {
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  position: relative;
}

.mobile-recipe-card:active {
  transform: scale(0.98);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* Card image - optimized for mobile */
.mobile-card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
  position: relative;
}

.mobile-card-image::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.4), transparent);
}

/* Card content */
.mobile-card-content {
  padding: 1rem;
}

.mobile-card-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #212121;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.mobile-card-meta {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  color: #757575;
}

.mobile-card-meta-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.mobile-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.mobile-tag {
  background: rgba(45, 80, 22, 0.08);
  color: #2d5016;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Card actions */
.mobile-card-actions {
  display: flex;
  gap: 0.5rem;
  border-top: 1px solid #f5f5f5;
  padding-top: 1rem;
}

.mobile-card-btn {
  flex: 1;
  padding: 0.75rem;
  border-radius: 8px;
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.mobile-card-btn-primary {
  background: linear-gradient(135deg, #2d5016 0%, #3d6e1f 100%);
  color: white;
}

.mobile-card-btn-secondary {
  background: white;
  color: #2d5016;
  border: 2px solid #2d5016;
}

.mobile-card-btn:active {
  transform: scale(0.97);
}

/* ============================================
   🎯 FLOATING ACTION BUTTON (FAB)
   Quick actions at thumb reach
   ============================================ */

.fab {
  position: fixed;
  bottom: calc(5rem + var(--safe-bottom));
  right: 1rem;
  z-index: 999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff6f00 0%, #ff8f00 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 16px rgba(255, 111, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.fab:active {
  transform: scale(0.9) rotate(90deg);
}

.fab-menu {
  position: fixed;
  bottom: calc(6.5rem + var(--safe-bottom));
  right: 1rem;
  z-index: 998;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.fab-menu.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(-10px);
}

.fab-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: white;
  padding: 0.75rem 1rem;
  border-radius: 28px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-size: 0.875rem;
  font-weight: 600;
  color: #212121;
  text-decoration: none;
  white-space: nowrap;
}

/* ============================================
   📱 SWIPEABLE SECTIONS
   Horizontal scrolling for categories
   ============================================ */

.mobile-swipe-container {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  margin: 0 -1rem;
  padding: 0 1rem;
}

.mobile-swipe-container::-webkit-scrollbar {
  display: none;
}

.mobile-swipe-items {
  display: flex;
  gap: 1rem;
  padding-bottom: 0.5rem;
}

.mobile-swipe-item {
  flex: 0 0 280px;
  scroll-snap-align: start;
}

/* ============================================
   🔍 MOBILE SEARCH BAR
   ============================================ */

.mobile-search {
  position: sticky;
  top: 4rem;
  z-index: 900;
  padding: 0.75rem 1rem;
  background: white;
  border-bottom: 1px solid #e0e0e0;
}

.mobile-search-input {
  width: 100%;
  padding: 0.875rem 1rem 0.875rem 3rem;
  border: 2px solid #e0e0e0;
  border-radius: 24px;
  font-size: 1rem;
  background: #f5f5f5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23757575' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 1rem center;
  background-size: 20px 20px;
}

.mobile-search-input:focus {
  outline: none;
  border-color: #2d5016;
  background-color: white;
}

/* ============================================
   🎨 MOBILE FILTER CHIPS
   Easy one-tap filtering
   ============================================ */

.mobile-filter-bar {
  position: sticky;
  top: 8rem;
  z-index: 850;
  background: white;
  border-bottom: 1px solid #e0e0e0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.mobile-filter-bar::-webkit-scrollbar {
  display: none;
}

.mobile-filter-chips {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  min-width: min-content;
}

.mobile-filter-chip {
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: 2px solid #e0e0e0;
  background: white;
  font-size: 0.875rem;
  font-weight: 600;
  color: #616161;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-filter-chip:active {
  transform: scale(0.95);
}

.mobile-filter-chip.active {
  background: linear-gradient(135deg, #2d5016 0%, #3d6e1f 100%);
  color: white;
  border-color: #2d5016;
}

/* ============================================
   📊 MOBILE STATS CARDS
   Quick info at a glance
   ============================================ */

.mobile-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.mobile-stat-card {
  background: linear-gradient(135deg, #f5f5f5 0%, #ffffff 100%);
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid #e0e0e0;
  text-align: center;
}

.mobile-stat-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.mobile-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #2d5016;
  display: block;
  margin-bottom: 0.25rem;
}

.mobile-stat-label {
  font-size: 0.75rem;
  color: #757575;
  font-weight: 500;
}

/* ============================================
   🎭 MOBILE SHEET/MODAL
   Bottom sheet for actions/details
   ============================================ */

.mobile-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.mobile-sheet-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.mobile-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2001;
  background: white;
  border-radius: 24px 24px 0 0;
  max-height: 85vh;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding-bottom: var(--safe-bottom);
}

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

.mobile-sheet-handle {
  width: 40px;
  height: 4px;
  background: #e0e0e0;
  border-radius: 2px;
  margin: 0.75rem auto;
}

.mobile-sheet-content {
  padding: 0 1.5rem 1.5rem;
  overflow-y: auto;
  max-height: calc(85vh - 3rem);
}

.mobile-sheet-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #212121;
  margin-bottom: 1rem;
}

/* ============================================
   🍽️ MEAL TYPE INDICATOR
   Visual meal categorization
   ============================================ */

.meal-type-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.375rem 0.75rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

.meal-breakfast {
  background: rgba(255, 193, 7, 0.9);
  color: #000;
}

.meal-lunch {
  background: rgba(76, 175, 80, 0.9);
  color: white;
}

.meal-dinner {
  background: rgba(63, 81, 181, 0.9);
  color: white;
}

.meal-snack {
  background: rgba(233, 30, 99, 0.9);
  color: white;
}

.meal-soup {
  background: rgba(255, 87, 34, 0.9);
  color: white;
}

/* ============================================
   ⚡ LOADING STATES
   Smooth loading experience
   ============================================ */

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

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

.mobile-skeleton-card {
  height: 300px;
  margin-bottom: 1rem;
  border-radius: 16px;
}

.mobile-skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

/* ============================================
   🎨 PULL-TO-REFRESH
   Native-feeling refresh gesture
   ============================================ */

.pull-to-refresh {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  z-index: 999;
  padding: 1rem;
  background: white;
  border-radius: 0 0 16px 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.pull-to-refresh.pulling {
  transform: translateX(-50%) translateY(0);
}

.pull-to-refresh-icon {
  width: 32px;
  height: 32px;
  border: 3px solid #e0e0e0;
  border-top-color: #2d5016;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   📱 RESPONSIVE BREAKPOINTS
   Progressive enhancement for larger screens
   ============================================ */

/* Small phones (375px+) */
@media (min-width: 375px) {
  .mobile-card-image {
    height: 220px;
  }

  .mobile-card-title {
    font-size: 1.25rem;
  }
}

/* Large phones (414px+) */
@media (min-width: 414px) {
  .mobile-card-container {
    padding: 5rem 1.5rem 5rem 1.5rem;
  }

  .mobile-stats-grid {
    gap: 1.25rem;
  }
}

/* Tablets (768px+) */
@media (min-width: 768px) {
  .container-mobile-first {
    max-width: 720px;
    padding: 1.5rem;
  }

  .mobile-card-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .mobile-stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .bottom-nav {
    display: none;
  }

  /* Show traditional desktop nav */
  .desktop-nav {
    display: flex;
  }

  .fab {
    bottom: 2rem;
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  .container-mobile-first {
    max-width: 960px;
  }

  .mobile-card-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
  }

  .mobile-swipe-item {
    flex: 0 0 320px;
  }
}

/* Large desktop (1280px+) */
@media (min-width: 1280px) {
  .container-mobile-first {
    max-width: 1200px;
  }

  .mobile-card-container {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================
   ✨ SMOOTH ANIMATIONS
   Micro-interactions for premium feel
   ============================================ */

@media (prefers-reduced-motion: no-preference) {
  .mobile-recipe-card,
  .mobile-card-btn,
  .mobile-filter-chip,
  .bottom-nav-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   🌙 DARK MODE SUPPORT
   ============================================ */

@media (prefers-color-scheme: dark) {
  .mobile-recipe-card {
    background: #1e1e1e;
    color: #e0e0e0;
  }

  .mobile-card-title {
    color: #ffffff;
  }

  .mobile-search-input {
    background: #2d2d2d;
    color: #e0e0e0;
    border-color: #424242;
  }

  .mobile-filter-chip {
    background: #2d2d2d;
    border-color: #424242;
    color: #e0e0e0;
  }

  .bottom-nav {
    background: rgba(30, 30, 30, 0.98);
    border-top-color: #424242;
  }
}
