/* VFIED - Complete iOS Optimized Version */

:root {
  /* Improved color system - better contrast and eye comfort */
  --primary-600: #6d28d9; /* Slightly deeper purple, less harsh */
  --primary-500: #7c3aed;
  --primary-400: #8b5cf6;
  
  /* Warmer grays - easier on eyes for extended use */
  --gray-950: #0f0f23; /* Warmer black with slight blue tint */
  --gray-900: #1a1a2e; /* Warmer dark background */
  --gray-800: #16213e; /* Warmer card background */
  --gray-700: #0f3460; /* Better contrast for borders */
  --gray-600: #533483; /* More purple-tinted for consistency */
  --gray-500: #6b7280;
  --gray-400: #9ca3af;
  --gray-300: #d1d5db;
  --gray-100: #f8fafc; /* Slightly warmer white */
  --gray-50: #f9fafb;
  
  --success-500: #059669; /* Slightly darker green for better contrast */
  --warning-500: #d97706; /* Warmer orange */
  --error-500: #dc2626; /* Slightly darker red */
  
  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  
  /* Typography scale */
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;
  
  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  
  /* Softer shadows for iOS */
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 8px -2px rgb(0 0 0 / 0.1), 0 2px 4px -1px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 20px -4px rgb(0 0 0 / 0.15), 0 4px 8px -2px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 30px -8px rgb(0 0 0 / 0.2), 0 8px 16px -4px rgb(0 0 0 / 0.1);
  
  /* iOS Safe areas */
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  
  /* Navigation height */
  --nav-height: 88px; /* Increased for better touch targets */
}

/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
  background: linear-gradient(180deg, var(--gray-950) 0%, var(--gray-900) 100%);
  color: var(--gray-100);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  height: auto;
  min-height: 100vh;
  /* iOS specific */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  /* Allow text selection for inputs */
  -webkit-tap-highlight-color: transparent;
}

/* Allow text selection for specific elements */
input, textarea, [contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

/* App container - iOS optimized */
#app {
  min-height: 100vh;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
  padding: 0 var(--safe-area-left) calc(var(--nav-height) + var(--safe-area-bottom) + 20px) var(--safe-area-right);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  /* iOS momentum scrolling */
  overscroll-behavior: contain;
}

/* Header - iOS safe area optimized */
header {
  padding: calc(var(--safe-area-top) + 20px) var(--space-4) var(--space-6);
  background: rgba(15, 15, 35, 0.85); /* Using new warmer color */
  backdrop-filter: blur(20px) saturate(180%); /* iOS style blur */
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--gray-700);
  position: sticky;
  top: 0;
  z-index: 50;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

header h1 {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--gray-100); /* Using warmer white */
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

header p {
  font-size: var(--text-sm);
  color: var(--gray-400);
  margin-top: var(--space-1);
}

/* Location bar */
.location-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gray-800);
  border: 1px solid var(--gray-700);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-4);
  font-size: var(--text-sm);
  /* iOS touch optimization */
  min-height: 44px;
}

.location-bar button {
  background: var(--gray-700);
  border: 1px solid var(--gray-600);
  color: var(--gray-300);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  /* iOS touch target */
  min-width: 44px;
  min-height: 32px;
}

.location-bar button:hover,
.location-bar button:active {
  background: var(--gray-600);
  color: var(--gray-100);
}

/* Cards with iOS-style design */
.glass-card {
  background: var(--gray-800);
  border: 1px solid var(--gray-700);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin: var(--space-4);
  box-shadow: var(--shadow-lg);
  height: auto;
  /* iOS style glass effect */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Content area */
.tab-content {
  padding-bottom: 40px;
}

/* Typography improvements - better contrast */
h1 { font-size: var(--text-3xl); font-weight: 800; line-height: 1.2; color: var(--gray-100); }
h2 { font-size: var(--text-2xl); font-weight: 700; line-height: 1.3; color: var(--gray-100); }
h3 { font-size: var(--text-xl); font-weight: 600; line-height: 1.4; color: var(--gray-100); }
h4 { font-size: var(--text-lg); font-weight: 600; line-height: 1.4; color: var(--gray-100); }
h5 { font-size: var(--text-base); font-weight: 600; line-height: 1.5; color: var(--gray-100); }

/* Dietary filters - iOS optimized touch targets */
.diet-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-4) 0;
}

.diet-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--gray-700);
  border: 1px solid var(--gray-600);
  border-radius: var(--radius-full);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-200);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px; /* iOS minimum touch target */
  -webkit-tap-highlight-color: transparent;
  /* iOS haptic feedback simulation */
  transform: scale(1);
}

.diet-chip:active {
  transform: scale(0.95);
  transition: transform 0.1s ease;
}

.diet-chip:hover {
  background: var(--gray-600);
  border-color: var(--gray-500);
}

.diet-chip.active {
  background: var(--primary-600);
  border-color: var(--primary-500);
  color: white;
  box-shadow: 0 4px 12px rgba(109, 40, 217, 0.3); /* Using new primary color */
}

