:root {
  /* Material Design 3 Light Color Palette (Indigo/Violet base) */
  /* Generated via M3 Color Tool */
  --md-sys-color-primary: #4f5b92;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #dfe1ff;
  --md-sys-color-on-primary-container: #001453;
  --md-sys-color-secondary: #5b5d72;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #e0e1f9;
  --md-sys-color-on-secondary-container: #181a2c;
  --md-sys-color-tertiary: #77536d;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #ffd7f1;
  --md-sys-color-on-tertiary-container: #2d1228;
  --md-sys-color-surface: #fefbff;
  --md-sys-color-on-surface: #1b1b1f;
  --md-sys-color-surface-variant: #e2e1ec;
  --md-sys-color-on-surface-variant: #45464f;
  --md-sys-color-outline: #767680;
  --md-sys-color-outline-variant: #c6c6d0;
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f7f3f9;
  --md-sys-color-surface-container: #f1edf4;
  --md-sys-color-surface-container-high: #ece7ee;
  --md-sys-color-surface-container-highest: #e6e1e9;
  --md-sys-color-background: #fefbff;
  --md-sys-color-on-background: #1b1b1f;

  /* Elevations */
  --md-sys-elevation-1: 0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.3);
  --md-sys-elevation-2: 0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.3);
  --md-sys-elevation-3: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px 0px rgba(0, 0, 0, 0.3);

  /* Shape */
  --md-sys-shape-corner-extra-small: 4px;
  --md-sys-shape-corner-small: 8px;
  --md-sys-shape-corner-medium: 12px;
  --md-sys-shape-corner-large: 16px;
  --md-sys-shape-corner-extra-large: 28px;
  --md-sys-shape-corner-full: 1000px;

  /* Typography Scale */
  --md-sys-typescale-display-large: 700 48px/56px 'Outfit', sans-serif;
  --md-sys-typescale-headline-large: 600 28px/36px 'Inter', sans-serif;
  --md-sys-typescale-headline-medium: 600 28px/36px 'Inter', sans-serif;
  --md-sys-typescale-title-large: 500 22px/28px 'Inter', sans-serif;
  --md-sys-typescale-title-medium: 500 16px/24px 'Inter', sans-serif;
  --md-sys-typescale-body-large: 400 16px/24px 'Inter', sans-serif;
  --md-sys-typescale-body-medium: 400 14px/20px 'Inter', sans-serif;
  --md-sys-typescale-label-large: 500 14px/20px 'Inter', sans-serif;
  --md-sys-typescale-label-medium: 500 12px/16px 'Inter', sans-serif;
}

body.dark-theme {
  --md-sys-color-primary: #bcc2ff;
  --md-sys-color-on-primary: #1f2d61;
  --md-sys-color-primary-container: #374379;
  --md-sys-color-on-primary-container: #dfe1ff;
  --md-sys-color-surface: #1b1b1f;
  --md-sys-color-on-surface: #e4e1e6;
  --md-sys-color-surface-variant: #45464f;
  --md-sys-color-on-surface-variant: #c6c6d0;
  --md-sys-color-outline: #90909a;
  --md-sys-color-surface-container-lowest: #0f0f11;
  --md-sys-color-surface-container-low: #1b1b1f;
  --md-sys-color-surface-container: #202023;
  --md-sys-color-surface-container-high: #2a2a2d;
  --md-sys-color-surface-container-highest: #353538;
  --md-sys-color-background: #1b1b1f;
  --md-sys-color-on-background: #e4e1e6;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  transition: background-color 0.3s, color 0.3s;
  min-height: 100vh;
}

/* Icons */
.material-symbols-rounded {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Layout */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 340px;
  grid-template-areas: 
    "search search"
    "main aside"
    "footer footer";
  gap: 24px;
}

.search-container { grid-area: search; }
main { grid-area: main; min-width: 0; }
aside { grid-area: aside; }
.footer { grid-area: footer; }

@media (max-width: 1000px) {
  .app-container {
    grid-template-columns: 1fr;
    grid-template-areas: 
      "search"
      "main"
      "aside"
      "footer";
  }
}

/* Header - Mobile Responsive */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background-color: transparent;
  z-index: 100;
  gap: 16px;
  flex-wrap: wrap; /* Allow wrapping on very small screens */
}

@media (max-width: 600px) {
  header {
    justify-content: center;
    padding: 16px 8px;
  }
  .title { display: none; } /* Hide title on very small screens to save space */
}

.top-app-bar .title {
  font: var(--md-sys-typescale-title-large);
  color: var(--md-sys-color-on-surface);
}

/* Search Bar & Suggestions */
.search-container {
  grid-area: search;
  position: relative;
  z-index: 500;
  display: flex;
  justify-content: center;
}

.search-bar-wrapper {
  width: 100%;
  max-width: 720px;
  position: relative;
}

.search-bar {
  height: 56px;
  width: 100%;
  background-color: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-extra-large);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  transition: all 0.3s cubic-bezier(0.2, 0, 0, 1);
  border: 1px solid transparent;
}

