/* =========================================================
   HEADER GENERAL
   ========================================================= */

.ag-navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  color: var(--ag-white);
  background:
    linear-gradient(135deg, rgba(17, 19, 21, 0.98), rgba(40, 45, 50, 0.96)),
    radial-gradient(circle at 8% 0%, rgba(227, 27, 35, 0.22), transparent 28%);
  border-bottom: 1px solid rgba(227, 27, 35, 0.35);
  box-shadow: var(--ag-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: agNavbarDrop 0.55s ease both;
}

.ag-navbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--ag-red-500),
    rgba(255, 255, 255, 0.55),
    var(--ag-red-500),
    transparent
  );
  opacity: 0.9;
  animation: agRedLineMove 4.5s linear infinite;
}

/* =========================================================
   TOPBAR
   ========================================================= */

.nav-topbar {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(90deg, #0f1113, #1d2125 45%, #111315);
  color: var(--ag-soft-white);
  font-size: 12.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-topbar::before {
  content: "";
  position: absolute;
  top: 0;
  left: -35%;
  width: 30%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(227, 27, 35, 0.22),
    transparent
  );
  transform: skewX(-18deg);
  animation: agTopbarSweep 6s ease-in-out infinite;
}

.nav-topbar-inner {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  position: relative;
  z-index: 1;
}

.nav-topbar-left,
.nav-topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.nav-topbar span,
.nav-topbar a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ag-soft-white);
  text-decoration: none;
  white-space: nowrap;
}

.nav-topbar i {
  color: var(--ag-red-400);
  font-size: 14px;
}

.nav-topbar a {
  transition: color 0.22s ease, transform 0.22s ease;
}

.nav-topbar a:hover {
  color: var(--ag-white);
  transform: translateY(-1px);
}

/* =========================================================
   CONTENEDOR PRINCIPAL
   ========================================================= */

.ag-navbar .nav-inner {
  min-height: 78px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 26px;
  position: relative;
}

/* =========================================================
   LOGO
   ========================================================= */

.ag-navbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--ag-white);
  text-decoration: none;
}

.brand-logo-img {
  width: 165px;
  height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  flex: 0 0 auto;
}

.brand-logo-img img {
  width: 100%;
  max-width: 165px;
  max-height: 58px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.38));
  transition: transform 0.28s ease, filter 0.28s ease;
}

.ag-navbar .brand:hover .brand-logo-img img {
  transform: translateY(-1px) scale(1.02);
  filter: drop-shadow(0 10px 22px rgba(227, 27, 35, 0.22));
}

/* Fallback si no carga el logo */
.brand-fallback-icon {
  width: 48px;
  height: 48px;
  display: none;
  place-items: center;
  border-radius: var(--ag-radius-md);
  color: var(--ag-white);
  background: linear-gradient(135deg, var(--ag-red-600), var(--ag-red-700));
  box-shadow: 0 12px 28px rgba(227, 27, 35, 0.28);
  font-size: 23px;
}

.brand-fallback-active .brand-logo-img {
  width: auto;
}

.brand-fallback-active .brand-fallback-icon {
  display: grid;
}

.brand-copy {
  display: none;
}

.brand-fallback-active .brand-copy {
  display: grid;
  line-height: 1.05;
}

.brand-name {
  font-size: 20px;
  font-weight: 950;
  letter-spacing: -0.03em;
  color: var(--ag-white);
}

.brand-tagline {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 800;
  color: var(--ag-muted-white);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* =========================================================
   LINKS DE NAVEGACIÓN
   ========================================================= */

.ag-navbar .nav-links {
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 5px;
  border-radius: var(--ag-radius-md);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 12px 28px rgba(0, 0, 0, 0.14);
}

.ag-navbar .nav-links a {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--ag-radius-sm);
  color: var(--ag-soft-white);
  font-size: 14px;
  font-weight: 850;
  text-decoration: none;
  letter-spacing: 0.01em;
  transition:
    color 0.22s ease,
    transform 0.22s ease,
    background 0.22s ease;
}

