/* ---- Reset & base ---- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #eef5fb;
  --color-card: #ffffff;
  --color-text: #1c2b3a;
  --color-muted: #5b7083;
  --color-accent: #2f80ed;
  --color-accent-dark: #1c5fbd;
  --color-border: #d7e6f5;
  --max-width: 480px;
}

:root[data-theme="dark"] {
  --color-bg: #0f1720;
  --color-card: #182430;
  --color-text: #eef5fb;
  --color-muted: #93a4b8;
  --color-accent: #5b9bf5;
  --color-accent-dark: #7fb0ff;
  --color-border: #2a3b4d;
}

:root[data-theme="dark"] body {
  background: linear-gradient(180deg, #0b1219 0%, #0f1720 240px, #0f1720 100%);
}

:root[data-theme="dark"] .status-message.error {
  color: #ff8a80;
  border-color: #5c2b26;
  background: #2a1614;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--color-text);
  background: linear-gradient(180deg, #dcebfa 0%, #eef5fb 240px, #eef5fb 100%);
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  justify-content: center;
  padding: 32px 16px 64px;
}

.app {
  width: 100%;
  max-width: var(--max-width);
}

/* ---- Header ---- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.unit-toggle,
.theme-toggle {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
  color: var(--color-accent);
  cursor: pointer;
}

.theme-toggle {
  padding: 6px 10px;
  font-size: 0.95rem;
}

.unit-toggle:hover,
.theme-toggle:hover {
  background: var(--color-border);
}

/* ---- Search ---- */
.search-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-form input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  font-size: 1rem;
  background: var(--color-card);
  color: var(--color-text);
}

.search-form input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

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

.btn-primary:hover {
  background: var(--color-accent-dark);
}

.btn-secondary {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  padding: 12px 14px;
}

.btn-secondary:hover {
  background: var(--color-border);
}

/* ---- Suggestions dropdown ---- */
.suggestions {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
}

.suggestions button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.95rem;
  color: var(--color-text);
  cursor: pointer;
}

.suggestions button:last-child {
  border-bottom: none;
}

.suggestions button:hover {
  background: var(--color-bg);
}

/* ---- Recent chips ---- */
.recent-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.recent-chips:empty {
  margin-bottom: 0;
}

.chip {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  color: var(--color-muted);
  cursor: pointer;
}

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

/* ---- Status message ---- */
.status-message {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  color: var(--color-muted);
  margin-bottom: 20px;
}

.status-message.error {
  color: #b3261e;
  border-color: #f2c7c3;
  background: #fdf1f0;
}

/* ---- Current weather ---- */
.current-weather {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 20px;
  text-align: center;
}

.current-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.current-icon {
  font-size: 3rem;
  line-height: 1;
}

.current-temp {
  font-size: 3.5rem;
  font-weight: 700;
}

.current-place {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 8px;
}

.current-condition {
  color: var(--color-muted);
}

.current-feels {
  color: var(--color-muted);
  font-size: 0.9rem;
  margin-top: 2px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.stat-value {
  font-weight: 700;
}

/* ---- Hourly forecast ---- */
.hourly-forecast h2 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: var(--color-muted);
}

.hourly-forecast {
  margin-bottom: 20px;
}

.hourly-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.hourly-hour {
  flex: 0 0 auto;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 10px 14px;
  text-align: center;
  min-width: 64px;
}

.hourly-hour .hour-time {
  font-size: 0.75rem;
  color: var(--color-muted);
  font-weight: 600;
}

.hourly-hour .hour-icon {
  font-size: 1.4rem;
  margin: 6px 0;
}

.hourly-hour .hour-temp {
  font-weight: 700;
  font-size: 0.9rem;
}

/* ---- Forecast ---- */
.forecast h2 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: var(--color-muted);
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.forecast-day {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 12px 6px;
  text-align: center;
}

.forecast-day .day-name {
  font-size: 0.75rem;
  color: var(--color-muted);
  font-weight: 600;
}

.forecast-day .day-icon {
  font-size: 1.5rem;
  margin: 6px 0;
}

.forecast-day .day-high {
  font-weight: 700;
  font-size: 0.9rem;
}

.forecast-day .day-low {
  color: var(--color-muted);
  font-size: 0.8rem;
}

/* ---- Weather icon animations ---- */
.current-icon,
.day-icon,
.hour-icon {
  display: inline-block;
}

@keyframes wx-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes wx-drift {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(4px); }
}

@keyframes wx-fall {
  0% { transform: translateY(-3px); opacity: 0.85; }
  50% { transform: translateY(2px); opacity: 1; }
  100% { transform: translateY(-3px); opacity: 0.85; }
}

@keyframes wx-drop {
  0% { transform: translateY(-2px); }
  60% { transform: translateY(3px); }
  100% { transform: translateY(-2px); }
}

@keyframes wx-flicker {
  0%, 100% { opacity: 1; }
  45% { opacity: 1; }
  50% { opacity: 0.4; }
  55% { opacity: 1; }
  90% { opacity: 1; }
  93% { opacity: 0.5; }
  96% { opacity: 1; }
}

@keyframes wx-pulse {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}

.wx-sun { animation: wx-spin 12s linear infinite; }
.wx-cloud { animation: wx-drift 4s ease-in-out infinite; }
.wx-rain { animation: wx-drop 1s ease-in-out infinite; }
.wx-snow { animation: wx-fall 2.4s ease-in-out infinite; }
.wx-storm { animation: wx-flicker 2.5s ease-in-out infinite; }
.wx-fog { animation: wx-pulse 3s ease-in-out infinite; }

@media (max-width: 420px) {
  .forecast-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }
  .forecast-day {
    padding: 8px 2px;
  }
  .current-temp {
    font-size: 2.75rem;
  }
}
