/* Mobile-First Foundation Styles for WinePairly */
/* This file ONLY adds mobile optimizations without changing existing functionality */

/* Mobile-First Base Styles (320px+) */
:root {
  --mobile-touch-target: 44px; /* iOS HIG minimum */
  --mobile-spacing: 16px;
  --mobile-typography: 16px; /* Prevent zoom on iOS */
}

/* Enhanced Mobile Typography - Non-breaking additions */
body {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

/* Mobile-First Button Enhancements - Additive only */
.btn-mobile-enhanced {
  min-height: var(--mobile-touch-target);
  min-width: var(--mobile-touch-target);
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Mobile-Optimized Form Input Enhancements - Additive only */
.input-mobile-enhanced {
  font-size: 16px; /* Prevent zoom on iOS */
  -webkit-appearance: none;
  border-radius: 12px;
}

/* Loading Animation Mobile Fixes */
#wine-loading-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  z-index: 99999 !important;
  -webkit-overflow-scrolling: touch;
  touch-action: none !important;
  overflow: hidden !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Loading content container */
#wine-loading-overlay .loading-content {
  max-height: 95vh;
  max-height: 95dvh;
  overflow: hidden;
  padding: 20px;
}

/* Trivia container mobile styling */
#wine-loading-overlay .trivia-container {
  margin: 0 10px;
}

/* Desktop enhancements for loading */
@media (min-width: 768px) {
  #wine-loading-overlay .loading-content {
    padding: 30px;
  }
  
  #wine-loading-overlay .trivia-container {
    max-width: 400px;
  }
}

/* Progressive Enhancement for Tablets (768px+) */
@media (min-width: 768px) {
  .btn-mobile-enhanced { 
    min-height: 48px;
  }
}

/* Desktop Enhancement (1024px+) */
@media (min-width: 1024px) {
  .btn-mobile-enhanced { 
    min-height: 52px;
  }
}

/* Mobile Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  /* iOS Safari specific optimizations */
  input, textarea, select {
    font-size: 16px; /* Prevent zoom */
  }
  
  /* Fix viewport height issues on iOS */
  #wine-loading-overlay {
    height: 100vh;
    height: -webkit-fill-available;
  }
}

/* Touch interaction improvements - Non-breaking */
.wine-recommendation-card {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  transition: transform 0.1s ease;
}

.wine-recommendation-card:active {
  transform: scale(0.98);
}

/* Enhanced quick tags for mobile */
.quick-tag.enhanced-tag {
  min-height: var(--mobile-touch-target);
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  touch-action: manipulation;
}

.quick-tag.enhanced-tag:active {
  transform: scale(0.95);
}

/* Mobile text input improvements */
.magic-input {
  font-size: 16px !important; /* Prevent zoom on iOS */
  -webkit-appearance: none;
  transition: all 0.2s ease;
}

/* Existing carousel mobile enhancements - Additive only */
.wine-carousel-container {
  -webkit-overflow-scrolling: touch;
  -webkit-user-select: none;
  user-select: none;
}

/* Mobile carousel scroll behavior improvements */
.wine-recommendation-card {
  scroll-snap-align: start;
}

.grid {
  scroll-snap-type: x mandatory;
}

/* Mobile loading screen improvements */
#wine-loading-overlay .text-2xl {
  font-size: 1.5rem; /* Smaller on mobile */
}

@media (max-width: 768px) {
  #wine-loading-overlay .text-2xl {
    font-size: 1.25rem;
  }
  
  #wine-loading-overlay .space-y-4 > * + * {
    margin-top: 0.75rem; /* Tighter spacing on mobile */
  }
  
  /* Make wine cards more mobile-friendly */
  .wine-recommendation-card {
    padding: 1rem;
  }
  
  /* Optimize badges for mobile */
  .wine-recommendation-card .absolute {
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.625rem;
    padding: 0.25rem 0.5rem;
  }
}

/* Mobile-specific viewport handling improvements */
@media screen and (max-width: 768px) {
  /* Prevent overscroll bounce on iOS */
  html, body {
    position: relative;
    overflow-x: hidden;
  }
  
  /* Enhanced mobile form interactions */
  .openai-input-container {
    min-height: var(--mobile-touch-target);
  }
  
  /* Better mobile wine card layout */
  .wine-recommendation-card {
    margin-bottom: 1rem;
  }
  
  /* Mobile-optimized badge positioning */
  .wine-recommendation-card .absolute.top-3.right-3 {
    top: 0.75rem;
    right: 0.75rem;
  }
  
  /* Improve mobile text readability */
  .prose {
    font-size: 0.95rem;
    line-height: 1.6;
  }
}

/* Tablet-specific optimizations */
@media screen and (min-width: 768px) and (max-width: 1024px) {
  .wine-recommendation-card {
    padding: 1.25rem;
  }
}

/* Quick meal buttons mobile optimization - Additive only */
.quick-meal {
  min-height: var(--mobile-touch-target);
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Send button mobile optimization - Additive only */
#send-btn {
  min-height: var(--mobile-touch-target);
  min-width: var(--mobile-touch-target);
}

/* Photo and voice button mobile optimization - Additive only */
#photo-btn, #voice-btn {
  min-height: var(--mobile-touch-target);
  min-width: var(--mobile-touch-target);
}
/* Voice Assistant Widget Styles */
.voice-widget {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 16px;
    padding: 24px;
    margin: 24px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.voice-widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #7600c9, #9f4bff, #7600c9);
    background-size: 200% 100%;
    animation: shimmer 3s ease-in-out infinite;
}

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

.voice-widget-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sommelier-info {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e9ecef;
}

.sommelier-avatar {
    font-size: 3rem;
    line-height: 1;
}

.sommelier-details h4 {
    margin: 0 0 4px 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #2d3748;
}

.sommelier-details p {
    margin: 0 0 8px 0;
    color: #718096;
    font-size: 0.9rem;
}

.specialty {
    background: linear-gradient(135deg, #7600c9, #9f4bff);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.voice-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.voice-play-btn, .voice-script-btn {
    flex: 1;
    min-width: 160px;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.voice-play-btn {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.voice-play-btn:hover {
    background: linear-gradient(135deg, #218838, #1ea080);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.voice-script-btn {
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #dee2e6;
}

.voice-script-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

.voice-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s ease;
}

.voice-script-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.script-content {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.script-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 16px 24px;
    border-bottom: 1px solid #e9ecef;
}

.script-header h4 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #2d3748;
}

.close-script {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
    padding: 4px 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.script-text {
    padding: 24px;
    font-size: 1rem;
    line-height: 1.6;
    color: #2d3748;
    max-height: 60vh;
    overflow-y: auto;
}
