/* =========================================
   1. VARIABLAT DHE RREGULLIMET GLOBALE
   ========================================= */
:root {
  --glass: rgba(255, 255, 255, 0.16);
  --glass-strong: rgba(255, 255, 255, 0.24);
  --glass-border: rgba(255, 255, 255, 0.28);
  --text: #ffffff;
  --text-soft: rgba(255, 255, 255, 0.78);
  --accent: #1c7ed6;
  --radius-lg: 28px;
  --radius-md: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(160deg, #1d6fdc 0%, #4fb3f6 100%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text);
  padding: 20px;
}

/* Shkëlqim i butë në cep, jep thellësi si te aplikacionet profesionale */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 85% 5%, rgba(255, 255, 255, 0.28), transparent 45%),
    radial-gradient(circle at 10% 95%, rgba(255, 255, 255, 0.10), transparent 40%);
  pointer-events: none;
  z-index: 0;
}

/* --- SFONDET DINAMIKE (vendosen nga JS) --- */
body.bg-sunny  { background: linear-gradient(160deg, #1c7ed6 0%, #4dabf7 55%, #8fd3fe 100%); background-attachment: fixed; background-repeat: no-repeat; }
body.bg-cloudy { background: linear-gradient(160deg, #5b6b85 0%, #8796ad 100%); background-attachment: fixed; background-repeat: no-repeat; }
body.bg-rainy  { background: linear-gradient(160deg, #2b3a55 0%, #4b6a8f 100%); background-attachment: fixed; background-repeat: no-repeat; }
body.bg-snowy  { background: linear-gradient(160deg, #6f8fb8 0%, #a9c2e0 100%); background-attachment: fixed; background-repeat: no-repeat; }
body.bg-night  { background: linear-gradient(160deg, #0b1026 0%, #1b2a4e 55%, #2d4a6e 100%); background-attachment: fixed; background-repeat: no-repeat; }

/* --- KONTEJNERI KRYESOR --- */
.weather-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 980px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* --- HEADER --- */
.weather-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--glass-border);
}

.weather-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.weather-icon-header img {
  width: 48px;
  height: auto;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

/* --- NOSCRIPT --- */
.noscript-msg {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: linear-gradient(160deg, #1d6fdc 0%, #4fb3f6 100%);
  color: var(--text);
  font-weight: 600;
}

/* =========================================
   2. FORMULARI DHE KËRKIMI
   ========================================= */
.weather-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.input-group {
  display: flex;
  gap: 10px;
}

.input-group input {
  flex: 1;
  min-width: 0;
  padding: 15px 22px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 1rem;
  color: var(--text);
  outline: none;
  transition: all 0.25s ease;
}

.input-group input::placeholder {
  color: var(--text-soft);
}

.input-group input:focus {
  background: var(--glass-strong);
  border-color: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.18);
}

.input-group button[type="submit"] {
  padding: 15px 28px;
  border: none;
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}

.input-group button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.2);
}

/* --- BUTONI I LOKACIONIT --- */
.btn-location {
  background: var(--glass);
  color: #fff;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  cursor: pointer;
  transition: all 0.25s ease;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 54px;
  min-height: 50px;
  padding: 0 16px;
}

.btn-location:hover {
  background: var(--glass-strong);
  transform: translateY(-2px);
}

.input-group button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* --- SUGJERIMET (AUTOCOMPLETE) --- */
.suggestions-list {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
  list-style: none;
  margin-top: 8px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 100;
}

.suggestions-list li {
  padding: 14px 22px;
  cursor: pointer;
  font-size: 0.95rem;
  color: #2c3e50;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  transition: background 0.2s, color 0.2s;
}

.suggestions-list li:hover {
  background: #eef5ff;
  color: var(--accent);
  font-weight: 600;
}

.suggestions-list li:last-child {
  border-bottom: none;
}

/* --- LISTA ZBRITËSE --- */
.location-select {
  width: 100%;
  padding: 15px 22px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  font-size: 1rem;
  color: #2c3e50;
  cursor: pointer;
  outline: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

/* --- KËRKIMET E FUNDIT --- */
.recent-searches {
  flex-wrap: wrap;
  gap: 8px;
}

.recent-chip {
  padding: 8px 16px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.25s ease;
}

.recent-chip:hover {
  background: var(--glass-strong);
  transform: translateY(-2px);
}

/* =========================================
   3. LOADING DHE GABIMET
   ========================================= */
.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  text-align: center;
  animation: fadeIn 0.5s ease;
}

.loading-indicator p {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-soft);
}

/* --- SKELETON --- */
.skeleton-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 22px;
  width: 100%;
  margin-bottom: 18px;
}

.skeleton {
  min-height: 300px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  animation: skeletonPulse 1.4s ease-in-out infinite;
}

@keyframes skeletonPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* --- MESAZHI I GABIMIT --- */
.error-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px 18px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.95rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.error-banner i {
  flex-shrink: 0;
  color: #ffd166;
  font-size: 1.1rem;
}

.error-banner span {
  flex: 1;
  min-width: 0;
}

.retry-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 8px 18px;
  border: none;
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.25s ease;
}

.retry-btn:hover {
  transform: translateY(-2px);
}

/* =========================================
   4. REZULTATET (2 KOLONA)
   ========================================= */
.weather-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 22px;
  align-items: stretch;
  animation: fadeIn 0.6s ease-in-out;
  width: 100%;
}

.weather-grid > * {
  min-width: 0;
}

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

/* --- KARTA E MOTIT AKTUAL (HERO) --- */
.weather-result {
  height: 100%;
}

.weather-card {
  background: var(--glass);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  min-width: 0;
}

.weather-card h2 {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  word-break: break-word;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.date-time-display {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.date-time-display::first-letter {
  text-transform: uppercase;
}

/* --- BARA E VEGLAVE (përditësuar, refresh, °C/°F) --- */
.card-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 6px;
}

.updated-at {
  font-size: 0.8rem;
  color: var(--text-soft);
}

.tool-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  background: var(--glass);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.25s ease;
}

.tool-btn:hover {
  background: var(--glass-strong);
  transform: rotate(90deg);
}

.unit-toggle {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--glass);
}

.unit-toggle button {
  padding: 4px 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}

.unit-toggle button.active {
  background: #ffffff;
  color: var(--accent);
}

.weather-details {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

/* Temperatura e madhe majtas, ikona djathtas */
.temp-icon {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.temp-icon img {
  width: 110px;
  max-width: 40%;
  height: auto;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.2));
}

.temperature {
  font-size: 5.2rem;
  font-weight: 300;
  color: var(--text);
  line-height: 1;
  letter-spacing: -2px;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
}

/* --- DETAJET SI PLAKA (2 KOLONA) --- */
.other-info {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.other-info p {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text);
  margin: 0;
  min-width: 0;
}

/* Përshkrimi zë të gjithë gjerësinë */
.other-info #description {
  grid-column: 1 / -1;
  font-weight: 600;
  font-size: 0.95rem;
}

.other-info p i {
  width: 1.2em;
  text-align: center;
  flex-shrink: 0;
}

/* --- PARASHIKIMI 5-DITOR --- */
.forecast-container {
  background: var(--glass);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 26px 24px;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
}

.forecast-container h3 {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--glass-border);
  text-align: left;
}

