/* ===============================
   CSS VARIABLES (THEME)
================================ */
:root {
  --primary: #0b69ff;
  --primary-soft: #4facfe;
  --bg-light: #f9fafb;
  --bg-dark: #020617;
  --text-dark: #0f172a;
  --text-muted: #6b7280;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --shadow-lg: 0 12px 30px rgba(2,6,23,0.18);
}

/* ===============================
   RESET & BASE
================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-soft), #00f2fe);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 28px;
  color: var(--text-dark);
}

/* ===============================
   APP LAYOUT
================================ */
.app {
  width: 100%;
  max-width: 560px;
}

/* ===============================
   HEADER
================================ */
.app-header {
  text-align: center;
  margin-bottom: 16px;
  color: #fff;
}

.app-header h1 {
  font-size: 26px;
  font-weight: 600;
}

.app-header p {
  font-size: 14px;
  opacity: 0.9;
}

/* ===============================
   CARD
================================ */
.card {
  background: linear-gradient(180deg, #fff, var(--bg-light));
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(15,23,42,0.04);
}

/* ===============================
   SEARCH
================================ */
.search {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.search input {
  flex: 1;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(15,23,42,0.06);
  font-size: 15px;
  transition: box-shadow .18s ease, transform .08s ease;
}

.search input:focus {
  outline: none;
  box-shadow: 0 6px 18px rgba(79,172,254,0.18);
  transform: translateY(-1px);
}

.search button {
  background: linear-gradient(180deg, var(--primary-soft), #3bb0f8);
  border: none;
  padding: 0 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .14s ease, box-shadow .14s ease;
}

.search button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(59,176,248,0.16);
}

.search .search-icon {
  width: 20px;
  height: 20px;
}

/* ===============================
   STATUS & LOADER
================================ */
.status-message {
  min-height: 18px;
  font-size: 14px;
  margin-bottom: 8px;
}

.loader {
  display: none;
  margin: 12px auto;
  width: 36px;
  height: 36px;
  border: 4px solid rgba(2,6,23,0.06);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.weather-summary {
  margin-top: 10px;
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
  max-width: 85%;
  margin-left: auto;
  margin-right: auto;
}
.outfit-suggestion {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.outfit-icon {
  margin-right: 6px;
}


.weather-score {
  margin-top: 10px;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 600;
}

.score-value {
  font-size: 24px;
  color: var(--primary);
}

.score-label {
  font-size: 12px;
  color: var(--text-muted);
}

.aqi-box {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.aqi-value {
  font-weight: 600;
  margin-right: 4px;
}
/* ===============================
   WEATHER RESULT
================================ */
.weather {
  display: none;
  text-align: center;
  margin-top: 18px;
}

.weather-icon {
  width: 96px;
  height: 96px;
  margin-bottom: -6px;
  animation: floatIcon 5s ease-in-out infinite;
}

.temp {
  font-size: 56px;
  font-weight: 800;
  line-height: 1;
  color: var(--primary);
  margin-top: 6px;
  animation: tempPop 0.35s ease;
}

.city {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 600;
}

.description {
  font-size: 14px;
  margin-top: 4px;
  text-transform: capitalize;
  color: var(--text-muted);
}

/* ===============================
   DETAILS (HUMIDITY / WIND)
================================ */
.col {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  max-width: 340px;
  margin: 10px auto;
  background: rgba(15,23,42,0.02);
}

.col p {
  font-weight: 600;
}

.col span {
  font-size: 12px;
  color: var(--text-muted);
}

/* 🌅 Sunrise–Sunset Card */
.sun-card {
  background: var(--card-bg, rgba(255,255,255,0.08));
  border-radius: 18px;
  padding: 18px;
  margin-top: 20px;
  backdrop-filter: blur(14px);
}

.sun-card-header h4 {
  margin-bottom: 12px;
  font-size: 15px;
  opacity: 0.85;
}

.sun-times-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sun-time-block {
  display: flex;
  flex-direction: column;
}

.sun-time-block .label {
  font-size: 12px;
  opacity: 0.6;
}

.sun-time-block strong {
  font-size: 18px;
}

.sun-progress-track {
  position: relative;
  height: 6px;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  overflow: hidden;
}

.sun-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #facc15, #f97316);
  transition: width 0.6s ease;
}

.sun-indicator {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: #facc15;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.8);
  left: 0%;
  transition: left 0.6s ease;
}
.moon-indicator {
  position: absolute;
  top: -6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e0e7ff;
  box-shadow: 0 0 10px rgba(180, 200, 255, 0.8);
  display: none;
}
.moon-info {
  margin-left: 4px;
  cursor: help;
  font-size: 13px;
  opacity: 0.8;
}

.sun-status {
  margin-top: 10px;
  font-size: 13px;
  opacity: 0.7;
  text-align: center;
}

.moon-times-row {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
}

.moon-time-block {
  text-align: center;
  font-size: 14px;
}

.moon-phase {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
}

.moon-emoji {
  font-size: 22px;
  transition: transform 0.6s ease;
}
@keyframes moonFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* 🌙 Moon Phase Animation */
#moon-phase-icon {
  display: inline-block;
  font-size: 1.4rem;
  margin-right: 6px;
  animation: moonPulse 3.5s ease-in-out infinite;
}

@keyframes moonPulse {
  0% {
    transform: scale(1);
    filter: drop-shadow(0 0 4px rgba(255,255,255,0.3));
  }
  50% {
    transform: scale(1.15);
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.6));
  }
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 4px rgba(255,255,255,0.3));
  }
}

