
/* ===============================
   VARIABLES DE DISEÑO
=============================== */
:root {
  --bg-dark: #0f172a;
  --bg-light: #f8fafc;

  --card-bg-dark: rgba(255, 255, 255, 0.08);
  --card-bg-light: rgba(255, 255, 255, 0.85);

  --text-main-dark: #e5e7eb;
  --text-soft-dark: #94a3b8;

  --text-main-light: #020617;
  --text-soft-light: #334155;

  --accent: #38bdf8;
  --danger: #f87171;

  --radius: 16px;
  --transition: 0.25s ease;
}

/* ===============================
   RESET
=============================== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

/* ===============================
   THEMES
=============================== */
body[data-theme="dark"] {
  background: linear-gradient(160deg, #020617, var(--bg-dark));
  color: var(--text-main-dark);
}

body[data-theme="light"] {
  background: linear-gradient(160deg, #e2e8f0, var(--bg-light));
  color: var(--text-main-light);
}

/* ===============================
   APP LAYOUT
=============================== */
.app {
  max-width: 420px;
  margin: auto;
  padding: 1rem;
}

/* ===============================
   TOPBAR
=============================== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar h1 {
  margin: 0;
  font-size: 1.5rem;
}

.topbar h1 span {
  color: var(--accent);
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
}

/* ===============================
   SEARCH
=============================== */
.search-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.search-card {
  display: flex;
  gap: 0.5rem;
}

.search-card input {
  flex: 1;
  padding: 0.75rem;
  border-radius: var(--radius);
  border: none;
  outline: none;
  font-size: 0.95rem;
}

.search-card button {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #020617;
  font-weight: 600;
  cursor: pointer;
}

.ghost-btn {
  background: transparent;
  border: 1px dashed var(--accent);
  color: inherit;
  padding: 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
}

/* ===============================
   LOADER
=============================== */
.loader {
  width: 36px;
  height: 36px;
  margin: 1.5rem auto;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

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

/* ===============================
   GLASS CARD
=============================== */
.glass-card {
  background: var(--card-bg-dark);
  backdrop-filter: blur(14px);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  animation: fadeUp 0.4s ease both;
}

body[data-theme="light"] .glass-card {
  background: var(--card-bg-light);
  color: var(--text-main-light);
}

/* ===============================
   CURRENT WEATHER
=============================== */
#currentWeather h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--accent);
}

.temp {
  font-size: 3rem;
  font-weight: 700;
  margin: 0.25rem 0;
}

.weather-desc {
  font-size: 0.95rem;
  opacity: 0.9;
}

.weather-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-soft-dark);
}

body[data-theme="light"] .weather-stats {
  color: var(--text-soft-light);
}

/* ===============================
   FORECAST 5 DAYS
=============================== */
#hourlyForecast h3 {
  margin-bottom: 1rem;
  font-size: 1rem;
  color: var(--accent);
}

.forecast-day {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  padding: 0.75rem 0;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.forecast-day:last-child {
  border-bottom: none;
}

.forecast-date {
  font-weight: 500;
}

.forecast-desc {
  font-size: 0.8rem;
  opacity: 0.9;
}

.forecast-temp {
  font-weight: 600;
}

/* ===============================
   ERROR
=============================== */
.error {
  color: var(--danger);
  text-align: center;
  margin-top: 1rem;
  font-size: 0.9rem;
}

/* ===============================
   HELPERS
=============================== */
.hidden {
  display: none;
}

/* ===============================
   WEATHER BACKGROUND
=============================== */
#weather-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  filter: brightness(0.55);
}

#weather-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(2, 6, 23, 0.7),
    rgba(2, 6, 23, 0.9)
  );
}

/* ===============================
   FIX DEFINITIVO MODO CLARO
=============================== */
body[data-theme="light"] h2,
body[data-theme="light"] h3 {
  color: #0284c7;
}

body[data-theme="light"] .temp {
  color: #020617;
}

body[data-theme="light"] .weather-desc,
body[data-theme="light"] .forecast-desc {
  color: #334155;
}

body[data-theme="light"] .forecast-day {
  color: #020617;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

body[data-theme="light"] .forecast-temp {
  color: #020617;
}

body[data-theme="light"] input {
  background: #ffffff;
  color: var(--text-main-light);
}

body[data-theme="light"] input::placeholder {
  color: var(--text-soft-light);
}

/* ===============================
   RESPONSIVE
=============================== */
@media (min-width: 768px) {
  .app {
    max-width: 520px;
  }

  .weather-stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ===============================
   ANIMATIONS
=============================== */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
