/* ================================
   도감 화면 스타일
   포켓몬 카드, 필터, 검색, 정렬
================================ */

.pokedex-container {
  max-width: 1000px;
  margin: 0 auto;
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.pokedex-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 16px 24px;
  background: rgba(18, 18, 18, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  backdrop-filter: blur(20px);
}

.pokedex-header h2 {
  color: white;
  font-size: 24px;
}

.pokedex-stats {
  color: var(--gold-primary);
  font-size: 18px;
  font-weight: 700;
}

.completion-rate {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  margin-left: 8px;
}

.pokedex-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.pokedex-tab {
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-normal);
  font-family: inherit;
}

.pokedex-tab:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.pokedex-tab.active {
  background: linear-gradient(135deg, var(--pokemon-red), #ff5a36);
  color: white;
}

/* 세대별 필터링 체크박스 */
.generation-filter-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  flex-wrap: wrap;
}

.generation-filter-controls .filter-label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.generation-checkboxes {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.generation-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.generation-checkbox:hover {
  background: rgba(255, 255, 255, 0.2);
}

.generation-checkbox input[type="checkbox"] {
  display: none;
}

.generation-checkbox .checkbox-label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 500;
  position: relative;
  padding-left: 22px;
}

.generation-checkbox .checkbox-label::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 4px;
  background: transparent;
  transition: all 0.2s ease;
}

.generation-checkbox .checkbox-label::after {
  content: '✓';
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: white;
  opacity: 0;
  transition: all 0.2s ease;
}

.generation-checkbox input[type="checkbox"]:checked+.checkbox-label::before {
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-color: #667eea;
}

.generation-checkbox input[type="checkbox"]:checked+.checkbox-label::after {
  opacity: 1;
}

.generation-checkbox input[type="checkbox"]:checked+.checkbox-label {
  color: white;
}

/* 도감 정렬 버튼 */
.pokedex-sort-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
}

.pokedex-sort-controls .sort-label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 500;
  margin-right: 4px;
}

.pokedex-sort-btn {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.pokedex-sort-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.pokedex-sort-btn.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.pokedex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  padding: 4px;
}

/* 도감 탭(전체/내 포켓몬/폼)에서는 카드가 그리드 셀 너비를 강제로 따르도록 고정 */
.pokedex-grid > .pokemon-card {
  width: 100%;
  min-width: 0;
  max-width: none;
  justify-self: stretch;
}

/* 내 포켓몬 카드는 성급/IV 영역이 있어 고정 비율 대신 최소 높이를 보장 */
.pokedex-grid > .my-pokemon-card {
  aspect-ratio: auto;
  min-height: 180px;
}

.pokedex-grid > .my-pokemon-card .pokemon-card-stats .star-rank {
  color: #ffd54f;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* 도감 프리미엄 필터링 & 검색 시스템 */
.pokedex-filter-controls {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 0 0 30px 0;
  padding: 28px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.2));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.rarity-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.rarity-filters .filter-btn {
  position: relative;
  padding: 10px 22px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(30, 30, 40, 0.6);
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  letter-spacing: 0.5px;
}

