/* =========================================================
   ML RENTABILIDAD · TOPBAR
   FUTURISTA / PREMIUM / FLAT
   BORDES MARCADOS / DIVISIONES / ANIMADO
   ========================================================= */


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

.topbar {
  position: relative;

  z-index: 100;

  width: 100%;
  height: var(--topbar-height);
  min-height: var(--topbar-height);

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

  gap: 12px;

  padding:
    0
    14px;

  overflow: hidden;

  border-bottom:
    1px solid
    var(--border-strong);

  background:
    color-mix(
      in srgb,
      var(--surface) 97%,
      transparent
    );

  backdrop-filter:
    blur(18px);

  -webkit-backdrop-filter:
    blur(18px);

  transition:
    background var(--transition),
    border-color var(--transition);
}


/* =========================================================
   ACCENT BOTTOM
   ========================================================= */

.topbar::after {
  position: absolute;

  right: 0;
  bottom: 0;
  left: 0;

  height: 1px;

  content: "";

  pointer-events: none;

  background:
    linear-gradient(
      90deg,
      var(--accent) 0,
      color-mix(
        in srgb,
        var(--accent) 40%,
        transparent
      ) 120px,
      transparent 34%
    );

  opacity: 0.8;
}


/* =========================================================
   SCAN GLOW
   ========================================================= */

.topbar::before {
  position: absolute;

  top: 0;
  bottom: 0;

  left: -160px;

  width: 130px;

  content: "";

  pointer-events: none;

  background:
    linear-gradient(
      90deg,
      transparent,
      color-mix(
        in srgb,
        var(--accent) 5%,
        transparent
      ),
      transparent
    );

  animation:
    topbarScan
    10s
    linear
    infinite;
}

@keyframes topbarScan {
  from {
    transform:
      translateX(0);
  }

  to {
    transform:
      translateX(
        calc(100vw + 320px)
      );
  }
}


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

.topbar-left {
  position: relative;
  z-index: 2;

  min-width: 0;

  display: flex;
  align-items: center;

  gap: 12px;
}


/* =========================================================
   SIDEBAR TOGGLE
   ========================================================= */

#sidebarToggle {
  position: relative;

  width: 34px;
  height: 34px;

  display: grid;
  place-items: center;

  flex:
    0
    0
    auto;

  padding: 0;

  border:
    1px solid
    var(--accent-border);

  border-radius: 7px;

  background:
    color-mix(
      in srgb,
      var(--accent) 7%,
      transparent
    );

  color:
    var(--accent);

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

#sidebarToggle:hover {
  border-color:
    var(--accent);

  background:
    color-mix(
      in srgb,
      var(--accent) 12%,
      transparent
    );

  transform:
    translateY(-1px);

  box-shadow:
    0 0 18px
    color-mix(
      in srgb,
      var(--accent) 12%,
      transparent
    );
}

#sidebarToggle:active {
  transform:
    scale(0.94);
}

#sidebarToggle svg {
  width: 14px;
  height: 14px;
}


/* =========================================================
   TOGGLE STATUS
   ========================================================= */

#sidebarToggle::after {
  position: absolute;

  right: 4px;
  bottom: 4px;

  width: 3px;
  height: 3px;

  content: "";

  border-radius: 50%;

  background:
    var(--accent);

  box-shadow:
    0 0 7px
    var(--accent);

  animation:
    topbarStatusPulse
    2s
    ease-in-out
    infinite;
}

@keyframes topbarStatusPulse {
  0%,
  100% {
    opacity: 0.4;
  }

  50% {
    opacity: 1;
  }
}


/* =========================================================
   TITLE
   ========================================================= */

.topbar-title {
  position: relative;

  min-width: 0;

  display: flex;
  align-items: center;

  gap: 8px;

  padding-left:
    12px;

  border-left:
    1px solid
    var(--border-strong);
}

.topbar-title span {
  color:
    var(--muted);

  font-size: 8px;
  font-weight: 850;

  letter-spacing:
    0.1em;

  text-transform:
    uppercase;

  white-space:
    nowrap;
}

