/* --- AI Modal General Styles --- */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: rgba(0, 0, 0, 0);
  justify-content: center;
  align-items: center;
  transition: background-color 0.5s cubic-bezier(0.32, 0.72, 0.33, 1.5);
}

.modal.show {
  display: flex !important;
  background-color: rgba(0, 0, 0, 0.6); /* Slightly darker overlay */
}

.modal-content {
  background-color: var(--wht);
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  max-width: 840px;
  width: 90%;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 92vh;
  overflow-y: auto;
  transform: scale(0.95);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0.33, 1.5), opacity 0.4s ease;
}

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

.modal-content h2 {
  color: var(--blk);
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray100);
}

.close-button {
  color: var(--gray500);
  font-size: 26px;
  font-weight: bold;
  position: absolute;
  top: 16px;
  right: 16px;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.2s ease;
}

.close-button:hover,
.close-button:focus {
  color: var(--blk);
  transform: rotate(90deg);
}

/* --- Modal Content Container --- */
.flight-results-container {
  position: relative;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  color: var(--gray600);
  font-size: 16px;
  font-style: italic;
  transition: background-color 0.3s ease;
  flex-grow: 1;
  overflow-y: auto;
}

#ai-status-message {
  font-size: 16px;
  font-weight: 500;
  margin: 20px 0;
}

/* --- AI Modal Loading Status --- */
.ai-loading-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: var(--gray600);
  font-size: 15px;
  width: 100%;
  min-height: 300px; /* Ensure loading state has enough space */
  background: #f8f9ff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.loading-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 20px;
  background: var(--wht);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#ai-loading-lottie {
  width: 70px;
  height: 70px;
  margin-bottom: 8px;
}

.ai-loading-progress {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 40px;
  width: 100%;
  padding: 22px;
  background: #f5f7ff;
  border-radius: 10px;
  border: 1px solid var(--gray100);
}

.ai-loading-progress .step {
  display: flex;
  align-items: center;
  font-size: 16px;
  color: var(--gray400);
  transition: color 0.3s ease;
}

.ai-loading-progress .circle {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gray50);
  color: var(--primary);
  margin-right: 8px;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.3s, color 0.3s, transform 0.3s;
}

.ai-loading-progress .step[data-status="done"] .circle {
  background: var(--secondary);
  color: var(--wht);
}

.ai-loading-progress .step[data-status="done"] .circle::before {
  content: '✓';
}

.ai-loading-progress .step[data-status="active"] .circle {
  background: var(--primary);
  color: var(--wht);
  animation: pulse 1.2s infinite ease-in-out;
}

.ai-loading-progress .step[data-status="done"] {
  color: var(--secondary);
  font-weight: 600;
}

.ai-loading-progress .step[data-status="active"] {
  color: var(--primary);
  font-weight: 600;
}

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

#ai-loading-text {
  font-weight: 600;
  font-size: 16px;
  line-height: 1.5;
  transition: opacity 0.3s ease-in-out;
  text-align: center;
}

/* --- AI Final Results Container --- */
#ai-final-results {
  width: 100%;
  height: auto;
  text-align: left;
  font-style: normal;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 10px;
}

/* Custom Scrollbar for Modal */
.custom-scrollbar::-webkit-scrollbar,
.modal-content::-webkit-scrollbar,
.flight-results-container::-webkit-scrollbar {
  width: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track,
.flight-results-container::-webkit-scrollbar-track {
  background: var(--gray50);
  border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb,
.flight-results-container::-webkit-scrollbar-thumb {
  background: var(--gray300);
  border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover,
.flight-results-container::-webkit-scrollbar-thumb:hover {
  background: var(--gray500);
}

/* --- AI Insight --- */
.ai-insight {
  background-color: #e9f5ff;
  padding: 14px;
  border-radius: 8px;
  border-left: 4px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-insight-badge {
  background: var(--gradient-blue-green);
  color: var(--wht);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  flex-shrink: 0;
}

#ai-insight-text {
  font-size: 14px;
  color: var(--gray700);
  font-style: normal;
  line-height: 1.6;
}

/* --- Flight Cards --- */
#ai-flight-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-flight-card {
  display: grid; /* Changed to Grid */
  grid-template-columns: auto 1fr auto; /* Default for larger screens */
  grid-template-areas:
    "header main button"; /* Define areas for larger screens */
  align-items: center;
  padding: 14px;
  border: 1px solid var(--gray100);
  border-radius: 12px;
  background-color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.ai-flight-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ai-flight-card.highlight {
  border: 2px solid var(--primary);
  background-color: #f7fbff;
  padding: 16px;
}

.flight-card-header {
  grid-area: header; /* Assign to header area */
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0; /* No margin-bottom needed with grid layout */
  padding-right: 15px; /* Add some spacing */
}

.airline-logo {
  width: 32px;
  height: 32px;
  border-radius: 4px;
}

.airline-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray700);
}

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--wht);
  margin-left: 8px; /* Add some spacing from airline name */
}

.badge.direct {
  background: #37a35b;
}

.badge.special {
  background: #f37a22;
}

.badge.recommend {
  background: #2186eb;
}

.flight-card-main {
  grid-area: main; /* Assign to main area */
  display: flex;
  flex-direction: row; /* Keep as row for larger screens */
  justify-content: space-between;
  align-items: center;
  padding: 0 10px; /* Adjust padding for grid layout */
  gap: 12px;
  width: 100%;
}

