/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap');

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background-image: url("img/bg1.jpg");
  background-repeat: no-repeat;
  background-position: top center;
  background-size: cover;
  min-height: 92vh;
  line-height: 1.5;
  transition: background 0.5s ease-in-out;
}

/* Optional weather-themed backgrounds */
body.sunny {
  background-image: linear-gradient(to bottom, #ffe47a, #ffcc00);
}
body.rainy {
  background-image: linear-gradient(to bottom, #6e8da7, #445c72);
}
body.snowy {
  background-image: linear-gradient(to bottom, #d8f1ff, #bde0f8);
}

/* App container */
.app-main {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 90vh;
  width: 100vw;
  padding: 40px 20px;
}

/* Weather card */
.weather-card {
  width: 100%;
  max-width: 1200px;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
  padding: 48px 32px;
  margin: 40px auto 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  font-size: 1.2rem;
}

/* Layout */
.main-layout {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  width: 100%;
  margin: 0;
  padding: 0;
  gap: 40px;
}

.left-panel,
.right-panel {
  flex: 1;
  min-width: 280px;
  background: #e0e7ef;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(60, 64, 67, 0.07);
  color: #222;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

/* Search Input */
.searchInputBox {
  position: relative;
  width: 100%;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
}

.searchInputBox i {
  position: absolute;
  top: 40%;
  transform: translateY(-50%);
  font-size: 2rem;
  color: #1976d2;
  z-index: 1;
  pointer-events: none;
  transition: color 0.3s ease;
  margin-left: 5px;
}

.input-box {
  width: 100%;
  background: azure;
  color: #1976d2;
  font-weight: 500;
  border: none;
  font-size: 1.1rem;
  border-radius: 10px;
  padding: 12px 12px 12px 42px;
  text-align: center;
  outline: none;
  margin-bottom: 16px;
  transition: all 0.3s ease-in-out;
  line-height: 1.2;
  min-height: 48px;
}

.input-box:focus {
  border: 1px solid #1976d2;
  background-color: #f0faff;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.2);
}

/* Unit toggle */
.unit-toggle-container {
  text-align: center;
  margin-bottom: 20px;
}

#unit-toggle-btn {
  background-color: #1976d2;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
  min-height: 48px;
  min-width: 120px;
}

#unit-toggle-btn:hover {
  background-color: #125ea7;
}

#unit-toggle-btn:focus,
#unit-toggle-btn:active {
  outline: none;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.4);
}

/* Weather Body */
.weather-body {
  margin-top: 24px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  padding: 32px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  font-size: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.3s ease;
}

.weather-body:hover {
  transform: scale(1.02);
}

.weather-body .temp,
.weather-body .min-max {
  font-size: 2rem;
  font-weight: bold;
}

.weather-body .temp {
  color: #1976d2;
}

.weather-body img {
  width: 80px;
  height: 80px;
  margin-top: 16px;
}

