/* CSS Variables for Theme Management */
:root {
  --primary-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary-bg: rgba(255, 255, 255, 0.1);
  --glass-bg: rgba(255, 255, 255, 0.15);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.8);
  --text-muted: rgba(255, 255, 255, 0.6);
  --accent-color: #4facfe;
  --error-color: #ff6b6b;
  --success-color: #4ecdc4;
  --warning-color: #ffe66d;
  --border-color: rgba(255, 255, 255, 0.2);
  --shadow-light: rgba(255, 255, 255, 0.1);
  --shadow-dark: rgba(0, 0, 0, 0.1);
  --backdrop-filter: blur(20px);
  --border-radius: 20px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Dark Theme Variables */
[data-theme="dark"] {
  --primary-bg: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  --secondary-bg: rgba(0, 0, 0, 0.3);
  --glass-bg: rgba(0, 0, 0, 0.25);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.9);
  --text-muted: rgba(255, 255, 255, 0.7);
  --border-color: rgba(255, 255, 255, 0.15);
  --shadow-light: rgba(255, 255, 255, 0.05);
}

/* Light Theme Variables */
[data-theme="light"] {
  --primary-bg: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
  --secondary-bg: rgba(255, 255, 255, 0.8);
  --glass-bg: rgba(255, 255, 255, 0.6);
  --text-primary: #2d3436;
  --text-secondary: #636e72;
  --text-muted: #b2bec3;
  --border-color: rgba(255, 255, 255, 0.8);
  --shadow-light: rgba(255, 255, 255, 0.9);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--primary-bg);
  min-height: 100vh;
  color: var(--text-primary);
  overflow-x: hidden;
  position: relative;
  transition: var(--transition-smooth);
}

/* Background Animation Container */
.background-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  overflow: hidden;
}

.background-animation {
  position: absolute;
  width: 100%;
  height: 100%;
  background: var(--primary-bg);
  transition: var(--transition-smooth);
}

/* Weather-based backgrounds */
.background-animation.clear-day {
  background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 50%, #e17055 100%);
}

.background-animation.clear-night {
  background: linear-gradient(135deg, #2d3436 0%, #636e72 50%, #b2bec3 100%);
}

.background-animation.cloudy {
  background: linear-gradient(135deg, #636e72 0%, #b2bec3 100%);
}

.background-animation.rainy {
  background: linear-gradient(135deg, #74b9ff 0%, #0984e3 50%, #2d3436 100%);
}

.background-animation.snowy {
  background: linear-gradient(135deg, #ddd6fe 0%, #a855f7 50%, #7c3aed 100%);
}

/* Weather Particles */
.weather-particles {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
}

/* Rain Particles */
.weather-particles.rain::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 0;
  width: 100%;
  height: 100%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fill='%23ffffff'%3E%3Cpath d='M20 20L25 80M40 20L45 80M60 20L65 80M80 20L85 80' stroke='%23ffffff' stroke-width='1' opacity='0.3'/%3E%3C/g%3E%3C/svg%3E") repeat;
  animation: rain 0.5s linear infinite;
}

/* Snow Particles */
.weather-particles.snow::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 0;
  width: 100%;
  height: 100%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fill='%23ffffff'%3E%3Ccircle cx='20' cy='20' r='2' opacity='0.8'/%3E%3Ccircle cx='80' cy='20' r='2' opacity='0.6'/%3E%3Ccircle cx='60' cy='60' r='2' opacity='0.7'/%3E%3Ccircle cx='30' cy='80' r='2' opacity='0.5'/%3E%3C/g%3E%3C/svg%3E") repeat;
  animation: snow 3s linear infinite;
}

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

@keyframes snow {
  0% { transform: translateY(-100px) rotate(0deg); }
  100% { transform: translateY(100vh) rotate(360deg); }
}

/* App Container */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* Header */
.header {
  margin-bottom: 30px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
}

.app-title {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 15px;
  color: var(--text-primary);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.app-title i {
  font-size: 1.2em;
  color: var(--accent-color);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 15px;
}

.theme-toggle {
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-smooth);
  backdrop-filter: var(--backdrop-filter);
  font-size: 1.2rem;
}

.theme-toggle:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 10px 30px var(--shadow-dark);
}

/* Search Section */
.search-section {
  margin-bottom: 30px;
}

.search-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.search-input-container {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 20px;
  color: var(--text-muted);
  z-index: 2;
}

.search-input {
  width: 100%;
  padding: 18px 20px 18px 50px;
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 16px;
  font-family: inherit;
  backdrop-filter: var(--backdrop-filter);
  transition: var(--transition-smooth);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
  transform: translateY(-2px);
}

.search-btn {
  position: absolute;
  right: 8px;
  background: var(--accent-color);
  border: none;
  border-radius: 12px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: var(--transition-bounce);
  z-index: 2;
}

.search-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 5px 20px rgba(79, 172, 254, 0.3);
}