/* 📱 Mobile polish for Sun & Moon card */
@media (max-width: 480px) {
  .sun-card {
    padding: 14px;
  }

  .sun-times-row,
  .moon-times-row {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .sun-progress-track {
    margin: 12px 0;
  }

  .moon-phase {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
  }

  #moon-phase-icon {
    font-size: 1.3rem;
  }
}


/* ===============================
   HOURLY TEMPERATURE CHART
================================ */
#hourly-temp-chart {
  width: 100%;
  height: 140px;          /* 🔴 REQUIRED */
  max-height: 140px;
  display: block;
  margin-top: 8px;
}

.hourly canvas{
  margin-bottom: 6px;
}

/* ===============================
   FORECAST
================================ */
.hourly-list,
.daily-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 6px;
}

.hourly-item,
.daily-item {
  min-width: 80px;
  background: #fff;
  border-radius: var(--radius-md);
  padding: 8px;
  text-align: center;
  transition: transform .12s ease, box-shadow .12s ease;
}

.hourly-item:hover,
.daily-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 26px rgba(2,6,23,0.08);
}

/* ===============================
   FOOTER
================================ */
.app-footer {
  text-align: center;
  margin-top: 14px;
  font-size: 12px;
  color: #fff;
  opacity: 0.85;
}

/* ===============================
   NIGHT MODE
================================ */
body.night {
  color: #e5e7eb;
  background: linear-gradient(135deg, #0f172a, var(--bg-dark));
}
body.night .col {
  background: rgba(255, 255, 255, 0.04);
}
body.night .description,
body.night .weather-summary {
  color: #cbd5f5;
}

body.night .card,
body.night .hourly-item,
body.night .daily-item {
  background: var(--bg-dark);
  border: 1px solid #1e293b;
  color: #e5e7eb;
}
.card {
  animation: cardFadeUp 0.6s ease both;
}

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

@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}


@keyframes tempPop {
  0% { transform: scale(0.94); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

.hourly-item,
.daily-item {
  animation: fadeSlide 0.4s ease both;
}

.hourly-item { animation-delay: calc(var(--i) * 0.05s); }
.daily-item  { animation-delay: calc(var(--i) * 0.06s); }

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

.search button:active {
  transform: scale(0.96);
}

body.night .weather-icon {
  animation-duration: 5s;
  opacity: 0.95;
}

/* ===============================
   WEATHER BACKGROUND EFFECTS
================================ */

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}

/* ☀️ Clear */
body.weather-clear::before {
  opacity: 1;
  background: linear-gradient(
    120deg,
    rgba(255,255,255,0.18),
    rgba(255,255,255,0.02),
    rgba(255,255,255,0.18)
  );
  animation: moveLight 12s ease-in-out infinite;
}

/* ☁️ Clouds */
body.weather-clouds::before {
  opacity: 1;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.08),
    rgba(255,255,255,0.02),
    rgba(255,255,255,0.08)
  );
  animation: drift 18s linear infinite;
}

/* 🌧 Rain */
body.weather-rain::before {
  opacity: 1;
  background: repeating-linear-gradient(
    -45deg,
    rgba(255,255,255,0.12),
    rgba(255,255,255,0.12) 2px,
    transparent 2px,
    transparent 6px
  );
  animation: rainMove 0.6s linear infinite;
}

/* ❄️ Snow */
body.weather-snow::before {
  opacity: 1;
  background: radial-gradient(
    circle,
    rgba(255,255,255,0.15) 2px,
    transparent 3px
  );
  background-size: 40px 40px;
  animation: snowFall 10s linear infinite;
}

/* ===============================
   ANIMATIONS
================================ */

@keyframes moveLight {
  0% { transform: translateX(-10%); }
  50% { transform: translateX(10%); }
  100% { transform: translateX(-10%); }
}

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(60px); }
}