.forecast-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
}

.forecast-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  transition: background 0.2s ease;
  min-width: 0;
}

.forecast-item:last-child {
  border-bottom: none;
}

.forecast-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

.forecast-item .day-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  min-width: 70px;
  text-align: left;
}

.forecast-item .day-name::first-letter {
  text-transform: uppercase;
}

.forecast-item .forecast-icon {
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.18));
}

/* Min / Max */
.forecast-item .forecast-temp {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  min-width: 90px;
  text-align: right;
}

.forecast-item .t-min {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-soft);
}

/* --- PARASHIKIMI SIPAS ORËVE --- */
.forecast-container.hourly-container {
  grid-column: 1 / -1;
  height: auto;
}

.hourly-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.4) transparent;
}

.hourly-item {
  flex: 0 0 auto;
  min-width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 10px;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
}

.hourly-time {
  font-size: 0.8rem;
  color: var(--text-soft);
}

.hourly-icon {
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.18));
}

.hourly-temp {
  font-size: 1.05rem;
  font-weight: 600;
}

.hourly-pop {
  font-size: 0.75rem;
  color: var(--text-soft);
  min-height: 1.1em;
}

/* --- FOOTER --- */
.weather-footer {
  margin-top: 30px;
  text-align: center;
  border-top: 1px solid var(--glass-border);
  padding-top: 20px;
}

.weather-footer p {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin-bottom: 14px;
}

.weather-footer .btn {
  background: transparent;
  border: none;
}

.weather-footer .btn a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 11px 24px;
  border-radius: 999px;
  transition: all 0.25s ease;
}

.weather-footer .btn a:hover {
  background: var(--glass-strong);
  transform: translateY(-2px);
}

