/* Dark Analytical Theme - TradingView inspired */

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-card: #1c2128;

  --border-primary: #30363d;
  --border-secondary: #21262d;

  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;

  --accent-red: #f85149;
  --accent-green: #3fb950;
  --accent-blue: #58a6ff;
  --accent-purple: #a371f7;
  --accent-orange: #e09f3e;
  --accent-cyan: #39c5cf;

  --aviation-color: #e09f3e;
  --forecast-color: #6b7280;
  --weathergov-color: #6d9dc5;
  --high-color: #e07850;
  --low-color: #5b9bd5;
  --avg-color: #9d8ec9;
}

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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica,
    Arial, sans-serif;
  background: var(--bg-primary);
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.5;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Glassmorphism effects */
.glass {
  background: rgba(22, 27, 34, 0.7) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.top-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  align-items: stretch;
}

.top-row > * {
  margin-bottom: 0 !important;
}

@media (max-width: 1200px) {
  .top-row {
    flex-direction: column;
  }
}

/* Header */
.header {
  flex: 1.5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  margin-bottom: 16px;
  transition: transform 0.3s ease;
}

.header:hover {
  transform: translateY(-2px);
}

h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

h1::before {
  content: "📡";
  font-size: 1.1rem;
}

.current-temp {
  display: flex;
  align-items: center;
  gap: 16px;
}

.temp-display {
  font-size: 2rem;
  font-weight: 700;
  font-family: "SF Mono", "Consolas", "Liberation Mono", monospace;
  color: var(--text-primary);
}

.temp-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.timestamp {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: "SF Mono", "Consolas", monospace;
}

/* Threshold Control */
.threshold-control {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  margin-bottom: 16px;
}

.threshold-form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

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

.threshold-input {
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: "SF Mono", "Consolas", monospace;
  color: var(--text-primary);
  width: 120px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.threshold-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
  transform: scale(1.02);
}

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

.set-button, .clear-button, .refresh-button, .dismiss-button {
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.set-button {
  background: var(--accent-green);
  color: #fff;
}

.set-button:hover {
  background: #2ea043;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(63, 185, 80, 0.2);
}

.clear-button {
  background: transparent;
  border-color: var(--border-primary);
  color: var(--text-secondary);
}

.clear-button:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-red);
  color: var(--accent-red);
  transform: translateY(-1px);
}

.threshold-display {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--accent-red);
  font-family: "SF Mono", "Consolas", monospace;
}

/* Chart Container */
.chart-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* Statistics Panel */
.stats-panel {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid var(--border-primary);
}

.stats-empty {
  grid-column: 1 / -1;
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  background: var(--bg-tertiary);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 8px;
  background: var(--bg-tertiary);
  text-align: center;
  transition: all 0.2s ease;
  min-height: 60px;
}

.stat-item:hover {
  background: var(--bg-secondary);
}

.stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: "SF Mono", "Consolas", monospace;
  color: var(--text-primary);
}

.stat-value.high {
  color: var(--high-color);
}

.stat-value.low {
  color: var(--low-color);
}

.stat-value.trend {
  font-weight: 600;
}

.stat-time {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 2px;
  font-family: "SF Mono", "Consolas", monospace;
}

/* TradingView Chart */
.tv-chart-wrapper {
  position: relative;
}

.tv-chart {
  width: 100%;
  height: 400px;
  border-radius: 8px;
  overflow: hidden;
}

/* Chart Tooltip */
.chart-tooltip {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  padding: 10px 12px;
  pointer-events: none;
  z-index: 10;
  min-width: 140px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
}

.chart-tooltip .tooltip-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-secondary);
  font-family: "SF Mono", "Consolas", monospace;
}

.chart-tooltip .tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.8rem;
  padding: 2px 0;
}

.chart-tooltip .tooltip-row span:first-child {
  color: var(--text-secondary);
}

.chart-tooltip .tooltip-row span:last-child {
  font-family: "SF Mono", "Consolas", monospace;
  font-weight: 600;
}

