/* =========================================================
   WIRTZ HUB · TOPBAR
   Barra superior premium · minimalista · responsive · dark safe
   Foto de perfil integrada
   ========================================================= */

/* =========================================================
   TOPBAR BASE
   ========================================================= */

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

  display: flex;
  align-items: center;
  justify-content: space-between;

  min-height: var(--topbar-height);
  padding: 0 10px;

  border-bottom: 1px solid rgba(0, 0, 0, 0.16);
  background: color-mix(in srgb, var(--panel-solid) 96%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);

  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.035),
    0 10px 28px rgba(0, 0, 0, 0.035);

  animation: topbarEnter 0.28s ease both;

  transition:
    background var(--transition),
    border-color var(--transition),
    box-shadow var(--transition),
    min-height var(--transition),
    padding var(--transition);
}

html[data-theme="dark"] .topbar {
  border-bottom-color: rgba(255, 255, 255, 0.13);
  background: rgba(8, 8, 8, 0.92);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.035),
    0 10px 28px rgba(0, 0, 0, 0.28);
}

/* =========================================================
   LADO IZQUIERDO
   ========================================================= */

.topbar__left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1 1 auto;
}

.topbar__title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.topbar__title span {
  color: var(--muted);
  font-size: 7.5px;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
}

.topbar__title h1 {
  max-width: clamp(180px, 44vw, 620px);
  margin: 0;

  color: var(--text-strong);
  font-size: 12.5px;
  font-weight: 950;
  line-height: 1.05;
  letter-spacing: -0.045em;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html[data-theme="dark"] .topbar__title h1 {
  color: rgba(255, 255, 255, 0.94);
}

html[data-theme="dark"] .topbar__title span {
  color: rgba(255, 255, 255, 0.48);
}

/* =========================================================
   LADO DERECHO · FORMATO LINEAL
   ========================================================= */

.topbar__right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;

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

  color: var(--text);
}

.topbar__divider {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 18px;
  min-width: 18px;

  color: rgba(0, 0, 0, 0.26);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;

  pointer-events: none;
  user-select: none;
}

html[data-theme="dark"] .topbar__divider {
  color: rgba(255, 255, 255, 0.22);
}

/* =========================================================
   BOTONES LINEALES
   ========================================================= */

.topbar__icon-btn,
.topbar__action,
.topbar__user {
  font-family: inherit;
}

.topbar__icon-btn,
.topbar__action {
  position: relative;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;

  min-height: 28px;
  padding: 0 6px;

  border: 0;
  border-radius: 8px;
  background: transparent;

  color: var(--text);
  font-size: 9px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;

  cursor: pointer;
  outline: none;

  transition:
    background var(--transition),
    color var(--transition),
    transform var(--transition),
    opacity var(--transition);
}

.topbar__icon-btn {
  width: 28px;
  min-width: 28px;
  padding: 0;
}

.topbar__icon-btn:hover,
.topbar__action:hover {
  background: rgba(0, 0, 0, 0.055);
  color: var(--text-strong);
}

html[data-theme="dark"] .topbar__icon-btn,
html[data-theme="dark"] .topbar__action {
  color: rgba(255, 255, 255, 0.72);
}

html[data-theme="dark"] .topbar__icon-btn:hover,
html[data-theme="dark"] .topbar__action:hover {
  background: rgba(255, 255, 255, 0.075);
  color: rgba(255, 255, 255, 0.96);
}

.topbar__icon-btn:active,
.topbar__action:active,
.topbar__user:active {
  transform: scale(0.96);
}

.topbar__icon-btn:focus-visible,
.topbar__action:focus-visible,
.topbar__user:focus-visible {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--text-strong) 18%, transparent);
}

/* Botón salir minimalista */
.topbar__action--danger {
  color: var(--text-strong);
}

.topbar__action--danger:hover {
  background: rgba(230, 0, 0, 0.08);
  color: #e60000;
}

html[data-theme="dark"] .topbar__action--danger {
  color: rgba(255, 255, 255, 0.82);
}

html[data-theme="dark"] .topbar__action--danger:hover {
  background: rgba(230, 0, 0, 0.16);
  color: #ff4b4b;
}

/* =========================================================
   USUARIO LINEAL + FOTO
   ========================================================= */

.topbar__user {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  min-height: 30px;
  max-width: 250px;

  padding: 0 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;

  color: var(--text);

  line-height: 1;
  white-space: nowrap;
  overflow: hidden;

  cursor: pointer;
  outline: none;

  transition:
    background var(--transition),
    color var(--transition),
    opacity var(--transition),
    transform var(--transition);
}

.topbar__user:hover {
  background: rgba(0, 0, 0, 0.045);
}

html[data-theme="dark"] .topbar__user:hover {
  background: rgba(255, 255, 255, 0.065);
}

.topbar__avatar {
  display: inline-grid;
  place-items: center;

  width: 27px;
  height: 27px;
  min-width: 27px;

  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 999px;
  background:
    linear-gradient(
      135deg,
      rgba(230, 0, 0, 0.08),
      rgba(0, 0, 0, 0.035)
    );

  color: var(--text-strong);

  overflow: hidden;

  font-size: 8.5px;
  font-weight: 950;
  letter-spacing: -0.04em;

  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.65) inset,
    0 8px 18px rgba(0, 0, 0, 0.055);

  transition:
    transform var(--transition),
    border-color var(--transition),
    box-shadow var(--transition),
    filter var(--transition);
}

.topbar__user:hover .topbar__avatar {
  transform: translateY(-1px);
  border-color: rgba(230, 0, 0, 0.38);
  filter: saturate(1.08);
}

