/* =========================================================
   TOP BAR
   Base desktop grande
   ========================================================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;

  height: var(--header-h, 68px);
  width: 100%;

  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 18px;

  padding: 0 clamp(14px, 2vw, 24px);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

/* =========================================================
   LEFT
   ========================================================= */

.left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-strong);
  min-width: 0;
}

.brand-logo {
  width: 36px;
  height: 36px;
  display: block;
  flex: 0 0 auto;
}

.brand-text {
  font-size: 1.9rem;
  line-height: 1;
  letter-spacing: 0.2px;
  white-space: nowrap;
  color: var(--text-strong);
}

/* =========================================================
   CENTER
   ========================================================= */

.center {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-width: 0;
}

.main-nav {
  display: inline-flex;
  align-items: stretch;
  justify-content: center;
  height: 100%;
}

.nav-item {
  position: relative;
  min-width: 128px;
  height: calc(100% - 10px);

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

  text-decoration: none;
  color: var(--text);
  background: transparent;
  border-radius: 8px;
  transition: background-color 0.2s ease, color 0.2s ease;
  align-self: center;
}

.nav-item i {
  font-size: 1.35rem;
  line-height: 1;
}

.nav-item:hover:not(.is-active) {
  background: var(--hover);
  color: var(--text-strong);
}

.nav-item.is-active {
  color: var(--brand);
  background: transparent;
}

.nav-item.is-active:hover {
  background: transparent;
}

.nav-item.is-active::after {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: -4px;
  height: 3px;
  border-radius: 999px;
  background: var(--brand);
}

/* =========================================================
   TOOLTIPS - CENTER
   ========================================================= */

.nav-item::before {
  content: attr(data-label);
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  bottom: -32px;

  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--text-strong);
  color: var(--panel);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
  z-index: 20;
}

