/* ============================================================
   COMPONENTS.CSS
   eIAWS — Enterprise Integrated Aviation Weather System
   I.M. Systems Group
   Reusable UI components — buttons, cards, toggles, inputs
   ============================================================ */

/* ----------------------------------------------------------
   CARDS
   ---------------------------------------------------------- */
.card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-md);
  padding: var(--space-3);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-standard);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-dark {
  background-color: var(--bg-card-dark);
}

/* ----------------------------------------------------------
   METRIC CARDS
   ---------------------------------------------------------- */
.metric-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-accent-primary);
  margin-bottom: var(--space-1);
}

.metric-value {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.metric-value-lg {
  font-size: var(--text-5xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1;
}

.metric-sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* ----------------------------------------------------------
   BUTTONS
   ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--border-radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: var(--transition-fast);
  border: none;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--color-action);
  color: var(--text-primary);
}

.btn-primary:hover {
  background-color: var(--color-action-hover);
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--border-color);
}

.btn-ghost {
  background-color: transparent;
  color: var(--color-accent-primary);
  padding: var(--space-1) 0;
}

.btn-ghost:hover {
  text-decoration: underline;
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

/* Glass button */
.btn-glass {
  backdrop-filter: blur(12px);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: var(--space-3) var(--space-6);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  box-shadow: var(--shadow-glass);
  transition: var(--transition-standard);
  cursor: pointer;
}

.btn-glass:hover {
  background: var(--glass-hover);
  box-shadow: var(--shadow-glass-hover);
  transform: scale(1.05);
}

.btn-glass:active {
  transform: scale(0.98);
}

/* ----------------------------------------------------------
   INPUTS
   ---------------------------------------------------------- */
.input {
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  transition: var(--transition-fast);
  width: 100%;
}

.input:focus {
  border-color: var(--color-action-light);
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.3);
}

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

.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.input-group label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}

.input-help {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ----------------------------------------------------------
   SELECT / DROPDOWN
   ---------------------------------------------------------- */
.select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.select:focus {
  border-color: var(--color-action-light);
}

.select option {
  background-color: var(--bg-panel);
  color: var(--text-primary);
}

/* Glass dropdown variant */
.select-glass {
  appearance: none;
  -webkit-appearance: none;
  color: var(--text-primary);
  background-color: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--border-radius-lg);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-glass);
  font-size: var(--text-base);
  cursor: pointer;
  transition: var(--transition-standard);
}

.select-glass:hover {
  background-color: var(--glass-hover);
}

.select-glass option {
  background-color: var(--bg-panel);
  color: var(--text-primary);
}

/* ----------------------------------------------------------
   TOGGLE SWITCH
   ---------------------------------------------------------- */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 30px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  cursor: pointer;
  background-color: #4b5563;
  border-radius: 30px;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  transition: var(--transition-standard);
}

.toggle-track::before {
  content: "";
  position: absolute;
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 3px;
  background-color: var(--color-accent-primary);
  transition: var(--transition-standard);
  border-radius: 50%;
  z-index: 2;
}

.toggle-switch input:checked + .toggle-track::before {
  transform: translateX(30px);
}

.toggle-label {
  position: absolute;
  width: 50%;
  text-align: center;
  line-height: 30px;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  z-index: 1;
  pointer-events: none;
}

.toggle-label-left  { left: 0; }
.toggle-label-right { right: 0; opacity: 0.6; }

.toggle-switch input:checked + .toggle-track .toggle-label-left  { opacity: 0.6; }
.toggle-switch input:checked + .toggle-track .toggle-label-right { opacity: 1; }

/* ----------------------------------------------------------
   BADGES
   ---------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--border-radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.badge-green   { background-color: #16a34a; }
.badge-yellow  { background-color: #ca8a04; }
.badge-red     { background-color: #dc2626; }
.badge-blue    { background-color: var(--color-action); }
.badge-gray    { background-color: #6b7280; }

/* ----------------------------------------------------------
   DIVIDER
   ---------------------------------------------------------- */
.divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: var(--space-4) 0;
}

.divider-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin: var(--space-4) 0;
}

.divider-label::before,
.divider-label::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border-color);
}

/* ----------------------------------------------------------
   SECTION HEADERS
   ---------------------------------------------------------- */
.section-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
}

.section-timestamp {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ----------------------------------------------------------
   LIVE CLOCK
   ---------------------------------------------------------- */
.live-clock {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-accent-primary);
  letter-spacing: 0.08em;
  min-width: 90px;
  text-align: center;
}

/* ----------------------------------------------------------
   LOGOUT BUTTON
   ---------------------------------------------------------- */
.btn-logout {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--border-radius-md);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-logout:hover {
  border-color: var(--text-danger);
  color: var(--text-danger);
}

/* ----------------------------------------------------------
   STATION BADGE & LOCATION
   ---------------------------------------------------------- */