.diet-chip.active:hover {
  background: var(--primary-500);
}

/* Mood input - iOS style */
#mood-input {
  width: 100%;
  background: var(--gray-700);
  border: 1px solid var(--gray-600);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--gray-100);
  min-height: 52px;
  transition: all 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
  /* iOS keyboard optimization */
  -webkit-user-select: text;
  user-select: text;
}

#mood-input:focus {
  outline: none;
  border-color: var(--primary-500);
  background: var(--gray-600);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.1);
}

#mood-input::placeholder {
  color: var(--gray-400);
}

/* Primary button - iOS optimized */
#decide-button {
  width: calc(100% - var(--space-8));
  margin: var(--space-6) var(--space-4) var(--space-8);
  padding: var(--space-5);
  border: none;
  border-radius: var(--radius-xl);
  font-size: var(--text-lg);
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
  box-shadow: 0 8px 24px rgba(109, 40, 217, 0.4);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  -webkit-tap-highlight-color: transparent;
  transform: scale(1);
}

#decide-button:active:not(:disabled) {
  transform: scale(0.96);
  transition: transform 0.1s ease;
}

#decide-button:hover:not(:disabled) {
  box-shadow: 0 12px 32px rgba(109, 40, 217, 0.5);
  background: linear-gradient(135deg, var(--primary-500), var(--primary-400));
}

#decide-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Bottom navigation - iOS style tab bar */
nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(26, 26, 46, 0.95); /* Using new warmer color */
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--gray-700);
  padding: var(--space-3) var(--safe-area-left) calc(var(--space-4) + var(--safe-area-bottom)) var(--safe-area-right);
  z-index: 50;
  height: var(--nav-height);
}

nav > div {
  max-width: 430px;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 100%;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2);
  border: none;
  background: transparent;
  color: var(--gray-500);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transform: scale(1);
}

.tab-btn:active {
  transform: scale(0.9);
  transition: transform 0.1s ease;
}

.tab-btn .tab-icon {
  font-size: 22px;
  line-height: 1;
}

.tab-btn.active {
  color: var(--primary-400);
}

.tab-btn:hover {
  color: var(--gray-300);
  background: var(--gray-800);
}

.tab-btn.active:hover {
  color: var(--primary-300);
}

/* Decision cards - iOS style */
.decision-card {
  background: var(--gray-800);
  border: 1px solid var(--gray-700);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-3);
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  transform: scale(1);
}

.decision-card:active {
  transform: scale(0.98);
  background: var(--gray-600);
  transition: transform 0.1s ease;
}

.decision-card:hover {
  background: var(--gray-700);
  border-color: var(--gray-600);
  box-shadow: var(--shadow-md);
}

/* Hide the "Why this choice?" section by default */
.reasoning-section,
div[style*="Why this choice"],
.reason-card {
  display: none !important;
}

/* Modals - iOS optimized */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4); /* Slightly lighter overlay */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: var(--gray-900);
  border: 1px solid var(--gray-700);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 430px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  transform: scale(0.9);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.modal.active .modal-content {
  transform: scale(1);
  opacity: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5);
  border-bottom: 1px solid var(--gray-700);
  flex-shrink: 0;
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--gray-100);
}

.modal-close {
  background: var(--gray-700);
  border: 1px solid var(--gray-600);
  border-radius: var(--radius-md);
  width: 36px; /* Larger for iOS */
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: var(--text-lg);
  -webkit-tap-highlight-color: transparent;
}

.modal-close:hover,
.modal-close:active {
  background: var(--gray-600);
  color: var(--gray-200);
}

.modal-body {
  padding: var(--space-5);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

/* iOS custom scrollbar */
.modal-body::-webkit-scrollbar {
  width: 2px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 1px;
}

/* Utility classes */
.hidden {
  display: none !important;
}

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

/* iOS Loading states */
.loading {
  position: relative;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--gray-600);
  border-top: 2px solid var(--primary-500);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* iOS Dark mode optimizations */
@media (prefers-color-scheme: dark) {
  body {
    color-scheme: dark;
  }
}

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

/* Travel Mode Chips - match dietary chips */
.travel-mode-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: rgba(22, 33, 62, 0.6);
  border: 1px solid rgba(83, 52, 131, 0.4);
  border-radius: var(--radius-full);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-200);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.travel-mode-chip:active {
  transform: scale(0.95);
}

.travel-mode-chip.active {
  background: var(--primary-600);
  border-color: var(--primary-500);
  color: white;
  box-shadow: 0 4px 12px rgba(109, 40, 217, 0.3);
}

/* Event Filter Chips - match dietary chips */
.event-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: rgba(22, 33, 62, 0.6);
  border: 1px solid rgba(83, 52, 131, 0.4);
  border-radius: var(--radius-full);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-200);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

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

.event-filter-chip.active {
  background: var(--primary-600);
  border-color: var(--primary-500);
  color: white;
  box-shadow: 0 4px 12px rgba(109, 40, 217, 0.3);
}

