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

:root {
  --primary-color: #4b6cb7;
  --secondary-color: #182848;
  --bg-gradient-start: #243b55;
  --bg-gradient-end: #141e30;
  --card-bg: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.15);
  --text-light: #e0e7ff;
  --text-dark: #1f2937;
  --detail-bg: rgba(255, 255, 255, 0.05);
  --error-bg: rgba(239, 68, 68, 0.2);
  --error-color: #fca5a5;
  --box-shadow-light: 0 4px 6px rgba(0, 0, 0, 0.2);
  --box-shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

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

body {
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow: auto;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%"><defs><radialGradient id="grad1" cx="50%" cy="50%" r="50%" fx="50%" fy="50%"><stop offset="0%" style="stop-color:rgba(255,255,255,0.05)" /><stop offset="100%" style="stop-color:rgba(255,255,255,0)" /></radialGradient></defs><rect width="100%" height="100%" fill="url(#grad1)" /></svg>');
  background-size: cover;
  opacity: 0.8;
  animation: bg-pan 20s infinite alternate ease-in-out;
  z-index: -1;
}

@keyframes bg-pan {
  0% { transform: translate(0, 0); }
  100% { transform: translate(-20px, 20px); }
}

.container {
  background: var(--card-bg);
  border-radius: 30px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--box-shadow-glass);
  backdrop-filter: blur(20px);
  padding: 3rem;
  width: 100%;
  max-width: 850px;
  margin: 20px auto;
  position: relative;
  z-index: 1;
  transition: all 0.5s ease;
  overflow: hidden;
}

header {
  text-align: center;
  margin-bottom: 2.5rem;
}

h1 {
  color: var(--text-light);
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 2.8rem;
  text-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  margin-bottom: 1.5rem;
  letter-spacing: 1px;
}

h1 i {
  color: var(--text-light);
  margin-right: 15px;
  font-size: 3rem;
  animation: icon-float 3s infinite ease-in-out;
}

@keyframes icon-float {
  0% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
  100% { transform: translateY(0); }
}

.search-box {
  display: flex;
  gap: 15px;
  margin-bottom: 2rem;
  max-width: 550px;
  margin: 0 auto 2.5rem;
}

#city-input {
  flex: 1;
  padding: 15px 25px;
  border: none;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 50px;
  font-size: 1.1rem;
  color: var(--text-dark);
  transition: all 0.4s ease;
  outline: none;
  box-shadow: var(--box-shadow-light);
}

#city-input::placeholder {
  color: #9ca3af;
}

#city-input:focus {
  background: white;
  box-shadow: 0 0 15px rgba(75, 108, 183, 0.5);
  transform: scale(1.02);
}

#search-btn {
  padding: 15px 35px;
  background: linear-gradient(135deg, #4b6cb7 0%, #182848 100%);
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 600;
  transition: all 0.4s ease;
  box-shadow: var(--box-shadow-light);
}

#search-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 20px rgba(75, 108, 183, 0.4);
}

.weather-info {
  text-align: center;
  display: none;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-light);
  padding: 3rem;
  border-radius: 20px;
  margin: 2.5rem 0;
  position: relative;
  overflow: hidden;
  box-shadow: var(--box-shadow-glass);
}

.weather-info::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 70%);
  animation: shine 4s infinite linear;
}

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

.weather-info.active {
  display: block;
  animation: fadeIn 0.8s ease forwards;
}

.weather-icon {
  width: 150px;
  height: 150px;
  margin: 1.5rem auto;
  filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.2));
  animation: icon-bounce 1.5s infinite alternate;
}

@keyframes icon-bounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-10px); }
}

.temperature {
  font-size: 4.5rem;
  font-weight: 700;
  margin: 1.5rem 0;
  text-shadow: 2px 4px 6px rgba(0, 0, 0, 0.3);
  font-family: 'Montserrat', sans-serif;
  letter-spacing: -2px;
}

.description {
  font-size: 1.6rem;
  text-transform: capitalize;
  margin-bottom: 1.5rem;
  font-weight: 500;
}

.details-container {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 2rem;
  margin-top: 3rem;
}

