/* 
  Weather Dashboard - Modern SaaS UI 
  CSS Variables & Theming 
*/
:root {
  /* Typography */
  --font-family: 'Inter', sans-serif;

  /* Transition Speeds */
  --trans-fast: 0.2s ease;
  --trans-normal: 0.3s ease;

  /* Glassmorphism Defaults */
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}

/* Light Mode Variables */
.light-mode {
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.05);

  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --error-color: #ef4444;
}

/* Dark Mode Variables */
.dark-mode {
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);

  --accent-color: #60a5fa;
  --accent-hover: #3b82f6;
  --error-color: #f87171;
}

/* Base Styles & Resets */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: background-color var(--trans-normal), color var(--trans-normal);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Dynamic Backgrounds */
body.bg-default {
  background: linear-gradient(135deg, #f1f5f9, #cbd5e1);
}

body.dark-mode.bg-default {
  background: linear-gradient(135deg, #0f172a, #1e293b);
}

body.bg-clear {
  background: linear-gradient(135deg, #93c5fd, #3b82f6);
}

body.dark-mode.bg-clear {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
}

body.bg-clouds {
  background: linear-gradient(135deg, #94a3b8, #64748b);
}

body.dark-mode.bg-clouds {
  background: linear-gradient(135deg, #1e293b, #334155);
}

body.bg-rain {
  background: linear-gradient(135deg, #818cf8, #4f46e5);
}

body.dark-mode.bg-rain {
  background: linear-gradient(135deg, #312e81, #4338ca);
}

body.bg-snow {
  background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
}

body.dark-mode.bg-snow {
  background: linear-gradient(135deg, #334155, #475569);
}

body.bg-thunder {
  background: linear-gradient(135deg, #475569, #1e293b);
}

body.dark-mode.bg-thunder {
  background: linear-gradient(135deg, #0f172a, #020617);
}

/* Layout Grid */
.app-container {
  display: flex;
  min-height: 100vh;
  padding: 1rem;
  gap: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
}

/* Glassmorphism Utility */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 20px;
  transition: all var(--trans-normal);
}

.glass-panel:not(.flat):hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.15);
}

/* Sidebar Styles */
.sidebar {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 2rem;
  gap: 2rem;
  height: calc(100vh - 2rem);
  position: sticky;
  top: 1rem;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--accent-color);
}

.brand h2 {
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--text-primary);
}

.brand .highlight {
  color: var(--accent-color);
}

/* Search Box */
.search-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
  transition: border-color var(--trans-fast);
}

.search-box:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.search-icon {
  color: var(--text-secondary);
  margin-right: 0.75rem;
}

#city-input {
  border: none;
  background: transparent;
  outline: none;
  color: var(--text-primary);
  font-size: 1rem;
  width: 100%;
  font-family: inherit;
}

#city-input::placeholder {
  color: var(--text-secondary);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1.1rem;
  transition: color var(--trans-fast);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  color: var(--accent-color);
}

.hidden-submit {
  display: none;
}

.error-msg {
  color: var(--error-color);
  font-size: 0.85rem;
  padding-left: 0.5rem;
}

/* History List */
.sidebar-nav {
  flex-grow: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
}

/* Scrollbar styling */
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--text-secondary);
  border-radius: 4px;
}

.sidebar-nav h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-weight: 600;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-item {
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--trans-fast);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.dark-mode .history-item {
  background: rgba(255, 255, 255, 0.05);
}

.history-item:hover {
  background: var(--bg-secondary);
  color: var(--accent-color);
  transform: translateX(4px);
}

/* Settings Section */
.settings-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--glass-border);
}

.toggle-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Toggle Switch CSS */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--text-secondary);
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}

input:checked+.slider {
  background-color: var(--accent-color);
}

input:checked+.slider:before {
  transform: translateX(20px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Main Dashboard Area */
.dashboard-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  position: relative;
  min-width: 0;
  /* Prevents overflow in flex child */
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
}

.greeting {
  font-size: 2rem;
  font-weight: 700;
}

.date {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-top: 0.25rem;
}

.dashboard-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Current Weather Focus */
.current-weather {
  padding: 2.5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 1100px) {
  .current-weather {
    grid-template-columns: 1fr 1fr;
    align-items: center;
  }
}

.weather-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.location-info h2 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.location-info p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 500;
}

.weather-icon-large {
  width: 120px;
  height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
  animation: float 4s ease-in-out infinite;
}

.weather-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.temperature {
  font-size: 5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -2px;
}

.condition {
  font-size: 1.5rem;
  text-transform: capitalize;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  font-weight: 500;
}