@keyframes rainMove {
  from { background-position: 0 0; }
  to { background-position: 40px 40px; }
}

@keyframes snowFall {
  from { background-position: 0 0; }
  to { background-position: 0 80px; }
}

/* Calm night mode */
body.night::before {
  opacity: 0.4;
  animation-duration: 2x;
}
/* 🌫 Fog / Mist */
body.weather-mist::before {
  opacity: 1;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.15), transparent 40%),
    radial-gradient(circle at 80% 60%, rgba(255,255,255,0.12), transparent 45%);
  animation: fogMove 18s ease-in-out infinite;
}

@keyframes fogMove {
  0% { transform: translateX(-6%); }
  50% { transform: translateX(6%); }
  100% { transform: translateX(-6%); }
}

/* 🌬 Wind overlay */
body.weather-wind::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background: repeating-linear-gradient(
    90deg,
    rgba(255,255,255,0.12),
    rgba(255,255,255,0.12) 1px,
    transparent 1px,
    transparent 14px
  );
  opacity: 0.25;
  animation: windMove 1.2s linear infinite;
  transform-origin: center;
  transform: rotate(var(--wind-angle, 0deg));

}

@keyframes windMove {
  from { background-position: 0 0; }
  to { background-position: 120px 0; }
}

/* 🌈 Rainbow */
body.weather-rainbow::before {
  opacity: 1;
  background: radial-gradient(
    circle at bottom,
    rgba(255,0,0,0.25),
    rgba(255,165,0,0.25),
    rgba(255,255,0,0.25),
    rgba(0,255,0,0.25),
    rgba(0,127,255,0.25),
    rgba(75,0,130,0.25),
    rgba(148,0,211,0.25),
    transparent 65%
  );
  animation: rainbowFade 6s ease-in-out forwards;
}

@keyframes rainbowFade {
  0% { opacity: 0; }
  20% { opacity: 0.7; }
  80% { opacity: 0.7; }
  100% { opacity: 0; }
}

/* ⚡ Thunder flash */
body.weather-thunder::after {
  content: "";
  position: fixed;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
  animation: thunderFlash 6s infinite;
}

@keyframes thunderFlash {
  0%, 92%, 100% { opacity: 0; }
  93% { opacity: 0.6; }
  94% { opacity: 0; }
  96% { opacity: 0.4; }
  97% { opacity: 0; }
}

/* ✨ Night stars */
body.night.weather-clear::before {
  opacity: 1;
  background:
    radial-gradient(1px 1px at 20% 30%, white, transparent),
    radial-gradient(1px 1px at 70% 40%, white, transparent),
    radial-gradient(1px 1px at 40% 80%, white, transparent),
    radial-gradient(1px 1px at 85% 70%, white, transparent);
  animation: starTwinkle 6s ease-in-out infinite;
}

@keyframes starTwinkle {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* 🧠 Performance fallback */
body.low-end *,
body.low-end *::before,
body.low-end *::after {
  animation: none !important;
  transition: none !important;
}

/* 🌬 Wind Direction Icon */
.wind-arrow {
  display: inline-block;
  margin-right: 6px;
  font-size: 18px;
  transition: transform 0.4s ease;
}

/* Speed-based pulse */
.wind-arrow.fast {
  animation: windPulseFast 0.6s infinite alternate;
}

.wind-arrow.medium {
  animation: windPulseMedium 1.2s infinite alternate;
}

@keyframes windPulseFast {
  from { transform: scale(1) rotate(var(--wind-rotation)); }
  to   { transform: scale(1.25) rotate(var(--wind-rotation)); }
}

@keyframes windPulseMedium {
  from { transform: scale(1) rotate(var(--wind-rotation)); }
  to   { transform: scale(1.12) rotate(var(--wind-rotation)); }
}


/* ===============================
   HOURLY SECTION SPACING FIX
================================ */

.hourly {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  position: relative;
}

#hourly-temp-chart {
  width: 100% !important;
  height: 140px !important;
  max-height: 140px !important;
  display: block !important;
}

/* ===============================
   INTELLIGENCE (COLLAPSIBLE)
================================ */
.intelligence {
  margin-top: 18px;
  text-align: left;
}

.intel-toggle {
  width: 100%;
  background: transparent;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 6px 0;
}

.intel-toggle .chevron {
  transition: transform 0.3s ease;
}

