/* ============================================================
   styles.css — Clima & Noticias · Ciudades Globales
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background-color: #f0f4f8;
  color: #222;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }

/* ---------- Header ---------- */
header {
  background: #1a73e8;
  color: #fff;
  text-align: center;
  padding: 2rem 1rem 1.5rem;
}

header h1 {
  font-size: 1.8rem;
  margin-bottom: 0.3rem;
}

.subtitle {
  font-size: 1rem;
  opacity: 0.85;
}

/* ---------- Main ---------- */
main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ---------- City Selector ---------- */
.city-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.city-btn {
  background: #fff;
  color: #1a73e8;
  border: 2px solid #1a73e8;
  border-radius: 24px;
  padding: 0.5rem 1.1rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.city-btn:hover,
.city-btn.active {
  background: #1a73e8;
  color: #fff;
}

/* ---------- Error ---------- */
.error-msg {
  background: #fce8e6;
  color: #c5221f;
  border: 1px solid #c5221f;
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  text-align: center;
}

/* ---------- Loading ---------- */
.loading {
  text-align: center;
  padding: 2rem;
  color: #555;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #d0e4ff;
  border-top-color: #1a73e8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 0.8rem;
}

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

/* ---------- City Photo ---------- */
.city-photo-section {
  position: relative;
  margin-bottom: 1.5rem;
  border-radius: 12px;
  overflow: hidden;
  max-height: 260px;
}

.city-photo {
  width: 100%;
  height: 260px;
  object-fit: cover;
  display: block;
}

.photo-credit {
  position: absolute;
  bottom: 6px;
  right: 10px;
  font-size: 0.75rem;
  color: #fff;
  background: rgba(0,0,0,0.45);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ---------- Sections ---------- */
.weather-section,
.forecast-section,
.news-section {
  background: #fff;
  border-radius: 12px;
  padding: 1.2rem 1.4rem;
  margin-bottom: 1.4rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

h2 {
  font-size: 1.1rem;
  margin-bottom: 0.9rem;
  color: #1a73e8;
}

/* ---------- Current Weather ---------- */
.weather-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.weather-card img {
  width: 64px;
  height: 64px;
}

.weather-info .temp {
  font-size: 2rem;
  font-weight: 700;
}

.weather-info .condition {
  font-size: 1rem;
  color: #555;
}

.weather-info .feels {
  font-size: 0.85rem;
  color: #777;
}

/* ---------- Forecast ---------- */
.forecast-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
}

.forecast-day {
  background: #f0f4f8;
  border-radius: 10px;
  padding: 0.8rem;
  text-align: center;
}

.forecast-day .day-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}

.forecast-day img {
  width: 48px;
  height: 48px;
}

.forecast-day .temps {
  font-size: 0.9rem;
  margin-top: 0.2rem;
}

.forecast-day .temps .max { color: #c62828; font-weight: 600; }
.forecast-day .temps .min { color: #1565c0; }

.forecast-day .cond {
  font-size: 0.78rem;
  color: #555;
  margin-top: 0.2rem;
}

/* ---------- News ---------- */
.news-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.news-item {
  border-left: 4px solid #1a73e8;
  padding-left: 0.9rem;
}

.news-item a {
  font-weight: 600;
  font-size: 0.95rem;
  color: #1a73e8;
  text-decoration: none;
}

.news-item a:hover { text-decoration: underline; }

.news-item .news-desc {
  font-size: 0.85rem;
  color: #444;
  margin-top: 0.2rem;
}

.news-item .news-source {
  font-size: 0.78rem;
  color: #888;
  margin-top: 0.1rem;
}

/* ---------- No-news message ---------- */
.no-news {
  color: #777;
  font-size: 0.9rem;
}

/* ---------- Footer ---------- */
footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.8rem;
  color: #888;
  background: #fff;
  border-top: 1px solid #e0e0e0;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  header h1 { font-size: 1.3rem; }
  .forecast-grid { grid-template-columns: 1fr; }
  .city-btn { font-size: 0.8rem; padding: 0.4rem 0.8rem; }
}
