/* ══════════════════════════════════════
   header.css
   Navbar, Desktop Menu, Mobile Menu
   ══════════════════════════════════════ */

html, body {
  overflow-x: hidden;
}

/* =========================
   NAVBAR
========================= */
.topbar {
  background: linear-gradient(90deg, var(--blue-900), var(--blue-700));
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: box-shadow 0.3s ease, padding 0.3s ease;
}

.topbar--scrolled {
  box-shadow: 0 2px 16px rgba(0, 0, 0, .2);
}

/* Header gets its own wider container — independent of body .container
   Max-width 1800px ensures all elements fit at large viewports.
   Container queries on .nav use this actual width for breakpoints. */
.topbar .container {
  width: min(100% - 32px, 1800px);
  margin-inline: auto;
  padding-inline: 0;
  container-name: header;
  container-type: inline-size;
}

.nav {
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: clamp(12px, 1.2vw, 24px);
  padding: 10px 0;
  container-name: header-nav;
  container-type: inline-size;
}

/* ── Brand ── */
.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.brand img {
  width: clamp(150px, 9.5vw, 190px);
  height: auto;
  max-height: 46px;
  object-fit: contain;
  display: block;
}

/* ── Desktop Menu ── */
.desktop-menu {
  display: flex;
  align-items: center;
  justify-content: center;

  flex: 1 1 auto;
  min-width: 0;

  gap: clamp(8px, .75vw, 18px);
}

.nav-link {
  color: var(--white);
  text-decoration: none;
  font-weight: 600;
  font-size: clamp(13px, .88vw, 17px);
  line-height: 1.1;
  padding: 8px 6px;
  border-radius: 8px;
  background: transparent;
  border: none;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  opacity: .94;
  transition: background .2s ease, opacity .2s ease;
}

.nav-link:hover {
  opacity: 1;
  background: rgba(255, 255, 255, .12);
}

.nav-toggle {
  appearance: none;
}

/* ── Dropdown ── */
.dropdown {
  position: relative;
}

.dropdown::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 14px;
}

.chev {
  font-size: 10px;
  transition: transform .2s ease;
}

.dropdown:hover .chev {
  transform: rotate(180deg);
}

.dropmenu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}

.dropmenu a {
  display: block;
  padding: 10px 12px;
  color: #17324b;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  transition: background .15s ease;
}

.dropmenu a:hover {
  background: #eaf5ff;
}

.dropdown:hover .dropmenu,
.dropdown:focus-within .dropmenu,
.dropdown.open .dropmenu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.dropdown:hover .chev,
.dropdown:focus-within .chev,
.dropdown.open .chev,
.nav-toggle.active .chev {
  transform: rotate(180deg);
}

/* ── Right side: social + CTA ── */
.header-right {
  display: flex;
  align-items: center;
  gap: clamp(8px, 0.8vw, 16px);
  flex-shrink: 0;
}

/* ── Social Icons ── */
.social {
  display: flex;
  align-items: center;
  gap: 6px;
}

.social a {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  text-decoration: none;
  color: #fff;
  transition: background .2s ease, transform .2s ease;
}

.social a:hover {
  background: rgba(255, 255, 255, .28);
  transform: translateY(-1px);
}

.social svg {
  width: 16px;
  height: 16px;
  fill: #fff;
  display: block;
  flex-shrink: 0;
}

/* ── Actions & CTA ── */
.actions {
  display: flex;
  align-items: center;
}

.cta {
  text-decoration: none;
  color: #fff;
  background: #14346D;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(227, 23, 42, .34);
  white-space: nowrap;
  transition: background .2s ease, transform .15s ease, box-shadow .2s ease;
}

.cta:hover {
  background: #bf0f22;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(227, 23, 42, .42);
}

.cta-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

/* ── Hamburger ── */
.hamburger {
  display: none;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}

.hamburger:hover {
  background: rgba(255, 255, 255, .12);
}

.hamburger span {
  display: block;
  width: 24px;
  height: 3px;
  border-radius: 999px;
  background: #fff;
  transition: transform .28s ease, opacity .28s ease;
}

.hamburger.open span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.hamburger.open span:nth-child(2) {
  opacity: 0;
}

.hamburger.open span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* =========================
   MOBILE MENU