.station-meta {
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

.icao-badge-aviation {
  display: inline-block;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #1d4ed8 100%);
  color: white;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  font-size: 1.2rem;
  padding: 12px 22px;
  margin-left: 20px;
  margin-top: 10px;
  border-radius: 12px;
  letter-spacing: 2px;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 0 8px rgba(255, 255, 255, 0.3);
  box-shadow:
    0 0 0 2px #fbbf24,
    0 4px 12px rgba(59, 130, 246, 0.4),
    0 0 20px rgba(251, 191, 36, 0.6),
    0 0 40px rgba(59, 130, 246, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border: 2px solid #fbbf24;
  position: relative;
  transition: all 0.3s ease;
  isolation: isolate;          /* keeps the glow layer (::before) behind the text but above the panel */
  text-align: center;
  line-height: 1.3;
}

.icao-code {
  display: block;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 3px;
  margin-bottom: 2px;
}

.airport-name {
  display: block;
  font-size: 14px;
  font-weight: normal;
  letter-spacing: 1px;
  opacity: 0.9;
  text-transform: uppercase;
}

.city-region-style {
  font-size: 18px;
  font-weight: 600;
  color: #fbbf24;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  font-style: italic;
  margin-left: 20px;
}

.icao-badge-aviation::after {
  content: '✈';
  position: absolute;
  top: -8px;
  right: -8px;
  background: #fbbf24;
  color: #1e40af;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  box-shadow:
    0 0 10px rgba(251, 191, 36, 0.8),
    0 2px 4px rgba(0, 0, 0, 0.2);
}

.icao-badge-aviation:hover {
  transform: translateY(-2px);
  box-shadow:
    0 0 0 2px #fbbf24,
    0 6px 16px rgba(59, 130, 246, 0.5),
    0 0 30px rgba(251, 191, 36, 0.8),
    0 0 50px rgba(59, 130, 246, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* The glow pulse. The badge itself keeps a static glow (the "from" shadow above). The brighter
   extra glow lives on ::before and only fades in and out. Animating box-shadow directly forced a
   repaint of five blurred shadows on every frame (150%+ CPU); an opacity fade runs on the GPU and
   needs no repaint. */
.icao-badge-aviation::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
  z-index: -1;
  box-shadow:
    0 4px 16px rgba(59, 130, 246, 0.6),
    0 0 30px rgba(251, 191, 36, 0.8),
    0 0 60px rgba(59, 130, 246, 0.5);
  opacity: 0;
  will-change: opacity;
  animation: aviation-glow 3s ease-in-out infinite alternate;
}

@keyframes aviation-glow {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ----------------------------------------------------------
   WEATHER ICON — beside badge, right-aligned
   ---------------------------------------------------------- */
.station-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.station-badge-left {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.weather-icon-container {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ----------------------------------------------------------
   SEARCH RESULTS
   ---------------------------------------------------------- */
.search-results-label {
  font-weight: var(--weight-semibold);
  color: var(--text-danger);
  margin-right: var(--space-1);
}

.search-result-btn {
  background: none;
  border: none;
  color: var(--color-accent-primary);
  font-size: var(--text-sm);
  cursor: pointer;
  padding: 0 var(--space-1);
  transition: var(--transition-fast);
}

.search-result-btn:hover {
  text-decoration: underline;
  color: var(--color-action-light);
}

/* ----------------------------------------------------------
   STATION SEARCH
   ---------------------------------------------------------- */
.station-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.station-search-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.station-search-input {
  width: 140px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: var(--weight-semibold);
  font-family: var(--font-mono);
}

.search-error {
  font-size: var(--text-sm);
  color: var(--text-danger);
  padding: var(--space-1) 0;
}

/* ----------------------------------------------------------
   CHART TOGGLE CONTAINERS
   ---------------------------------------------------------- */
.chart-container {
  min-height: 150px;
  display: none;
}

.chart-container.visible {
  display: block;
}

.chart-container-tall {
  min-height: 400px;
  display: none;
}

.chart-container-tall.visible {
  display: block;
}

/* ----------------------------------------------------------
   NAVBAR DROPDOWN
   A navbar link that opens a small menu while it is hovered or has keyboard focus:
     <div class="navbar-item has-dropdown">
       <a class="navbar-link" href="...">Parent</a>
       <div class="navbar-dropdown"><a class="navbar-dropdown-link" href="...">Item</a>...</div>
     </div>
   ---------------------------------------------------------- */
.navbar-item {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.navbar-item.has-dropdown > .navbar-link::after {
  content: '\25BE';
  margin-left: 0.35em;
  font-size: 0.8em;
  opacity: 0.7;
}

.navbar-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 13em;
  padding: var(--space-1) 0;
  background-color: var(--bg-navbar);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 2000;
}

/* an invisible strip above the menu, so the pointer can cross from the link to the menu without closing it */
.navbar-dropdown::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -10px;
  height: 10px;
}

.navbar-item:hover > .navbar-dropdown,
.navbar-item:focus-within > .navbar-dropdown {
  display: block;
}

.navbar-dropdown-link {
  display: block;
  padding: var(--space-2) var(--space-4);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  text-decoration: none;
  white-space: nowrap;
}

.navbar-dropdown-link:hover,
.navbar-dropdown-link:focus-visible {
  background-color: rgba(2, 170, 252, 0.12);
  color: var(--text-primary);
  outline: none;
}

.navbar-dropdown-link.active {
  color: var(--color-accent-primary);
}
