:root {
  --blue: #1e3a8a;
  --blue-light: #2563eb;
  --gray: #6b7280;
  --light-gray: #f3f4f6;
  --white: #ffffff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Arial, sans-serif;
}

body {
  background: var(--light-gray);
}

/* NAVBAR */
header {
  position: absolute;
  width: 100%;
  top: 0;
  left: 0;
  z-index: 10;
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 40px;
  background: rgba(0, 0, 0, 0.4);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--white);
  font-weight: bold;
  font-size: 20px;
}

.logo img {
  height: 50px;
}

/* MENU */
.menu {
  display: flex;
  list-style: none;
  gap: 25px;
}

.menu li {
  position: relative;
}

.menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--white);
  font-weight: 500;
  transition: 0.3s;
}

.menu a img {
  height: 20px;
  width: auto;
  display: block;
  transition: filter 0.25s ease, transform 0.25s ease;
  filter: none;
}

.menu a:hover img {
  filter: brightness(0) saturate(100%) invert(42%) sepia(95%) saturate(450%) hue-rotate(170deg) brightness(95%) contrast(90%);
  transform: translateY(-1px);
}

.menu a:hover {
  color: var(--blue-light);
}

/* SUBMENU */
.submenu {
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  min-width: 210px;
  padding: 8px;

  display: flex;
  flex-direction: column;
  gap: 3px;

  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 12px;
  box-shadow: 0 16px 35px rgba(15, 23, 42, 0.18);

  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  transform: translate(-50%, -8px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0.2s ease;

  z-index: 1000;
}

/* Puente invisible para que no se cierre al mover el cursor */
.submenu::after {
  content: "";
  position: absolute;
  top: -12px;
  left: 0;
  width: 100%;
  height: 12px;
}

/* Flecha superior */
.submenu::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  width: 12px;
  height: 12px;

  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  border-left: 1px solid #e2e8f0;

  transform: translateX(-50%) rotate(45deg);
}

/* Opciones */
.submenu a {
  position: relative;
  z-index: 1;

  width: 100%;
  padding: 11px 14px;

  color: #475569;
  background: transparent;
  border-radius: 8px;

  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;

  transition:
    color 0.18s ease,
    background-color 0.18s ease,
    transform 0.18s ease;
}

/* Hover */
.submenu a:hover {
  color: var(--blue);
  background: #eff6ff;
  transform: translateX(3px);
}

/* Mostrar */
.menu>li:hover>.submenu,
.menu>li:focus-within>.submenu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .menu {
    display: none;
  }
}

.welcome-user {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--white);
  font-weight: 500;
  transition: 0.3s;
}

/* Elementos relacionados con la cuenta */
/* Elemento de idioma igual que los demás del navbar */
.menu>.language-item {
  position: relative;
}

/* Icono del idioma */
.language-item .language-toggle .material-symbols-outlined {
  color: inherit;
  font-size: 21px;
  line-height: 1;
  transition: color 0.3s ease;
}

/* Submenú de idiomas */
.language-submenu {
  min-width: 140px;
}

/* Idioma seleccionado */
.language-submenu .active-language {
  color: var(--blue-light);
  font-weight: bold;
}

/* Al pasar el mouse por el idioma seleccionado */
.language-submenu .active-language:hover {
  color: var(--white);
}

.flag-icon {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.menu .language-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--white);
  font-weight: 500;
  transition: 0.3s;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-size: inherit;
  padding: 0;
}

.menu .language-toggle:hover {
  color: var(--blue-light);
}

.menu .language-toggle img {
  height: 20px;
  width: auto;
  display: block;
  transition: filter 0.25s ease, transform 0.25s ease;
  filter: none;
}

.menu .language-toggle:hover img {
  filter: brightness(0) saturate(100%) invert(42%) sepia(95%) saturate(450%) hue-rotate(170deg) brightness(95%) contrast(90%);
  transform: translateY(-1px);
}

.menu .language-toggle:hover img.flag-icon {
  filter: none;
}

.language-item .language-toggle .material-symbols-outlined {
  color: inherit;
  font-size: 21px;
  line-height: 1;
  transition: color 0.3s ease;
}

.menu {
  position: relative;
}

.navbar .menu>li>a.nav-link {
  position: relative;
  z-index: 2;
}

.navbar .menu>li>a.nav-link.active {
  color: #2563eb;
  font-weight: 600;
}

.public-nav-indicator {
  position: absolute;
  left: 0;
  bottom: -3px;
  width: 0;
  height: 3px;
  background: #2563eb;
  border-radius: 999px;
  pointer-events: none;
  z-index: 5;
  transition:
    left 0.35s ease,
    width 0.35s ease;
}

.menu>li:has(.submenu)>.nav-link::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: 1px;

  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;

  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.2s ease;
}

.menu>li:has(.submenu):hover>.nav-link::after {
  transform: rotate(225deg) translate(-2px, -2px);
}

/* LOGOUT PÚBLICO */
.public-logout-form {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
}

.public-logout-button {
  display: flex;
  align-items: center;
  gap: 8px;

  padding: 0;
  margin: 0;

  border: none;
  background: transparent;

  color: var(--white);
  font-family: Arial, sans-serif;
  font-size: inherit;
  font-weight: 500;

  cursor: pointer;

  transition: color 0.3s ease;
}

.public-logout-button:hover {
  color: var(--blue-light);
}

.public-logout-button img {
  width: auto;
  height: 20px;
  display: block;

  filter: none;

  transition:
    filter 0.25s ease,
    transform 0.25s ease;
}

.public-logout-button:hover img {
  filter:
    brightness(0) saturate(100%) invert(42%) sepia(95%) saturate(450%) hue-rotate(170deg) brightness(95%) contrast(90%);

  transform: translateY(-1px);
}

