/* ==========================================================================
   MY ENGINEERING TOOLBOX - WEATHER DOWNLOAD PORTAL
   Design System & Tokenized CSS (AI Studio Ready)
   ========================================================================== */

:root {
  /* Core Color Palette Tokens */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: rgba(37, 99, 235, 0.1);
  --color-accent-green: #10b981;
  --color-accent-green-bg: rgba(16, 185, 129, 0.15);
  --color-accent-amber: #f59e0b;
  --color-accent-amber-bg: rgba(245, 158, 11, 0.15);
  --color-accent-purple: #8b5cf6;
  --color-accent-purple-bg: rgba(139, 92, 246, 0.15);

  /* Surfaces & Backgrounds (Dark Mode Base with Sleek Engineering Slate) */
  --bg-app: #0f172a;
  --bg-surface-1: #1e293b;
  --bg-surface-2: #334155;
  --bg-surface-hover: #2d3d54;
  --bg-surface-glass: rgba(30, 41, 59, 0.85);

  /* Borders & Dividers */
  --border-subtle: #334155;
  --border-focus: #3b82f6;
  --border-active: #60a5fa;

  /* Typography Colors */
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  /* Typography Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Radii & Shadows */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.25);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Navigation */
.app-header {
  background: var(--bg-surface-glass);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.85rem 1.5rem;
}

.nav-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent-purple));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: white;
  box-shadow: var(--shadow-glow);
}

.brand-text h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-text span {
  font-size: 0.75rem;
  color: var(--color-accent-amber);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-link:hover {
  color: var(--text-primary);
}

/* Main Container */
.main-content {
  max-width: 1050px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  flex: 1;
  width: 100%;
}

/* Hero Section */
.hero-section {
  text-align: center;
  margin-bottom: 2.5rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  color: var(--color-accent-green);
  font-weight: 600;
  margin-bottom: 1rem;
}

.hero-title {
  font-size: 2.3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #ffffff 40%, var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 680px;
  margin: 0 auto;
}

/* Active Station Card */
.station-card {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  margin-bottom: 2.5rem;
  position: relative;
  overflow: hidden;
}

.station-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent-green), var(--color-accent-purple));
}

.station-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.station-title-group h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.station-meta-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.meta-tag {
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}

.btn-select-station {
  background: var(--color-primary);
  color: white;
  border: none;
  padding: 0.7rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s, transform 0.1s;
}

.btn-select-station:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
}

/* Climate Quick Stats */
.climate-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.85rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.stat-item {
  background: var(--bg-app);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* Section Header */
.section-header {
  margin-bottom: 1.25rem;
}

.section-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.section-header p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Single Selector List Layout
   ========================================================================== */
.format-selection-panel {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  margin-bottom: 2.5rem;
}

.format-list-container {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.75rem;
}

.format-list-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.format-list-item:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-focus);
}

.format-list-item.active {
  background: rgba(37, 99, 235, 0.12);
  border-color: var(--color-primary);
}

.format-radio-wrapper {
  display: flex;
  align-items: center;
}

.format-radio-wrapper input[type="radio"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  outline: none;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}

.format-radio-wrapper input[type="radio"]:checked {
  border-color: var(--color-primary);
  background: var(--color-primary);
  box-shadow: inset 0 0 0 3px var(--bg-surface-1);
}

.format-info-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.format-name-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.format-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-primary);
}

.format-code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-surface-2);
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
}

.badge-free {
  background: var(--color-accent-green-bg);
  color: var(--color-accent-green);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.05em;
}

.badge-premium {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: white;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.format-short-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Premium Highlight */
.format-list-item.premium-list-item {
  border: 1px solid rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.04);
}

.format-list-item.premium-list-item.active {
  background: rgba(245, 158, 11, 0.12);
  border-color: var(--color-accent-amber);
}

.format-list-item.premium-list-item .format-radio-wrapper input[type="radio"]:checked {
  border-color: var(--color-accent-amber);
  background: var(--color-accent-amber);
}

/* Tooltip / Info Popover */
.format-action-col {
  display: flex;
  align-items: center;
}

.tooltip-wrapper {
  position: relative;
  display: inline-block;
}

.btn-info-popover {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.btn-info-popover:hover {
  color: var(--color-primary);
}

.tooltip-content {
  position: absolute;
  right: 0;
  bottom: 125%;
  width: 290px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-focus);
  color: var(--text-primary);
  font-size: 0.8rem;
  line-height: 1.45;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: all 0.2s ease;
  z-index: 200;
}

.tooltip-content::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 12px;
  border-width: 6px;
  border-style: solid;
  border-color: var(--bg-surface-2) transparent transparent transparent;
}

.tooltip-wrapper:hover .tooltip-content,
.tooltip-wrapper:focus-within .tooltip-content {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Download Action Bar */
.download-action-bar {
  display: flex;
  justify-content: center;
  padding-top: 0.5rem;
}

.btn-execute-download {
  width: 100%;
  max-width: 480px;
  background: var(--color-primary);
  color: white;
  border: none;
  padding: 0.95rem 1.75rem;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  box-shadow: var(--shadow-glow);
  transition: all 0.2s;
}

.btn-execute-download:hover {
  background: var(--color-primary-hover);
  transform: translateY(-2px);
}

.btn-execute-download.premium-action {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0f172a;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
}

.btn-execute-download.premium-action:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #000;
}

/* Provenance Section */
.provenance-panel {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-top: 2rem;
}

.provenance-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.provenance-text h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.provenance-text p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  max-width: 720px;
}

.btn-view-guide {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  text-decoration: none;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  transition: all 0.2s;
}

.btn-view-guide:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-focus);
}

/* Modal Overlay & Container */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-container {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 1100px;
  height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  position: relative;
}

.modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface-1);
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
  transition: color 0.2s;
}

.btn-close-modal:hover {
  color: var(--text-primary);
}

/* Modal Search Bar */
.modal-search-bar {
  padding: 0.75rem 1.5rem;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  gap: 1rem;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
}

.search-input-wrapper input {
  width: 100%;
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  padding: 0.65rem 1rem 0.65rem 2.5rem;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input-wrapper input:focus {
  border-color: var(--border-focus);
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.station-count-badge {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Modal Map Body */
.modal-body {
  flex: 1;
  position: relative;
  display: flex;
}

#map-container {
  width: 100%;
  height: 100%;
  background: #0f172a;
}

/* Custom Marker Cluster Styling */
.custom-cluster-icon {
  background: rgba(37, 99, 235, 0.85);
  border: 2px solid #ffffff;
  border-radius: 50%;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(37, 99, 235, 0.6);
}

/* Custom Leaflet Popup */
.leaflet-popup-content-wrapper {
  background: var(--bg-surface-1) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg);
  padding: 0 !important;
}

.leaflet-popup-content {
  margin: 0.85rem 1rem !important;
  font-family: var(--font-sans);
}

.popup-station-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: #fff;
}

.popup-station-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.btn-popup-select {
  background: var(--color-primary);
  color: white;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

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

/* Footer */
.app-footer {
  background: var(--bg-surface-1);
  border-top: 1px solid var(--border-subtle);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--text-primary);
}
