/* ========== RESET & BASE ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Inter", sans-serif;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  transition: background 0.6s cubic-bezier(0.2, 0.9, 0.4, 1.1);
}

/* ========== BACKGROUND GRADIENTS (dynamic via JS) ========== */
/* DEFAULT */
body.default-bg {
  background: url("images/default.jpg") no-repeat center/cover;
}

/* ========== MAIN CARD (GLASS + PREMIUM) ========== */
.app-container {
  max-width: 620px;
  width: 100%;
  margin: 0 auto;
}

.weather-card {
  padding: 2rem 1.8rem;
  border-radius: 2rem;
  background: rgba(15, 25, 35, 0.35);
  backdrop-filter: blur(18px);
  box-shadow:
    0 30px 50px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.2);
  transition:
    transform 0.3s ease,
    box-shadow 0.3s;
}

.weather-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 35px 55px rgba(0, 0, 0, 0.3);
}

/* Title */
.app-title {
  font-size: 2.2rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1.8rem;
  color: white;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.app-title i {
  font-size: 2rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* ========== SEARCH SECTION ========== */
.search-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.input-group {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

#cityInput {
  flex: 1;
  padding: 0.9rem 1.2rem;
  border: none;
  outline: none;
  border-radius: 3rem;
  background: rgba(255, 255, 255, 0.92);
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.25s;
  color: #1e293b;
}

#cityInput:focus {
  background: white;
  box-shadow: 0 0 0 3px rgba(255, 215, 150, 0.5);
  transform: scale(1.01);
}

.search-btn {
  background: #0f172a;
  border: none;
  padding: 0 1.6rem;
  border-radius: 3rem;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.3px;
}

.search-btn:hover {
  background: #020617;
  transform: scale(0.96);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.unit-toggle-container {
  display: flex;
  justify-content: flex-end;
}

.unit-toggle {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 0.5rem 1.2rem;
  border-radius: 2.5rem;
  color: white;
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: all 0.2s;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.unit-toggle:hover {
  background: rgba(0, 0, 0, 0.55);
  transform: scale(0.96);
}

/* ========== ERROR + LOADING ========== */
.error-message {
  background: rgba(255, 235, 235, 0.95);
  color: #c62828;
  padding: 0.8rem 1rem;
  border-radius: 2rem;
  margin: 1rem 0;
  font-weight: 500;
  text-align: center;
  backdrop-filter: blur(4px);
  animation: fadeSlide 0.3s ease;
}

.hidden {
  display: none !important;
}

.spinner-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 0;
  margin: 0.5rem 0;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid rgba(255, 255, 255, 0.4);
  border-top: 5px solid white;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.loading-text {
  margin-top: 0.8rem;
  color: white;
  font-weight: 500;
  font-size: 0.9rem;
}

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

@keyframes fadeSlide {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: white;
  animation: fadeSlide 0.4s;
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.9;
}

.empty-state h3 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.9rem;
  opacity: 0.85;
}

/* ========== WEATHER INFO CARD ========== */
.weather-info {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 1.8rem;
  padding: 1.6rem;
  margin: 0.8rem 0 1.2rem;
  backdrop-filter: blur(12px);
  transition: all 0.3s;
  animation: fadeSlideUp 0.4s ease;
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.city-header {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

#cityName {
  font-size: 2rem;
  font-weight: 700;
  color: white;
  letter-spacing: -0.3px;
}

.country-badge {
  background: rgba(0, 0, 0, 0.4);
  padding: 0.2rem 0.8rem;
  border-radius: 40px;
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
}

.datetime {
  text-align: center;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 1rem;
  font-weight: 400;
  letter-spacing: 0.2px;
}

.weather-main {
  text-align: center;
  margin: 0.2rem 0 0.8rem;
}

.weather-icon {
  width: 85px;
  height: 85px;
  margin: 0 auto;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.2));
}

.temperature-section {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  margin: 0.5rem 0;
}

.temp-value {
  font-size: 3.5rem;
  font-weight: 800;
  color: white;
  line-height: 1;
}

.temp-unit {
  font-size: 1.5rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
}

.weather-desc {
  font-size: 1.2rem;
  font-weight: 500;
  text-transform: capitalize;
  color: white;
  margin-top: 0.2rem;
}

.details-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  margin-top: 1.3rem;
}

.detail-card {
  flex: 1;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 1.2rem;
  padding: 0.9rem 0.5rem;
  text-align: center;
  backdrop-filter: blur(2px);
  transition: all 0.2s;
}

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

.detail-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 0.4rem;
  letter-spacing: 0.3px;
}

.detail-label i {
  margin-right: 4px;
  font-size: 0.8rem;
}

.detail-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
}

/* ========== HISTORY SECTION ========== */
.history-section {
  margin-top: 1.6rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 1.4rem;
  padding: 0.9rem 1.2rem;
  backdrop-filter: blur(4px);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
  font-weight: 500;
  margin-bottom: 0.9rem;
  font-size: 0.9rem;
}

.clear-history {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  padding: 0.3rem 0.9rem;
  border-radius: 2rem;
  color: white;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 500;
  transition: 0.2s;
}

.clear-history:hover {
  background: rgba(220, 60, 60, 0.8);
  transform: scale(0.94);
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
}

.history-item {
  background: rgba(255, 255, 255, 0.22);
  padding: 0.45rem 1.2rem;
  border-radius: 2rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(2px);
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.45);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.history-placeholder {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
  font-style: italic;
  padding: 0.2rem 0;
}

/* Footer */
.app-footer {
  text-align: center;
  margin-top: 1.2rem;
  font-size: 1rem;
  color: rgb(255, 251, 251);
}

.app-footer a {
  color: white;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.5);
}

.app-footer a:hover {
  color: #ffecb3;
}

/* ========== RESPONSIVENESS ========== */
@media (max-width: 580px) {
  body {
    padding: 1rem;
  }
  .weather-card {
    padding: 1.4rem;
  }
  .app-title {
    font-size: 1.7rem;
    gap: 8px;
  }
  .temp-value {
    font-size: 2.8rem;
  }
  .details-grid {
    flex-direction: column;
    gap: 0.7rem;
  }
  .input-group {
    flex-direction: column;
  }
  .search-btn {
    justify-content: center;
    padding: 0.75rem;
  }
  .city-header {
    flex-direction: column;
    align-items: center;
  }
  #cityName {
    font-size: 1.7rem;
  }
  .weather-icon {
    width: 70px;
    height: 70px;
  }
}

/* ========== UTILITIES ========== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