/* --- QASSHMËRIA: fokusi i tastierës --- */
.tool-btn:focus-visible,
.unit-toggle button:focus-visible,
.recent-chip:focus-visible,
.retry-btn:focus-visible,
.weather-footer .btn a:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* =========================================
   5. ANIMACIONI I HYRJES (SPLASH SCREEN)
   ========================================= */
#splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: linear-gradient(160deg, #1d6fdc 0%, #4fb3f6 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

#splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
}

.splash-content {
  text-align: center;
  animation: popIn 0.6s ease-out forwards;
}

.splash-animation {
  position: relative;
  width: 150px;
  height: 150px;
  margin: 0 auto 20px;
}

.splash-animation .sun-anim {
  font-size: 5rem;
  color: #ffca28;
  position: absolute;
  top: 10px;
  left: 10px;
  animation: spinSun 4s linear infinite;
}

.splash-animation .cloud-anim {
  font-size: 6rem;
  color: #ffffff;
  position: absolute;
  bottom: 0;
  right: 0;
  filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.15));
  animation: floatCloud 2s ease-in-out infinite;
}

.splash-title {
  font-size: 2.4rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.splash-text {
  font-size: 1.05rem;
  color: var(--text-soft);
  font-weight: 400;
  animation: pulseText 1.5s infinite;
}

@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

@keyframes floatCloud {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

@keyframes pulseText {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* =========================================
   6. RESPONSIVE (gjithmonë në fund, që të fitojë mbi rregullat bazë)
   ========================================= */

/* Tableta dhe celularë (deri në 850px) */
@media (max-width: 850px) {
  .weather-grid,
  .skeleton-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .skeleton {
    min-height: 220px;
  }

  .weather-result,
  .weather-card,
  .forecast-container {
    height: auto;
  }
}

/* Celularë (deri në 600px) */
@media (max-width: 600px) {
  body {
    padding: 14px;
    align-items: flex-start;
  }

  .weather-header {
    margin-bottom: 16px;
    padding-bottom: 14px;
  }

  .weather-header h1 {
    font-size: 1.25rem;
  }

  .weather-icon-header img {
    width: 40px;
  }

  .weather-form {
    gap: 10px;
    margin-bottom: 18px;
  }

  /* Inputi sipër; "Kërko" dhe lokacioni bashkë poshtë */
  .input-group {
    flex-wrap: wrap;
    gap: 10px;
  }

  .input-group input {
    flex: 1 1 100%;
    width: 100%;
  }

  .input-group button[type="submit"] {
    flex: 1 1 0;
    min-height: 50px;
    padding: 14px 20px;
  }

  .btn-location {
    flex: 0 0 56px;
    padding: 0;
  }

  .error-banner {
    flex-wrap: wrap;
  }

  .weather-card {
    padding: 26px 18px;
    border-radius: 24px;
  }

  .weather-card h2 {
    font-size: 1.6rem;
  }

  .temperature {
    font-size: 4.2rem;
  }

  .temp-icon img {
    width: 90px;
  }

  .other-info {
    margin-top: 16px;
    gap: 8px;
  }

  .other-info p {
    padding: 11px 12px;
    font-size: 0.8rem;
  }

  .forecast-container {
    padding: 22px 16px;
    border-radius: 24px;
  }

  .forecast-item {
    padding: 8px 6px;
  }

  .forecast-item .day-name,
  .forecast-item .forecast-temp {
    min-width: 60px;
    font-size: 0.95rem;
  }

  .forecast-item .forecast-temp {
    min-width: 84px;
  }

  .weather-footer {
    margin-top: 24px;
  }
}

/* Celularë shumë të vegjël (deri në 380px) */
@media (max-width: 380px) {
  body {
    padding: 10px;
  }

  .other-info {
    grid-template-columns: minmax(0, 1fr);
  }

  .temperature {
    font-size: 3.6rem;
  }

  .splash-title {
    font-size: 2rem;
  }
}

/* Pajisje me prekje: pa efekte hover që ngecin */
@media (hover: none) {
  .forecast-item:hover {
    background: transparent;
  }
}

/* Përdoruesit që preferojnë më pak lëvizje (në fund, që të mbizotërojë) */
@media (prefers-reduced-motion: reduce) {
  .skeleton,
  .splash-content,
  .splash-animation .sun-anim,
  .splash-animation .cloud-anim,
  .splash-text,
  .loading-indicator,
  .weather-grid {
    animation: none;
  }
}