/* =========================================================
   DA Modul 8 – Pokemon Card Display
   styles.css (cleaned)
   ========================================================= */

/* =========================
   1) Header / Navigation
   ========================= */

header {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
  height: 250px;
}

#poke-btn {
  width: 43.8%;
  cursor: pointer;
}

#poke-btn:hover {
  animation: tab-wobble 220ms ease-out;
  opacity: 1;
}

#last-btn,
#next-btn {
  width: 10.6%;
  cursor: pointer;
}

#last-btn:hover,
#next-btn:hover {  
  animation: tab-wobble 220ms ease-out;
  opacity: 1;
}

#last-btn:hover {
  transform: translateY(-2px);
}

#next-btn.disabled,
#last-btn.disabled {
  opacity: 0.4;
  cursor: default;
}

#next-btn.disabled:hover,
#last-btn.disabled:hover {
  width: 10.6%;
  transform: none;
}

/* =========================
   2) Search Bar
   ========================= */

.search-wrap {
  position: relative;
  width: 60%;
  max-width: 420px;
  min-width: 240px;
  margin: 2% auto;
  z-index: 10;
}

.search-input {
  width: 100%;
  height: 32px;
  padding: 2%;
  font-size: 1rem;
  font-weight: 600;
  background: var(--yellow-main);
  color: var(--blue-dark);
  outline: 0.2em solid var(--white-soft);
  border: 0.3em solid var(--blue-mid);
  border-radius: 1em 1em 0 0;
  outline-offset: 0;
  transition:
    box-shadow 120ms ease,
    transform 120ms ease;
}

.search-input::placeholder {
  color: var(--blue-dark);
  opacity: 0.6;
}

.search-input:focus {
  border-color: var(--white-soft);
  outline-color: var(--blue-mid);
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  outline: 0.2em solid var(--white-soft);
  border: 0.3em solid var(--blue-mid);
  border-top: none;
  border-radius: 0 0 1em 1em;
  background: var(--yellow-main);
  z-index: 100;
}

.search-input.dropdown-open {
  border-bottom: none;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.autocomplete-dropdown ul {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

.autocomplete-dropdown li {
  padding: 6px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--white-soft);
}

.autocomplete-dropdown li:hover {
  background: var(--yellow-light);
}

.autocomplete-dropdown li:last-child {
  border-bottom: none;
}

#search-feedback {
  margin-top: 6px;
  padding: 6px 10px;
  font-size: 0.9rem;
  color: var(--blue-mid);
  border-radius: 0 0 1em 1em;
  background: var(--white-soft);
  font-weight: 600;
  text-align: center;
  border: 0.3em solid var(--blue-mid);
  width: 60%;
  margin: auto;
}

.autocomplete-dropdown li.is-active {
  background: var(--yellow-light);
  font-weight: 700;
  color: var(--blue-dark);
}

/* =========================
   3) Main Grid (Cards)
   ========================= */

#pokemon-container {
  display: grid;
  grid-template-columns: repeat(5, 18%);
  gap: 16px;
  padding: 16px;
}

/* =========================
   4) Loading Spinner
   ========================= */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.5);
}

.loading-overlay.active {
  display: flex;
}

.spinner {
  position: relative;
  width: 160px;
  height: 160px;
  border: 4px solid #ccc;
  border-radius: 50%;
  background: linear-gradient(to bottom, red 50%, white 50%);
  animation: spin 6s linear infinite;
}

.spinner .line {
  position: absolute;
  top: 0;
  left: 50%;
  width: 4px;
  height: 100%;
  transform: translateX(-50%);
  border-radius: 2px;
  background: #ffd400;
  color: var(--blue-mid);
  font-size: large;
  font-weight: 700;
  text-align: center;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================
   5) Responsive
   ========================= */

@media (max-width: 800px) {
  #pokemon-container {
    grid-template-columns: repeat(2, 38%);
    justify-content: center;
  }

  .pokemon-box {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .dialog-img {
    max-width: 180px;
    width: 60%;
    padding-top: 0;
  }

  .poke-info {
    width: 100%;
    padding: 20px;
  }
}

@media (max-width: 420px) {
  dialog#lightbox {
    width: 96vw;
    max-height: 92vh;
  }

  #dialog-header {
    padding: 12px 14px;
  }

  #dialog-title {
    font-size: 24px;
  }

  #dialog-tabs {
    padding: 10px 14px;
    flex-wrap: wrap;
  }

  #dialog-body {
    padding: 12px 14px;
    overflow-y: auto;
  }

  .poke-menu {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    height: auto;
  }

  .pokemon-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .test-dialog {
    height: auto;
  }
}

@media (max-width: 400px) {
  #pokemon-container {
    grid-template-columns: 1fr;
  }
}