.weather-body .weather {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.weather-body .weather img {
  width: 60px;
  height: 60px;
}

/* Forecast */
.forecast-body {
  background: #ffffff;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  transition: all 0.3s ease;
  color: #bde0f8;
}

.forecast-list {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  gap: 16px;
  padding-bottom: 12px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
  color: #1976d2;
}

.forecast-list::-webkit-scrollbar {
  height: 8px;
}

.forecast-list::-webkit-scrollbar-thumb {
  background-color: #ccc;
  border-radius: 6px;
}

.forecast-card {
  flex: 0 0 auto;
  width: 180px;
  background: linear-gradient(135deg, #f0f4f8, #ffffff);
  color: #1976d2;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  text-align: center;
  min-height: 200px;
  height: 250px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 1rem;
  scroll-snap-align: start;
  transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.forecast-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  background: #eaf2f9;
  cursor: pointer;
}

.forecast-card img {
  width: 60px;
  height: 60px;
  margin-bottom: 16px;
}

.forecast-card .date {
  font-weight: bold;
  margin-bottom: 12px;
}

.forecast-card .temp {
  font-size: 1.5rem;
  font-weight: bold;
  color: #1976d2;
}

.forecast-card .weather {
  color: #555;
}

/* Loading Spinner */
.loading-spinner-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.loading-spinner {
  border: 6px solid #e0e0e0;
  border-top: 6px solid #1976d2;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  animation: spin 0.8s linear infinite;
}

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

/* Footer */
.footer {
  text-align: center;
  color: #888;
  margin-top: 40px;
  font-size: 1rem;
  padding: 20px 10px 10px;
}

/* Responsive Design */

/* Large Desktop (1200px and above) */
@media (min-width: 1200px) {
  .weather-card {
    padding: 60px 48px;
  }
  
  .main-layout {
    gap: 60px;
  }
  
  .left-panel,
  .right-panel {
    padding: 32px;
  }
}

/* Desktop/Tablet landscape (768px to 1199px) */
@media (max-width: 1199px) and (min-width: 768px) {
  .weather-card {
    padding: 40px 24px;
  }
  
  .main-layout {
    gap: 30px;
  }
  
  .left-panel,
  .right-panel {
    min-width: 320px;
    padding: 20px;
  }
}

/* Tablet portrait and small desktop (769px to 900px) */
@media (max-width: 900px) and (min-width: 769px) {
  .main-layout {
    flex-direction: column;
    gap: 24px;
  }
  
  .left-panel,
  .right-panel {
    min-width: unset;
    width: 100%;
  }
}

/* Mobile landscape and large mobile (481px to 768px) */
@media (max-width: 768px) {
  .app-main {
    padding: 20px 15px;
  }
  
  .weather-card {
    padding: 24px 16px;
    margin: 20px auto 10px;
    border-radius: 12px;
    font-size: 1.1rem;
  }
  
  .main-layout {
    flex-direction: column;
    gap: 20px;
  }
  
  .left-panel,
  .right-panel {
    min-width: unset;
    width: 100%;
    padding: 20px;
  }
  
  .weather-body {
    padding: 24px;
    margin-top: 16px;
  }
  
  .weather-body .temp,
  .weather-body .min-max {
    font-size: 1.8rem;
  }
  
  .forecast-card {
    width: 160px;
    height: 220px;
    padding: 12px;
  }
  
  .forecast-card .temp {
    font-size: 1.3rem;
  }
  
  .forecast-card img {
    width: 50px;
    height: 50px;
    margin-bottom: 12px;
  }
  
  .footer {
    font-size: 0.9rem;
    margin-top: 20px;
  }
}

/* Mobile portrait (320px to 480px) */
@media (max-width: 480px) {
  .app-main {
    padding: 15px 10px;
  }
  
  .weather-card {
    padding: 20px 12px;
    margin: 15px auto 10px;
    gap: 16px;
    font-size: 1rem;
  }
  
  .left-panel,
  .right-panel {
    padding: 16px;
  }
  
  .input-box {
    font-size: 1rem;
    padding: 10px 10px 10px 38px;
    min-height: 44px;
  }
  
  .searchInputBox i {
    font-size: 1.1em;
    left: 10px;
  }
  
  #unit-toggle-btn {
    padding: 10px 20px;
    font-size: 0.95rem;
    min-height: 44px;
    min-width: 100px;
  }
  
  .weather-body {
    padding: 20px;
    font-size: 1rem;
  }
  
  .weather-body .temp,
  .weather-body .min-max {
    font-size: 1.6rem;
  }
  
  .weather-body img {
    width: 70px;
    height: 70px;
    margin-top: 12px;
  }
  
  .weather-body .weather img {
    width: 50px;
    height: 50px;
  }
  
  .forecast-body {
    padding: 16px;
  }
  
  .forecast-list {
    gap: 12px;
  }
  
  .forecast-card {
    width: 140px;
    height: 200px;
    padding: 10px;
    font-size: 0.9rem;
  }
  
  .forecast-card .temp {
    font-size: 1.2rem;
  }
  
  .forecast-card img {
    width: 45px;
    height: 45px;
    margin-bottom: 10px;
  }
  
  .forecast-card .date {
    margin-bottom: 8px;
    font-size: 0.85rem;
  }
  
  .loading-spinner {
    width: 40px;
    height: 40px;
    border-width: 4px;
  }
  
  .footer {
    font-size: 0.8rem;
    padding: 15px 5px 5px;
    margin-top: 15px;
  }
}

/* Extra small mobile (320px and below) */
@media (max-width: 320px) {
  .weather-card {
    padding: 16px 8px;
  }
  
  .left-panel,
  .right-panel {
    padding: 12px;
  }
  
  .forecast-card {
    width: 120px;
    height: 180px;
    padding: 8px;
  }
  
  .forecast-card .temp {
    font-size: 1.1rem;
  }
  
  .forecast-card img {
    width: 40px;
    height: 40px;
  }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
  .app-main {
    padding: 10px 20px;
  }
  
  .weather-card {
    margin: 10px auto 5px;
    padding: 16px 20px;
  }
  
  .weather-body {
    padding: 16px;
    margin-top: 12px;
  }
  
  .weather-body .temp,
  .weather-body .min-max {
    font-size: 1.4rem;
  }
  
  .weather-body img {
    width: 60px;
    height: 60px;
  }
  
  .forecast-card {
    height: 160px;
  }
  
  .footer {
    margin-top: 10px;
    padding: 10px 0 5px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .weather-body {
    backdrop-filter: blur(12px);
  }
}

/* Improved accessibility for larger text */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .weather-card {
    background: #1a1a1a;
    color: #ffffff;
  }
  
  .left-panel,
  .right-panel {
    background: #2d2d2d;
    color: #ffffff;
  }
  
  .input-box {
    background: #333333;
    color: #1976d2;
  }
  
  .forecast-body {
    background: #2d2d2d;
  }
  
  .forecast-card {
    background: linear-gradient(135deg, #333333, #2d2d2d);
    color: #ffffff;
  }
  
  .forecast-card:hover {
    background: #404040;
  }
}