/* ── Topbar base ─────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  overflow-x: clip;
  isolation: isolate;
  backdrop-filter: blur(12px);
  background: linear-gradient(180deg, rgba(14, 14, 14, .97) 0%, rgba(10, 10, 10, .99) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, .10);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .24);
}

.topbar .inner {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 70px;
  min-height: 70px;
  padding: 0;
  gap: 18px;
  width: min(100% - 32px, 1220px);
  margin: 0 auto;
  min-width: 0;
}

body.topbar-menu-open {
  overflow: hidden;
}

.topbar-menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 0;
  border: 0;
  background: transparent;
  color: #fff;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  position: relative;
  z-index: 140;
  box-shadow: none;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.topbar-menu-toggle span {
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .9);
  transition: transform .2s ease, opacity .2s ease;
}

.topbar-menu-toggle:hover,
.topbar-menu-toggle:focus-visible {
  background: transparent;
  border-color: transparent;
}

.topbar-menu-toggle:focus-visible {
  outline: 2px solid rgba(239, 68, 68, .55);
  outline-offset: 3px;
}

.topbar-menu-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.topbar-menu-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.topbar-menu-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ── Brand / logo ───────────────────────────────────── */
.topbar-home {
  display: flex;
  align-items: center;
  color: #ffffff;
  text-decoration: none;
  min-width: 0;
  flex: 0 1 250px;
  border-radius: 12px;
  outline-offset: 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .2px;
  white-space: nowrap;
  min-width: 0;
  line-height: 1;
}

.logo {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: url("/static/img/logo.png") center/contain no-repeat;
  transform-origin: center;
  will-change: transform;
  transition: transform .7s ease;
  flex-shrink: 0;
}

.brand-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  line-height: 1.05;
  padding-top: 1px;
}

/* ── Nav links ──────────────────────────────────────── */
.nav {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-right: auto;
  font-size: 13px;
  min-width: 0;
  flex: 1 1 auto;
}

.nav a {
  color: rgba(255, 255, 255, .62);
  text-decoration: none;
  transition: color .18s ease;
  white-space: nowrap;
}

.nav a:hover {
  color: #ffffff;
}

.nav-admin {
  color: #fecaca !important;
  font-weight: 700;
}

.nav-agendar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  color: #fff7f7 !important;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  background: linear-gradient(180deg, rgba(153, 27, 27, .82), rgba(127, 29, 29, .74));
  border: 1px solid rgba(193, 18, 31, .68);
  padding: 0 11px;
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
  transition: all .18s ease;
  white-space: nowrap;
}

.nav-agendar i {
  font-size: 13px;
  line-height: 1;
}

.nav-agendar:hover {
  background: linear-gradient(180deg, rgba(153, 27, 27, .94), rgba(127, 29, 29, .86)) !important;
  border-color: rgba(193, 18, 31, .84) !important;
  color: #ffffff !important;
  transform: translateY(-1px);
}

#nav-gift-card-link {
  color: #f8f6f2 !important;
  background: rgba(8, 8, 8, .76);
  border-color: rgba(212, 175, 55, .70);
  box-shadow: none;
}

#nav-gift-card-link i {
  color: #d4af37 !important;
}

#nav-gift-card-link:hover {
  background: rgba(212, 175, 55, .08) !important;
  border-color: rgba(212, 175, 55, .86) !important;
  color: #ffffff !important;
}

#mobile-nav-gift-card-link {
  color: #ffffff !important;
}

#mobile-nav-gift-card-link i {
  color: #fbbf24 !important;
}

/* ── Actions area ───────────────────────────────────── */
.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  align-self: center;
  margin-left: auto;
  flex-shrink: 0;
  min-height: 0;
}

/* ── User greeting block ────────────────────────────── */
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  max-width: 190px;
  overflow: hidden;
}

.topbar-user__avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}

.topbar-user__greeting {
  font-size: 12.5px;
  color: rgba(255, 255, 255, .70);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ── Topbar compact buttons ─────────────────────────── */
.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0;
  border-radius: 0;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
  outline-offset: 2px;
}

.topbar-btn i {
  font-size: 15px;
  line-height: 1;
}

/* Profile button – outline glass */
.topbar-btn--profile {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, .85);
}

.topbar-btn--profile:hover {
  background: transparent;
  border-color: transparent;
  color: #ffffff;
  box-shadow: none;
}

.topbar-btn--profile:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .4);
}

/* Logout button – subtle, red on hover */
.topbar-btn--logout {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, .58);
}

.topbar-btn--logout:hover {
  background: transparent;
  border-color: transparent;
  color: #fca5a5;
}

.topbar-btn--logout:focus-visible {
  outline: 2px solid rgba(239, 68, 68, .45);
}

/* Login / Ingresar button */
.topbar-btn--login {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, .82);
}

.topbar-btn--login:hover {
  background: transparent;
  color: #ffffff;
}

/* Support button – minimal */
.topbar-btn--support {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, .7);
}

.topbar-btn--support:hover {
  background: transparent;
  border-color: transparent;
  color: #ffffff;
}

.topbar-btn--support i {
  font-size: 20px;
}

.topbar-mobile-menu {
  display: none;
}