.rarity-filters .filter-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.rarity-filters .filter-btn.active {
  background: var(--btn-bg);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 20px var(--btn-glow), inset 0 0 10px rgba(255, 255, 255, 0.2);
  transform: translateY(-1px) scale(1.02);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* 등급별 테마 변수 정의 */
.filter-btn[data-filter="all"] {
  --btn-bg: linear-gradient(135deg, #718096, #2d3748);
  --btn-glow: rgba(113, 128, 150, 0.5);
}

.filter-btn[data-filter="common"] {
  --btn-bg: linear-gradient(135deg, #a0aec0, #718096);
  --btn-glow: rgba(160, 174, 192, 0.5);
}

.filter-btn[data-filter="uncommon"] {
  --btn-bg: linear-gradient(135deg, #48bb78, #2f855a);
  --btn-glow: rgba(72, 187, 120, 0.5);
}

.filter-btn[data-filter="rare"] {
  --btn-bg: linear-gradient(135deg, #4299e1, #2b6cb0);
  --btn-glow: rgba(66, 153, 225, 0.6);
}

.filter-btn[data-filter="epic"] {
  --btn-bg: linear-gradient(135deg, #9f7aea, #6b46c1);
  --btn-glow: rgba(159, 122, 234, 0.6);
}

.filter-btn[data-filter="legendary"] {
  --btn-bg: linear-gradient(135deg, #ed8936, #c05621);
  --btn-glow: rgba(237, 137, 54, 0.6);
}

.filter-btn[data-filter="mythical"] {
  --btn-bg: linear-gradient(135deg, #ed64a6, #b83280);
  --btn-glow: rgba(237, 100, 166, 0.6);
}

/* 타입 + 이름 검색 한 줄 */
.pokedex-type-and-search-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.pokedex-type-and-search-row .filter-label {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.pokedex-type-select {
  min-width: 140px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
.pokedex-type-select:hover,
.pokedex-type-select:focus {
  border-color: rgba(255, 255, 255, 0.3);
  outline: none;
}

/* 도감 검색창: 타입 셀렉트 옆 */
.search-filter.pokedex-search-inline {
  position: relative;
  min-width: 420px;
  width: 420px;
  max-width: 520px;
  margin: 0;
}
.search-filter.pokedex-search-inline input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-family: 'Noto Sans KR', sans-serif;
  transition: all 0.3s ease;
}
.search-filter.pokedex-search-inline::after {
  left: 12px;
  font-size: 14px;
}

/* 검색창 디자인 개선 (다른 페이지용 전체 너비) */
.pokedex-filter-controls > .search-filter:not(.pokedex-search-inline) {
  position: relative;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}
.search-filter input {
  width: 100%;
  padding: 16px 24px 16px 52px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  color: #fff;
  font-size: 16px;
  font-family: 'Noto Sans KR', sans-serif;
  transition: all 0.3s ease;
}
.pokedex-search-inline input {
  padding: 10px 14px 10px 36px;
  border-radius: 10px;
  font-size: 14px;
}

.search-filter input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.search-filter::after {
  content: '🔍';
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: rgba(255, 255, 255, 0.4);
  pointer-events: none;
  transition: all 0.3s ease;
}

.search-filter:focus-within::after {
  color: var(--pokemon-yellow);
  transform: translateY(-50%) scale(1.1);
}

.search-filter input:focus {
  outline: none;
  background: rgba(0, 0, 0, 0.5);
  border-color: var(--pokemon-yellow);
  box-shadow: 0 0 0 4px rgba(255, 203, 5, 0.15);
}

/* 정렬 컨트롤도 스타일 일치화 */
.pokedex-sort-controls {
  border-radius: 15px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

.pokedex-sort-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.6);
  padding: 6px 16px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.pokedex-sort-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.pokedex-sort-btn.active {
  background: var(--pokemon-yellow);
  color: var(--pokemon-blue);
  border-color: var(--pokemon-yellow);
  font-weight: 700;
  box-shadow: 0 0 15px rgba(255, 203, 5, 0.3);
}

/* 미디어 쿼리 */
@media (max-width: 768px) {
  .pokedex-container {
    padding: 12px;
  }

  .pokedex-header {
    flex-direction: column;
    gap: 12px;
    text-align: center;
    padding: 12px 16px;
  }

  .pokedex-header h2 {
    font-size: 20px;
  }

  .pokedex-stats {
    font-size: 16px;
  }

  .pokedex-tabs {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .pokedex-tab {
    padding: 10px 16px;
    font-size: 13px;
  }

  .pokedex-filter-controls {
    padding: 16px;
    gap: 16px;
  }

  .pokedex-type-and-search-row {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .pokedex-type-select {
    min-width: 120px;
    flex: 1 1 auto;
    max-width: 160px;
  }

  .search-filter.pokedex-search-inline {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    flex: 1 1 200px;
  }

  .generation-filter-controls {
    padding: 10px 12px;
  }

  .generation-checkbox .checkbox-label {
    font-size: 12px;
  }

  .rarity-filters .filter-btn {
    padding: 8px 14px;
    font-size: 12px;
  }

  .pokedex-sort-controls {
    flex-wrap: wrap;
    justify-content: center;
    padding: 10px 12px;
    gap: 8px;
  }

  .pokedex-sort-btn {
    padding: 6px 12px;
    font-size: 12px;
  }

  .pokedex-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .pokedex-container {
    padding: 10px;
  }

  .pokedex-filter-controls {
    padding: 12px;
  }

  .pokedex-type-and-search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .pokedex-type-and-search-row .filter-label {
    text-align: center;
  }

  .pokedex-type-select {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  .search-filter.pokedex-search-inline {
    width: 100%;
  }

  .pokedex-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
}

@media (max-width: 360px) {
  .pokedex-header h2 {
    font-size: 18px;
  }

  .pokedex-tab {
    padding: 8px 12px;
    font-size: 12px;
  }

  .rarity-filters .filter-btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  .pokedex-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
}
