/* =========================
   RESET & GLOBAL
========================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scroll-behavior: smooth;
}

/* =========================
   BASE
========================= */
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(to right, #cde4f7, #f2f9ff);
  color: #222;
  min-height: 100vh;
  padding-top: 80px;
  line-height: 1.6;
  transition: background 0.4s ease, color 0.4s ease;
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================
   DARK MODE
========================= */
body.dark {
  background: linear-gradient(to right, #1e1e2f, #2e2e3f);
  color: #eee;
}

/* =========================
   THEME TOGGLE
========================= */
#theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  font-size: 1.5rem;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
  z-index: 999;
  transition: transform 0.3s ease;
}

#theme-toggle:hover {
  transform: rotate(20deg);
}

/* =========================
   HEADER
========================= */
.header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem 1rem 1rem;
}

.logo {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #0c3c78;
}

body.dark .logo {
  color: #5ea0ff;
}

/* =========================
   SEARCH
========================= */
.search-section {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

.search-section input {
  width: 260px;
  padding: 0.7rem 1.2rem;
  font-size: 1rem;
  border-radius: 999px;
  border: none;
  outline: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.search-section input:focus {
  box-shadow: 0 0 0 3px rgba(0, 119, 204, 0.3);
}

.search-section button {
  position: relative;
  overflow: hidden;
  padding: 0.7rem 1.4rem;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: 999px;
  background: #0077cc;
  color: white;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 119, 204, 0.35);
  transition: background 0.3s ease, transform 0.2s ease;
}

.search-section button:hover {
  background: #005fa3;
  transform: translateY(-2px);
}

.search-section button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.35), transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.search-section button:hover::after {
  opacity: 1;
}

body.dark .search-section button {
  background: #5596ff;
}

body.dark .search-section button:hover {
  background: #3b7aff;
}

/* =========================
   WEATHER CARD
========================= */
.weather-card {
  position: relative;
  max-width: 600px;
  margin: 2rem auto;
  padding: 2rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  transition: transform 0.3s ease;
  animation: cardPop 0.5s ease-out;
}

@keyframes cardPop {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.weather-card:hover {
  transform: translateY(-6px);
}

.weather-card::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(120deg, transparent, rgba(0,119,204,0.25), transparent);
  pointer-events: none;
}

body.dark .weather-card {
  background: rgba(40, 40, 60, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark .weather-card::after {
  background: linear-gradient(120deg, transparent, rgba(94,160,255,0.25), transparent);
}

/* =========================
   WEATHER INFO
========================= */
.weather-info div:first-child {
  font-size: 2.4rem;
  font-weight: 700;
}

.weather-info div:nth-child(2) {
  font-size: 1.3rem;
  opacity: 0.8;
}

.weather-info div {
  margin-bottom: 0.8rem;
  font-size: 1.1rem;
}

/* =========================
   FORECAST
========================= */
.forecast-section {
  max-width: 900px;
  margin: 0 auto 2rem;
  padding: 1rem;
}

.forecast-section h2 {
  text-align: center;
  margin-bottom: 1.2rem;
  font-size: 1.6rem;
  font-weight: 600;
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.forecast-day {
  padding: 1.2rem;
  text-align: center;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  opacity: 0;
  animation: fadeUp 0.5s ease forwards;
}

.forecast-day:nth-child(1) { animation-delay: 0.05s; }
.forecast-day:nth-child(2) { animation-delay: 0.1s; }
.forecast-day:nth-child(3) { animation-delay: 0.15s; }
.forecast-day:nth-child(4) { animation-delay: 0.2s; }
.forecast-day:nth-child(5) { animation-delay: 0.25s; }

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.forecast-day:hover {
  transform: translateY(-6px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.15);
}

body.dark .forecast-day {
  background: rgba(30, 30, 50, 0.9);
}

/* =========================
   RECENT SEARCHES
========================= */
.recent-searches {
  max-width: 600px;
  margin: 0 auto 3rem;
  text-align: center;
}

#recent-searches {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.8rem;
}

.recent-btn {
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.06);
  transition: background 0.3s ease, transform 0.2s ease;
}

.recent-btn:hover {
  background: rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

body.dark .recent-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

body.dark .recent-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Clear recent */
#clear-recent-btn {
  margin-top: 1rem;
  padding: 0.5rem 1.2rem;
  font-size: 0.85rem;
  border: none;
  border-radius: 999px;
  background: #f44336;
  color: white;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease;
}

#clear-recent-btn:hover {
  background: #c62828;
  transform: translateY(-2px);
}

/* =========================
   FOOTER
========================= */
.footer {
  text-align: center;
  padding: 1.2rem 0;
  font-size: 0.85rem;
  opacity: 0.7;
}

/* =========================
   ACCESSIBILITY
========================= */
button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(0, 119, 204, 0.6);
  outline-offset: 2px;
}

body.dark button:focus-visible,
body.dark input:focus-visible {
  outline-color: rgba(94, 160, 255, 0.7);
}

/* =========================
   MOBILE
========================= */
@media (max-width: 600px) {
  .logo {
    font-size: 2.1rem;
  }

  .search-section input {
    width: 100%;
  }

  .weather-card {
    margin: 1.2rem;
    padding: 1.5rem;
  }

  .forecast-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* =========================
   REDUCED MOTION
========================= */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
