/*
 * mobile.css - Mobile-specific styles for ScanFood
 * Mobile-First Design - FUNDAMENTALLY OPTIMIZED
 * Updated: 2025-10-04
 */

/* ========================================
   1. MOBILE BASE STYLES
   ======================================== */

/* Touch-friendly tap targets */
button, a, input, select, textarea {
  -webkit-tap-highlight-color: rgba(255, 107, 71, 0.2);
  min-height: 44px; /* Apple's recommended minimum touch target */
}

/* Prevent zoom on input focus (iOS) */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
textarea,
select {
  font-size: 16px !important; /* Prevents zoom on iOS */
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Prevent pull-to-refresh on mobile */
body {
  overscroll-behavior-y: contain;
}

/* Better text rendering on mobile */
body {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   2. MOBILE HEADER - COMPACT FOR MOBILE
   ======================================== */

.mobile-header {
  position: sticky;
  top: 0;
  background: rgba(255, 249, 246, 0.98);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  padding: 0.5rem 0.75rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  border-bottom: 1px solid rgba(247, 191, 180, 0.2);
}

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

.mobile-logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--wellness-coral);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.mobile-logo .emoji {
  font-size: 1rem;
}

/* ========================================
   3. MOBILE NAVIGATION - ULTRA COMPACT
   ======================================== */

.mobile-nav {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-wrap: nowrap;
  flex-shrink: 1;
}

.mobile-nav a,
.mobile-nav button {
  white-space: nowrap;
  font-size: 0.6875rem !important;
  padding: 0.375rem 0.5rem !important;
  min-height: 36px !important;
  border-radius: 0.5rem !important;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Language switcher in nav - extra compact */
.mobile-nav > div {
  display: flex;
  gap: 0.125rem;
  margin-right: 0.25rem;
}

.mobile-nav > div a {
  padding: 0.25rem 0.375rem !important;
  font-size: 1rem !important;
  min-width: 32px !important;
  min-height: 32px !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========================================
   4. MOBILE FORMS
   ======================================== */

.form-input {
  font-size: 16px !important; /* Prevents iOS zoom */
  min-height: 54px !important;
  padding: 14px 18px !important;
}

.btn {
  min-height: 54px !important;
  padding: 14px 28px !important;
  font-size: 0.875rem !important;
}

.btn-lg {
  min-height: 60px !important;
  padding: 16px 32px !important;
  font-size: 1rem !important;
}

.btn-sm {
  min-height: 44px !important;
  padding: 10px 16px !important;
  font-size: 0.75rem !important;
}

.btn-full {
  width: 100% !important;
}

/* Form groups spacing on mobile */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  font-size: 0.8125rem;
  margin-bottom: 0.5rem;
}

/* ========================================
   5. MOBILE CARDS
   ======================================== */

.card {
  padding: 1.25rem;
  margin-bottom: 1rem;
  border-radius: 1rem;
}

.card:hover {
  transform: none; /* Disable hover transform on mobile */
}

.card-title {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

.card-body {
  font-size: 0.9375rem;
  line-height: 1.6;
}

/* ========================================
   6. MOBILE TABLES
   ======================================== */

.table-container {
  margin: 0 -1rem;
  border-radius: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  min-width: 100%;
  font-size: 0.875rem;
}

.table th,
.table td {
  padding: 0.75rem 0.5rem;
  white-space: nowrap;
}

.table th {
  font-size: 0.75rem;
  position: sticky;
  top: 0;
  background: var(--wellness-softPink);
  z-index: 10;
}

/* Make first column sticky on mobile */
.table th:first-child,
.table td:first-child {
  position: sticky;
  left: 0;
  background: white;
  z-index: 5;
}

.table th:first-child {
  z-index: 15;
  background: var(--wellness-softPink);
}

/* ========================================
   7. MOBILE MODALS
   ======================================== */

.modal-backdrop {
  padding: 0.5rem;
  align-items: flex-end;
}

.modal {
  max-height: 85vh;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin-bottom: 0;
  width: 100%;
  max-width: 100%;
}

.modal-header {
  padding: 1.25rem 1rem;
}

.modal-title {
  font-size: 1.25rem;
}

.modal-body {
  padding: 1rem;
  max-height: calc(85vh - 140px);
  overflow-y: auto;
}

.modal-close {
  min-width: 44px;
  min-height: 44px;
  font-size: 1.75rem;
}

/* ========================================
   8. MOBILE TYPOGRAPHY
   ======================================== */

h1 {
  font-size: 1.875rem !important; /* 30px */
  line-height: 1.2;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.5rem !important; /* 24px */
  line-height: 1.3;
  margin-bottom: 0.875rem;
}

h3 {
  font-size: 1.25rem !important; /* 20px */
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

p {
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}

p.lead {
  font-size: 1.125rem !important;
  line-height: 1.5;
}

small {
  font-size: 0.875rem;
}

/* ========================================
   9. MOBILE SPACING & LAYOUT
   ======================================== */

.container {
  padding-left: 1rem;
  padding-right: 1rem;
}

.section {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

/* Grid adjustments for mobile */
[style*="grid-template-columns"] {
  grid-template-columns: 1fr !important;
}

/* Specific grid overrides */
.mobile-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* ========================================
   10. SAFE AREAS (iPhone X+)
   ======================================== */

@supports (padding: max(0px)) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .mobile-header {
    padding-top: max(0.5rem, env(safe-area-inset-top));
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }
  
  .container {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  
  .modal-backdrop {
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  }
}

/* ========================================
   11. MOBILE-SPECIFIC UTILITIES
   ======================================== */

.mobile-only {
  display: block;
}

.desktop-only {
  display: none;
}

.mobile-text-center {
  text-align: center;
}

.mobile-full-width {
  width: 100%;
}

.mobile-no-scroll {
  overflow: hidden;
}

/* ========================================
   12. MOBILE ALERTS & NOTIFICATIONS
   ======================================== */

.alert {
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  margin-bottom: 0.875rem;
}

.alert .emoji {
  font-size: 1.25rem;
}

/* ========================================
   13. MOBILE BADGES
   ======================================== */

.badge {
  font-size: 0.6875rem;
  padding: 0.375rem 0.625rem;
}

/* ========================================
   14. MOBILE STATS DISPLAY
   ======================================== */

.stat-period {
  font-size: 0.9375rem;
}

.stat-period > div {
  padding: 0.75rem;
}

.stat-period [style*="font-size: 1.5rem"] {
  font-size: 1.25rem !important;
}

/* ========================================
   15. MOBILE BREAKPOINTS
   ======================================== */

/* Small phones (375px - iPhone SE, 11 Pro) */
@media (min-width: 375px) {
  .mobile-logo {
    font-size: 1.25rem;
  }
  
  .mobile-nav a,
  .mobile-nav button {
    font-size: 0.75rem !important;
    padding: 0.4rem 0.6rem !important;
  }
  
  h1 {
    font-size: 2rem !important;
  }
}

/* Medium phones (390px - iPhone 12/13/14) */
@media (min-width: 390px) {
  .container {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
  
  .card {
    padding: 1.5rem;
  }
  
  .mobile-nav a,
  .mobile-nav button {
    font-size: 0.8125rem !important;
    padding: 0.5rem 0.75rem !important;
    min-height: 40px !important;
  }
}

/* Large phones (428px - iPhone 14 Plus/Pro Max) */
@media (min-width: 428px) {
  .mobile-logo {
    font-size: 1.375rem;
  }
  
  .mobile-nav a,
  .mobile-nav button {
    font-size: 0.875rem !important;
    padding: 0.625rem 1rem !important;
    min-height: 44px !important;
  }
  
  h1 {
    font-size: 2.25rem !important;
  }
  
  h2 {
    font-size: 1.75rem !important;
  }
}

/* Tablets and desktop */
@media (min-width: 768px) {
  .mobile-only {
    display: none;
  }
  
  .desktop-only {
    display: block;
  }
  
  .mobile-header {
    padding: 0rem 1.5rem;
  }
  
  .mobile-logo {
    font-size: 1.5rem;
  }
  
  .mobile-nav a,
  .mobile-nav button {
    font-size: 0.875rem !important;
    padding: 0.75rem 1.25rem !important;
    min-height: 48px !important;
  }
  
  .table-container {
    margin: 0;
    border-radius: 1.5rem;
  }
  
  .modal-backdrop {
    align-items: center;
    padding: 1rem;
  }
  
  .modal {
    max-width: 32rem;
    border-radius: 2rem;
    max-height: 90vh;
  }
  
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* ========================================
   16. MOBILE PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* GPU acceleration for animations */
.btn,
.card,
.modal {
  transform: translateZ(0);
  will-change: transform;
}

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