========================= */
.mobile-menu {
  display: none;
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  max-height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  background: linear-gradient(160deg, #0a3a74 0%, #0b6fb3 100%);
  z-index: 999;
  padding: 16px 18px 22px;
  box-shadow: 0 16px 28px rgba(0, 0, 0, .24);
}

.mobile-menu.open {
  display: block;
}

.mobile-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  background: #e91c1c;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 13px 18px;
  border-radius: 12px;
  text-decoration: none;
}

.mobile-cta img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.mobile-menu-item {
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.mobile-menu-item:last-child {
  border-bottom: none;
}

.mobile-link,
.mobile-menu-btn {
  width: 100%;
  background: transparent;
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  padding: 14px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.mobile-chev {
  font-size: 12px;
  transition: transform .25s ease;
}

.mobile-menu-item.open .mobile-chev {
  transform: rotate(180deg);
}

.mobile-submenu {
  display: none;
  padding: 0 0 10px 14px;
}

.mobile-menu-item.open .mobile-submenu {
  display: block;
}

.mobile-submenu a {
  display: block;
  padding: 9px 8px;
  color: rgba(255, 255, 255, .86);
  text-decoration: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

.mobile-submenu a:hover {
  background: rgba(255, 255, 255, .12);
  color: #fff;
}

.mobile-social {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, .18);
}

.mobile-social a {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, .14);
  border-radius: 50%;
  display: grid;
  place-items: center;
  text-decoration: none;
  color: #fff;
}

.mobile-social svg {
  width: 20px;
  height: 20px;
  fill: #fff;
  display: block;
}

/* =========================
   RESPONSIVE NAVBAR
========================= */

/* Desktop amplio */
@media (min-width: 1800px) {

  .social {
    display: flex;
  }

  .desktop-menu {
    gap: clamp(12px, .8vw, 18px);
  }

  .nav-link {
    font-size: clamp(14px, .78vw, 16px);
  }
}


/* Desktop normal: ocultamos redes */
@media (max-width: 1799px) {

  .social {
    display: none;
  }

  .header-right {
    gap: 8px;
  }

  .desktop-menu {
    gap: clamp(8px, .65vw, 14px);
  }

  .nav-link {
    font-size: clamp(13px, .78vw, 15px);
    padding-inline: 4px;
  }
}


/* Desktop intermedio */
@media (max-width: 1450px) {

  .topbar .container {
    width: calc(100% - 24px);
  }

  .nav {
    gap: 8px;
  }

  .brand img {
    width: clamp(145px, 11vw, 175px);
  }

  .desktop-menu {
    gap: 6px;
  }

  .nav-link {
    font-size: 13px;
    padding: 7px 3px;
  }

  .cta {
    padding: 9px 12px;
    font-size: 12px;
  }
}


/* Antes de que el menú pueda superponerse,
   pasar directamente a hamburger */
@media (max-width: 1249px) {

  .desktop-menu,
  .header-right {
    display: none;
  }

  .hamburger {
    display: flex;
    margin-left: auto;
  }

  .nav {
    justify-content: space-between;
  }

  .brand img {
    width: clamp(150px, 16vw, 185px);
    max-height: 42px;
  }
}


/* Tablet */
@media (max-width: 1024px) {

  :root {
    --header-h: 72px;
  }

  .topbar .container {
    width: calc(100% - 24px);
  }

  .brand img {
    width: 160px;
    max-height: 38px;
  }
}

/* ── ≤640px: mobile ── */
@media (max-width: 640px) {
  :root {
    --header-h: 68px;
  }

  .topbar .container {
    width: min(100% - 28px, 100%);
    padding: 0;
  }

  .container {
    padding: 0 14px;
  }

  .nav {
    min-height: var(--header-h);
    padding: 8px 0;
  }

  .brand img {
    width: 138px;
    max-height: 32px;
  }

  .hamburger {
    width: 40px;
    height: 40px;
  }

  .hamburger span {
    width: 22px;
  }

  .mobile-menu {
    padding: 14px 14px 20px;
  }
}

/* ── ≤380px: small mobile ── */
@media (max-width: 380px) {
  .brand img {
    width: 124px;
    max-height: 29px;
  }

  .mobile-cta {
    font-size: 13px;
    padding: 12px 14px;
  }
}
