/* General body styles */
body {
  min-height: 100vh;
  height: auto;
  background: #8c52ff;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 20px; /* Add space for small viewports */
  transition: background 0.5s ease;
  overflow-y: auto;
}

.dark-mode {
  background: #1e1e2f;
}

/* Main container */
#weather-container {
  position: relative;
  background: rgba(255, 255, 255, 0.3);
  max-width: 400px;
  width: 100%;
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  transition: background 0.5s ease;
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dark-mode #weather-container {
  background: rgba(255, 255, 255, 0.1);
}

#theme {
  font-weight: bold;
}

h2,
label,
p {
  color: #fff;
  margin: 8px 0;
}

/* Input + Button */
input {
  width: calc(100% - 16px);
  padding: 8px;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid #fff;
  margin-top: 20px;
  outline-color: #8c52ff;
}

button {
  background: #8c52ff;
  color: #fff;
  padding: 10px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 20px;
  width: 100px;
  font-size: 16px;
  font-weight: bold;
  transition: background 0.3s ease;
}

button:hover {
  background: #8b48d7;
}

/* Temperature display */
#temp-div p {
  font-size: 60px;
  margin-top: -30px;
  color: #fff;
  transition: 1s ease;
}

.dark-mode #temp-div p {
  color: #8c52ff;
}

/* Weather info */
#weather-info {
  font-size: 20px;
  color: #fff;
}

/* Weather icon */
#weather-icon {
  width: 200px;
  height: 200px;
  margin: 0 auto 0;
  display: none;
}

@media (max-width: 450px) {
  #weather-icon {
    width: 100px;
    height: 100px;
  }
}

/* Hourly forecast section */
#hourly-forecast {
  margin-top: 16px;
  overflow-x: auto;
  white-space: nowrap;
  display: flex;
  justify-content: space-between;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  padding: 12px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  scrollbar-color: #a977ff rgba(255, 255, 255, 0.1);
}

#hourly-forecast::-webkit-scrollbar {
  height: 10px;
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 1rem;
}

#hourly-forecast:hover::-webkit-scrollbar {
  opacity: 1;
}

#hourly-forecast::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
}

#hourly-forecast::-webkit-scrollbar-thumb {
  background: linear-gradient(45deg, #a977ff, #debff4);
  border-radius: 20px;
  animation: scroll-pulse 1.5s infinite ease-in-out;
}

@keyframes scroll-pulse {
  0%,
  100% {
    opacity: 0.7;
    transform: scaleY(1);
  }
  50% {
    opacity: 1;
    transform: scaleY(1.3);
  }
}

/* Hourly item styling */
.hourly-item {
  flex: 0 0 auto;
  width: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-right: 10px;
  margin-bottom: 24px;
  color: #fff;
}

.hourly-item img {
  width: 30px;
  height: 30px;
  margin-bottom: 5px;
}

.hourly-item p {
  font-size: 12px;
  margin: 2px 0;
}

/* Loader spinner */
#loader {
  display: none;
  margin: 20px auto;
  border: 6px solid rgba(255, 255, 255, 0.2);
  border-top: 6px solid #fff;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

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

/* Toggle switch */
.toggle-container {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  background-color: #debff4;
  border-radius: 26px;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  transition: 0.4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: #fff;
  border-radius: 50%;
  transition: 0.4s;
}

input:checked + .slider {
  background-color: #8c52ff;
}

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

/* Mobile-friendly tweaks */
@media (max-width: 480px) {
  #weather-container {
    padding: 16px;
    margin: 10px;
  }

  h2 {
    font-size: 20px;
  }

  #temp-div p {
    font-size: 48px;
  }

  #weather-info {
    font-size: 16px;
  }

  .hourly-item {
    width: 60px;
  }

  .hourly-item p {
    font-size: 11px;
  }
}

@media (max-width: 400px) {
  #weather-container {
    margin-top: 40px; /* ✅ Add space below Theme switch */
  }
}
