/* =============================================================================
 * PAGE-HEADERS.CSS - En-têtes de page visibles et modernes
 *
 * Classes : page-header--league | page-header--combat | page-header--pokedex
 * =============================================================================
 */

/* Moteur de recherche Pokémon - à gauche du header, sur toutes les pages */
.pokemon-header-search-wrap {
  grid-column: 1;
  flex-shrink: 0;
  position: relative;
  margin-right: 0;
  z-index: 1;
}

/* Mobile : recherche dans le menu burger, masquer du header */
@media (max-width: 992px) {
  .main-header .pokemon-header-search-wrap {
    display: none !important;
  }
}

.pokemon-header-search-wrap > input,
.pokemon-header-search-wrap .pokemon-header-search-input,
#pokemon-header-search {
  width: 220px;
  max-width: 280px;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  background-color: rgba(30, 41, 59, 0.95) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.75rem center;
  color: #f1f5f9 !important;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

#pokemon-header-search::placeholder {
  color: #94a3b8 !important;
}

#pokemon-header-search:focus,
.pokemon-header-search-input:focus {
  outline: none;
  border-color: var(--primary-color, #4d5bff);
  box-shadow: 0 0 0 2px rgba(77, 91, 255, 0.3);
  background-color: rgba(30, 41, 59, 1) !important;
}

.pokemon-header-search-results {
  position: fixed;
  top: auto;
  left: auto;
  width: 380px;
  min-width: 380px;
  margin-top: 4px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--dark-bg-secondary, #1e293b);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: none;
}

.pokemon-header-search-results[aria-hidden="false"] {
  display: block;
}

.pokemon-header-search-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  color: var(--text-light, #f1f5f9);
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.15s;
}

.pokemon-header-search-result-item:last-child {
  border-bottom: none;
}

.pokemon-header-search-result-item:hover,
.pokemon-header-search-result-item:focus {
  background: rgba(77, 91, 255, 0.15);
  outline: none;
}

.pokemon-header-search-result-item img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.pokemon-header-search-result-item .result-name {
  flex: 1;
  min-width: 0;
}

.pokemon-header-search-result-item .result-id {
  color: var(--text-muted, #94a3b8);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.pokemon-header-search-result-item .btn-add-compare-result {
  flex-shrink: 0;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 50%, #4b5563 100%);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.pokemon-header-search-result-item .btn-add-compare-result:hover:not(:disabled) {
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 50%, #6b7280 100%);
}

.pokemon-header-search-result-item .btn-add-compare-result.added,
.pokemon-header-search-result-item .btn-add-compare-result:disabled {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  cursor: default;
}

.main-header .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* =============================================================================
 * HEADER BASE
 * =============================================================================
 */

.main-header {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 24px 34px;
  background: var(--dark-bg-secondary);
  border-bottom: 2px solid var(--border-color);
  min-height: var(--header-height);
}

.main-header h1 {
  grid-column: 1 / -1;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: calc(100% - 280px);
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-light);
  margin: 0;
  padding: 0 1rem;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 1;
  box-sizing: border-box;
  pointer-events: none;
}

/* Accent bar à gauche - Arène (défaut) */
.main-header::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--primary-color);
}

/* Ligue - Championnats */
.main-header.page-header--league::before {
  background: linear-gradient(180deg, #fbbf24, #f59e0b);
}

.main-header.page-header--league h1 {
  color: #fef3c7;
}

/* Combat - Duels */
.main-header.page-header--combat::before {
  background: linear-gradient(180deg, #ef4444, #3b82f6);
}

.main-header.page-header--combat h1 {
  color: #fecaca;
}

/* Pokédex */
.main-header.page-header--pokedex::before {
  background: linear-gradient(180deg, #22c55e, #16a34a);
}

.main-header.page-header--pokedex h1 {
  color: #bbf7d0;
}

/* Comparaison */
.main-header.page-header--comparaison::before {
  background: linear-gradient(180deg, #6366f1, #4f46e5);
}

.main-header.page-header--comparaison h1 {
  color: #c7d2fe;
}

/* =============================================================================
 * HEADER CHARACTERS - Unifié : 50% haut (buste+tête), bas touchant la ligne
 * Toutes les pages : pokedex, pokemon, duels, championnat
 * ============================================================================= */
.main-header.page-header-with-character,
.main-header.page-header--pokemon-detail {
  overflow: hidden;
  min-height: 85px;
  padding-bottom: 0;
}

/* Conteneur personnage : positionné en bas à droite, bas = ligne du header */
.header-character-wrap,
.header-prof-chen-wrap {
  position: absolute;
  right: 34px;
  bottom: 0;
  width: 90px;
  height: 75px;
  overflow: hidden;
  z-index: 1;
}

.header-character-img,
.header-prof-chen-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0%;
  display: block;
  vertical-align: bottom;
}

.header-character-img:not([src]),
.header-character-img[src=""],
.header-prof-chen-img:not([src]),
.header-prof-chen-img[src=""] {
  display: none;
}

.header-character-wrap:has(.header-character-img:not([src])),
.header-character-wrap:has(.header-character-img[src=""]),
.header-prof-chen-wrap:has(.header-prof-chen-img:not([src])),
.header-prof-chen-wrap:has(.header-prof-chen-img[src=""]) {
  display: none;
}

/* Duo Red + Bleu */
.header-characters-duo {
  position: absolute;
  right: 34px;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 75px;
  overflow: hidden;
  z-index: 1;
}

.header-characters-duo .header-character-wrap {
  position: relative;
  right: auto;
  bottom: auto;
  width: 68px;
  height: 75px;
}

.header-characters-duo .header-character-img {
  object-fit: cover;
  object-position: 50% 0%;
}

@media (max-width: 768px) {
  .main-header.page-header-with-character {
    min-height: 75px;
  }

  .header-character-wrap,
  .header-prof-chen-wrap {
    right: 20px;
    width: 75px;
    height: 65px;
  }

  .header-characters-duo {
    right: 20px;
    height: 65px;
  }

  .header-characters-duo .header-character-wrap {
    width: 55px;
    height: 65px;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .main-header {
    padding: 16px 20px 16px 50px;
    gap: 0.75rem;
  }

  .main-header.page-header-with-character,
  .main-header.page-header--pokemon-detail {
    padding-bottom: 0;
  }
  
  .main-header h1 {
    font-size: 1.35rem;
    letter-spacing: 0.04em;
    white-space: normal;
    line-height: 1.2;
  }
}

@media (max-width: 480px) {
  .main-header h1 {
    font-size: 1.1rem;
    letter-spacing: 0.03em;
  }
}