.flight-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  flex: 1;
  justify-content: center; /* Center content horizontally */
}

.time-airport {
  text-align: center;
  min-width: 100px;
}

.airport {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray700);
}

.flight-time {
  font-size: 18px;
  font-weight: 700;
  color: var(--blk);
}

.date {
  font-size: 13px;
  color: var(--gray500);
}

.arrow {
  font-size: 18px;
  color: var(--primary);
  font-weight: bold;
}

.flight-details {
  display: flex;
  flex-direction: column;
  align-items: flex-end; /* Align price and button to the right */
  gap: 6px;
  font-size: 13px;
  color: var(--gray600);
  padding-left: 10px; /* Add some spacing */
}

.price {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.select-btn {
  grid-area: button; /* Assign to button area */
  background-color: var(--primary);
  color: var(--wht);
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: background-color 0.2s ease, transform 0.2s ease;
  width: auto; /* Allow button to size based on content */
  min-width: 120px; /* Set a minimum width for consistency */
  text-align: center;
  margin-left: 15px; /* Add some spacing from flight details */
}

.select-btn:hover {
  background-color: #1565c0;
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* --- AI Recommendation Text --- */
.ai-recommendation-text {
  background-color: #f9f9f9;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--gray100);
  margin-top: 10px;
}

.ai-recommendation-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray700);
  margin: 0 0 8px 0;
}

#ai-additional-recommendation {
  font-size: 14px;
  color: var(--gray600);
  line-height: 1.6;
  margin: 0;
}

/* --- AI Follow-up Actions --- */
.ai-follow-up-actions {
  background: #f7fbff;
  border-radius: 8px;
  padding: 14px;
  margin-top: 10px;
  box-shadow: 0 2px 6px rgba(33, 134, 235, 0.05);
}

.ai-chat-bubble {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  background: #e9f5ff;
  padding: 8px 14px;
  border-radius: 18px;
  display: inline-block;
  margin-bottom: 10px;
}

.follow-up-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-action-btn {
  border: none;
  background: #eef6fc;
  color: var(--primary);
  padding: 8px 14px;
  border-radius: 18px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s, transform 0.2s;
}

.ai-action-btn:hover {
  background: var(--primary);
  color: var(--wht);
  transform: translateY(-2px);
}

.ai-action-btn .icon {
  font-size: 15px;
}

/* --- Confetti Container --- */
.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1001;
}

/* --- Retry Button --- */
.retry-btn {
  background-color: var(--primary);
  color: var(--wht);
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  margin-top: 12px;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.retry-btn:hover {
  background-color: #1565c0;
  transform: translateY(-2px);
}

/* --- Responsive Adjustments --- */
@media (min-width: 768px) {
  /* No changes needed here, as the default grid setup handles larger screens */
}

@media (max-width: 767px) {
  .modal-content {
    padding: 16px;
    width: 95%;
    max-height: 90vh;
  }

  .modal-content h2 {
    font-size: 20px;
  }

  .close-button {
    font-size: 22px;
    top: 12px;
    right: 12px;
  }

  .ai-loading-status {
    gap: 12px;
    min-height: 250px;
  }

  .loading-wrapper {
    padding: 16px;
  }

  .ai-loading-progress {
    gap: 8px;
    max-width: 300px;
  }

  .ai-loading-progress .step {
    font-size: 12px;
  }

  .ai-loading-progress .circle {
    width: 20px;
    height: 20px;
  }

  .ai-flight-card {
    grid-template-columns: 1fr; /* Single column for small screens */
    grid-template-areas:
      "header"
      "main"
      "button"; /* Stack elements vertically */
    padding: 12px;
  }

  .flight-card-header {
    margin-bottom: 10px; /* Add back margin for spacing in column layout */
    padding-right: 0;
    justify-content: center; /* Center header content */
  }

  .badge {
    margin-left: 0; /* Reset margin for badges */
  }

  .flight-card-main {
    flex-direction: column; /* Stack flight info and details */
    align-items: center; /* Center horizontally */
    padding: 0;
  }

  .flight-info {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  .arrow {
    transform: rotate(90deg);
  }

  .flight-details {
    flex-direction: column; /* Ensure details stack vertically */
    align-items: center; /* Center items in column for small screens */
    width: 100%;
    padding-left: 0;
  }

  .select-btn {
    width: 100%; /* Full width button on small screens */
    padding: 12px;
    font-size: 14px;
    margin-top: 10px; /* Add space above button */
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  .modal-content h2 {
    font-size: 18px;
  }

  .ai-flight-card {
    padding: 10px;
  }

  .flight-time {
    font-size: 16px;
  }

  .airport {
    font-size: 14px;
  }

  .date {
    font-size: 12px;
  }
}

/* ai_results.css or other relevant CSS file */
.ai-insight .more-link {
    font-size: 0.9em; /* Adjust font size as needed */
    margin-left: 10px; /* Space from the text */
    text-decoration: underline; /* Add underline */
    color: #007bff; /* Example color, match your design */
    cursor: pointer;
}

.ai-insight .more-link:hover {
    color: #0056b3; /* Darker color on hover */
    text-decoration: none; /* Remove underline on hover, or keep it */
}