.topbar-title strong {
  max-width: 240px;

  overflow: hidden;

  color:
    var(--text);

  font-size: 13px;
  font-weight: 900;

  letter-spacing:
    -0.025em;

  text-overflow:
    ellipsis;

  white-space:
    nowrap;
}


/* =========================================================
   TITLE DOT
   ========================================================= */

.topbar-title::before {
  position: absolute;

  top: 50%;
  left: -3px;

  width: 5px;
  height: 5px;

  content: "";

  border-radius: 50%;

  background:
    var(--accent);

  transform:
    translateY(-50%);

  box-shadow:
    0 0 9px
    color-mix(
      in srgb,
      var(--accent) 70%,
      transparent
    );
}


/* =========================================================
   TITLE ANIMATION
   ========================================================= */

.topbar-title-changing {
  animation:
    topbarTitleEnter
    220ms
    ease;
}

@keyframes topbarTitleEnter {
  from {
    opacity: 0;

    transform:
      translateY(4px);
  }

  to {
    opacity: 1;

    transform:
      translateY(0);
  }
}


/* =========================================================
   ACTIONS
   ========================================================= */

.topbar-actions {
  position: relative;
  z-index: 2;

  min-width: 0;

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

  gap: 0;
}


/* =========================================================
   CLOCK
   ========================================================= */

.topbar-clock {
  min-width: 145px;
  height: 38px;

  display: flex;
  align-items: center;

  gap: 8px;

  padding:
    0
    12px;

  border-left:
    1px solid
    var(--border-strong);

  border-right:
    1px solid
    var(--border-strong);

  background:
    transparent;

  transition:
    background var(--transition);
}

.topbar-clock:hover {
  background:
    color-mix(
      in srgb,
      var(--accent) 4%,
      transparent
    );
}


/* =========================================================
   CLOCK ICON
   ========================================================= */

.topbar-clock-icon {
  width: 27px;
  height: 27px;

  flex:
    0
    0
    auto;

  display: grid;
  place-items: center;

  border:
    1px solid
    var(--accent-border);

  border-radius: 6px;

  background:
    color-mix(
      in srgb,
      var(--accent) 7%,
      transparent
    );

  color:
    var(--accent);
}

.topbar-clock-icon svg {
  width: 12px;
  height: 12px;
}


/* =========================================================
   CLOCK COPY
   ========================================================= */

.topbar-clock-copy {
  min-width: 0;

  display: grid;

  gap: 2px;
}

.topbar-clock-time {
  display: flex;
  align-items: baseline;

  gap: 3px;
}

.topbar-clock-time strong {
  color:
    var(--text);

  font-size: 12px;
  font-weight: 900;

  line-height: 1;

  letter-spacing:
    -0.035em;

  font-variant-numeric:
    tabular-nums;
}

.topbar-clock-time span {
  min-width: 13px;

  color:
    var(--accent);

  font-size: 7px;
  font-weight: 900;

  line-height: 1;

  font-variant-numeric:
    tabular-nums;
}

#topbarClockDate {
  max-width: 100px;

  overflow: hidden;

  color:
    var(--muted);

  font-size: 7px;
  font-weight: 700;

  text-overflow:
    ellipsis;

  text-transform:
    capitalize;

  white-space:
    nowrap;
}


/* =========================================================
   ICON BUTTONS
   ========================================================= */

.topbar .icon-button {
  width: 34px;
  height: 34px;

  display: grid;
  place-items: center;

  flex:
    0
    0
    auto;

  padding: 0;

  border: 0;
  border-left:
    1px solid
    var(--border);

  border-radius: 0;

  background:
    transparent;

  color:
    var(--muted);

  box-shadow:
    none;

  transition:
    background var(--transition),
    color var(--transition),
    border-color var(--transition);
}

.topbar .icon-button:hover {
  background:
    color-mix(
      in srgb,
      var(--accent) 7%,
      transparent
    );

  color:
    var(--text);
}

.topbar .icon-button:active {
  background:
    color-mix(
      in srgb,
      var(--accent) 12%,
      transparent
    );
}