.weather-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  grid-column: 1 / -1;
  margin-top: 1rem;
  border-top: 1px solid var(--glass-border);
  padding-top: 2rem;
}

.detail-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
}

.detail-card i {
  font-size: 1.5rem;
  color: var(--accent-color);
  width: 32px;
  text-align: center;
}

.detail-card .label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.detail-card .value {
  font-size: 1.1rem;
  font-weight: 600;
}

/* Forecast Section */
.forecast-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  padding: 1rem 1.5rem;
  margin: 0;
}

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

.forecast-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.75rem;
  cursor: pointer;
}

.forecast-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--accent-color);
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
}

.dark-mode .forecast-card:hover {
  background: rgba(255, 255, 255, 0.08);
}

.forecast-card .date-day {
  font-weight: 600;
  font-size: 1.1rem;
}

.forecast-card .date-short {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

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

.forecast-card .temps {
  display: flex;
  gap: 0.75rem;
  font-weight: 600;
}

.forecast-card .temp-high {
  color: var(--text-primary);
}

.forecast-card .temp-low {
  color: var(--text-secondary);
}

/* Animations & Utilities */
@keyframes float {
  0% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-10px);
  }

  100% {
    transform: translateY(0px);
  }
}

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

.fade-in {
  animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hidden {
  display: none !important;
}

/* --- Dynamic Background Elements --- */
.animated-bg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

/* The Sun */
.sun {
  position: absolute;
  top: 10%;
  right: 15%;
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, #fcd34d 30%, transparent 70%);
  border-radius: 50%;
  box-shadow: 0 0 60px 30px rgba(251, 191, 36, 0.4);
  animation: pulse-sun 4s infinite alternate;
}

@keyframes pulse-sun {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }

  100% {
    transform: scale(1.1);
    opacity: 1;
  }
}

/* The Moon */
.moon {
  position: absolute;
  top: 10%;
  right: 20%;
  width: 100px;
  height: 100px;
  background: transparent;
  border-radius: 50%;
  box-shadow: -20px 20px 0 0 #e2e8f0;
  animation: float-slow 6s ease-in-out infinite alternate;
}

/* Clouds */
.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50px;
  animation: drift linear infinite;
}

.cloud::before,
.cloud::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
}

.cloud::before {
  width: 60px;
  height: 60px;
  top: -30px;
  left: 15px;
}

.cloud::after {
  width: 80px;
  height: 80px;
  top: -45px;
  right: 20px;
}

/* Dark mode clouds */
.dark-mode .cloud,
.dark-mode .cloud::before,
.dark-mode .cloud::after {
  background: rgba(255, 255, 255, 0.1);
}

@keyframes drift {
  from {
    transform: translateX(-200px);
  }

  to {
    transform: translateX(110vw);
  }
}

@keyframes float-slow {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(-15px);
  }
}

/* Raindrops */
.raindrop {
  position: absolute;
  width: 2px;
  height: 25px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.7));
  animation: rain linear infinite;
}

@keyframes rain {
  0% {
    transform: translateY(-100px);
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  90% {
    opacity: 1;
  }

  100% {
    transform: translateY(100vh);
    opacity: 0;
  }
}

/* Snowflakes */
.snowflake {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  filter: blur(1px);
  animation: snow linear infinite;
}

@keyframes snow {
  0% {
    transform: translateY(-10vh) translateX(0);
    opacity: 1;
  }

  100% {
    transform: translateY(100vh) translateX(20px);
    opacity: 0.3;
  }
}

/* Lightning */
.lightning {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0);
  animation: flash 5s infinite;
}

@keyframes flash {

  0%,
  95%,
  98% {
    background: rgba(255, 255, 255, 0);
  }

  96%,
  99% {
    background: rgba(255, 255, 255, 0.4);
  }
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  gap: 1rem;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--text-secondary);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Hourly Forecast Section */
.hourly-forecast {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hourly-graph-wrapper {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  padding: 1rem;
}

.chart-container {
  position: relative;
  height: 200px;
  width: 100%;
}

.hourly-details-container {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  padding: 0 10px;
  /* Aligns with chart points approximately */
}

.hourly-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

.hourly-item img {
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.hourly-time {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.hourly-wind {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.hourly-wind i {
  font-size: 0.7rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    top: 0;
  }

  .weather-details {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
}

@media (max-width: 600px) {
  .detail-card {
    padding: 0.75rem;
  }

  .forecast-grid {
    grid-template-columns: 1fr;
  }

  .forecast-card {
    flex-direction: row;
    justify-content: space-between;
    padding: 1rem 1.5rem;
  }
}