/* CSS Variables for theming */
:root {
  --primary-color: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary-color: #f59e0b;
  --accent-color: #10b981;
  --background-color: #ffffff;
  --surface-color: #f8fafc;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-accent: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* Dark theme variables */
[data-theme="dark"] {
  --background-color: #0f172a;
  --surface-color: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border-color: #334155;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--background-color);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Theme Toggle */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  width: 50px;
  height: 50px;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.theme-toggle:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-xl);
}

.theme-toggle i {
  color: white;
  font-size: 20px;
  transition: transform 0.3s ease;
}

/* Header */
.header {
  position: relative;
  background: var(--gradient-primary);
  color: white;
  padding: 4rem 2rem 6rem;
  text-align: center;
  overflow: hidden;
}

.header-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 100" fill="white" opacity="0.1"><polygon points="0,0 1000,0 1000,100 0,80"/></svg>') no-repeat bottom;
  background-size: cover;
}

.header-content {
  position: relative;
  z-index: 2;
  max-width: 800px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.logo i {
  font-size: 2.5rem;
  animation: float 3s ease-in-out infinite;
}

.logo h1 {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 1.25rem;
  opacity: 0.9;
  font-weight: 300;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.loading-overlay.show {
  display: flex;
}

.loading-spinner {
  text-align: center;
  color: white;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

/* Main Content */
.main {
  padding: 2rem;
  margin-top: -4rem;
  position: relative;
  z-index: 3;
}

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

/* Search Form */
.search-form {
  background: var(--surface-color);
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  margin-bottom: 3rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.search-form:hover {
  transform: translateY(-2px);
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
}

.form-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.form-header h2 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.form-header p {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* Route Section */
.route-section {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1.5rem;
  align-items: end;
  margin-bottom: 2rem;
}

.route-swap {
  width: 50px;
  height: 50px;
  background: var(--gradient-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: var(--shadow-md);
  margin-bottom: 1rem;
}

.route-swap:hover {
  transform: rotate(180deg) scale(1.1);
  box-shadow: var(--shadow-lg);
}

.route-swap i {
  color: white;
  font-size: 1.2rem;
}

/* Input Groups */
.input-group {
  margin-bottom: 1.5rem;
}

.input-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.input-label i {
  color: var(--primary-color);
  width: 16px;
}

.input-wrapper {
  position: relative;
}

.airport-input,
.duration-input,
.select-input {
  width: 100%;
  padding: 1rem 1.25rem;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  font-size: 1rem;
  background: var(--background-color);
  color: var(--text-primary);
  transition: all 0.3s ease;
  outline: none;
}

.airport-input:focus,
.duration-input:focus,
.select-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  transform: translateY(-1px);
}

/* Duration Controls */
.duration-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.duration-btn {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border-color);
  background: var(--background-color);
  color: var(--text-primary);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 600;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.duration-btn:hover {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: white;
  transform: scale(1.05);
}

.duration-input {
  flex: 1;
  text-align: center;
  font-weight: 600;
}

/* Trip Details */
.trip-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

/* Advanced Options */
.advanced-options {
  margin-bottom: 2rem;
}

.advanced-toggle {
  width: 100%;
  padding: 1rem;
  background: var(--surface-color);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.3s ease;
}

.advanced-toggle:hover {
  border-color: var(--primary-color);
  background: rgba(37, 99, 235, 0.05);
}

.advanced-toggle i:last-child {
  transition: transform 0.3s ease;
}

.advanced-toggle.active i:last-child {
  transform: rotate(180deg);
}

.advanced-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.advanced-content.show {
  max-height: 200px;
  padding-top: 1.5rem;
}

.advanced-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: end;
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  position: relative;
  transition: all 0.3s ease;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

/* Month Selection */
.month-selection {
  margin-bottom: 2.5rem;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

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

.month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.month-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--background-color);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.month-item:hover {
  border-color: var(--primary-color);
  background: rgba(37, 99, 235, 0.05);
  transform: translateY(-1px);
}

.month-item.selected {
  border-color: var(--primary-color);
  background: rgba(37, 99, 235, 0.1);
}

.month-item input[type="checkbox"] {
  display: none;
}

.month-item .month-check {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  transition: all 0.3s ease;
}

.month-item.selected .month-check {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.month-item.selected .month-check::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.month-label {
  font-weight: 500;
  color: var(--text-primary);
}

/* Search Button */
.search-btn {
  width: 100%;
  padding: 1.25rem 2rem;
  background: var(--gradient-primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.search-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

.search-btn:active {
  transform: translateY(0);
}

.search-btn.loading {
  pointer-events: none;
  opacity: 0.8;
}

.search-btn.loading i {
  animation: spin 1s linear infinite;
}

/* Autocomplete Results */
.autocomplete-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--background-color);
  border: 2px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 12px 12px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: none;
  max-height: 300px;
  overflow-y: auto;
}

.autocomplete-results.show {
  display: block;
}

.autocomplete-results ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.autocomplete-results li {
  padding: 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s ease;
}

.autocomplete-results li:hover {
  background: rgba(37, 99, 235, 0.05);
}

.autocomplete-results li:last-child {
  border-bottom: none;
}

.list_item_header {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.list_item_info {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
}

/* Popup Modal */
.popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
  backdrop-filter: blur(4px);
}

.popup.show {
  display: flex;
}

.popup-content {
  background: var(--background-color);
  border-radius: 20px;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  animation: popupSlideIn 0.3s ease-out;
}

@keyframes popupSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2rem 2rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.popup-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.close-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--surface-color);
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.close-btn:hover {
  background: var(--primary-color);
  color: white;
  transform: scale(1.1);
}

.results-summary {
  padding: 1rem 2rem;
  background: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.flights-container {
  padding: 1.5rem 2rem;
  max-height: 400px;
  overflow-y: auto;
}

.flight_div {
  background: var(--surface-color);
  border: 2px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  transition: all 0.3s ease;
  cursor: pointer;
}

.flight_div:hover {
  border-color: var(--primary-color);
  background: rgba(37, 99, 235, 0.05);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.flight_div:last-child {
  margin-bottom: 0;
}

.times {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.flight-date {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
  color: var(--text-primary);
}

.flight_icon {
  width: 24px;
  height: 24px;
  color: var(--primary-color);
}

.vl {
  width: 2px;
  height: 24px;
  background: var(--border-color);
  border-radius: 1px;
}

.price {
  text-align: right;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-color);
  margin-top: 0.5rem;
}

.popup-footer {
  padding: 1rem 2rem 2rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: center;
}

.export-btn {
  padding: 0.75rem 1.5rem;
  background: var(--gradient-secondary);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
}

.export-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Recent Searches */
.recent-searches {
  background: var(--surface-color);
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 2rem;
  border: 1px solid var(--border-color);
}

.recent-searches h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--background-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.recent-item:hover {
  border-color: var(--primary-color);
  background: rgba(37, 99, 235, 0.05);
}

.recent-route {
  font-weight: 500;
  color: var(--text-primary);
}

.recent-date {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Popular Routes */
.popular-routes {
  background: var(--surface-color);
  border-radius: 16px;
  padding: 2rem;
  border: 1px solid var(--border-color);
}

.popular-routes h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.routes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.route-card {
  background: var(--background-color);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.route-card:hover {
  border-color: var(--primary-color);
  background: rgba(37, 99, 235, 0.05);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.route-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
  font-weight: 500;
  color: var(--text-primary);
}

.route-info i {
  color: var(--primary-color);
}

.route-price {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-color);
}

/* Footer */
.footer {
  background: var(--surface-color);
  border-top: 1px solid var(--border-color);
  padding: 2rem;
  text-align: center;
  margin-top: 4rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-links {
  display: flex;
  gap: 2rem;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
}

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

/* Responsive Design */
@media (max-width: 768px) {
  .header {
    padding: 3rem 1rem 4rem;
  }
  
  .logo h1 {
    font-size: 2rem;
  }
  
  .tagline {
    font-size: 1rem;
  }
  
  .main {
    padding: 1rem;
    margin-top: -2rem;
  }
  
  .search-form {
    padding: 1.5rem;
  }
  
  .route-section {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .route-swap {
    justify-self: center;
    margin: 0;
  }
  
  .trip-details {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .advanced-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .month-grid {
    grid-template-columns: 1fr;
  }
  
  .routes-grid {
    grid-template-columns: 1fr;
  }
  
  .popup {
    padding: 1rem;
  }
  
  .popup-content {
    border-radius: 16px;
  }
  
  .popup-header,
  .flights-container,
  .popup-footer {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
  
  .footer-content {
    flex-direction: column;
    text-align: center;
  }
  
  .theme-toggle {
    top: 15px;
    right: 15px;
    width: 45px;
    height: 45px;
  }
}

@media (max-width: 480px) {
  .search-form {
    padding: 1rem;
  }
  
  .form-header h2 {
    font-size: 1.5rem;
  }
  
  .form-header p {
    font-size: 1rem;
  }
  
  .popup-header,
  .flights-container,
  .popup-footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-form,
.recent-searches,
.popular-routes {
  animation: fadeInUp 0.6s ease-out;
}

.search-form {
  animation-delay: 0.1s;
}

.recent-searches {
  animation-delay: 0.2s;
}

.popular-routes {
  animation-delay: 0.3s;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface-color);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

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