:root {
  --bg-gradient: radial-gradient(circle at 20% 20%, #1e293b 0%, #0f172a 100%);
  --card-bg: rgba(30, 41, 59, 0.72);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-hover: rgba(51, 65, 85, 0.65);
  --accent: #38bdf8;
  --accent-warm: #fbbf24;
  --accent-rose: #fb7185;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --badge-bg: rgba(56, 189, 248, 0.15);
}

/* Light Theme */
[data-theme="light"] {
  --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-border: rgba(0, 0, 0, 0.1);
  --card-hover: rgba(255, 255, 255, 1);
  --text-main: #0f172a;
  --text-muted: #475569;
  --badge-bg: rgba(56, 189, 248, 0.25);
}

/* Dark/OLED Theme */
[data-theme="dark"] {
  --bg-gradient: #000000;
  --card-bg: #111111;
  --card-border: #333333;
  --card-hover: #1a1a1a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

body {
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  padding: 2rem 1rem;
  display: flex;
  justify-content: center;
  transition: background 0.3s ease, color 0.3s ease;
}

.container {
  width: 100%;
  max-width: 980px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.location-selector {
  display: flex;
  gap: 0.5rem;
  background: rgba(15, 23, 42, 0.55);
  padding: 0.35rem;
  border-radius: 9999px;
  border: 1px solid var(--card-border);
}
[data-theme="light"] .location-selector {
  background: rgba(255,255,255,0.5);
}

.loc-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}

.loc-btn.active {
  background: var(--accent);
  color: #0f172a;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
}

.location-sub {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 0.35rem;
}

.btn-refresh {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 0.55rem 1.1rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.2s ease;
}
[data-theme="light"] .btn-refresh {
  background: rgba(0, 0, 0, 0.05);
}

.btn-refresh:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
}
[data-theme="light"] .btn-refresh:hover {
  background: rgba(0, 0, 0, 0.1);
}

/* Cards */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--card-border);
  border-radius: 1.25rem;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: background 0.3s, border-color 0.3s;
}
[data-theme="light"] .card {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

/* Current Weather Hero */
.current-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.hero-main {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.weather-icon-large {
  font-size: 4rem;
  line-height: 1;
}

.temp-big {
  font-size: 4.5rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--text-main);
}

.temp-feels {
  color: var(--text-muted);
  font-size: 1rem;
  margin-top: 0.45rem;
}

.weather-desc {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 0.25rem;
}
[data-theme="light"] .weather-desc { color: #0284c7; }

.badge {
  display: inline-block;
  background: var(--badge-bg);
  color: var(--accent);
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
[data-theme="light"] .badge { color: #0369a1; }

/* Astro Block */
.astro-block {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 1rem 1.25rem;
  border-radius: 1rem;
}
[data-theme="light"] .astro-block {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.05);
}

.astro-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.astro-icon {
  font-size: 1.5rem;
}

.astro-text {
  display: flex;
  flex-direction: column;
}

.astro-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.astro-val {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 0.75rem;
}

.metric-box {
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 1rem;
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
[data-theme="light"] .metric-box {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.05);
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-val {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.wind-arrow {
  display: inline-block;
  transition: transform 0.3s ease;
  font-size: 1.1rem;
}

/* Titles */
.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.2rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Chart Containers */
.chart-wrapper {
  position: relative;
  height: 290px;
  width: 100%;
}

.chart-wrapper-square {
  position: relative;
  height: 250px;
  width: 100%;
}

/* Advanced Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
}
.chart-card {
  display: flex;
  flex-direction: column;
}

/* ISS Stats Grid */
.iss-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}
.iss-stats .metric-box { padding: 0.85rem; }

/* Daily Grid */
.daily-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.85rem;
}

.daily-card {
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 1rem;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: transform 0.2s ease, background 0.2s ease;
}
[data-theme="light"] .daily-card {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.05);
}

.daily-card:hover {
  background: var(--card-hover);
  transform: translateY(-2px);
}

.daily-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 0.5rem;
}
[data-theme="light"] .daily-header { border-bottom-color: rgba(0,0,0,0.1); }

.daily-day {
  font-weight: 600;
  font-size: 0.95rem;
}

.daily-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.daily-temp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0.2rem 0;
}

.daily-max {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent-rose);
}

