html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 80px; /* Increased to prevent footer overlap on mobile */
}

@media (min-width: 768px) {
  body {
    margin-bottom: 60px;
  }
}

/* ===== Mobile Optimization Styles ===== */

/* Map responsive height */
#routeMap {
  width: 100%;
  height: 300px;
}

@media (min-width: 576px) {
  #routeMap {
    height: 400px;
  }
}

@media (min-width: 768px) {
  #routeMap {
    height: 500px;
  }
}

@media (min-width: 992px) {
  #routeMap {
    height: 600px;
  }
}

/* Touch-friendly buttons on mobile */
@media (max-width: 767px) {
  .btn {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    min-height: 44px; /* iOS recommended touch target */
  }

  .btn-lg {
    min-height: 48px;
  }

  .popular-route {
    min-height: 40px;
    margin: 0.25rem;
  }
}

/* Mobile-optimized spacing */
@media (max-width: 767px) {
  .container {
    padding-left: 0;
    padding-right: 0;
  }

  /* Reduce row gutters for better mobile spacing */
  .row {
    --bs-gutter-x: 0;
  }

  /* Add minimal padding to columns for content breathing room */
  .col,
  [class*="col-"] {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .card-body {
    padding: 1rem;
  }

  h1.display-4 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  h5 {
    font-size: 1.1rem;
  }
}

/* Mobile table styling */
@media (max-width: 767px) {
  .table-responsive {
    font-size: 0.85rem;
  }

  .table th,
  .table td {
    padding: 0.5rem 0.25rem;
  }
}

/* Collapsible card headers (all screen sizes) */
.collapsible-mobile {
  cursor: pointer;
  user-select: none;
}

/* Chart canvas sizing */
#altitudeChart {
  max-height: 300px;
}

/* Chart canvas mobile optimization */
@media (max-width: 767px) {
  canvas {
    max-height: 250px !important;
  }

  /* Comprehensive Flight Profile needs more height on mobile */
  #altitudeChart {
    max-height: 500px !important;
  }
}

/* Mobile navigation improvements */
@media (max-width: 767px) {
  .navbar-brand {
    font-size: 1.1rem;
  }

  .navbar-nav .nav-link {
    padding: 0.75rem 1rem;
  }
}

/* Badge sizing for mobile */
@media (max-width: 767px) {
  .badge {
    font-size: 0.5em;
    padding: 0.35em 0.65em;
  }

  .display-4 .badge {
    font-size: 0.5em;
    padding: 0.5rem 1rem;
  }
}

/* Improve touch targets for map markers */
.maplibregl-marker {
  cursor: pointer;
}

.maplibregl-popup-content {
  padding: 10px;
  max-width: 280px;
}

@media (max-width: 767px) {
  .maplibregl-popup-content {
    font-size: 0.85rem;
    padding: 8px;
    max-width: 240px;
  }
}

/* MapLibre controls repositioning for mobile */
@media (max-width: 767px) {
  .maplibregl-ctrl-top-right {
    top: 10px;
    right: 10px;
  }

  .maplibregl-ctrl-bottom-right {
    bottom: 10px;
    right: 10px;
  }
}

/* Prevent horizontal scroll on mobile */
body {
  overflow-x: hidden;
}

.container-fluid,
.row {
  max-width: 100%;
  overflow-x: hidden;
}

/* Improve form inputs on mobile */
@media (max-width: 767px) {
  input[type="text"],
  input[type="datetime-local"],
  .form-control {
    font-size: 16px; /* Prevents iOS zoom on focus */
  }
}

/* ===== Airport Autocomplete Styles ===== */
.airport-autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #dee2e6;
  border-top: none;
  border-radius: 0 0 0.375rem 0.375rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  margin-top: 1px;
}

.airport-autocomplete-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f3f5;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: background-color 0.15s ease;
}

.airport-autocomplete-item:last-child {
  border-bottom: none;
}

