* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: url("a.webp") no-repeat center center/cover;
  transition: background 1s ease, color 0.3s ease;
  color: #111;
}
body.dark {
  color: #fff;
}

.app {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(14px);
  padding: 20px;
  border-radius: 20px;
  width: 90%;
  max-width: 900px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  transition: background 0.3s ease, color 0.3s ease;
}
body.dark .app {
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
}

header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
h1 {
  font-size: 2rem;
  margin-bottom: 10px;
  font-weight: 600;
  text-align: center;
}

.search-box {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.search-box input {
  padding: 10px;
  border: none;
  border-radius: 10px;
  outline: none;
  width: 200px;
  background: rgba(255, 255, 255, 0.9);
  color: #111;
  box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.15);
}
.search-box input::placeholder {
  color: #555;
}
body.dark .search-box input {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}
body.dark .search-box input::placeholder {
  color: #ccc;
}

.search-box button,
#unitToggle,
#saveCity,
#themeToggle {
  padding: 10px 15px;
  border: none;
  border-radius: 10px;
  background: #111;
  color: #fff;
  cursor: pointer;
  transition: 0.3s;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.search-box button:hover,
#unitToggle:hover,
#saveCity:hover,
#themeToggle:hover {
  background: #333;
}
body.dark .search-box button,
body.dark #unitToggle,
body.dark #saveCity,
body.dark #themeToggle {
  background: #fff;
  color: #111;
}
body.dark .search-box button:hover,
body.dark #unitToggle:hover,
body.dark #saveCity:hover,
body.dark #themeToggle:hover {
  background: #ddd;
}

.favorites {
  margin: 10px 0;
  text-align: center;
  flex-wrap: wrap;
}
.favorites button {
  margin: 5px;
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  background: #f0f0f0;
  color: #111;
  cursor: pointer;
  font-weight: 500;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}
.favorites button:hover {
  background: #ddd;
}
body.dark .favorites button {
  background: #333;
  color: #fff;
}
body.dark .favorites button:hover {
  background: #555;
}

.current-weather {
  text-align: center;
  margin: 20px 0;
}
.current-weather img {
  width: 100px;
  background: #fff;
  border-radius: 50%;
  padding: 10px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}
body.dark .current-weather img {
  background: #222;
}

.forecast {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 15px;
}
.forecast-card {
  background: rgba(255, 255, 255, 0.8);
  padding: 10px;
  border-radius: 15px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.3s;
  color: #111;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.forecast-card img {
  width: 60px;
  height: 60px;
  background: #fff;
  border-radius: 50%;
  padding: 8px;
  margin-bottom: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.forecast-card:hover {
  transform: scale(1.05);
  background: #f9f9f9;
}
body.dark .forecast-card {
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}
body.dark .forecast-card img {
  background: #222;
}
body.dark .forecast-card:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.modal-content {
  background: #fff;
  color: #111;
  padding: 20px;
  border-radius: 15px;
  max-width: 500px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  animation: fadeIn 0.3s ease;
}
.close {
  float: right;
  font-size: 1.5rem;
  cursor: pointer;
  color: #111;
}
.close:hover {
  color: red;
}
body.dark .modal-content {
  background: #111;
  color: #fff;
}
body.dark .close {
  color: #fff;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

#weatherTip {
  margin-top: 15px;
  font-style: italic;
  text-align: center;
  font-weight: 500;
  color: #222;
}
body.dark #weatherTip {
  color: #ddd;
}

/* Responsive Chart */
.chart-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 400px; /* default desktop height */
  margin-top: 20px;
}
@media (max-width: 768px) {
  .chart-container {
    height: 300px;
  }
}
@media (max-width: 480px) {
  .chart-container {
    height: 250px;
  }
}

/* Responsive */
@media (max-width: 768px) {
  h1 {
    font-size: 1.6rem;
  }
  .search-box input {
    width: 160px;
  }
  .forecast {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  }
}
@media (max-width: 480px) {
  .search-box {
    flex-direction: column;
    align-items: center;
  }
  .search-box input {
    width: 100%;
  }
  .search-box button {
    width: 100%;
  }
  .favorites {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }
}