.intel-content {
  display: none;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.intelligence.open .intel-content {
  display: block;
}

.intelligence.open .chevron {
  transform: rotate(180deg);
}

body.night .intel-content {
  color: #cbd5f5;
}

.intelligence {
  margin-top: 18px;
  border-top: 1px solid rgba(15,23,42,0.08);
  padding-top: 12px;
}

.intel-greeting {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 8px;
}

body.night .intel-greeting {
  color: #e5e7eb;
}

.intel-toggle {
  width: 100%;
  background: none;
  border: none;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 8px 0;
}

.chevron {
  transition: transform 0.3s ease;
}

.intel-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease;
  opacity: 0;
}

.intelligence.open .intel-content {
  max-height: 300px;
  opacity: 1;
}

.intelligence.open .chevron {
  transform: rotate(180deg);
}
/* ===============================
   VIP HOURLY CHART POLISH
================================ */

.chart-container {
  position: relative;
  width: 100%;
  height: 140px;
  margin-top: 10px;
}

/* Day chart glow */
body.day #hourly-temp-chart {
  filter: drop-shadow(0 6px 14px rgba(79,172,254,0.25));
}

/* Night chart glow */
body.night #hourly-temp-chart {
  filter: drop-shadow(0 6px 16px rgba(140,160,255,0.35));
}

/* ===============================
   VIP INSIGHTS ZONE
================================ */

.zone-insights {
  margin-top: 18px;
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.insight-card {
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.2s ease;
}

.insight-card:hover {
  transform: translateY(-2px);
}

.insight-card .label {
  font-size: 12px;
  color: var(--text-muted);
}

.insight-card .value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
}

/* 🌫 AQI emphasis */
.aqi-card {
  grid-column: span 2;
  background: linear-gradient(
    135deg,
    rgba(79,172,254,0.25),
    rgba(255,255,255,0.85)
  );
}

body.night .insight-card {
  background: rgba(15,23,42,0.6);
}

body.night .insight-card .value {
  color: #e5e7eb;
}

/* ===============================
   🌙 NIGHT MODE — VIP INSIGHTS FIX
================================ */

body.night .zone-insights {
  margin-top: 18px;
}

body.night .insight-card {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.06);
}

body.night .insight-card .label {
  color: #9ca3af;
}

body.night .insight-card .value {
  color: #f1f5f9;
}

/* 🌫 AQI emphasis in night mode */
body.night .aqi-card {
  background: linear-gradient(
    135deg,
    rgba(79,172,254,0.28),
    rgba(15,23,42,0.9)
  );
  border: 1px solid rgba(79,172,254,0.35);
  box-shadow: 0 0 18px rgba(79,172,254,0.15);
}

/* Gentle hover lift in night */
body.night .insight-card:hover {
  transform: translateY(-2px);
}

/* ===============================
   ⚙️ PERSONAL SPACE (VIP PANEL)
================================ */

.personal-bar {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 20;
}

.personal-bar button {
  background: rgba(255,255,255,0.75);
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  cursor: pointer;
  font-size: 16px;
}

body.night .personal-bar button {
  background: rgba(15,23,42,0.85);
  color: #e5e7eb;
}

/* Slide-in panel */
.personal-panel {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  height: 100vh;
  background: #fff;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
  transition: right 0.35s ease;
  z-index: 100;
  padding: 16px;
}

body.night .personal-panel {
  background: linear-gradient(180deg, #020617, #020617);
  color: #e5e7eb;
}
body.night .close-personal {
  color: #e5e7eb;
}

/* Open state */
.personal-panel.open {
  right: 0;
}
.personal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.close-personal {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #111;
}
.close-personal:hover {
  opacity: 0.7;
}
.personal-bar {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 20;
}

/* Section styling */
.personal-panel h4 {
  font-size: 18px;
  margin-bottom: 16px;
}

.personal-section .label {
  font-size: 13px;
  opacity: 0.7;
  margin-bottom: 8px;
}
#open-personal {
  background: rgba(255,255,255,0.9);
  border: none;
  border-radius: 50%;
  padding: 8px 10px;
  font-size: 16px;
  cursor: pointer;
}

.add-fav {
  margin-top: 6px;
  font-size: 13px;
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
}

.favorites {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.favorite-item {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(15,23,42,0.05);
  cursor: pointer;
}

body.night .favorite-item {
  background: rgba(255,255,255,0.06);
}
body.night .personal-panel {
  background: #020617;
  color: #e5e7eb;
}
/* Panel overlay */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 90;
}

.panel-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.panel-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
body.night .panel-overlay {
  background: rgba(0,0,0,0.4);
}

.unit-toggle {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  background: linear-gradient(135deg, #4facfe, #0b69ff);
  color: white;
  transition: transform 0.2s ease;
}

.unit-toggle:hover {
  transform: translateY(-2px);
}

body.night .unit-toggle {
  background: linear-gradient(135deg, #64748b, #334155);
}