/* ── Logo hover animation ───────────────────────────── */
@media (hover: hover) and (pointer: fine) and (min-width: 781px) {

  .topbar-home:hover .logo,
  .topbar-home:focus-visible .logo {
    transform: rotate(16deg);
  }
}

/* ── Responsive: medium (hide greeting text, icon-only buttons) ── */
@media (max-width: 900px) {
  .topbar .inner {
    width: min(100% - 24px, 1220px);
  }

  .topbar-home {
    flex-basis: auto;
  }

  .nav {
    gap: 10px;
  }

  .nav-agendar {
    padding-inline: 10px;
  }

  .topbar-user__greeting {
    display: none;
  }

  .topbar-user {
    padding: 4px;
    max-width: unset;
    background: transparent;
    border-color: transparent;
  }

  .topbar-btn span {
    display: none;
  }

  .topbar-btn {
    width: 36px;
    padding: 0;
    justify-content: center;
  }
}

@media (max-width: 780px) {
  .topbar .inner {
    width: min(100% - 20px, 1220px);
    height: 56px;
    min-height: 56px;
    padding: 0;
    gap: 10px;
    justify-content: center;
    position: relative;
  }

  .logo {
    width: 34px;
    height: 34px;
  }

  .brand {
    font-size: clamp(11px, 3vw, 12.5px);
    letter-spacing: .1px;
    gap: 8px;
  }

  .nav {
    display: none;
  }

  .topbar-menu-toggle {
    display: inline-flex;
    flex: 0 0 44px;
    margin-left: auto;
  }

  .topbar-home {
    position: absolute;
    left: 50%;
    top: 50%;
    max-width: calc(100% - 112px);
    transform: translate(-50%, -50%);
    justify-content: center;
  }

  .actions {
    display: none;
  }

  .topbar-mobile-menu {
    position: fixed;
    inset: 56px 0 0 0;
    z-index: 1200;
    display: grid;
    align-items: start;
    justify-items: stretch;
    padding: 10px 12px 18px;
    background: rgba(15, 23, 42, .34);
    backdrop-filter: blur(8px);
  }

  .topbar-mobile-menu[hidden] {
    display: none;
  }

  .topbar-mobile-menu__panel {
    width: min(100%, 430px);
    margin: 0 auto;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .24);
    padding: 10px;
    display: grid;
    gap: 10px;
    max-height: calc(100vh - 76px);
    overflow: auto;
    transform-origin: top center;
    animation: topbarPanelIn .18s ease-out;
  }

  .topbar-mobile-menu__nav {
    display: grid;
    gap: 8px;
  }

  .topbar-mobile-menu__nav a {
    min-height: 48px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    color: #1f2937;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
  }

  .topbar-mobile-menu__nav a i {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 17px;
    flex: 0 0 24px;
  }

  .topbar-mobile-menu__nav a:hover,
  .topbar-mobile-menu__nav a:focus-visible {
    background: #f8fafc;
    border-color: #fecaca;
    color: #111827;
    transform: translateY(-1px);
    outline: none;
  }

  #mobile-nav-agendar-link {
    border-color: rgba(127, 29, 29, .22);
    background: #7f1d1d;
    color: #fff7f7;
  }

  #mobile-nav-agendar-link i {
    color: #fff7f7;
  }

  #mobile-nav-agendar-link:hover,
  #mobile-nav-agendar-link:focus-visible {
    border-color: rgba(153, 27, 27, .35);
    background: #991b1b;
    color: #ffffff;
  }

  #mobile-nav-gift-card-link {
    border-color: rgba(212, 175, 55, .48);
    background: #111111;
    color: #f8f6f2 !important;
  }

  #mobile-nav-gift-card-link i {
    color: #d4af37 !important;
  }

  #mobile-nav-gift-card-link:hover,
  #mobile-nav-gift-card-link:focus-visible {
    border-color: rgba(212, 175, 55, .66);
    background: rgba(212, 175, 55, .08);
    color: #ffffff !important;
  }

  .topbar-mobile-menu__actions {
    display: grid;
    gap: 8px;
    border-top: 1px solid #e5e7eb;
    padding-top: 10px;
  }

  .topbar-mobile-menu__actions .topbar-btn {
    width: 100%;
    height: 46px;
    justify-content: center;
    border-radius: 12px;
  }

  .topbar-mobile-menu__actions .topbar-btn span {
    display: inline;
  }

  .topbar-mobile-menu__actions .topbar-btn--profile {
    background: #f8fafc;
    border-color: #e5e7eb;
    color: #374151;
  }

  .topbar-mobile-menu__actions .topbar-btn--logout {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #e11d48;
  }

  .topbar-mobile-menu__actions .topbar-btn--login {
    background: #ef4444;
    border-color: #ef4444;
    color: #ffffff;
  }
}

@media (max-width: 520px) {
  .brand {
    max-width: 250px;
  }

  .topbar .inner {
    gap: 8px;
  }

  .topbar-home {
    min-width: 0;
    max-width: calc(100% - 112px);
    flex: 0 1 auto;
  }

  .topbar-mobile-menu {
    padding-inline: 10px;
  }
}

@media (max-width: 360px) {
  .brand {
    max-width: 210px;
    gap: 7px;
  }

  .logo {
    width: 32px;
    height: 32px;
  }

  .topbar-menu-toggle {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }
}

@keyframes topbarPanelIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
