/* =============================================
   Weather Dashboard
   Aesthetic: Neo Corporate
   ============================================= */

:root {
  --font-display: 'Manrope', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;

  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-light: #dbeafe;
  --color-success: #059669;
  --color-warning: #d97706;
  --color-error: #dc2626;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.06);
  --shadow-lg: 0 12px 32px rgba(15,23,42,0.08);

  --duration-fast: 120ms;
  --duration-normal: 200ms;
  --duration-slow: 350ms;
}

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

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--color-accent);
  color: #fff;
}

/* ── Layout ── */
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-lg) var(--space-2xl);
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-logo {
  width: 36px;
  height: 36px;
  background: var(--color-accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-logo svg { color: #fff; }

.header-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ── Search ── */
.search-wrapper {
  position: relative;
}

.search-input {
  font-family: var(--font-body);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  width: 260px;
  transition: border-color var(--duration-normal) ease, box-shadow var(--duration-normal) ease;
  outline: none;
}

.search-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

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

.search-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: none;
  max-height: 260px;
  overflow-y: auto;
}

.search-results.active { display: block; }

.search-result-item {
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transition: background var(--duration-fast) ease;
}

.search-result-item:hover { background: var(--color-bg); }
.search-result-item .city-name { font-weight: 600; }
.search-result-item .country { color: var(--color-text-muted); font-size: 0.8rem; }

/* ── Unit Toggle ── */
.unit-toggle {
  display: flex;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
}

.unit-btn {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.unit-btn.active {
  background: var(--color-accent);
  color: #fff;
}

/* ── Refresh ── */
.refresh-btn {
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-normal) ease;
}

.refresh-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.refresh-btn.spinning svg {
  animation: spin 0.8s linear infinite;
}

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

/* ── Hero ── */
.hero {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-xl);
  align-items: center;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute;
  top: -60%;
  right: -10%;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, var(--color-accent-light) 0%, transparent 70%);
  opacity: 0.5;
  pointer-events: none;
}

.hero-location {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: var(--space-xs);
}

.hero-location svg { flex-shrink: 0; }

.hero-temp {
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  margin-bottom: var(--space-xs);
}

.hero-condition {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.hero-meta {
  display: flex;
  gap: var(--space-lg);
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.hero-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.hero-right {
  position: relative;
  z-index: 1;
  text-align: center;
}

.weather-icon-large {
  font-size: 6rem;
  line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.08));
}

.hero-updated {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: var(--space-sm);
}

/* ── Stat Cards ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat-card {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-normal) ease, box-shadow var(--duration-normal) ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-xs);
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-label svg { opacity: 0.6; }

.stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ── Chart Cards ── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.chart-card {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.chart-card-header {
  padding: var(--space-lg) var(--space-lg) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chart-card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.chart-card-body {
  position: relative;
  height: 320px;
  padding: var(--space-sm) var(--space-md) var(--space-md);
}

.chart-card-body canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ── Sun Card ── */
.sun-card {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-lg);
}

.sun-card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--space-md);
}

.sun-track {
  position: relative;
  height: 80px;
  margin: 0 var(--space-lg);
}

.sun-arc {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
}

.sun-arc-path {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 2;
  stroke-dasharray: 6 4;
}

.sun-arc-active {
  fill: none;
  stroke: var(--color-warning);
  stroke-width: 2.5;
  stroke-linecap: round;
}

.sun-dot {
  fill: var(--color-warning);
  filter: drop-shadow(0 0 6px rgba(217,119,6,0.4));
}

.sun-times {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-sm);
}

.sun-time { text-align: center; }

.sun-time-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.sun-time-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
}

/* ── 7-Day Forecast ── */
.forecast-section-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-md);
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.forecast-day {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-normal) ease, box-shadow var(--duration-normal) ease;
}

.forecast-day:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.forecast-day-name {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.forecast-day-icon {
  font-size: 2rem;
  margin-bottom: var(--space-sm);
}

.forecast-day-temps {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
}

.temp-high { color: var(--color-text); }
.temp-low { color: var(--color-text-muted); }

.forecast-day-precip {
  font-size: 0.7rem;
  color: var(--color-accent);
  margin-top: var(--space-xs);
  font-weight: 500;
}

/* ── Loading / Error ── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: var(--space-md);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.loading-text {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.error-banner {
  background: #fef2f2;
  border: 1.5px solid #fecaca;
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-lg);
  color: var(--color-error);
  font-size: 0.875rem;
  display: none;
  align-items: center;
  gap: var(--space-sm);
}

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

/* ── Footer ── */
.footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  padding: var(--space-md) 0;
  border-top: 1px solid var(--color-border);
}

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

.footer a:hover { text-decoration: underline; }

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

@media (max-width: 700px) {
  .app { padding: var(--space-md); }
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
    padding: var(--space-lg);
  }
  .hero-meta { justify-content: center; flex-wrap: wrap; }
  .hero-temp { font-size: 3.5rem; }
  .hero-location { justify-content: center; }
  .hero-right { display: none; }
  .search-input { width: 180px; }
  .forecast-grid { grid-template-columns: repeat(3, 1fr); }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .header { gap: var(--space-sm); }
}

@media (max-width: 480px) {
  .forecast-grid { grid-template-columns: repeat(2, 1fr); }
  .header-title { font-size: 1rem; }
  .search-input { width: 140px; font-size: 0.8rem; }
}