.topbar .icon-button:disabled {
  cursor:
    not-allowed;

  opacity: 0.35;
}

.topbar .icon-button svg {
  width: 13px;
  height: 13px;
}


/* =========================================================
   KEEP SIDEBAR TOGGLE SPECIAL
   ========================================================= */

.topbar #sidebarToggle {
  border:
    1px solid
    var(--accent-border);

  border-radius: 7px;
}


/* =========================================================
   ZOOM
   ========================================================= */

.zoom-control {
  height: 38px;

  display: flex;
  align-items: center;

  overflow: hidden;

  border: 0;
  border-left:
    1px solid
    var(--border-strong);

  border-right:
    1px solid
    var(--border-strong);

  border-radius: 0;

  background:
    transparent;
}

.topbar-action,
.zoom-value {
  height: 37px;

  display: grid;
  place-items: center;

  padding: 0;

  border: 0;

  background:
    transparent;

  color:
    var(--muted);

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

.topbar-action {
  width: 30px;
}

.topbar-action:hover {
  background:
    color-mix(
      in srgb,
      var(--accent) 6%,
      transparent
    );

  color:
    var(--text);
}

.topbar-action:active {
  background:
    var(--accent-soft);
}

.topbar-action:disabled {
  cursor:
    not-allowed;

  opacity: 0.25;
}

.topbar-action svg {
  width: 11px;
  height: 11px;
}

.zoom-value {
  min-width: 48px;

  padding:
    0
    6px;

  border-left:
    1px solid
    var(--border);

  border-right:
    1px solid
    var(--border);

  color:
    var(--text-2);

  font-size: 9px;
  font-weight: 900;

  font-variant-numeric:
    tabular-nums;
}

.zoom-value:hover {
  background:
    color-mix(
      in srgb,
      var(--accent) 7%,
      transparent
    );

  color:
    var(--text);
}

.zoom-reset-pulse {
  animation:
    zoomResetPulse
    280ms
    ease;
}

@keyframes zoomResetPulse {
  50% {
    background:
      var(--accent-soft);

    transform:
      scale(0.92);
  }
}


/* =========================================================
   DIVIDER
   ========================================================= */

.topbar-divider {
  width: 1px;
  height: 38px;

  margin: 0;

  flex:
    0
    0
    auto;

  background:
    var(--border-strong);
}


/* =========================================================
   THEME
   ========================================================= */

#themeButton:hover {
  color:
    var(--accent);
}

#themeButton svg {
  transition:
    transform
    240ms
    ease;
}

#themeButton:hover svg {
  transform:
    rotate(25deg)
    scale(1.08);
}


/* =========================================================
   USER
   ========================================================= */

.topbar-user {
  height: 38px;

  display: flex;
  align-items: center;

  gap: 7px;

  padding:
    0
    10px;

  border: 0;
  border-left:
    1px solid
    var(--border-strong);

  border-right:
    1px solid
    var(--border-strong);

  border-radius: 0;

  background:
    transparent;

  transition:
    background var(--transition);
}

.topbar-user:hover {
  background:
    color-mix(
      in srgb,
      var(--accent) 4%,
      transparent
    );
}


/* =========================================================
   AVATAR
   ========================================================= */

.topbar-avatar {
  width: 27px;
  height: 27px;

  display: grid;
  place-items: center;

  flex:
    0
    0
    auto;

  border:
    1px solid
    var(--accent-border);

  border-radius: 6px;

  background:
    color-mix(
      in srgb,
      var(--accent) 6%,
      transparent
    );

  color:
    var(--accent);
}

.topbar-avatar svg {
  width: 12px;
  height: 12px;
}


/* =========================================================
   USER COPY
   ========================================================= */

.topbar-user-copy {
  min-width: 0;

  display: grid;

  gap: 1px;
}

.topbar-user-copy strong {
  max-width: 110px;

  overflow: hidden;

  color:
    var(--text);

  font-size: 9px;
  font-weight: 850;

  line-height: 1;

  text-overflow:
    ellipsis;

  white-space:
    nowrap;
}

