/* ============================================================================
   Vuelame — header.css
   ============================================================================
   Header (#masthead), branding/logo, nav menu desktop (dropdowns),
   selector de moneda, panel mobile + overlay, hamburger, mode-toggle.
   Se carga en TODAS las páginas (home y rutas) porque el header es compartido.
   ========================================================================== */

/* ================================================================
   HEADER
================================================================ */
#masthead {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #ffffff;
  background: var(--bg, #ffffff);
  border-bottom: 1px solid rgba(0,0,0,0.08);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s, box-shadow 0.3s, border-color 0.3s;
}
#masthead.scrolled { box-shadow: 0 2px 16px rgba(0,0,0,0.09); }
body.dark-mode #masthead {
  background: #24262B;
  border-bottom-color: rgba(255,255,255,0.09);
}

.header-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
  gap: 20px;
}

/* Logo (sube 2px para centrarse visualmente con el resto del header) */
.branding a { display: flex; align-items: center; }
.branding img {
  height: 40px;
  width: auto;
  margin-top: -3px;
}

/* Right side */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ================================================================
   NAV
================================================================ */
.nav-menu {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  font-family: var(--font-title);
  font-size: 14px;
  font-weight: 500;
}

.nav-menu > li { position: relative; }

.nav-menu > li > a {
  color: var(--text);
  padding: 8px 13px;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: background 0.18s, color 0.18s;
}
.nav-menu > li > a:hover,
.nav-menu > li.current > a {
  background: rgba(255,94,58,0.08);
  color: var(--color-primary);
  opacity: 1;
}

/* Chevron on dropdown items */
.nav-menu .has-sub > a::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  margin-left: 1px;
  flex-shrink: 0;
}

/* Dropdown
   El submenú aparece pegado al item (sin gap real); el margin-top de 6px
   da separación visual y el ::before crea un "bridge" invisible para que
   el hover no se rompa al cruzar el espacio. */
.nav-menu .sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.13);
  min-width: 220px;
  list-style: none;
  padding: 6px 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.18s, transform 0.18s;
  z-index: 200;
  border: 1px solid var(--border);
}
.nav-menu .sub-menu::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 0;
  right: 0;
  height: 10px;
  background: transparent;
}
.nav-menu li:hover > .sub-menu {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}
.nav-menu .sub-menu li a {
  display: block;
  padding: 10px 18px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-text);
  font-weight: 400;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.nav-menu .sub-menu li a:hover {
  background: rgba(255,94,58,0.06);
  color: var(--color-primary);
  opacity: 1;
}

.menu-fire-img { width: 18px; height: 18px; vertical-align: middle; }

/* Dark/light mode toggle — desktop y mobile, a la izquierda del currency selector */
.mode-toggle {
  display: inline-flex;
  background: none;
  border: none;
  padding: 7px;
  border-radius: 50%;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.18s;
}
.mode-toggle:hover { background: rgba(255,115,30,0.1); }
.mode-toggle .icon-sun  { display: none;  fill: var(--text); }
.mode-toggle .icon-moon { display: block; fill: var(--text); }
body.dark-mode .mode-toggle .icon-sun  { display: block; }
body.dark-mode .mode-toggle .icon-moon { display: none;  }

/* Hamburger */
.hamburger-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  padding: 8px;
}
.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.25s;
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ================================================================
   CURRENCY SELECTOR
================================================================ */
.custom-currency-selector {
  position: relative;
  font-size: 13px;
  font-weight: 600;
}

.selected-option {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 6px 9px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  transition: border-color 0.2s, background 0.2s;
  white-space: nowrap;
  user-select: none;
}
.selected-option:hover { border-color: var(--color-primary); }

.currency-flag  { width: 18px; height: 12px; border-radius: 2px; object-fit: cover; flex-shrink: 0; }

.options-container {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  max-height: 290px;
  overflow-y: auto;
  min-width: 75px;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.18s, transform 0.18s;
  border: 1px solid var(--border);
  scrollbar-width: thin;
}
.options-container.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.currency-option {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background 0.15s;
  white-space: nowrap;
}
.currency-option:hover { background: rgba(255,94,58,0.07); color: var(--color-primary); }
.currency-option.active { color: var(--color-primary); font-weight: 700; }

/* ================================================================
   MOBILE MENU PANEL
================================================================ */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 900;
}
.mobile-overlay.open { display: block; }

.mobile-panel {
  position: fixed;
  top: 0;
  right: -310px;
  width: 290px;
  height: 100%;
  background: var(--bg-card);
  z-index: 901;
  padding: 20px 22px 30px;
  overflow-y: auto;
  transition: right 0.28s ease;
  border-left: 1px solid var(--border);
}
.mobile-panel.open { right: 0; }

.mobile-close-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 22px;
}
.mobile-close-btn {
  background: none;
  border: none;
  padding: 4px;
}
.mobile-close-btn svg { fill: var(--text); }

.mobile-nav { list-style: none; }
.mobile-nav > li { border-bottom: 1px solid var(--border); }
.mobile-nav > li > a {
  display: block;
  padding: 14px 0;
  color: var(--text);
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 600;
}
.mobile-nav > li > a:hover { color: var(--color-primary); opacity: 1; }

.mobile-sub {
  list-style: none;
  padding: 0 0 10px 14px;
}
.mobile-sub li a {
  display: block;
  padding: 7px 0;
  color: var(--text-muted);
  font-size: 13px;
}
.mobile-sub li a:hover { color: var(--color-primary); opacity: 1; }

.mobile-footer-copy {
  margin-top: 28px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.8;
}
.mobile-footer-copy a { color: var(--text-muted); }
.mobile-footer-copy a:hover { color: var(--color-primary); opacity: 1; }

/* ================================================================
   RESPONSIVE — header (mobile breakpoints)
================================================================ */
@media (max-width: 768px) {
  .nav-menu      { display: none; }
  .hamburger-btn { display: flex; }
}

@media (max-width: 520px) {
  .header-wrap     { height: 62px; }
  .branding img    { height: 38px; margin-top: -3px; }
}

@media(max-width:420px){
  .branding img    { height: 36px; margin-top: -8px; }
}
