/**
 * Header Styles - BEM Methodology
 * Estudio Defensor
 */

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

.header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: #f5f5f5;
  transition: box-shadow 0.3s ease, backdrop-filter 0.3s ease;
}

.header--scrolled {
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(10px);
}

/* Overlay para menú móvil */
.header__overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.header__overlay--visible {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

.header__container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

/* ============================================
   LOGO
   ============================================ */

.header__logo {
  flex-shrink: 0;
  position: relative;
  z-index: 1003;
  transition: transform 0.3s ease;
}

.header__logo-link {
  display: block;
  text-decoration: none;
  transition: transform 0.3s ease, filter 0.3s ease;
}

.header__logo-link:hover {
  transform: scale(1.05);
  filter: brightness(1.1);
}

.header__logo-image {
  display: block;
  height: 40px;
  width: auto;
}

/* ============================================
   BOTÓN MENÚ MÓVIL
   ============================================ */

.header__menu-toggle {
  display: none;
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  z-index: 1001;
  transition: transform 0.3s ease;
}

.header__menu-toggle:hover {
  transform: scale(1.1);
}

.header__menu-icon {
  display: block;
  fill: currentColor;
}

/* ============================================
   NAVEGACIÓN
   ============================================ */

.header__nav {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

.header__nav-close {
  display: none;
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  z-index: 1002;
}

.header__nav-close svg {
  display: block;
  fill: currentColor;
}

.header__nav-list {
  display: flex;
  align-items: center;
  gap: 2rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.header__nav-item {
  margin: 0;
  padding: 0;
}

.header__nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  color: #333;
  text-decoration: none;
  font-weight: 400;
  transition: color 0.3s ease;
}

.header__nav-icon {
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.header__nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: #FF6600;
  transition: width 0.3s ease;
}

.header__nav-link:hover {
  color: #FF6600;
}

.header__nav-link:hover::after {
  width: 100%;
}

.header__nav-link[aria-current="page"] {
  color: #FF6600;
  font-weight: 500;
}

/* ============================================
   RESPONSIVIDAD - MÓVIL
   ============================================ */

@media (max-width: 768px) {
  .header__container {
    padding: 1rem 1.5rem;
  }

  .header__logo-image {
    height: 35px;
  }

  /* Mostrar botón de menú */
  .header__menu-toggle {
    display: block;
    color: #333;
  }

  /* Ocultar botón cuando el menú está abierto */
  .header__nav--open + .header__menu-toggle {
    opacity: 0;
    pointer-events: none;
  }

  /* Navegación móvil */
  .header__nav {
    position: fixed;
    top: 0;
    right: -100%;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height para móviles */
    width: 75%;
    max-width: 320px;
    background-color: #f5f5f5;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    transition: right 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 5rem 1.5rem 1.5rem;
    z-index: 1002;
    display: flex;
    flex-direction: column;
    border-top-left-radius: 24px;
    border-bottom-left-radius: 24px;
  }

  .header__nav--open {
    right: 0;
  }

  /* Mostrar botón cerrar */
  .header__nav-close {
    display: block;
    color: #333;
    transition: color 0.3s ease, transform 0.3s ease;
  }

  .header__nav-close:hover {
    color: #FF6600;
    transform: rotate(90deg);
  }

  /* Lista vertical */
  .header__nav-list {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 2rem;
  }

  .header__nav-item {
    width: 100%;
    animation: slideInRight 0.4s ease-out backwards;
  }

  .header__nav-item:nth-child(1) { animation-delay: 0.1s; }
  .header__nav-item:nth-child(2) { animation-delay: 0.15s; }
  .header__nav-item:nth-child(3) { animation-delay: 0.2s; }
  .header__nav-item:nth-child(4) { animation-delay: 0.25s; }
  .header__nav-item:nth-child(5) { animation-delay: 0.3s; }

  .header__nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    font-size: 1.125rem;
    color: #333;
    font-weight: 500;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
  }

  .header__nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background-color: #FF6600;
    transform: scaleY(0);
    transition: transform 0.3s ease;
  }

  .header__nav-link:hover::before,
  .header__nav-link[aria-current="page"]::before {
    transform: scaleY(1);
  }

  .header__nav-icon {
    flex-shrink: 0;
    transition: transform 0.3s ease;
  }

  .header__nav-link:hover {
    color: #FF6600;
    background-color: rgba(255, 102, 0, 0.08);
    transform: translateX(8px);
    box-shadow: 0 4px 12px rgba(255, 102, 0, 0.15);
  }

  .header__nav-link:hover .header__nav-icon {
    transform: scale(1.2) rotate(5deg);
  }

  .header__nav-link::after {
    display: none;
  }

  .header__nav-link[aria-current="page"] {
    color: #FF6600;
    font-weight: 600;
    background-color: rgba(255, 102, 0, 0.12);
  }

  /* Footer del menú móvil - visible solo en móvil */
  .header__nav-footer {
    display: block !important;
    margin-top: auto;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.6s ease-out 0.4s backwards;
  }

  .header__nav-contact {
    padding: 1rem;
    background: linear-gradient(135deg, rgba(255, 102, 0, 0.08) 0%, rgba(255, 102, 0, 0.03) 100%);
    border-radius: 12px;
    border: 1px solid rgba(255, 102, 0, 0.2);
  }

  .header__nav-contact-label {
    margin: 0 0 0.5rem 0;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666;
  }

  .header__nav-contact-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #FF6600;
    text-decoration: none;
    transition: all 0.3s ease;
  }

  .header__nav-contact-link:hover {
    gap: 0.75rem;
    transform: scale(1.05);
  }

  .header__nav-contact-link svg {
    flex-shrink: 0;
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 480px) {
  .header__container {
    padding: 0.75rem 1rem;
  }

  .header__logo-image {
    height: 30px;
  }

  .header__nav {
    width: 85%;
  }
}

/* ============================================
   ACCESIBILIDAD
   ============================================ */

.header__logo-link:focus-visible,
.header__nav-link:focus-visible,
.header__menu-toggle:focus-visible,
.header__nav-close:focus-visible {
  outline: 3px solid rgba(255, 102, 0, 0.5);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================
   ANIMACIONES
   ============================================ */

/* Respetar preferencias de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  .header,
  .header * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