.topbar-user-copy span {
  color:
    var(--muted);

  font-size: 7px;
  font-weight: 650;

  line-height: 1;
}


/* =========================================================
   LOGOUT
   ========================================================= */

.logout-icon:hover {
  background:
    var(--danger-soft) !important;

  color:
    var(--danger) !important;
}


/* =========================================================
   SPINNER
   ========================================================= */

.topbar-spinner {
  animation:
    topbarSpin
    650ms
    linear
    infinite;
}

@keyframes topbarSpin {
  to {
    transform:
      rotate(360deg);
  }
}


/* =========================================================
   THEME TRANSITION
   ========================================================= */

html.theme-transitioning
.topbar,
html.theme-transitioning
.topbar *,
html.theme-transitioning
.topbar *::before,
html.theme-transitioning
.topbar *::after {
  transition:
    background 220ms ease,
    color 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease;
}


/* =========================================================
   DARK
   ========================================================= */

html[data-theme="dark"]
.topbar {
  background:
    rgba(
      10,
      13,
      17,
      0.97
    );
}


/* =========================================================
   LIGHT
   ========================================================= */

html[data-theme="light"]
.topbar {
  background:
    rgba(
      255,
      255,
      255,
      0.97
    );
}


/* =========================================================
   DESKTOP MEDIUM
   ========================================================= */

@media (
  max-width: 1150px
) {
  .topbar-clock {
    min-width: 120px;

    padding:
      0
      9px;
  }

  #topbarClockDate {
    max-width: 78px;
  }

  .topbar-title span {
    display: none;
  }
}


/* =========================================================
   TABLET
   ========================================================= */

@media (
  max-width: 1000px
) {
  .topbar-user-copy {
    display: none;
  }

  .topbar-user {
    padding:
      0
      6px;
  }

  .topbar-clock {
    min-width: 105px;
  }

  .topbar-clock-icon {
    display: none;
  }
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (
  max-width: 820px
) {
  .topbar {
    position: sticky;

    top: 0;

    z-index: 150;

    padding:
      0
      9px;
  }

  .topbar-clock {
    min-width: 92px;
    height: 34px;

    padding:
      0
      7px;
  }

  .topbar-clock-time strong {
    font-size: 11px;
  }

  #topbarClockDate {
    max-width: 72px;

    font-size: 6px;
  }
}


/* =========================================================
   MOBILE 700
   ========================================================= */

@media (
  max-width: 700px
) {
  .topbar {
    gap: 6px;
  }

  .topbar-left {
    gap: 6px;
  }

  .topbar-title {
    padding-left:
      8px;
  }

  .topbar-title strong {
    max-width: 120px;

    font-size: 12px;
  }

  .topbar-user {
    display: none;
  }

  .topbar-divider {
    display: none;
  }

  .topbar-clock {
    min-width: 82px;
  }

  #topbarClockSeconds {
    display: none;
  }
}


/* =========================================================
   MOBILE 580
   ========================================================= */

@media (
  max-width: 580px
) {
  .zoom-control {
    display: none;
  }

  .topbar-title strong {
    max-width: 100px;
  }
}


/* =========================================================
   MOBILE 450
   ========================================================= */

@media (
  max-width: 450px
) {
  .topbar {
    padding:
      0
      6px;
  }

  .topbar-clock {
    min-width: 68px;

    padding:
      0
      5px;
  }

  #topbarClockDate {
    display: none;
  }

  .topbar-clock-copy {
    display: flex;
    align-items: center;
  }

  .topbar-title strong {
    max-width: 75px;

    font-size: 11px;
  }
}


/* =========================================================
   VERY SMALL
   ========================================================= */

@media (
  max-width: 360px
) {
  .topbar-title {
    display: none;
  }

  .topbar-clock {
    min-width: 62px;
  }
}


/* =========================================================
   TOUCH
   ========================================================= */

@media (
  hover: none
) {
  #sidebarToggle:hover {
    transform: none;
  }
}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (
  prefers-reduced-motion:
  reduce
) {
  .topbar::before,
  #sidebarToggle::after,
  .topbar-spinner {
    animation:
      none !important;
  }
}