.details-container.active {
  display: grid;
  animation: fadeIn 0.8s ease forwards;
}

.detail-box {
  background: var(--detail-bg);
  padding: 1.8rem;
  border-radius: 20px;
  box-shadow: var(--box-shadow-light);
  text-align: center;
  transition: transform 0.4s ease, box-shadow 0.4s ease, background 0.4s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-light);
}

.detail-box:hover {
  transform: translateY(-8px) scale(1.05);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  background: rgba(255, 255, 255, 0.1);
}

.detail-box i {
  font-size: 2.5rem;
  color: var(--text-light);
  margin-bottom: 0.8rem;
  transition: color 0.4s ease;
}

.detail-box:hover i {
  color: #fff;
}

.detail-label {
  color: var(--text-light);
  font-size: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 400;
}

.detail-value {
  color: var(--text-light);
  font-size: 1.4rem;
  font-weight: 700;
}

.error-message {
  color: var(--error-color);
  text-align: center;
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--error-bg);
  border-radius: 15px;
  display: none;
  font-weight: 500;
  box-shadow: var(--box-shadow-light);
}

.error-message.active {
  display: block;
  animation: fadeIn 0.5s ease;
}

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

.loading {
  display: none;
  justify-content: center;
  align-items: center;
  margin: 3rem 0;
}

/* Responsive Design */
@media screen and (max-width: 992px) {
  .container {
    padding: 2rem;
    margin: 15px;
  }

  h1 {
    font-size: 2.4rem;
  }

  h1 i {
    font-size: 2.6rem;
  }

  .temperature {
    font-size: 4rem;
  }

  .weather-icon {
    width: 130px;
    height: 130px;
  }

  .details-container {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1.5rem;
  }
}

@media screen and (max-width: 768px) {
  .container {
    padding: 1.5rem;
  }

  h1 {
    font-size: 2rem;
    margin-bottom: 1.2rem;
  }

  .search-box {
    flex-direction: row;
    gap: 10px;
  }

  #city-input {
    padding: 12px 20px;
    font-size: 1rem;
  }

  #search-btn {
    padding: 12px 25px;
    font-size: 1rem;
  }

  .temperature {
    font-size: 3.5rem;
  }

  .description {
    font-size: 1.4rem;
  }

  .weather-icon {
    width: 120px;
    height: 120px;
  }

  .details-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2rem;
  }

  .detail-box {
    padding: 1.5rem;
  }

  .detail-box i {
    font-size: 2rem;
  }

  .detail-value {
    font-size: 1.2rem;
  }
}

@media screen and (max-width: 480px) {
  body {
    padding: 10px;
  }

  .container {
    padding: 1.2rem;
    margin: 10px;
    border-radius: 20px;
  }

  h1 {
    font-size: 1.8rem;
  }

  h1 i {
    font-size: 2rem;
    margin-right: 8px;
  }

  .search-box {
    margin-bottom: 1.5rem;
  }

  #city-input {
    padding: 10px 15px;
  }

  #search-btn {
    padding: 10px 20px;
  }

  .weather-info {
    padding: 2rem 1rem;
    margin: 1.5rem 0;
  }

  .temperature {
    font-size: 3rem;
  }

  .description {
    font-size: 1.2rem;
  }

  .weather-icon {
    width: 100px;
    height: 100px;
    margin: 1rem auto;
  }

  .details-container {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .detail-box {
    padding: 1.2rem;
  }

  .detail-box:hover {
    transform: translateY(-5px) scale(1.02);
  }

  .error-message {
    padding: 1rem;
    margin-top: 1rem;
    font-size: 0.9rem;
  }
}

.loading.active {
  display: flex;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 6px solid rgba(255, 255, 255, 0.3);
  border-top: 6px solid #e0e7ff;
  border-radius: 50%;
  animation: spin 1s linear infinite, glow 1.5s infinite alternate;
}

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

@keyframes glow {
  0% { box-shadow: 0 0 5px var(--text-light), 0 0 10px var(--text-light); }
  100% { box-shadow: 0 0 10px var(--text-light), 0 0 20px var(--text-light); }
}

#search-btn.loading {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(0.98); }
  100% { transform: scale(1); }
}