.daily-min {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--accent);
}
[data-theme="light"] .daily-min { color: #0284c7; }

.daily-weather-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sun-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}
[data-theme="light"] .sun-times { border-top-color: rgba(0,0,0,0.1); }

/* Loader */
#status-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  transition: opacity 0.3s ease;
}
[data-theme="light"] #status-overlay {
  background: rgba(255, 255, 255, 0.82);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
[data-theme="light"] .spinner {
  border-color: rgba(0,0,0,0.1);
  border-top-color: #0284c7;
}

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

/* Modal Settings */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(5px);
  display: flex; justify-content: center; align-items: center; z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal.show { opacity: 1; pointer-events: all; }
.modal-content {
  background: var(--card-bg); border: 1px solid var(--card-border);
  padding: 1.5rem; border-radius: 1rem; width: 95%; max-width: 500px;
  max-height: 90vh; overflow-y: auto; color: var(--text-main);
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
.modal-content h2 { margin-bottom: 1rem; font-size: 1.4rem; }
.modal-content h3 { font-size: 1rem; margin: 1.5rem 0 0.75rem 0; color: var(--accent); }
[data-theme="light"] .modal-content h3 { color: #0284c7; }

.theme-select {
  width: 100%; padding: 0.75rem; border-radius: 0.5rem; 
  border: 1px solid var(--card-border); background: rgba(0,0,0,0.2); 
  color: var(--text-main); outline: none;
}
[data-theme="light"] .theme-select { background: rgba(0,0,0,0.05); }

.loc-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.loc-list-item { 
  display: flex; justify-content: space-between; align-items: center; 
  padding: 0.75rem; background: rgba(0,0,0,0.2); border-radius: 0.5rem; 
}
[data-theme="light"] .loc-list-item { background: rgba(0,0,0,0.05); }
.btn-remove { 
  background: #ef4444; color: white; border: none; padding: 0.3rem 0.6rem; 
  border-radius: 0.25rem; cursor: pointer; font-weight: bold; 
}
.btn-remove:hover { background: #dc2626; }

.search-box { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.search-box input { 
  flex: 1; padding: 0.75rem; border-radius: 0.5rem; border: 1px solid var(--card-border); 
  background: rgba(0,0,0,0.2); color: var(--text-main); 
}
[data-theme="light"] .search-box input { background: rgba(0,0,0,0.05); }
.search-box button { 
  background: var(--accent); color: #0f172a; border: none; padding: 0.75rem 1rem; 
  border-radius: 0.5rem; cursor: pointer; font-weight: bold; 
}
[data-theme="light"] .search-box button { color: #fff; background: #0284c7; }

.search-results { list-style: none; margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.25rem;}
.search-result-item { 
  display: flex; justify-content: space-between; padding: 0.75rem; cursor: pointer; 
  background: rgba(255,255,255,0.05); border-radius: 0.5rem; align-items: center;
}
[data-theme="light"] .search-result-item { background: rgba(0,0,0,0.03); }
.search-result-item:hover { background: rgba(255,255,255,0.1); }
[data-theme="light"] .search-result-item:hover { background: rgba(0,0,0,0.08); }

.btn-close-modal { 
  width: 100%; padding: 0.85rem; background: rgba(255,255,255,0.1); 
  color: var(--text-main); border: 1px solid var(--card-border); 
  border-radius: 0.5rem; margin-top: 2rem; cursor: pointer; font-weight: bold; 
}
.btn-close-modal:hover { background: rgba(255,255,255,0.2); }
[data-theme="light"] .btn-close-modal { background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.1); }
[data-theme="light"] .btn-close-modal:hover { background: rgba(0,0,0,0.1); }


/* Error Toast */
#error-toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(150px);
  background: rgba(239, 68, 68, 0.95); color: white;
  padding: 1rem 1.5rem; border-radius: 0.75rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000; display: flex; align-items: center;
  gap: 0.75rem; font-weight: 500; backdrop-filter: blur(8px);
}
#error-toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 850px) {
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .current-hero { flex-direction: column; align-items: flex-start; }
  .temp-big { font-size: 3.5rem; }
  .chart-wrapper { height: 250px; }
  .chart-wrapper-square { height: 220px; }
  .daily-grid { grid-template-columns: 1fr 1fr; }
}
