@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap");

:root {
  --primary-color: #5598fd;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

body {
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  padding: 50px;
  background: var(--primary-color);
  background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
    url("./images/cd.jpg");
  background-size: cover;
  background-position: center;
  transition: background-image 0.3s ease;
}

img {
  width: 100%;
  display: block;
}

.wrapper {
  display: flex;
  width: 1200px;
  max-width: 100%;
  border-radius: 20px;
  overflow: hidden;
  flex-wrap: wrap;
}

/* Sidebar */
.sidebar {
  width: 30%;
  min-width: 250px;
  max-width: 100%;
  padding: 20px;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  margin-bottom: 20px;
}

.search {
  display: flex;
  align-items: center;
  margin-top: 20px;
  margin-bottom: 30px;
  position: relative;
  width: 100%;
}

.search input {
  flex: 1;
  height: 40px;
  border: 1px solid #ced4da;
  border-right: none;
  border-top-left-radius: 5px;
  border-bottom-left-radius: 5px;
  padding: 0 15px;
  font-size: 14px;
  color: #495057;
}

.search input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.search button {
  width: 45px;
  height: 40px;
  border: none;
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
  background: var(--primary-color);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Search suggestions */
.search ul {
  position: absolute;
  top: 40px;
  width: 100%;
  max-height: 300px;
  overflow-y: auto;
  background: #fff;
  border-radius: 5px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.search ul li {
  padding: 10px 15px;
  border-bottom: 1px solid #f1f1f1;
  cursor: pointer;
  text-transform: capitalize;
}

.search ul li:hover,
.search ul li.active {
  background-color: #f1f1f1;
}

.weather-icon {
  width: 100%;
  height: 150px;
  text-align: center;
  margin: 20px 0;
}
.weather-icon #icon {
  width: 80%;
  object-fit: cover;
}

.temperature {
  display: flex;
  align-items: flex-start;
}
.temperature #temp {
  font-size: 70px;
  font-weight: 100;
  line-height: 1;
}
.temperature span {
  font-size: 40px;
  margin-top: -10px;
  display: block;
}

.divider {
  width: 100%;
  height: 1px;
  background: #e9ecef;
  margin: 20px 0;
}

.condition-rain {
  font-size: 12px;
  text-transform: capitalize;
}
.condition-rain div {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.condition-rain div i {
  width: 20px;
}

.location {
  display: flex;
  align-items: center;
  font-size: 14px;
  gap: 10px;
  margin-top: 10px;
}
.location i {
  font-size: 18px;
}

/* Main content */
.main {
  flex: 1;
  min-width: 300px;
  width: 70%;
  padding: 20px 40px;
  background-color: #f6f6f8;
  position: relative;
  padding-bottom: 90px;
}

.main nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.main nav .options {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
  list-style: none;
  padding: 0;
  margin: 0;
}

.main nav .options button {
  border: none;
  background: none;
  font-size: 16px;
  font-weight: 600;
  color: #495057;
  cursor: pointer;
  text-transform: capitalize;
}
.main nav .options button.active {
  color: var(--primary-color);
}

.main nav .units button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #1a1a1a;
  background-color: #fff;
}
.main nav .units button.active {
  color: #fff;
  background-color: #1a1a1a;
}

.main .cards {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 50px;
  justify-content: center;
}

.cards .card {
  width: 100px;
  height: 130px;
  border-radius: 20px;
  color: #1a1a1a;
  background-color: #fff;
  text-align: center;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.card h2 {
  font-size: 15px;
  font-weight: 600;
}
.card .card-icon {
  width: 50%;
  margin: 0 auto;
}
.card .day-temp {
  font-size: 12px;
  display: flex;
  justify-content: center;
}

.highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 50px;
}
.highlights .heading {
  width: 100%;
  font-size: 20px;
  font-weight: 600;
  text-transform: capitalize;
}

.card2 {
  width: 250px;
  max-width: 100%;
  height: 150px;
  border-radius: 20px;
  color: #1a1a1a;
  background-color: #fff;
  padding: 10px 20px;
  display: flex;
  flex-direction: column;
}
.card2 .card-heading {
  color: #c2c2c2;
}
.card2 .content {
  margin-top: 20px;
}
.card2 .content p:first-child {
  text-align: center;
  font-size: 30px;
}
.card2 .content p:nth-child(2) {
  font-size: 12px;
  margin-top: 20px;
  text-align: left;
}

.credits {
  text-align: center;
  font-size: 1.25rem;
  color: #2e79ba;
  font-weight: 600;
  font-family: 'Papyrus', cursive;
  margin: 0;
}

.credits-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 50px;
  margin-top: 30px;
  flex-wrap: wrap;
}

.credits a {
  color: inherit;
  font-weight: inherit;
  font-family: inherit;
  text-decoration: none;
  padding: 4px 6px;
  transition: all 0.25s ease;
}

.credits a:hover,
.credits a:active {
  text-decoration: underline;
  background-color: rgba(46, 121, 186, 0.18);
  border-radius: 4px;
}

.sound-btn {
  margin-top: 20px;
  padding: 8px 14px;
  border-radius: 20px;
  border: none;
  background-color: var(--primary-color);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: 0.3s ease;
}

.sound-btn:hover {
  background-color: #4174d9;
}

#preloader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(15, 23, 42, 0.95);
  z-index: 9999;
  transition: opacity 0.5s ease;
}
#preloader.hidden {
  opacity: 0;
  pointer-events: none;
}

/* --- MOBILE RESPONSIVE --- */
@media (max-width: 1024px) {
  .wrapper {
    flex-direction: column;
    padding: 20px;
  }
  .sidebar {
    width: 100%;
    margin-bottom: 20px;
  }
  .main {
    width: 100%;
    padding: 20px;
  }
}

@media (max-width: 768px) {
  .temperature #temp {
    font-size: 50px;
  }
  .temperature span {
    font-size: 30px;
  }
  .cards .card {
    width: 90px;
    height: 120px;
  }
  .card2 {
    width: 100%;
  }
}

@media (max-width: 480px) {
  body {
    padding: 20px;
  }
  .search input {
    font-size: 13px;
    padding: 0 10px;
  }
  .search button {
    width: 40px;
    height: 35px;
    font-size: 14px;
  }
  .temperature #temp {
    font-size: 40px;
  }
  .temperature span {
    font-size: 25px;
  }
  .main nav .options button {
    font-size: 14px;
  }
  .cards .card {
    width: 80px;
    height: 110px;
  }
  .card2 .content p:first-child {
    font-size: 25px;
  }
  .card2 .content p:nth-child(2) {
    font-size: 11px;
  }
  .sound-btn {
    padding: 6px 12px;
    font-size: 14px;
  }
}