/* Reset and base styles */
* {
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--md-sys-color-background, #f0f0f0);
  color: var(--md-sys-color-on-background, #333);
  overflow-x: hidden;
  overflow-y: auto; /* Allow scrolling */
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

/* Hide scrollbar for Chrome, Safari and Opera */
body::-webkit-scrollbar {
  display: none;
}

/* Also hide scrollbar on html element */
html {
  overflow-y: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  /* Fix white background on overscroll (iOS Safari bounce effect) */
  background-color: var(--md-sys-color-background, #f0f0f0);
}

html::-webkit-scrollbar {
  display: none;
}

/* Historical Section Styles */
.historical-section {
  margin-top: 0;
  padding: 24px 16px;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

.metric-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  justify-content: center;
}

.metric-btn {
  padding: 8px 16px;
  border: 2px solid transparent;
  background: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
  border-radius: 16px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.metric-btn:hover {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.metric-btn.active {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: var(--md-sys-color-primary);
}


/* Material Design Table Styles */
.md-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--md-sys-color-surface);
  border-radius: 12px;
  overflow: hidden;
}

.md-table thead {
  background: var(--md-sys-color-primary-container);
}

.md-table th {
  padding: 16px;
  text-align: left;
  font-weight: 600;
  color: var(--md-sys-color-on-primary-container);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.5;
}

.md-table tbody tr {
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.md-table tbody tr:hover {
  background-color: var(--md-sys-color-surface-variant);
}

.md-table tbody tr:last-child {
  border-bottom: none;
}

.md-table td {
  padding: 16px;
  color: var(--md-sys-color-on-surface);
  font-size: 0.875rem;
  line-height: 1.5;
  vertical-align: middle;
}

.md-table td:first-child {
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
}


@media (max-width: 768px) {
  .historical-section {
    padding: 16px;
    margin: 24px 8px;
  }

  .section-header {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

  .period-selector {
    width: 100%;
    justify-content: center;
  }
}

/* Pull to Refresh Styles - Smaller & More Refined */
.pull-to-refresh {
  position: fixed;
  top: -60px;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--md-sys-color-primary) 0%, var(--md-sys-color-primary-container) 100%);
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.15);
  opacity: 0.4;
  border-radius: 0 0 12px 12px;
}

.pull-to-refresh-content {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: white;
  padding: 0 16px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
  flex-shrink: 0;
}

.refresh-text {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  opacity: 0.95;
}

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

.pull-to-refresh.refreshing .spinner {
  display: block;
}

.pull-to-refresh.refreshing .refresh-text {
  display: inline;
}

.pull-to-refresh.pulled {
  transform: translateY(60px);
}

/* Prevent overscroll bounce on iOS */
body.refreshing {
  overflow: hidden;
}



/* =================================================================
   DARK MODE STYLES
   ================================================================= */
@media (prefers-color-scheme: dark) {
  html {
    background-color: #121212;
  }

  body {
    background-color: #121212;
    color: #e0e0e0;
  }
}

/* Footer styles - Override all backgrounds */
footer,
footer.text-center {
  background-color: transparent !important;
  background: transparent !important;
  border: none !important;
  border-top: none !important;
  box-shadow: none !important;
  margin-top: 2rem;
  padding: 1rem 0 2rem 0;
}

footer p,
footer p.text-muted {
  margin: 0;
  font-size: 0.875rem;
  opacity: 0.7;
  background: transparent !important;
}


/* Ensure Material Design cards are responsive */
@media (max-width: 768px) {
  .md-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .md-card {
    margin: 8px 0;
    padding: 20px;
  }
  
  .md-top-app-bar {
    padding: 12px 16px;
  }
  
  .md-top-app-bar__title {
    font-size: 1.25rem;
  }
}

@media (max-width: 480px) {
  .md-card {
    padding: 16px;
  }
  
  .md-container {
    padding: 0 12px;
  }
}

/* Custom Material Design component styling for weather app */
.md-weather-icon {
  width: 96px;
  height: 96px;
  margin-bottom: 16px;
  border-radius: 50%;
  box-shadow: var(--md-sys-elevation-level2);
  transition: transform var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}

.md-weather-icon:hover {
  transform: scale(1.05);
}

/* Ensure proper spacing for app bar */
.md-top-app-bar + main {
  padding-top: 16px;
}

/* Enhanced Material Design animations */
.md-card {
  transition: all var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-standard);
}

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

/* Staggered animation for cards */
.md-card:nth-child(1) { animation-delay: 0ms; }
.md-card:nth-child(2) { animation-delay: 100ms; }
.md-card:nth-child(3) { animation-delay: 200ms; }

/* FAB improvements */
.md-fab {
  transition: all var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-emphasized);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.md-fab:hover {
  transform: scale(1.1);
  box-shadow: var(--md-sys-elevation-level5);
}

.md-fab:active {
  transform: scale(0.95);
}


/* App bar entrance animation */
.md-top-app-bar {
  animation: md-slide-down var(--md-sys-motion-duration-medium4) var(--md-sys-motion-easing-emphasized);
}

@keyframes md-slide-down {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