.location-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px 25px;
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-bounce);
  backdrop-filter: var(--backdrop-filter);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  min-height: 56px;
}

.location-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px var(--shadow-dark);
  border-color: var(--accent-color);
}

.location-btn i {
  font-size: 1.1rem;
}

/* Glassmorphism Effect */
.glassmorphism {
  background: var(--glass-bg);
  backdrop-filter: var(--backdrop-filter);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: 
    0 8px 32px var(--shadow-dark),
    inset 0 1px 0 var(--shadow-light);
}

/* Loading Spinner */
.loader-container {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.loader-container.show {
  display: flex;
}

.weather-loader {
  position: relative;
  width: 100px;
  height: 100px;
  margin-bottom: 20px;
}

.sun {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 30px;
  height: 30px;
  background: #ffd700;
  border-radius: 50%;
  animation: sunRotate 4s linear infinite;
}

.sun-rays {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 50px;
  height: 50px;
  background: radial-gradient(circle, transparent 40%, rgba(255, 215, 0, 0.3) 41%);
  border-radius: 50%;
}

.cloud {
  position: absolute;
  background: #ffffff;
  border-radius: 50px;
}

.cloud1 {
  width: 50px;
  height: 20px;
  top: 40px;
  left: 10px;
  animation: cloudFloat 3s ease-in-out infinite;
}

.cloud2 {
  width: 40px;
  height: 15px;
  top: 30px;
  right: 10px;
  animation: cloudFloat 3s ease-in-out infinite reverse;
}

.rain-drops {
  position: absolute;
  top: 60px;
  left: 30px;
  width: 40px;
  height: 20px;
}

.drop {
  position: absolute;
  width: 2px;
  height: 10px;
  background: #74b9ff;
  border-radius: 2px;
  animation: rainDrop 1s ease-in-out infinite;
}

.drop:nth-child(1) {
  left: 10px;
  animation-delay: 0s;
}

.drop:nth-child(2) {
  left: 20px;
  animation-delay: 0.3s;
}

.drop:nth-child(3) {
  left: 30px;
  animation-delay: 0.6s;
}

@keyframes sunRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes cloudFloat {
  0%, 100% { transform: translateX(0px); }
  50% { transform: translateX(10px); }
}

@keyframes rainDrop {
  0% { opacity: 1; transform: translateY(0px); }
  100% { opacity: 0; transform: translateY(20px); }
}

.loading-text {
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 500;
  animation: fadeInOut 2s ease-in-out infinite;
}

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

/* Error Container */
.error-container {
  display: none;
  text-align: center;
  padding: 40px 20px;
}

.error-container.show {
  display: block;
}

.error-content {
  background: var(--glass-bg);
  backdrop-filter: var(--backdrop-filter);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 40px;
  max-width: 500px;
  margin: 0 auto;
}

.error-icon {
  font-size: 3rem;
  color: var(--error-color);
  margin-bottom: 20px;
}

.error-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 15px;
  color: var(--text-primary);
}

.error-message {
  color: var(--text-secondary);
  margin-bottom: 25px;
  line-height: 1.6;
}

.retry-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: var(--accent-color);
  border: none;
  border-radius: 12px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-bounce);
}

.retry-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(79, 172, 254, 0.3);
}

/* Weather Content */
.weather-content {
  display: none;
  grid-template-columns: 1fr;
  gap: 30px;
}

.weather-content.show {
  display: grid;
}

/* Current Weather Card */
.current-weather-card {
  padding: 30px;
  transition: var(--transition-smooth);
}

.current-weather-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px var(--shadow-dark);
}

.current-weather-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 25px;
}