/* Time Filter Buttons - match style */
.time-filter {
  background: rgba(22, 33, 62, 0.6);
  border: 1px solid rgba(83, 52, 131, 0.4);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-200);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

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

.time-filter.active {
  background: var(--primary-600);
  border-color: var(--primary-500);
  color: white;
  box-shadow: 0 4px 12px rgba(109, 40, 217, 0.3);
}

/* Travel Action Buttons */
.travel-action-btn {
  background: rgba(22, 33, 62, 0.8);
  border: 1px solid rgba(83, 52, 131, 0.4);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--gray-100);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.travel-action-btn:active {
  transform: scale(0.96);
  background: rgba(15, 60, 96, 0.9);
}

.travel-action-btn:hover {
  background: rgba(15, 60, 96, 0.8);
  border-color: rgba(83, 52, 131, 0.5);
}

/* Event Cards */
.event-card {
  background: rgba(22, 33, 62, 0.6);
  border: 1px solid rgba(83, 52, 131, 0.4);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-3);
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  gap: var(--space-3);
}

.event-card:active {
  transform: scale(0.98);
  background: rgba(15, 60, 96, 0.7);
}

.event-card:hover {
  background: rgba(22, 33, 62, 0.8);
  border-color: rgba(83, 52, 131, 0.5);
  box-shadow: var(--shadow-md);
}

.event-emoji {
  font-size: 32px;
  flex-shrink: 0;
}

.event-info {
  flex: 1;
}

.event-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--gray-100);
  margin-bottom: var(--space-1);
}

.event-details {
  font-size: var(--text-xs);
  color: var(--gray-400);
  margin-bottom: var(--space-2);
}

.event-description {
  font-size: var(--text-sm);
  color: var(--gray-300);
  line-height: 1.4;
}

/* Modal Info Banners - consistent styling */
.modal-info-banner {
  background: linear-gradient(135deg, rgba(109, 40, 217, 0.15), rgba(99, 102, 241, 0.15));
  border: 1px solid rgba(109, 40, 217, 0.3);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  text-align: center;
}

.modal-info-banner p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--gray-300);
}

.modal-info-banner span {
  color: #8b5cf6;
  font-weight: 700;
}

/* Form inputs in modals - match main interface */
.modal-body select,
.modal-body input[type="text"] {
  width: 100%;
  background: rgba(22, 33, 62, 0.8);
  border: 1px solid rgba(83, 52, 131, 0.4);
  color: var(--gray-100);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
}

.modal-body select:focus,
.modal-body input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.1);
}

.modal-body label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-300);
  margin-bottom: var(--space-2);
  display: block;
}

/* Section headers in modals */
.modal-body h5 {
  margin: 0 0 var(--space-3) 0;
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--gray-100);
}

.modal-body h6 {
  margin: 0 0 var(--space-2) 0;
  font-size: var(--text-sm);
  font-weight: 700;
  color: #8b5cf6;
}
/* ===== RESPONSIVE DESKTOP LAYOUT ===== */

/* Tablets and larger - responsive layout */
@media (min-width: 431px) and (max-width: 1023px) {
  #app {
    max-width: 600px;
    margin: 0 auto;
    box-shadow: 0 0 40px rgba(0,0,0,0.3);
  }
}

/* Desktop and large screens - full width adaptive */
@media (min-width: 1024px) {
  #app {
    max-width: 1200px;
    margin: 0 auto;
    box-shadow: 0 0 60px rgba(0,0,0,0.4);
  }

  /* Make tabs horizontal on desktop */
  .tab-bar {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1rem 2rem;
  }

  .tab-btn {
    min-width: 150px;
  }

  /* Grid layouts for desktop */
  #travel-grid,
  #local-gems-grid {
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
  }

  /* Better modal sizing for desktop */
  .modal-content {
    max-width: 800px;
    margin: 2rem auto;
    border-radius: 24px;
  }

  /* Two-column layout for forms on desktop */
  .diet-chips, .friend-chips {
    max-width: 100%;
  }

  /* Better hover states for desktop */
  .travel-card:hover,
  .gem-card:hover,
  .event-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(124,58,237,0.3);
  }

  /* Desktop-friendly input sizes */
  #mood-input {
    font-size: 18px !important;
    padding: 1rem 1.5rem;
  }

  button, .cta-button, .decide-btn {
    cursor: pointer;
    transition: all 0.2s ease;
  }

  button:hover, .cta-button:hover, .decide-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(124,58,237,0.4);
  }

  /* Better spacing for desktop */
  .tabpanel {
    padding: 2rem;
  }

  header h1 {
    font-size: 2rem;
  }

  /* Results section full width */
  .results-section {
    max-width: 100%;
  }
}

/* Ultra-wide screens */
@media (min-width: 1600px) {
  #app {
    max-width: 1400px;
  }

  #travel-grid,
  #local-gems-grid {
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 2rem;
  }
}