.search-bar:focus-within {
  background-color: var(--md-sys-color-surface-container-highest);
  box-shadow: var(--md-sys-elevation-2);
  border-color: var(--md-sys-color-outline-variant);
}

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background-color: var(--md-sys-color-surface-container-highest);
  border-radius: var(--md-sys-shape-corner-extra-large);
  box-shadow: var(--md-sys-elevation-3);
  max-height: 300px;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  padding: 8px;
  z-index: 1000;
  animation: menuOpen 0.3s cubic-bezier(0.2, 0, 0, 1);
}

.search-results.show { display: flex; }

.search-result-item {
  padding: 12px 16px;
  border-radius: var(--md-sys-shape-corner-large);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font: var(--md-sys-typescale-body-large);
  transition: background-color 0.2s;
}

.search-result-item:hover {
  background-color: var(--md-sys-color-surface-variant);
}

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

.search-bar input {
  background: transparent;
  border: none;
  outline: none;
  flex: 1;
  font: var(--md-sys-typescale-body-large);
  color: var(--md-sys-color-on-surface);
}

/* M3 Custom Menu (Expressive) */
.m3-menu-wrapper {
  position: relative;
}

.m3-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 220px;
  background-color: var(--md-sys-color-surface-container-highest);
  border-radius: var(--md-sys-shape-corner-extra-large);
  box-shadow: var(--md-sys-elevation-3);
  padding: 8px;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transform-origin: top right;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.4) translateY(-20px);
  transition: 
    opacity 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), 
    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    visibility 0.4s;
  max-height: 500px;
  overflow-y: auto;
}

.m3-menu.show {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: scale(1) translateY(0);
}

.m3-menu-item {
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-radius: var(--md-sys-shape-corner-large);
  font: var(--md-sys-typescale-label-large);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  transition: all 0.2s;
  gap: 12px;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.m3-menu-item:hover {
  background-color: var(--md-sys-color-surface-container-highest);
  transform: translateX(4px);
}

.m3-menu-item.selected {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.m3-menu-item .material-symbols-rounded {
  font-size: 20px;
}

/* Main Card (Elevated) */
.current-weather-card {
  background-color: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-extra-large);
  padding: 32px;
  box-shadow: var(--md-sys-elevation-1);
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: fadeInUp 0.8s cubic-bezier(0.2, 0, 0, 1);
  transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.3s;
}

.current-weather-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--md-sys-elevation-2);
}

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

.current-weather-card .location {
  font: var(--md-sys-typescale-headline-small);
  color: var(--md-sys-color-on-surface);
}

.current-weather-card .temp-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.current-weather-card .temp {
  font: var(--md-sys-typescale-display-large);
  color: var(--md-sys-color-primary);
}

.current-weather-card .condition-icon {
  font-size: 80px !important;
  color: var(--md-sys-color-secondary);
}

/* Forecast Section (Filled Cards) */
.forecast-section {
  background-color: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-extra-large);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeInUp 0.8s cubic-bezier(0.2, 0, 0, 1) 0.1s both;
}

.section-header {
  font: var(--md-sys-typescale-title-medium);
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 8px;
}

.hourly-scroll {
  display: flex;
  overflow-x: auto;
  gap: 12px;
  padding: 8px 0 16px 0;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--md-sys-color-primary) var(--md-sys-color-surface-container-highest);
}

/* Custom Scrollbar for M3 */
.hourly-scroll::-webkit-scrollbar {
  height: 8px;
}

.hourly-scroll::-webkit-scrollbar-track {
  background: var(--md-sys-color-surface-container-highest);
  border-radius: var(--md-sys-shape-corner-full);
}

.hourly-scroll::-webkit-scrollbar-thumb {
  background: var(--md-sys-color-primary);
  border-radius: var(--md-sys-shape-corner-full);
  border: 2px solid var(--md-sys-color-surface-container-highest);
}

.hourly-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--md-sys-color-primary-container);
}

.hourly-item {
  min-width: 80px;
  background-color: var(--md-sys-color-surface-container-highest);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.hourly-item:hover {
  transform: scale(1.05);
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

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

.weekly-item {
  height: 56px;
  background-color: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-medium);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

/* Footer & Controls */
.footer {
  grid-column: 1 / -1;
  padding: 64px 16px 32px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-links a {
  color: var(--md-sys-color-primary);
  text-decoration: none;
  font: var(--md-sys-typescale-label-large);
}

.footer-credits {
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
}

/* IconButton */
.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: background-color 0.2s;
}

.icon-button:hover {
  background-color: var(--md-sys-color-surface-variant);
}

/* Map Section */
.map-container {
  height: 400px;
  border-radius: var(--md-sys-shape-corner-extra-large);
  overflow: hidden;
  border: 1px solid var(--md-sys-color-outline-variant);
}

#map { height: 100%; width: 100%; }

/* Expressive Loading Animation */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--md-sys-color-background);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
}

.weather-cycle-icon {
  font-size: 80px !important;
  color: var(--md-sys-color-primary);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

@keyframes weatherPulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.1); opacity: 1; }
}

.loading-overlay p {
  animation: fadePulse 2s infinite;
}

@keyframes fadePulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
