/**
 * METAR Ops Wall - Styles
 * Dark/light themes, responsive grid, kiosk mode, aviation-inspired design
 */

/* CSS Variables for Theming */
:root {
  /* Dark theme (default) */
  --bg-primary: #0a0e27;
  --bg-secondary: #1a1f3a;
  --bg-tertiary: #252b4a;
  --text-primary: #e8eaf6;
  --text-secondary: #b0b8d0;
  --text-muted: #7a8499;
  --border-color: #2d3450;
  --accent: #4a90e2;
  --accent-hover: #5ba0f2;
  --vmc: #4caf50;
  --imc: #f44336;
  --unknown: #9e9e9e;
  --fresh: #4caf50;
  --old: #ff9800;
  --stale: #f44336;
  --error-bg: #d32f2f;
  --error-text: #ffffff;
}

.theme-light {
  --bg-primary: #f5f7fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e8ecf1;
  --text-primary: #1a1f3a;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --border-color: #cbd5e0;
  --accent: #3182ce;
  --accent-hover: #2c5aa0;
  --vmc: #38a169;
  --imc: #e53e3e;
  --unknown: #718096;
  --fresh: #38a169;
  --old: #d69e2e;
  --stale: #e53e3e;
  --error-bg: #c53030;
  --error-text: #ffffff;
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden; /* Prevent scrolling */
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

body {
  display: flex;
  flex-direction: column;
}

/* Error Banner */
.error-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: var(--error-bg);
  color: var(--error-text);
  padding: 1rem;
  text-align: center;
  font-weight: bold;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  display: none;
}

.error-banner-visible {
  display: block;
}

/* Wall Container */
.wall-container {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(var(--grid-cols, 4), 1fr);
  grid-template-rows: repeat(var(--grid-rows, 3), 1fr);
  gap: 1.5rem;
  padding: 1.5rem;
  overflow: hidden;
  transform: scale(var(--tile-scale, 1));
  transform-origin: top left;
  width: calc(100% / var(--tile-scale, 1));
  height: calc(100% / var(--tile-scale, 1));
}

.wall-empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-muted);
  text-align: center;
}

/* Airport Tiles */
.tile {
  background-color: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: all 0.2s ease;
  min-height: 0;
  overflow: hidden;
}

.tile:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.2);
  transform: translateY(-2px);
}

.tile:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.tile-icao {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: bold;
  letter-spacing: 0.1em;
  color: var(--text-primary);
}

.age-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
  text-transform: uppercase;
}

.age-badge.fresh {
  background-color: var(--fresh);
  color: white;
}

.age-badge.old {
  background-color: var(--old);
  color: white;
}

.age-badge.stale {
  background-color: var(--stale);
  color: white;
}

.conditions-badge {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: clamp(0.875rem, 2vw, 1.125rem);
  font-weight: bold;
  text-align: center;
  width: fit-content;
}

.conditions-badge.vmc {
  background-color: var(--vmc);
  color: white;
}

.conditions-badge.imc {
  background-color: var(--imc);
  color: white;
}

.conditions-badge.unknown {
  background-color: var(--unknown);
  color: white;
}

.tile-wind {
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  font-weight: 600;
  color: var(--text-primary);
}

.tile-runway {
  font-size: clamp(0.875rem, 2vw, 1.125rem);
  font-weight: 600;
  color: var(--accent);
}

.tile-wind-indicator {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0.5rem 0;
  min-height: 0;
  flex-shrink: 1;
}

.tile-wind-indicator svg {
  width: 100%;
  max-width: 100%;
  height: auto;
  min-width: 120px;
  max-width: 250px;
  aspect-ratio: 1;
}

.tile-visibility {
  font-size: clamp(0.875rem, 2vw, 1.125rem);
  color: var(--text-secondary);
}

.tile-clouds {
  font-size: clamp(0.875rem, 2vw, 1.125rem);
  color: var(--text-secondary);
}

.tile-footer {
  display: flex;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  font-size: clamp(0.75rem, 1.5vw, 0.875rem);
  color: var(--text-muted);
}