html[data-theme="dark"] .topbar__avatar {
  border-color: rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(
      135deg,
      rgba(230, 0, 0, 0.20),
      rgba(255, 255, 255, 0.055)
    );

  color: rgba(255, 255, 255, 0.92);

  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.055) inset,
    0 8px 18px rgba(0, 0, 0, 0.24);
}

.topbar__avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.topbar__avatar--photo {
  padding: 0;
  background: rgba(0, 0, 0, 0.035);
}

.topbar__avatar .icon {
  width: 12px;
  height: 12px;
}

.topbar__user-info {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  min-width: 0;
  overflow: hidden;
}

.topbar__user-name {
  max-width: 128px;

  color: var(--text-strong);
  font-size: 9.2px;
  font-weight: 900;

  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__user-separator {
  color: rgba(0, 0, 0, 0.24);
  font-size: 9px;
  font-weight: 700;
}

.topbar__user-role {
  max-width: 102px;

  color: var(--muted);
  font-size: 7.6px;
  font-weight: 850;
  letter-spacing: 0.045em;
  text-transform: uppercase;

  overflow: hidden;
  text-overflow: ellipsis;
}

html[data-theme="dark"] .topbar__user-name {
  color: rgba(255, 255, 255, 0.92);
}

html[data-theme="dark"] .topbar__user-role {
  color: rgba(255, 255, 255, 0.48);
}

html[data-theme="dark"] .topbar__user-separator {
  color: rgba(255, 255, 255, 0.22);
}

/* =========================================================
   ICONOS
   ========================================================= */

.topbar .icon {
  width: 12px;
  height: 12px;
  stroke-width: 2;
}

/* =========================================================
   ESTADOS GLOBALES
   ========================================================= */

:root[data-sidebar="hidden"] #sidebarToggleBtn i {
  opacity: 0.82;
}

:root[data-rightbar="hidden"] #rightbarToggleBtn {
  opacity: 0.72;
}

/* =========================================================
   RESPONSIVE · TABLET
   ========================================================= */

@media (max-width: 980px) {
  .topbar {
    position: sticky;
    top: 0;
    z-index: 80;

    min-height: 44px;
    padding: 6px 8px;

    border-bottom-color: rgba(0, 0, 0, 0.12);
  }

  .topbar__title h1 {
    max-width: clamp(150px, 42vw, 380px);
  }

  .topbar__user {
    max-width: 205px;
  }

  .topbar__user-name {
    max-width: 96px;
  }

  .topbar__user-role {
    max-width: 78px;
  }
}

@media (max-width: 820px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;

    min-height: 44px;
    padding: 6px 8px;
  }

  .topbar__left {
    width: auto;
    min-width: 0;
  }

  .topbar__right {
    width: auto;
    max-width: 48vw;

    justify-content: flex-end;

    overflow-x: auto;
    overflow-y: hidden;

    padding-bottom: 0;

    scrollbar-width: none;
  }

  .topbar__right::-webkit-scrollbar {
    display: none;
  }

  .topbar__title span {
    display: none;
  }

  .topbar__title h1 {
    max-width: calc(100vw - 190px);
    font-size: 12px;
  }

  .topbar__icon-btn,
  .topbar__action,
  .topbar__user {
    min-height: 30px;
  }

  .topbar__user {
    flex: 0 0 auto;
  }
}

/* =========================================================
   RESPONSIVE · MOBILE
   ========================================================= */

@media (max-width: 560px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;

    min-height: 42px;
    gap: 6px;
    padding: 5px 7px;
  }

  .topbar__left {
    gap: 6px;
  }

  .topbar__title h1 {
    max-width: calc(100vw - 176px);
    font-size: 11.5px;
    letter-spacing: -0.035em;
  }

  .topbar__divider {
    display: none;
  }

  .topbar__action span {
    display: none;
  }

  .topbar__action {
    width: 29px;
    min-width: 29px;
    height: 29px;
    min-height: 29px;
    padding: 0;
  }

  .topbar__icon-btn {
    width: 31px;
    min-width: 31px;
    height: 31px;
    min-height: 31px;
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.04);
  }

  html[data-theme="dark"] .topbar__icon-btn {
    background: rgba(255, 255, 255, 0.06);
  }

  .topbar__right {
    max-width: 116px;
    gap: 4px;
  }

  .topbar__user {
    width: 30px;
    min-width: 30px;
    max-width: 30px;
    height: 30px;
    min-height: 30px;
    padding: 0;
  }

  .topbar__avatar {
    width: 27px;
    height: 27px;
    min-width: 27px;
  }

  .topbar__user-info {
    display: none;
  }
}

@media (max-width: 420px) {
  .topbar {
    min-height: 41px;
    padding: 5px 6px;
  }

  .topbar__title h1 {
    max-width: calc(100vw - 160px);
    font-size: 11px;
  }

  .topbar__right {
    max-width: 106px;
  }

  .topbar__icon-btn {
    width: 30px;
    min-width: 30px;
    height: 30px;
    min-height: 30px;
  }

  .topbar__action {
    width: 28px;
    min-width: 28px;
    height: 28px;
    min-height: 28px;
  }

  .topbar__user {
    width: 29px;
    min-width: 29px;
    max-width: 29px;
    height: 29px;
    min-height: 29px;
  }

  .topbar__avatar {
    width: 26px;
    height: 26px;
    min-width: 26px;
  }
}

@media (max-width: 340px) {
  .topbar__title h1 {
    max-width: calc(100vw - 148px);
  }

  .topbar__right {
    max-width: 96px;
  }
}

/* =========================================================
   ANIMACIONES
   ========================================================= */

@keyframes topbarEnter {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .topbar,
  .topbar *,
  .topbar *::before,
  .topbar *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