.ag-navbar .nav-links a::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(135deg, var(--ag-red-600), var(--ag-red-500));
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.ag-navbar .nav-links a::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 7px;
  height: 2px;
  background: var(--ag-white);
  opacity: 0;
  transform: scaleX(0.25);
  transform-origin: left;
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.ag-navbar .nav-links a:hover {
  color: var(--ag-white);
  transform: translateY(-1px);
}

.ag-navbar .nav-links a:hover::before {
  opacity: 1;
  transform: translateY(0);
}

.ag-navbar .nav-links a:hover::after {
  opacity: 0.9;
  transform: scaleX(1);
}

/* =========================================================
   BOTONES / ACCIONES
   ========================================================= */

.ag-navbar .nav-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.ag-navbar .nav-actions .btn {
  min-height: 42px;
  border-radius: var(--ag-radius-md) !important;
  font-weight: 900;
  letter-spacing: 0.01em;
  box-shadow: none;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    background 0.22s ease,
    border-color 0.22s ease,
    color 0.22s ease;
}

.ag-navbar .nav-login-btn {
  color: var(--ag-white);
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.055);
}

.ag-navbar .nav-login-btn:hover {
  color: var(--ag-white);
  border-color: var(--ag-line-red);
  background: rgba(227, 27, 35, 0.14);
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.22);
}

.ag-navbar .nav-cart-btn {
  position: relative;
  overflow: hidden;
  gap: 8px;
  color: var(--ag-white);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(135deg, var(--ag-red-700), var(--ag-red-500));
  box-shadow: 0 14px 30px rgba(227, 27, 35, 0.26);
}

.ag-navbar .nav-cart-btn::before {
  content: "";
  position: absolute;
  top: -60%;
  left: -45%;
  width: 38%;
  height: 220%;
  background: rgba(255, 255, 255, 0.28);
  transform: rotate(25deg);
  transition: left 0.55s ease;
}

.ag-navbar .nav-cart-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(227, 27, 35, 0.34);
}

.ag-navbar .nav-cart-btn:hover::before {
  left: 125%;
}

.ag-navbar #cartCount {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--ag-radius-sm);
  color: var(--ag-white);
  background: rgba(17, 19, 21, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 12px;
  font-weight: 950;
}

/* Botón menú móvil */
.ag-navbar .mobile-menu {
  display: none;
  width: 44px;
  min-width: 44px;
  padding: 0;
  color: var(--ag-white);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.055);
}

.ag-navbar .mobile-menu:hover {
  border-color: var(--ag-line-red);
  background: rgba(227, 27, 35, 0.18);
}

.ag-navbar .mobile-menu i {
  font-size: 23px;
}

/* =========================================================
   ANIMACIONES
   ========================================================= */

