/* ==========================================================================
   Éditions ATP — Thème Enfant Header CSS (Correctifs PC & Mobile)
   ========================================================================== */

:root {
  --atp-hd-yellow-accent: var(--atp-yellow, #f59e0b);
  --atp-hd-yellow-bright: #fbbf24;
  --atp-hd-border-dark: #000000;
  --atp-hd-text-dark: #000000;
}

/* ── Top Bar ── */
.top-bar {
  background-color: #000000;
  color: #ffffff;
  padding: 8px 24px;
  font-size: 0.85rem;
  border-bottom: 1px solid #1a1a1a;
}

.top-bar-wrapper {
  max-width: var(--atp-container-max-width, 1150px);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.top-email {
  color: var(--atp-hd-yellow-accent);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.top-email:hover {
  color: var(--atp-hd-yellow-bright);
}

.top-email svg {
  flex-shrink: 0;
}

.top-right-links {
  display: flex;
  align-items: center;
  gap: 14px;
}

.top-right-links a {
  color: #ffffff;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 400;
  transition: color 0.2s ease;
}

.top-right-links a:hover {
  color: var(--atp-hd-yellow-accent);
}

.top-right-links .divider {
  color: #94a3b8;
  font-size: 0.8rem;
}

/* ── Main Header ── */
.main-header {
  background-color: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.header-wrapper {
  max-width: var(--atp-container-max-width, 1150px);
  margin: 0 auto;
  padding: 12px 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  position: relative;
}

.header-nav {
  justify-self: start;
}

.header-logo,
.custom-logo-link {
  justify-self: center;
}

.header-actions {
  justify-self: end;
}

/* ── Navigation (Desktop) ── */
.header-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.header-nav ul,
.header-nav .menu,
.header-nav .header-nav-list {
  display: flex;
  align-items: center;
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-item,
.header-nav li {
  position: relative;
  list-style: none;
}

.nav-link,
.header-nav a {
  color: #000000;
  text-decoration: none;
  font-weight: 600 ;
  font-size: 0.88rem;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  transition: color 0.2s ease;
  font-family: inherit !important;
}

.nav-link:hover,
.header-nav a:hover {
  color: var(--atp-hd-yellow-accent);
}

.nav-arrow {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.dropdown:hover .nav-arrow,
.menu-item-has-children:hover > a .nav-arrow {
  transform: rotate(180deg);
}

/* Dropdown Menu (Desktop) */
.dropdown-menu,
.header-nav .sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background-color: #ffffff;
  min-width: 260px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.12);
  border-radius: 12px;
  padding: 10px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s ease;
  border: 1px solid #f1f5f9;
  z-index: 1200;
  list-style: none;
  margin: 0;
}

.dropdown:hover .dropdown-menu,
.menu-item-has-children:hover > .sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-menu a,
.header-nav .sub-menu a {
  display: block;
  padding: 10px 20px;
  color: #334155;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  text-transform: none;
  transition: background-color 0.2s, color 0.2s;
  font-family: inherit !important;
}

.dropdown-menu a:hover,
.header-nav .sub-menu a:hover {
  background-color: #fefce8;
  color: #000000;
}

/* ── Logo Dynamique ── */
.header-logo,
.custom-logo-link {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  cursor: pointer;
  margin: 0 10px;
  flex-shrink: 0;
}

.custom-logo {
  max-height: 54px;
  width: auto;
  height: auto;
  display: block;
}

.logo-badge {
  width: 54px;
  height: 54px;
  background-color: var(--atp-hd-yellow-accent);
  border: 2px solid #000000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  transition: transform 0.2s ease;
  color: #000000;
}

.header-logo:hover .logo-badge {
  transform: scale(1.05);
}

.logo-underline {
  width: 44px;
  height: 6px;
  background-color: var(--atp-hd-yellow-accent);
  border: 2px solid #000000;
  border-top: none;
  border-radius: 0 0 10px 10px;
  margin-top: 3px;
}

/* ── Actions Header : Recherche & Mon Compte ── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-container {
  position: relative;
  width: 240px;
  margin: 0;
}

.search-input {
  width: 100%;
  padding: 10px 42px 10px 16px;
  border-radius: var(--atp-radius, 8px);
  border: 1.5px solid #cbd5e1;
  font-size: 0.88rem;
  outline: none;
  background-color: #ffffff;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit !important;
}

.search-input:focus {
  border-color: var(--atp-hd-yellow-accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.search-input::placeholder {
  color: #94a3b8;
}

.search-submit-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #000000;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.2s, background-color 0.2s;
}

.search-submit-btn:hover {
  color: var(--atp-hd-yellow-accent);
  background-color: rgba(245, 158, 11, 0.12);
}

.btn-login {
  background-color: var(--atp-hd-yellow-accent);
  color: #000000;
  border: 1.5px solid #000000;
  border-radius: var(--atp-radius, 8px);
  padding: 10px 20px;
  font-weight: 600 ;
  font-size: 0.82rem;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  text-decoration: none;
  font-family: inherit !important;
}

.btn-login:hover {
  background-color: var(--atp-hd-yellow-bright);
  transform: translateY(-1px);
  color: #000000;
}

.btn-login svg {
  flex-shrink: 0;
}

/* ── Elements Mobiles Cachés sur Desktop ── */
.mobile-search-wrapper,
.mobile-topbar-links {
  display: none;
}

.mobile-menu-btn {
  display: none !important;
  background: none;
  border: none;
  color: #000000;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background-color 0.2s;
}

.mobile-menu-btn:hover {
  background-color: #f1f5f9;
}

.mobile-menu-btn .icon-close {
  display: none;
}

/* ── RÈGLES DESKTOP (>= 992px) ── */
@media (min-width: 992px) {
  .header-nav {
    display: flex !important;
    flex-direction: row !important;
    position: static !important;
    box-shadow: none !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
  }

  .mobile-menu-btn {
    display: none !important;
  }
}

/* ── RÈGLES TABLETTES ET MOBILES (< 991px) ── */
@media (max-width: 991px) {
  .header-wrapper {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    padding: 10px 16px !important;
  }

  .header-logo,
  .custom-logo-link {
    grid-column: auto !important;
    justify-self: flex-start !important;
    margin: 0 !important;
  }

  .header-actions {
    grid-column: auto !important;
    justify-self: flex-end !important;
    gap: 10px !important;
  }

  .search-container--desktop {
    display: none !important;
  }

  .header-nav {
    display: none;
  }

  /* Tiroir Mobile Ouvert */
  .header-nav.is-mobile-open {
    display: flex !important;
    flex-direction: column !important;
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background-color: #ffffff !important;
    padding: 20px 24px 28px !important;
    border-bottom: 2px solid var(--atp-hd-yellow-accent) !important;
    box-shadow: 0 16px 32px rgba(0,0,0,0.15) !important;
    z-index: 1500 !important;
    gap: 20px !important;
    max-height: 85vh;
    overflow-y: auto;
  }

  /* Recherche dans le Tiroir Mobile */
  .mobile-search-wrapper {
    display: block !important;
    width: 100%;
  }

  .search-container--mobile {
    width: 100% !important;
    max-width: 100% !important;
  }

  .header-nav.is-mobile-open ul,
  .header-nav.is-mobile-open .menu,
  .header-nav.is-mobile-open .header-nav-list {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 14px !important;
    width: 100% !important;
  }

  .header-nav.is-mobile-open .nav-link,
  .header-nav.is-mobile-open a {
    width: 100%;
    justify-content: space-between;
    font-size: 0.95rem;
    padding: 6px 0;
  }

  .header-nav.is-mobile-open .dropdown-menu,
  .header-nav.is-mobile-open .sub-menu {
    position: static !important;
    display: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    box-shadow: none !important;
    border: none !important;
    padding: 6px 0 6px 16px !important;
    min-width: 100% !important;
    background-color: #f8fafc !important;
    border-left: 3px solid var(--atp-hd-yellow-accent) !important;
    border-radius: 0 8px 8px 0 !important;
  }

  .header-nav.is-mobile-open .dropdown.is-open > .dropdown-menu,
  .header-nav.is-mobile-open .menu-item-has-children.is-open > .sub-menu {
    display: block !important;
  }

  .header-nav.is-mobile-open .dropdown.is-open .nav-arrow,
  .header-nav.is-mobile-open .menu-item-has-children.is-open > a .nav-arrow {
    transform: rotate(180deg);
  }

  /* Liens TopBar intégrés en bas du tiroir mobile */
  .mobile-topbar-links {
    display: flex !important;
    flex-direction: column;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
    width: 100%;
  }

  .mobile-topbar-links a {
    color: #475569;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    text-transform: none;
  }

  .mobile-topbar-links a:hover {
    color: var(--atp-hd-yellow-accent);
  }

  /* Bouton Hamburger */
  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  /* Inversion d'icône quand le menu est ouvert */
  .header-nav.is-mobile-open ~ .header-actions .mobile-menu-btn .icon-open,
  .mobile-menu-btn[aria-expanded="true"] .icon-open {
    display: none !important;
  }

  .header-nav.is-mobile-open ~ .header-actions .mobile-menu-btn .icon-close,
  .mobile-menu-btn[aria-expanded="true"] .icon-close {
    display: block !important;
  }
}

/* ── RÈGLES SMARTPHONES (< 768px) ── */
@media (max-width: 768px) {
  /* Masquer la TopBar sur smartphone pour maximiser l'espace écran */
  .top-bar {
    display: none !important;
  }

  .btn-login span {
    display: none; /* Conserver uniquement l'icône sur petit écran */
  }

  .btn-login {
    padding: 10px 12px;
  }
}

@media (max-width: 768px) {
  /* Smart-Scroll Header Mobile */
  .main-header {
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s ease !important;
    will-change: transform;
  }

  .main-header.is-scrolled-down {
    transform: translateY(-100%) !important;
    box-shadow: none !important;
  }
}

/* ── MODAL DE RECHERCHE AJAX INSTANTANÉE MOBILE ── */
.atp-search-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
}

.atp-search-modal.is-open {
  display: block;
  animation: atpSearchModalFadeIn 0.2s ease;
}

@keyframes atpSearchModalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.atp-search-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
}

.atp-search-modal__dialog {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  padding: 16px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.atp-search-modal__header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.atp-search-modal__form {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.atp-search-modal__icon {
  position: absolute;
  left: 14px;
  color: #64748b;
  pointer-events: none;
}

.atp-search-modal__input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border-radius: 50px;
  border: 1.5px solid #cbd5e1;
  font-size: 14.5px;
  font-weight: 500;
  outline: none;
  background: #f8fafc;
  color: #0f172a;
}

.atp-search-modal__input:focus {
  border-color: #f59e0b;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.atp-search-modal__close {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #334155;
  cursor: pointer;
  flex-shrink: 0;
}

.atp-search-modal__results {
  margin-top: 16px;
  overflow-y: auto;
  max-height: 60vh;
}

.atp-search-modal__hint {
  font-size: 13.5px;
  color: #64748b;
  text-align: center;
  padding: 20px 0;
}

.atp-search-result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-bottom: 1px solid #f1f5f9;
  text-decoration: none;
  color: inherit;
  border-radius: 10px;
  transition: background 0.2s;
}

.atp-search-result-item:hover {
  background: #f8fafc;
}

.atp-search-result-img {
  width: 44px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
}

.atp-search-result-title {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  margin: 0 0 4px;
}

.atp-search-result-price {
  font-size: 13px;
  font-weight: 600;
  color: #b45309;
}
