/* ============================================
   FlyLine Chat UI – Design System & Styles
   ============================================ */

:root {
  /* Color Palette */
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --accent: #06d6a0;
  --accent-glow: rgba(6, 214, 160, 0.2);

  /* Surfaces */
  --bg-deep: #0a0e1a;
  --bg-main: #0f1326;
  --bg-card: #161b33;
  --bg-elevated: #1c2240;
  --bg-hover: #242c50;
  --bg-input: #1a1f3a;

  /* Text */
  --text-primary: #f0f0f5;
  --text-secondary: #9ca3c2;
  --text-muted: #6b7199;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-active: rgba(99, 102, 241, 0.4);

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #6366f1, #818cf8);
  --gradient-header: linear-gradient(135deg, #0f1326 0%, #1a1142 100%);
  --gradient-bot-msg: linear-gradient(135deg, #1c2240 0%, #1a1f3a 100%);

  /* Effects */
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);
  --blur-glass: blur(20px);

  /* Sizing */
  --header-height: 68px;
  --input-area-height: auto;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Reset & Base
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* ============================================
   Background Particles
   ============================================ */

.bg-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  border-radius: 50%;
  opacity: 0.08;
  animation: particleFloat 20s infinite ease-in-out;
}

.particle:nth-child(1) {
  width: 300px; height: 300px;
  background: var(--primary);
  top: -100px; left: -50px;
  animation-delay: 0s;
}
.particle:nth-child(2) {
  width: 200px; height: 200px;
  background: var(--accent);
  top: 50%; right: -80px;
  animation-delay: -5s;
}
.particle:nth-child(3) {
  width: 250px; height: 250px;
  background: var(--primary-light);
  bottom: -100px; left: 40%;
  animation-delay: -10s;
}
.particle:nth-child(4) {
  width: 150px; height: 150px;
  background: var(--accent);
  top: 20%; left: 60%;
  animation-delay: -3s;
}
.particle:nth-child(5) {
  width: 180px; height: 180px;
  background: var(--primary);
  bottom: 20%; right: 30%;
  animation-delay: -7s;
}
.particle:nth-child(6) {
  width: 120px; height: 120px;
  background: var(--primary-light);
  top: 40%; left: 20%;
  animation-delay: -12s;
}

@keyframes particleFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -40px) scale(1.1); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(15px, 35px) scale(1.05); }
}

/* ============================================
   Chat Container
   ============================================ */

.chat-container {
  width: 100%;
  max-width: 520px;
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-glow);
}

@media (min-width: 768px) {
  .chat-container {
    height: 92vh;
    max-height: 800px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
  }
}

/* ============================================
   Header
   ============================================ */

.chat-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--gradient-header);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  backdrop-filter: var(--blur-glass);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.header-info h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #f0f0f5, #c4c6d8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px transparent; }
}

.header-right {
  display: flex;
  gap: 8px;
}

.header-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  transform: scale(1.05);
}

/* ============================================
   Messages Area
   ============================================ */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* ============================================
   Welcome Card
   ============================================ */

.welcome-card {
  text-align: center;
  padding: 32px 20px;
  animation: fadeInUp 0.6s ease;
}

.welcome-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

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

.welcome-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text-primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  max-width: 340px;
  margin: 0 auto 24px;
  line-height: 1.7;
}

.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 300px;
  margin: 0 auto;
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
  text-align: left;
}

.quick-action-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-active);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.qa-icon {
  font-size: 1.1rem;
}

/* ============================================
   Message Bubbles
   ============================================ */

.message {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: fadeInUp 0.3s ease;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.bot {
  align-self: flex-start;
}

.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.8rem;
  margin-top: 2px;
}

.message.bot .message-avatar {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.message.user .message-avatar {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.6;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message.bot .message-bubble {
  background: var(--gradient-bot-msg);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
}

.message.user .message-bubble {
  background: var(--gradient-primary);
  border-bottom-right-radius: 4px;
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.message-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.message.user .message-time {
  text-align: right;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ============================================
   Input Area
   ============================================ */

.chat-input-area {
  padding: 12px 16px 16px;
  background: var(--bg-main);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 6px 6px 16px;
  transition: var(--transition-smooth);
}

.input-wrapper:focus-within {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.message-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 8px 0;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 24px;
}

.message-input::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border: none;
  border-radius: 10px;
  background: var(--gradient-primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
  opacity: 0.5;
  pointer-events: none;
}

.send-btn.active {
  opacity: 1;
  pointer-events: auto;
}

.send-btn.active:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.send-btn.active:active {
  transform: scale(0.95);
}

.input-footer {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

.powered-by {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ============================================
   Animations
   ============================================ */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Mobile Responsive
   ============================================ */

@media (max-width: 520px) {
  .chat-container {
    max-width: 100%;
    border-radius: 0;
    border: none;
  }

  .welcome-card {
    padding: 24px 16px;
  }

  .message {
    max-width: 90%;
  }
}

/* ============================================
   Flight Result Cards
   ============================================ */

.flight-results-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
  width: 100%;
}

.flight-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.flight-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 4px; height: 100%;
  background: var(--primary);
  opacity: 0.6;
}

.flight-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-active);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.flight-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.airline-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.airline-logo {
  font-size: 1.2rem;
}

.airline-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

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

.flight-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.time-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.time {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.airport {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.duration-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.duration-line {
  width: 60px;
  height: 2px;
  background: var(--border-subtle);
  position: relative;
}

.duration-line::after {
  content: '✈️';
  position: absolute;
  top: -8px; left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
}

.duration {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.stops {
  font-size: 0.7rem;
  color: var(--accent);
}

.flight-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.baggage-info {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.select-flight-btn {
  padding: 8px 16px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--primary-light);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.select-flight-btn:hover {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.google-flights-link {
  display: block;
  text-align: center;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition-fast);
}

.google-flights-link:hover {
  color: var(--primary-light);
  text-decoration: underline;
}

/* Search Form Styles */
.search-form-container {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    margin: 15px 0;
    max-width: 100%;
    animation: slideIn 0.3s ease-out;
}

.search-form-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group.full-width {
    grid-column: span 2;
}

.form-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s ease;
}

.form-input:focus {
    border-color: var(--accent-primary);
    background: rgba(0, 0, 0, 0.3);
}

.search-submit-btn {
    grid-column: span 2;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.search-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
}

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

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
    .search-form {
        grid-template-columns: 1fr;
    }
    .form-group.full-width {
        grid-column: span 1;
    }
}