@keyframes agNavbarDrop {
  from {
    opacity: 0;
    transform: translateY(-14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes agTopbarSweep {
  0% {
    left: -35%;
    opacity: 0;
  }

  18% {
    opacity: 1;
  }

  42% {
    opacity: 1;
  }

  65%,
  100% {
    left: 115%;
    opacity: 0;
  }
}

@keyframes agRedLineMove {
  0% {
    background-position: -220px 0;
  }

  100% {
    background-position: 220px 0;
  }
}

@keyframes agMobileMenuIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================================
   RESPONSIVE TABLET
   ========================================================= */

@media (max-width: 1120px) {
  .ag-navbar .nav-inner {
    gap: 16px;
  }

  .brand-logo-img {
    width: 145px;
  }

  .brand-logo-img img {
    max-width: 145px;
  }

  .ag-navbar .nav-links a {
    padding: 0 12px;
    font-size: 13px;
  }
}

/* =========================================================
   RESPONSIVE MÓVIL
   ========================================================= */

@media (max-width: 920px) {
  .nav-topbar-inner {
    justify-content: center;
  }

  .nav-topbar-left {
    display: none;
  }

  .nav-topbar-right {
    width: 100%;
    justify-content: space-between;
    gap: 12px;
  }

  .ag-navbar .nav-inner {
    min-height: 72px;
    grid-template-columns: auto 1fr;
  }

  .ag-navbar .brand {
    grid-column: 1 / 2;
  }

  .ag-navbar .nav-actions {
    grid-column: 2 / 3;
    justify-self: end;
  }

  .ag-navbar .mobile-menu {
    display: inline-flex;
  }

  .ag-navbar .nav-links {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 10px);
    display: none;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 8px;
    padding: 12px;
    border-radius: var(--ag-radius-lg);
    background:
      linear-gradient(145deg, rgba(17, 19, 21, 0.98), rgba(40, 45, 50, 0.98));
    border: 1px solid rgba(227, 27, 35, 0.32);
    box-shadow: 0 22px 50px rgba(0, 0, 0, 0.36);
    z-index: 1001;
    animation: agMobileMenuIn 0.24s ease both;
  }

  .ag-navbar .nav-links.open,
  .ag-navbar .nav-links.show,
  .ag-navbar .nav-links.active,
  .ag-navbar .nav-links.is-open,
  .ag-navbar.nav-open .nav-links,
  body.nav-open .ag-navbar .nav-links {
    display: flex;
  }

  .ag-navbar .nav-links a {
    min-height: 48px;
    justify-content: flex-start;
    padding: 0 16px;
    border-radius: var(--ag-radius-md);
    font-size: 15px;
    color: var(--ag-white);
    background: rgba(255, 255, 255, 0.055);
    border-left: 3px solid transparent;
  }

  .ag-navbar .nav-links a:hover {
    border-left-color: var(--ag-red-500);
    background: rgba(227, 27, 35, 0.18);
  }

  .ag-navbar .nav-links a::after {
    display: none;
  }
}

/* =========================================================
   RESPONSIVE CELULAR PEQUEÑO
   ========================================================= */

@media (max-width: 560px) {
  .nav-topbar {
    font-size: 12px;
  }

  .nav-topbar-right a:last-child {
    display: none;
  }

  .nav-topbar-right {
    justify-content: center;
  }

  .ag-navbar .nav-inner {
    min-height: 68px;
    gap: 10px;
  }

  .brand-logo-img {
    width: 122px;
    height: 48px;
  }

  .brand-logo-img img {
    max-width: 122px;
    max-height: 48px;
  }

  .ag-navbar .nav-actions {
    gap: 7px;
  }

  .ag-navbar .nav-login-btn {
    width: 42px;
    min-width: 42px;
    padding: 0;
  }

  .ag-navbar .nav-login-btn .action-label {
    display: none;
  }

  .ag-navbar .nav-cart-btn {
    min-width: 48px;
    padding: 0 10px;
  }

  .ag-navbar .nav-cart-btn .cart-label {
    display: none;
  }

  .ag-navbar #cartCount {
    min-width: 22px;
    height: 22px;
    font-size: 11px;
  }

  .ag-navbar .mobile-menu {
    width: 42px;
    min-width: 42px;
  }
}

/* =========================================================
   ACCESIBILIDAD
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  .ag-navbar,
  .ag-navbar::after,
  .nav-topbar::before,
  .ag-navbar .nav-links,
  .ag-navbar .nav-links a,
  .ag-navbar .nav-links a::before,
  .ag-navbar .nav-links a::after,
  .ag-navbar .nav-actions .btn,
  .ag-navbar .nav-cart-btn::before,
  .nav-topbar a,
  .brand-logo-img img {
    animation: none !important;
    transition: none !important;
  }
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nav-links a i {
  font-size: 16px;
  color: var(--ag-red-500, #e31b23);
  line-height: 1;
}

.nav-links a span {
  line-height: 1;
}

@media (max-width: 900px) {
  .nav-links a {
    justify-content: flex-start;
    gap: 10px;
  }

  .nav-links a i {
    width: 22px;
    font-size: 18px;
    text-align: center;
  }
}