/* Controls Panel */
.controls {
  background-color: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
  padding: 1rem 1.5rem;
  display: flex;
  gap: 1.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.kiosk-mode .controls {
  display: none !important;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-group label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.control-group input,
.control-group button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.875rem;
}

.control-group input {
  width: 80px;
}

.control-group input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.control-group button {
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
}

.control-group button:hover {
  background-color: var(--accent);
  border-color: var(--accent);
  color: white;
}

.control-group button:active {
  transform: scale(0.98);
}

#theme-toggle {
  font-size: 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  transition: transform 0.2s ease;
}

#theme-toggle:hover {
  transform: scale(1.1);
}

/* Favorites List */
.favorites-list {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 1rem;
}

.favorite-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  background-color: var(--bg-tertiary);
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.favorite-icao {
  font-weight: 600;
  color: var(--text-primary);
}

.favorite-controls {
  display: flex;
  gap: 0.25rem;
}

.reorder-btn,
.remove-btn {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.reorder-btn:hover,
.remove-btn:hover {
  background-color: var(--accent);
  border-color: var(--accent);
  color: white;
}

.favorites-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 1rem;
}

/* Airport View */
.airport-view {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.airport-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.airport-icao {
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: bold;
  letter-spacing: 0.1em;
  color: var(--text-primary);
}

.airport-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.airport-section {
  background-color: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
}

.airport-section h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.airport-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.airport-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.airport-raw {
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  color: var(--text-secondary);
  background-color: var(--bg-tertiary);
  padding: 1rem;
  border-radius: 4px;
  word-break: break-all;
}

.runways-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.runway-item {
  padding: 1rem;
  background-color: var(--bg-tertiary);
  border-radius: 4px;
}

.runway-label {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.runway-label.optimal {
  color: var(--accent);
}

.runway-components {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.cloud-layers {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.cloud-layer {
  font-size: 0.875rem;
  color: var(--text-secondary);
  padding: 0.25rem 0;
}

.airport-loading,
.airport-error {
  font-size: 1.25rem;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

/* Wind Indicator */
.wind-indicator-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 2rem 0;
  padding: 1.5rem;
  background-color: var(--bg-tertiary);
  border-radius: 8px;
  width: 100%;
}

.wind-indicator-label {
  font-size: clamp(1rem, 2vw, 1.125rem);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  text-align: center;
}

.wind-indicator {
  display: block;
  max-width: 100%;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
}

.wind-indicator-container svg {
  max-width: 100%;
  width: min(400px, 100%);
  height: auto;
}

/* Back Button */
#back-button {
  position: fixed;
  top: 1rem;
  left: 1rem;
  padding: 0.75rem 1.5rem;
  background-color: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 100;
}

#back-button:hover {
  background-color: var(--accent);
  border-color: var(--accent);
  color: white;
}

.kiosk-mode #back-button {
  display: none !important;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .wall-container {
    grid-template-columns: repeat(2, 1fr);
    padding: 1rem;
    gap: 1rem;
  }
  
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .control-group {
    width: 100%;
  }
  
  .airport-content {
    grid-template-columns: 1fr;
  }
  
  .tile-wind-indicator svg {
    max-width: 180px;
    min-width: 100px;
  }
  
  .wind-indicator-container svg {
    max-width: 100%;
    width: min(400px, 90vw);
  }
}

@media (max-width: 480px) {
  .tile-wind-indicator svg {
    max-width: 150px;
    min-width: 80px;
  }
  
  .wind-indicator-container svg {
    width: min(350px, 95vw);
  }
}

@media (min-width: 1920px) {
  .tile-wind-indicator svg {
    max-width: 280px;
  }
  
  .wind-indicator-container svg {
    max-width: 450px;
  }
}

/* Print Styles */
@media print {
  .controls,
  #back-button,
  .error-banner {
    display: none !important;
  }
  
  .wall-container {
    transform: none;
    width: 100%;
    height: auto;
  }
}