.location-name {
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.last-updated {
  color: var(--text-muted);
  font-size: 14px;
}

.weather-icon-container {
  flex-shrink: 0;
}

.weather-icon {
  width: 80px;
  height: 80px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
}

.temperature-section {
  margin-bottom: 30px;
}

.main-temperature {
  display: flex;
  align-items: baseline;
  gap: 15px;
  margin-bottom: 10px;
}

.temperature {
  font-size: clamp(3rem, 8vw, 4.5rem);
  font-weight: 300;
  color: var(--text-primary);
  line-height: 1;
}

.condition {
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  color: var(--text-secondary);
  font-weight: 500;
}

.feels-like {
  color: var(--text-muted);
  font-size: 16px;
}

/* Weather Details Grid */
.weather-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.detail-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 15px;
  transition: var(--transition-smooth);
}

.detail-item:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.detail-icon {
  font-size: 1.2rem;
  color: var(--accent-color);
  width: 20px;
  text-align: center;
}

.detail-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.detail-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Section Titles */
.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 25px;
}

.section-title i {
  color: var(--accent-color);
}

/* Chart Section */
.chart-section {
  padding: 30px;
}

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

/* Forecast Section */
.forecast-section {
  padding: 30px;
}

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

.forecast-item {
  text-align: center;
  padding: 20px 15px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 15px;
  transition: var(--transition-smooth);
  cursor: pointer;
}

.forecast-item:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-5px);
  box-shadow: 0 10px 25px var(--shadow-dark);
}

.forecast-date {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.forecast-icon {
  width: 50px;
  height: 50px;
  margin: 0 auto 15px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
}

.forecast-temps {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.temp-max {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.temp-min {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-muted);
}

.forecast-condition {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: capitalize;
  line-height: 1.3;
}

/* Responsive Design */
@media (min-width: 768px) {
  .app-container {
    padding: 40px;
  }
  
  .search-container {
    flex-direction: row;
    align-items: center;
    gap: 20px;
  }
  
  .search-input-container {
    flex: 1;
  }
  
  .location-btn {
    flex-shrink: 0;
    min-width: 180px;
  }
  
  .weather-content {
    grid-template-columns: 1fr;
  }
  
  .weather-details-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .weather-content {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: auto auto;
  }
  
  .current-weather-card {
    grid-column: 1 / -1;
  }
  
  .chart-section {
    grid-column: 1;
  }
  
  .forecast-section {
    grid-column: 2;
  }
  
  .forecast-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .forecast-item {
    display: flex;
    align-items: center;
    text-align: left;
    padding: 15px;
    gap: 15px;
  }
  
  .forecast-date {
    min-width: 80px;
    margin-bottom: 0;
    font-size: 13px;
  }
  
  .forecast-icon {
    width: 40px;
    height: 40px;
    margin: 0;
    flex-shrink: 0;
  }
  
  .forecast-temps {
    margin-left: auto;
    margin-bottom: 0;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
  }
  
  .forecast-condition {
    display: none;
  }
}

@media (min-width: 1200px) {
  .weather-details-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* Mobile Optimizations */
@media (max-width: 480px) {
  .app-container {
    padding: 15px;
  }
  
  .current-weather-card {
    padding: 20px;
  }
  
  .current-weather-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 20px;
  }
  
  .main-temperature {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
  }
  
  .weather-details-grid {
    grid-template-columns: 1fr;
  }
  
  .forecast-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .chart-section,
  .forecast-section {
    padding: 20px;
  }
  
  .section-title {
    font-size: 1.1rem;
  }
}

/* High DPI Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .weather-icon,
  .forecast-icon {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *,
  ::before,
  ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .weather-particles::before {
    animation: none;
  }
}

/* Focus Styles for Accessibility */
button:focus,
input:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Loading States */
.loading {
  opacity: 0.7;
  pointer-events: none;
}

.loading * {
  cursor: wait !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--accent-color);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 172, 254, 0.8);
}

/* Print Styles */
@media print {
  .background-container,
  .weather-particles,
  .theme-toggle,
  .search-section,
  .loader-container,
  .error-container {
    display: none !important;
  }
  
  .app-container {
    max-width: none;
    padding: 0;
  }
  
  .glassmorphism {
    background: white;
    color: black;
    border: 1px solid #ccc;
  }
}