.airport-autocomplete-item:hover,
.airport-autocomplete-item.active {
  background-color: #f8f9fa;
}

.airport-autocomplete-item.active {
  background-color: #e7f3ff;
}

.airport-code {
  font-weight: 600;
  font-size: 1rem;
  color: #0d6efd;
  min-width: 50px;
  font-family: 'Courier New', monospace;
}

.airport-details {
  flex: 1;
  min-width: 0;
}

.airport-name {
  font-weight: 500;
  color: #212529;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.95rem;
}

.airport-location {
  font-size: 0.85rem;
  color: #6c757d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.airport-autocomplete-no-results {
  padding: 1rem;
  text-align: center;
  color: #6c757d;
  font-style: italic;
}

/* Mobile optimization */
@media (max-width: 767px) {
  .airport-autocomplete-dropdown {
    max-height: 250px;
  }

  .airport-autocomplete-item {
    padding: 0.5rem 0.75rem;
    gap: 0.75rem;
  }

  .airport-code {
    min-width: 40px;
    font-size: 0.9rem;
  }

  .airport-name {
    font-size: 0.85rem;
  }

  .airport-location {
    font-size: 0.75rem;
  }
}

/* ===== Timeframe Selection Styles ===== */
.btn-group[role="group"] {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-group .btn-check:checked + .btn-outline-primary {
  background-color: #0d6efd;
  border-color: #0d6efd;
  color: white;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.btn-group .btn-outline-primary {
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-group .btn-outline-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-group .btn-outline-primary i {
  margin-right: 0.5rem;
}

/* Mobile optimization for timeframe buttons */
@media (max-width: 767px) {
  .btn-group {
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  .btn-group .btn {
    border-radius: 0.375rem !important;
    margin-bottom: 0.5rem;
  }

  .btn-group .btn:last-child {
    margin-bottom: 0;
  }
}

/* ===== Custom Badge Colors ===== */
.bg-orange {
  background-color: #fd7e14 !important;
}

.text-orange {
  color: #fd7e14 !important;
}

.border-orange {
  border-color: #fd7e14 !important;
}

/* ===== Live Activity Feed Styles ===== */
.activity-feed {
  max-height: 500px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Mobile optimization for activity feed */
@media (max-width: 767px) {
  .activity-feed {
    max-height: 400px;
  }
}

.activity-item {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.activity-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12) !important;
}

.activity-icon {
  flex-shrink: 0;
}

/* Pulse animation for live indicator */
.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Scrollbar styling for activity feed */
.activity-feed::-webkit-scrollbar {
  width: 6px;
}

.activity-feed::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.activity-feed::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 10px;
}

.activity-feed::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* ===== Paper Plane Background Animation ===== */
.paper-plane {
    position: fixed;
    width: 50px;
    height: 50px;
    opacity: 0;
    transition: opacity 0.3s ease;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
    z-index: 1;
    pointer-events: none; /* Allow clicks to pass through */
    will-change: transform, opacity;
}

.paper-plane svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Mobile: smaller plane */
@media (max-width: 767px) {
    .paper-plane {
        width: 40px;
        height: 40px;
    }
}

.paper-plane.flying.fly-ltr {
    opacity: 0.9;
    animation: fly-left-to-right linear forwards;
}

.paper-plane.flying.fly-rtl {
    opacity: 0.9;
    animation: fly-right-to-left linear forwards;
}

/* Left to right - smooth parabolic arc with rotation */
@keyframes fly-left-to-right {
    0% {
        left: -100px;
        top: var(--start-height, 50vh);
        transform: rotate(-45deg); /* Launch - nose pointing up-right */
    }
    /* Ascending curve - early phase */
    15% {
        left: 15vw;
        top: calc(var(--start-height, 50vh) - (var(--start-height, 50vh) - var(--peak-height, 20vh)) * 0.6);
        transform: rotate(-35deg); /* Climbing steeper */
    }
    25% {
        left: 25vw;
        top: calc(var(--start-height, 50vh) - (var(--start-height, 50vh) - var(--peak-height, 20vh)) * 0.9);
        transform: rotate(-25deg); /* Near peak, more horizontal */
    }
    /* Peak at 35% */
    35% {
        left: 35vw;
        top: var(--peak-height, 20vh);
        transform: rotate(-5deg); /* Almost level at peak */
    }
    /* Descending curve - gravity takes over */
    50% {
        left: 50vw;
        top: calc(var(--peak-height, 20vh) + (var(--end-height, 60vh) - var(--peak-height, 20vh)) * 0.35);
        transform: rotate(10deg); /* Starting descent - horizontal to slight down */
    }
    70% {
        left: 70vw;
        top: calc(var(--peak-height, 20vh) + (var(--end-height, 60vh) - var(--peak-height, 20vh)) * 0.75);
        transform: rotate(30deg); /* Nose down - descending */
    }
    85% {
        left: 85vw;
        top: calc(var(--peak-height, 20vh) + (var(--end-height, 60vh) - var(--peak-height, 20vh)) * 0.92);
        transform: rotate(30deg); /* Hold nose down */
    }
    92% {
        left: 92vw;
        top: calc(var(--peak-height, 20vh) + (var(--end-height, 60vh) - var(--peak-height, 20vh)) * 0.97);
        transform: rotate(15deg); /* Quick leveling */
    }
    100% {
        left: calc(100vw + 100px);
        top: var(--end-height, 60vh);
        transform: rotate(0deg); /* Level out at end - preparing to land */
    }
}

/* Right to left - smooth parabolic arc with rotation (flipped) */
@keyframes fly-right-to-left {
    0% {
        left: calc(100vw + 100px);
        top: var(--start-height, 50vh);
        transform: scaleX(-1) rotate(-45deg); /* Flipped + launch nose up-left */
    }
    /* Ascending curve - early phase */
    15% {
        left: 85vw;
        top: calc(var(--start-height, 50vh) - (var(--start-height, 50vh) - var(--peak-height, 20vh)) * 0.6);
        transform: scaleX(-1) rotate(-35deg); /* Flipped + climbing steeper */
    }
    25% {
        left: 75vw;
        top: calc(var(--start-height, 50vh) - (var(--start-height, 50vh) - var(--peak-height, 20vh)) * 0.9);
        transform: scaleX(-1) rotate(-25deg); /* Flipped + near peak */
    }
    /* Peak at 35% */
    35% {
        left: 65vw;
        top: var(--peak-height, 20vh);
        transform: scaleX(-1) rotate(-5deg); /* Flipped + almost level at peak */
    }
    /* Descending curve - gravity takes over */
    50% {
        left: 50vw;
        top: calc(var(--peak-height, 20vh) + (var(--end-height, 60vh) - var(--peak-height, 20vh)) * 0.35);
        transform: scaleX(-1) rotate(10deg); /* Flipped + starting descent */
    }
    70% {
        left: 30vw;
        top: calc(var(--peak-height, 20vh) + (var(--end-height, 60vh) - var(--peak-height, 20vh)) * 0.75);
        transform: scaleX(-1) rotate(30deg); /* Flipped + nose down */
    }
    85% {
        left: 15vw;
        top: calc(var(--peak-height, 20vh) + (var(--end-height, 60vh) - var(--peak-height, 20vh)) * 0.92);
        transform: scaleX(-1) rotate(30deg); /* Flipped + hold nose down */
    }
    92% {
        left: 8vw;
        top: calc(var(--peak-height, 20vh) + (var(--end-height, 60vh) - var(--peak-height, 20vh)) * 0.97);
        transform: scaleX(-1) rotate(15deg); /* Flipped + quick leveling */
    }
    100% {
        left: -100px;
        top: var(--end-height, 60vh);
        transform: scaleX(-1) rotate(0deg); /* Flipped + level out at end */
    }
}