.nav-item:hover::before,
.nav-item:focus-visible::before {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* =========================================================
   RIGHT
   ========================================================= */

.right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.icon-btn,
.lang-btn {
  position: relative;

  height: 40px;
  border: none;
  background: var(--hover);
  color: var(--text);
  border-radius: 999px;

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

  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.icon-btn {
  width: 40px;
  min-width: 40px;
}

.icon-btn i {
  font-size: 1.25rem;
  line-height: 1;
}

.lang-btn {
  gap: 8px;
  padding: 0 12px;
  white-space: nowrap;
}

.lang-btn i {
  font-size: 1.2rem;
  line-height: 1;
}

.lang-text {
  font-size: var(--font-size-base);
  color: var(--text);
}

.icon-btn:hover,
.lang-btn:hover {
  background: var(--active);
  border-color: var(--border-strong);
  color: var(--text-strong);
}

.icon-btn:active,
.lang-btn:active {
  transform: scale(0.98);
}

.lang-btn::before {
  display: none;
}

/* =========================================================
   TOOLTIPS - RIGHT
   ========================================================= */

.icon-btn::before,
.lang-btn::before {
  content: attr(data-label);
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  bottom: -38px;

  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--text-strong);
  color: var(--panel);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
  z-index: 20;
}

.icon-btn:hover::before,
.lang-btn:hover::before,
.icon-btn:focus-visible::before,
.lang-btn:focus-visible::before {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* =========================================================
   FOCUS
   ========================================================= */

.brand:focus-visible,
.nav-item:focus-visible,
.icon-btn:focus-visible,
.lang-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* =========================================================
   DESKTOP MUY GRANDE
   1440px+
   ========================================================= */

@media (min-width: 1440px) {
  .topbar {
    height: 70px;
    column-gap: 22px;
    padding-left: 24px;
    padding-right: 24px;
  }

  .brand-logo {
    width: 38px;
    height: 38px;
  }

  .brand-text {
    font-size: 2rem;
  }

  .nav-item {
    min-width: 142px;
    height: calc(100% - 10px);
  }

  .nav-item i {
    font-size: 1.45rem;
  }

  .icon-btn {
    width: 42px;
    min-width: 42px;
    height: 42px;
  }

  .icon-btn i,
  .lang-btn i {
    font-size: 1.3rem;
  }
}

/* =========================================================
   DESKTOP NORMAL / LAPTOP GRANDE
   1200px - 1439px
   ========================================================= */

@media (max-width: 1439px) {
  .topbar {
    height: 66px;
    column-gap: 16px;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
  }

  .brand-text {
    font-size: 1.7rem;
  }

  .nav-item {
    min-width: 118px;
  }

  .nav-item i {
    font-size: 1.3rem;
  }
}

/* =========================================================
   LAPTOP MEDIA / 15.6 / TABLET HORIZONTAL GRANDE
   992px - 1199px
   ========================================================= */

@media (max-width: 1199px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    column-gap: 12px;
    height: 62px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .brand {
    gap: 10px;
  }

  .brand-logo {
    width: 32px;
    height: 32px;
  }

  .brand-text {
    font-size: 1.42rem;
  }

  .main-nav {
    width: 100%;
    justify-content: center;
  }

  .nav-item {
    min-width: 84px;
    height: calc(100% - 8px);
  }

  .nav-item i {
    font-size: 1.18rem;
  }

  .nav-item.is-active::after {
    left: 16px;
    right: 16px;
  }

  .right {
    gap: 8px;
  }

  .icon-btn {
    width: 38px;
    min-width: 38px;
    height: 38px;
  }

  .lang-btn {
    height: 38px;
    padding: 0 10px;
    gap: 6px;
  }

  .icon-btn i,
  .lang-btn i {
    font-size: 1.08rem;
  }

  .lang-text {
    font-size: 0.94rem;
  }
}

/* =========================================================
   LAPTOP APRETADA / AJUSTE FINO
   1180px hacia abajo
   ========================================================= */

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    column-gap: 8px;
    height: 60px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .brand {
    gap: 8px;
  }

  .brand-logo {
    width: 30px;
    height: 30px;
  }

  .brand-text {
    font-size: 1.25rem;
  }

  .main-nav {
    width: 100%;
    justify-content: center;
  }

  .nav-item {
    min-width: 76px;
    height: calc(100% - 8px);
  }

  .nav-item i {
    font-size: 1.08rem;
  }

  .nav-item.is-active::after {
    left: 14px;
    right: 14px;
  }

  .right {
    gap: 6px;
  }

  .icon-btn {
    width: 36px;
    min-width: 36px;
    height: 36px;
  }

  .lang-btn {
    height: 36px;
    padding: 0 8px;
    gap: 5px;
  }

  .icon-btn i,
  .lang-btn i {
    font-size: 1rem;
  }

  .lang-text {
    font-size: 0.88rem;
  }
}

/* =========================================================
   DESKTOP COMPACTO / TABLET HORIZONTAL
   900px - 991px
   ========================================================= */

@media (max-width: 991px) {
  .topbar {
    height: 60px;
    column-gap: 10px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .brand-logo {
    width: 30px;
    height: 30px;
  }

  .brand-text {
    font-size: 1.22rem;
  }

  .nav-item {
    min-width: 72px;
  }

  .nav-item i {
    font-size: 1.08rem;
  }

  .icon-btn {
    width: 36px;
    min-width: 36px;
    height: 36px;
  }

  .icon-btn i,
  .lang-btn i {
    font-size: 1rem;
  }

  .lang-btn {
    height: 36px;
    padding: 0 8px;
  }

  .lang-text {
    font-size: 0.9rem;
  }
}

/* =========================================================
   MOBILE / TABLET VERTICAL
   899px hacia abajo
   ========================================================= */

@media (max-width: 899px) {
  .topbar {
    grid-template-columns: auto auto;
    grid-template-areas:
      "left right"
      "center center";
    height: auto;
    row-gap: 0;
    column-gap: 12px;
    padding-top: 10px;
    padding-bottom: 0;
  }

  .left {
    grid-area: left;
  }

  .right {
    grid-area: right;
  }

  .center {
    grid-area: center;
    width: 100%;
    justify-content: stretch;
    border-top: 1px solid var(--border);
    margin-top: 10px;
    min-height: 54px;
  }

  .main-nav {
    width: 100%;
  }

  .nav-item {
    min-width: unset;
    flex: 1 1 0;
    height: 54px;
  }

  .nav-item i {
    font-size: 1.1rem;
  }

  .nav-item.is-active::after {
    left: 14px;
    right: 14px;
    bottom: 0;
  }

  .brand-text {
    font-size: 1.12rem;
  }

  .lang-text {
    display: none;
  }

  .lang-btn {
    width: 36px;
    min-width: 36px;
    padding: 0;
    gap: 0;
  }

  .nav-item::before,
  .icon-btn::before,
  .lang-btn::before {
    display: none;
  }
}

/* =========================================================
   MOBILE PEQUEÑO
   640px hacia abajo
   ========================================================= */

@media (max-width: 640px) {
  .topbar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .brand {
    gap: 10px;
  }

  .brand-logo {
    width: 30px;
    height: 30px;
  }

  .brand-text {
    font-size: 1rem;
  }

  .right {
    gap: 8px;
  }

  .icon-btn,
  .lang-btn {
    height: 34px;
  }

  .icon-btn,
  .lang-btn {
    width: 34px;
    min-width: 34px;
  }

  .icon-btn i,
  .lang-btn i {
    font-size: 1rem;
  }

  .center {
    min-height: 52px;
  }

  .nav-item {
    height: 52px;
  }

  .nav-item i {
    font-size: 1.02rem;
  }
}

/* =========================================================
   MOBILE MUY PEQUEÑO
   420px hacia abajo
   ========================================================= */

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

  .brand {
    gap: 8px;
  }

  .brand-logo {
    width: 28px;
    height: 28px;
  }

  .brand-text {
    font-size: 0.92rem;
  }

  .right {
    gap: 6px;
  }

  .icon-btn,
  .lang-btn {
    width: 32px;
    min-width: 32px;
    height: 32px;
  }

  .icon-btn i,
  .lang-btn i {
    font-size: 0.95rem;
  }

  .center {
    min-height: 50px;
  }

  .nav-item {
    height: 50px;
  }

  .nav-item i {
    font-size: 0.98rem;
  }
}