.public-logout-button:focus-visible {
  outline: 2px solid var(--blue-light);
  outline-offset: 4px;
  border-radius: 4px;
}

/* =========================================================
   RESPONSIVE GLOBAL FINAL - HEADER
   Mantiene la navegación utilizable sin depender de un
   menú hamburguesa adicional.
========================================================= */

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.logo,
.logo img,
.menu,
.menu li,
.menu a,
.public-logout-form,
.public-logout-button {
  min-width: 0;
}

.logo img,
.menu img,
.flag-icon,
.public-logout-button img {
  max-width: 100%;
  object-fit: contain;
}

@media (max-width: 1100px) {
  .navbar {
    padding: 14px 22px;
    gap: 18px;
  }

  .menu {
    gap: 16px;
  }

  .logo {
    font-size: 18px;
  }

  .logo img {
    height: 44px;
  }

  .menu a,
  .menu .language-toggle,
  .public-logout-button {
    font-size: 14px;
  }
}

@media (max-width: 900px) {
  header {
    position: relative;
    background: #111827;
  }

  .navbar {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    padding: 14px 18px 18px;
    background: #111827;
  }

  .logo {
    justify-content: center;
  }

  .menu {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .menu>li {
    width: 100%;
    min-width: 0;
  }

  .menu>li>a,
  .menu .language-toggle,
  .public-logout-button,
  .welcome-user {
    width: 100%;
    min-height: 44px;
    justify-content: center;
    padding: 10px 12px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.06);
    text-align: center;
    white-space: normal;
  }

  .submenu {
    position: static;
    width: 100%;
    min-width: 0;
    margin-top: 6px;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    box-shadow: none;
    border-radius: 9px;
  }

  .submenu::before,
  .submenu::after {
    display: none;
  }

  .submenu a {
    white-space: normal;
    justify-content: center;
    text-align: center;
  }

  .menu>li:hover>.submenu,
  .menu>li:focus-within>.submenu {
    transform: none;
  }

  .public-nav-indicator {
    display: none;
  }
}

/* Sobrescribe la regla antigua que ocultaba completamente el menú */

@media (max-width: 560px) {
  .navbar {
    padding: 12px;
  }

  .logo {
    font-size: 17px;
  }

  .logo img {
    height: 40px;
  }

  .menu {
    grid-template-columns: minmax(0, 1fr);
  }

  .menu>li>a,
  .menu .language-toggle,
  .public-logout-button,
  .welcome-user {
    justify-content: flex-start;
    text-align: left;
  }

  .submenu a {
    justify-content: flex-start;
    text-align: left;
    padding-left: 18px;
  }
}

@media (max-width: 360px) {
  .navbar {
    padding-left: 10px;
    padding-right: 10px;
  }

  .logo {
    font-size: 16px;
  }

  .logo img {
    height: 36px;
  }

  .menu>li>a,
  .menu .language-toggle,
  .public-logout-button,
  .welcome-user {
    font-size: 13px;
  }
}

/* =========================================
   BOTÓN HAMBURGUESA
========================================= */

.menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  padding: 9px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.menu-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--white);
  border-radius: 999px;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}


/* =========================================
   CELULAR
========================================= */

@media (max-width: 768px) {

  header {
    position: relative;
    width: 100%;
    background: #111827;
  }

  .navbar {
    position: relative;
    width: 100%;
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    background: #111827;
  }

  .logo {
    font-size: 17px;
  }

  .logo img {
    height: 40px;
  }

  /* Mostrar hamburguesa */
  .menu-toggle {
    display: flex;
  }

  /* Menú principal cerrado */
  .menu {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 0;

    max-height: 0;
    overflow: hidden;
    opacity: 0;

    transition:
      max-height 0.4s ease,
      opacity 0.25s ease;

    position: static;
  }

  /* Menú principal abierto */
  .menu.mobile-open {
    max-height: 1500px;
    opacity: 1;
    margin-top: 12px;
  }

  .menu>li {
    width: 100%;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
  }

  .menu>li>a,
  .menu .language-toggle,
  .public-logout-button,
  .welcome-user {
    width: 100%;
    min-height: 48px;
    padding: 12px 8px;

    display: flex;
    align-items: center;
    justify-content: flex-start;

    color: var(--white);
    text-align: left;
  }


  /* =========================================
     SUBMENÚS EN CELULAR
  ========================================= */

  .submenu {
    position: static;

    width: 100%;
    min-width: 0;

    padding: 0 0 0 16px;
    margin: 0;

    display: flex;
    flex-direction: column;

    background: rgba(255, 255, 255, 0.06);
    border: none;
    border-radius: 0;
    box-shadow: none;

    max-height: 0;
    overflow: hidden;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transform: none;

    transition:
      max-height 0.35s ease,
      opacity 0.25s ease;
  }

  .submenu::before,
  .submenu::after {
    display: none;
  }

  /* Evitar que hover abra automáticamente
     submenús en pantallas táctiles */
  .menu>li:hover>.submenu {
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  /* Submenú abierto mediante JS */
  .menu>li.submenu-open>.submenu {
    max-height: 500px;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .submenu a {
    width: 100%;
    padding: 11px 14px;

    color: #d1d5db;
    background: transparent;

    white-space: normal;
    border-radius: 0;
  }

  .submenu a:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.08);
    transform: none;
  }

  .public-nav-indicator {
    display: none;
  }


  /* =========================================
     ANIMACIÓN HAMBURGUESA
  ========================================= */

  .menu-toggle.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .menu-toggle.active span:nth-child(2) {
    opacity: 0;
  }

  .menu-toggle.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
}