.chart-tooltip .tooltip-row.cloud span:last-child {
  color: var(--text-muted);
}

.chart-tooltip .tooltip-row.wind span:last-child {
  color: var(--accent-cyan);
}

.chart-tooltip .tooltip-row.aviation span:last-child {
  color: var(--aviation-color);
}

.chart-tooltip .tooltip-row.forecast span:last-child {
  color: var(--forecast-color);
}

.chart-tooltip .tooltip-row.weathergov span:last-child {
  color: var(--weathergov-color);
}

/* Chart Legend */
.chart-legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 12px 0 0;
  flex-wrap: wrap;
}

.chart-legend.dark {
  background: transparent;
  padding: 16px 0 0;
  margin-top: 0;
  border-top: 1px solid var(--border-primary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: color 0.2s ease;
  cursor: default;
}

.legend-item:hover {
  color: var(--text-primary);
}

.chart-legend.dark .legend-item {
  color: var(--text-secondary);
}

.legend-line {
  width: 24px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
}

.legend-line.aviation {
  background: var(--aviation-color);
}

.legend-line.forecast {
  background: var(--forecast-color);
  background: repeating-linear-gradient(
    90deg,
    var(--forecast-color) 0px,
    var(--forecast-color) 6px,
    transparent 6px,
    transparent 10px
  );
}

.legend-line.weathergov {
  background: var(--weathergov-color);
}

/* Status Bar */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  flex-wrap: wrap;
  gap: 12px;
}

.status-bar span {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: "SF Mono", "Consolas", monospace;
}

.refresh-button {
  background: var(--accent-blue);
  color: #fff;
}

.refresh-button:hover {
  background: #4493e6;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(88, 166, 255, 0.2);
}

/* Alert Overlay */
.alert-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13, 17, 23, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(8px);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.alert-content {
  background: var(--bg-secondary);
  border: 2px solid var(--accent-red);
  padding: 40px;
  border-radius: 16px;
  max-width: 420px;
  text-align: center;
  animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 60px rgba(248, 81, 73, 0.3);
}

@keyframes slideUp {
  from {
    transform: translateY(40px) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.alert-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.alert-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-red);
  margin-bottom: 16px;
}

.alert-message {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

.alert-message strong {
  color: var(--text-primary);
  font-weight: 600;
  font-family: "SF Mono", "Consolas", monospace;
}

.alert-source {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.dismiss-button {
  background: var(--accent-red);
  color: #fff;
  padding: 12px 32px;
  font-size: 1rem;
}

.dismiss-button:hover {
  background: #da3633;
}

/* Loading & Error States */
.loading-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg-primary);
  z-index: 1000;
}

.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-primary);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 1s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-container p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.error-container h2 {
  color: var(--accent-red);
  font-size: 1.2rem;
}

.error-container p {
  color: var(--text-secondary);
}

.error-container button {
  background: var(--accent-blue);
  color: #fff;
  padding: 10px 24px;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.error-container button:hover {
  background: #4493e6;
}

/* Page Transitions */
.fade-in {
  animation: fadeIn 0.5s ease-out forwards;
}

/* Responsive */
@media (max-width: 900px) {
  .stats-panel {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .app {
    padding: 12px;
  }

  .header {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

  .current-temp {
    flex-direction: column;
  }

  .temp-meta {
    align-items: center;
  }

  .temp-display {
    font-size: 2.5rem;
  }

  h1 {
    font-size: 1.1rem;
  }

  .stat-value {
    font-size: 1rem;
  }

  .tv-chart-wrapper .tv-chart {
    height: 350px;
  }

  .chart-legend {
    gap: 16px;
  }

  .threshold-form {
    flex-direction: column;
    align-items: stretch;
  }

  .threshold-input {
    width: 100%;
  }

  .threshold-display {
    margin-left: 0;
    margin-top: 8px;
    text-align: center;
  }

  .status-bar {
    flex-direction: column;
    text-align: center;
  }
}
