/* CSS Variables - Light Mode (Default) */
:root {
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #6c757d;
  --text-tertiary: #adb5bd;
  --accent: #0066cc;
  --accent-hover: #0052a3;
  --success: #28a745;
  --warning: #ffc107;
  --danger: #dc3545;
  --border: #dee2e6;
  --shadow: rgba(0, 0, 0, 0.08);
  --shadow-hover: rgba(0, 0, 0, 0.12);
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0d0d0d;
    --bg-secondary: #1a1a1a;
    --bg-card: #1a1a1a;
    --text-primary: #e8e8e8;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: #2d2d2d;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.4);
  }
}

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

/* Base */
html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Container */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
}

/* Header */
header {
  text-align: center;
  padding: 2rem 0 1.5rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 400;
}

/* Search Section */
.search-section {
  margin-bottom: 1.5rem;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-group {
  display: flex;
  gap: 0.5rem;
}

.input-group input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input-group input::placeholder {
  color: var(--text-tertiary);
}

.input-group button {
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.input-group button:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 4px var(--shadow);
}

.input-group button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Error Message */
.error-message {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--danger);
  border-radius: 6px;
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Flight Info */
.flight-info {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px var(--shadow);
}

.flight-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.flight-number {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.flight-number span:first-child {
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.aircraft-reg {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.flight-status {
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.flight-status.in-air {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.flight-status.landed {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.flight-status.scheduled {
  background: rgba(156, 163, 175, 0.1);
  color: var(--text-secondary);
  border: 1px solid rgba(156, 163, 175, 0.2);
}

.flight-status.delayed {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.flight-status.cancelled {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Route Display */
.current-leg {
  margin-bottom: 1.5rem;
}

.route {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.airport {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 60px;
}

.airport.origin {
  align-items: flex-start;
  text-align: left;
}

.airport.destination {
  align-items: flex-end;
  text-align: right;
}

.airport .code {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.airport .name {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
}

.airport .time {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-weight: 500;
}

.route-line {
  flex: 1;
  position: relative;
}

.progress-container {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  position: relative;
  overflow: visible;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.5s ease;
}

.plane-icon {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  font-size: 1.25rem;
  transition: left 0.5s ease;
}

/* Delay Info */
.delay-info {
  margin-top: 1rem;
  padding: 0.625rem 0.875rem;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 6px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.delay-badge {
  background: var(--warning);
  color: #000;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

/* Legs Section */
.legs-section {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.legs-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 3px var(--shadow);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.legs-list, .history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.leg-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  gap: 0.75rem;
  transition: all 0.15s ease;
}

.leg-item:hover {
  border-color: var(--text-tertiary);
}

.leg-item .leg-flight {
  font-weight: 600;
  min-width: 70px;
  font-size: 0.875rem;
}

.leg-item .leg-route {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.leg-item .leg-status {
  font-size: 0.6875rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.leg-item .leg-status.landed {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.leg-item .leg-status.in-air {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.leg-item .leg-status.scheduled {
  background: rgba(156, 163, 175, 0.1);
  color: var(--text-secondary);
  border: 1px solid rgba(156, 163, 175, 0.2);
}

.history-item {
  padding: 0.625rem 0.75rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8125rem;
}

.history-item .time {
  color: var(--text-secondary);
  font-size: 0.6875rem;
  font-weight: 500;
}

.no-data {
  text-align: center;
  color: var(--text-secondary);
  padding: 1rem;
  font-size: 0.9rem;
}

/* Settings Section */
.settings-section {
  margin-bottom: 1rem;
}

.settings-section details {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.settings-section summary {
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9375rem;
  user-select: none;
  transition: background 0.15s ease;
}

.settings-section summary:hover {
  background: var(--bg-primary);
}

.settings-content {
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}

.setting-item {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.setting-item label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  user-select: none;
}

.setting-item input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--accent);
}

.btn-primary {
  width: 100%;
  padding: 0.625rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 4px var(--shadow);
}

.btn-small {
  padding: 0.375rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-small:hover {
  background: var(--bg-primary);
  border-color: var(--text-tertiary);
}

.btn-secondary {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--bg-primary);
  border-color: var(--text-tertiary);
}

/* Footer */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.polling-status {
  margin-top: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.polling-status.active {
  color: var(--success);
}

.polling-status.active::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  margin-right: 0.5rem;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Notification Banner */
.notification-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  padding: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px var(--shadow);
  backdrop-filter: blur(10px);
}

.notification-banner p {
  flex: 1 1 100%;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.notification-banner button {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

#enable-notifications {
  background: var(--accent);
  color: white;
  border: none;
}

#enable-notifications:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 4px var(--shadow);
}

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

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

.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg-card);
  opacity: 0.7;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Responsive */
@media (min-width: 480px) {
  .container {
    padding: 1.5rem;
  }

  header h1 {
    font-size: 1.75rem;
  }

  .notification-banner {
    padding: 1rem 2rem;
  }

  .notification-banner p {
    flex: 1;
    text-align: left;
  }
}

@media (min-width: 768px) {
  .container {
    padding: 2rem;
  }

  header {
    padding: 2.5rem 0 2rem;
  }

  .flight-info {
    padding: 2rem;
  }

  .airport .name {
    max-width: 120px;
  }
}

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

.flight-info {
  animation: fadeIn 0.3s ease;
}
