/* ─────────────────────────────────────────
   VolatilX Sidebar + Topbar
   static/css/sidebar.css
───────────────────────────────────────── */

:root {
  --vx-sidebar-width: 76px;
  --vx-topbar-height: 56px;
  --vx-sidebar-bg: #070a12;
  --vx-topbar-bg: #07090f;
  --vx-page-bg: #06080F;
  --vx-border: rgba(255, 255, 255, 0.05);
  --vx-gold: #F5A623;
  --vx-gold-dim: rgba(245, 166, 35, 0.1);
  --vx-gold-border: rgba(245, 166, 35, 0.2);
  --vx-green: #22C55E;
  --vx-green-dim: rgba(34, 197, 94, 0.08);
  --vx-green-border: rgba(34, 197, 94, 0.15);
  --vx-text: #E8EEF6;
  --vx-text-dim: #6c7f94;
  --vx-text-muted: #435364;
  --vx-icon-inactive: #47627a;
  --vx-tooltip-bg: #0d1825;
  --vx-tooltip-border: rgba(255, 255, 255, 0.08);
}

/* ── Body offset ── */
body.vx-app {
  margin-left: var(--vx-sidebar-width);
  padding-top: var(--vx-topbar-height);
  background: var(--vx-page-bg);
  min-height: 100vh;
}

/* ── Sidebar ── */
.vx-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--vx-sidebar-width);
  height: 100vh;
  background: var(--vx-sidebar-bg);
  border-right: 1px solid var(--vx-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0 0;
  z-index: 200;
  gap: 4px;
  overflow: visible;
}

/* Logo mark */
.vx-sidebar__logo {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  margin-bottom: 16px;
  flex-shrink: 0;
  transition: opacity 0.15s;
  background: transparent;
  border-radius: 14px;
  padding: 4px;
}

.vx-sidebar__logo:hover {
  opacity: 0.8;
}

.vx-sidebar__logo-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  display: block;
}

/* Nav groups */
.vx-sidebar__nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  flex: 1;
}

.vx-sidebar__group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.vx-sidebar__divider {
  width: 36px;
  height: 1px;
  background: rgba(255, 255, 255, 0.04);
  margin: 8px 0;
}

/* Nav button */
.vx-sidebar__btn {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--vx-icon-inactive);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}

.vx-sidebar__btn svg {
  width: 24px;
  height: 24px;
}

.vx-sidebar__btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #7e95a8;
}

/* Active state */
.vx-sidebar__btn--active {
  background: rgba(245, 166, 35, 0.14);
  color: var(--vx-gold);
  box-shadow: inset 0 0 0 1px rgba(245, 166, 35, 0.1);
}

.vx-sidebar__btn--active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 30px;
  background: var(--vx-gold);
  border-radius: 0 4px 4px 0;
}

.vx-sidebar__btn--active:hover {
  background: rgba(245, 166, 35, 0.18);
  color: var(--vx-gold);
}

/* Tooltip */
.vx-sidebar__btn[data-tooltip]::after,
.vx-sidebar__runs[data-tooltip]::after,
.vx-sidebar__avatar[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--vx-tooltip-bg);
  border: 1px solid var(--vx-tooltip-border);
  color: var(--vx-text);
  font-family: 'DM Mono', 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 300;
}

.vx-sidebar__btn[data-tooltip]:hover::after,
.vx-sidebar__runs[data-tooltip]:hover::after,
.vx-sidebar__avatar[data-tooltip]:hover::after {
  opacity: 1;
}

/* Bottom section */
.vx-sidebar__bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-bottom: 24px;
  flex-shrink: 0;
  width: 100%;
  position: relative;
}

/* Runs counter */
.vx-sidebar__runs {
  position: relative;
  width: 40px;
  background: var(--vx-green-dim);
  border: 1px solid var(--vx-green-border);
  border-radius: 8px;
  padding: 7px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: default;
  flex-shrink: 0;
}

.vx-sidebar__runs-num {
  font-family: 'DM Mono', 'Courier New', monospace;
  font-size: 9px;
  color: var(--vx-green);
  line-height: 1;
}

.vx-sidebar__runs-track {
  width: 24px;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}

.vx-sidebar__runs-fill {
  height: 100%;
  background: var(--vx-green);
  border-radius: 2px;
  transition: width 0.3s ease;
  min-width: 2px;
}

.vx-sidebar__runs-total {
  font-family: 'DM Mono', 'Courier New', monospace;
  font-size: 8px;
  color: rgba(34, 197, 94, 0.3);
  line-height: 1;
}

/* Avatar */
.vx-sidebar__avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--vx-gold-dim);
  border: 1px solid var(--vx-gold-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'DM Mono', 'Courier New', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--vx-gold);
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
  flex-shrink: 0;
}

.vx-sidebar__avatar:hover {
  background: rgba(245, 166, 35, 0.16);
}

/* Account dropdown */
.vx-account-menu {
  position: absolute;
  bottom: 4px;
  left: calc(100% + 12px);
  width: 200px;
  background: #0d1825;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 6px;
  z-index: 400;
  display: none;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.vx-account-menu--open {
  display: flex;
}

.vx-account-menu__email {
  font-family: 'DM Mono', 'Courier New', monospace;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.25);
  padding: 6px 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 4px;
  word-break: break-all;
}

.vx-account-menu__item {
  display: block;
  font-family: 'DM Mono', 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #5a7a9a;
  text-decoration: none;
  padding: 7px 10px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.vx-account-menu__item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #c8d8e8;
}

.vx-account-menu__item--danger {
  color: rgba(239, 68, 68, 0.6);
}

.vx-account-menu__item--danger:hover {
  background: rgba(239, 68, 68, 0.07);
  color: #ef4444;
}

.vx-account-menu__divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.05);
  margin: 4px 0;
}

/* ── Topbar ── */
.vx-topbar {
  position: fixed;
  top: 0;
  left: var(--vx-sidebar-width);
  right: 0;
  height: var(--vx-topbar-height);
  background: var(--vx-topbar-bg);
  border-bottom: 1px solid var(--vx-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
  gap: 12px;
}

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

.vx-topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.vx-topbar__badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'DM Mono', 'Courier New', monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--vx-gold);
  background: rgba(245, 166, 35, 0.08);
  border: 1px solid var(--vx-gold-border);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.vx-topbar__badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--vx-gold);
  flex-shrink: 0;
}

.vx-topbar__title {
  font-family: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--vx-text);
  line-height: 1;
  letter-spacing: -0.35px;
  white-space: nowrap;
  flex-shrink: 0;
}

.vx-topbar__sep {
  font-family: 'DM Mono', 'Courier New', monospace;
  font-size: 12px;
  color: var(--vx-text-muted);
  flex-shrink: 0;
}

.vx-topbar__subtitle {
  font-family: 'DM Mono', 'Courier New', monospace;
  font-size: 12px;
  color: var(--vx-text-dim);
  letter-spacing: 0.04em;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(760px, 56vw);
}

.vx-topbar__alert-btn {
  position: relative;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(245, 166, 35, 0.12);
  background: rgba(255, 255, 255, 0.02);
  color: #6f89a5;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.vx-topbar__alert-btn:hover {
  color: var(--vx-gold);
  border-color: rgba(245, 166, 35, 0.28);
  background: rgba(245, 166, 35, 0.06);
}

.vx-topbar__alert-btn:focus-visible {
  outline: 2px solid rgba(245, 166, 35, 0.42);
  outline-offset: 2px;
}

.vx-topbar__alert-badge {
  position: absolute;
  top: -4px;
  right: -5px;
  pointer-events: none;
}

@media (max-width: 1180px) {
  .vx-topbar__subtitle {
    max-width: 38vw;
    font-size: 11px;
  }
}

@media (max-width: 980px) {
  .vx-topbar__sep,
  .vx-topbar__subtitle {
    display: none;
  }
}

/* ── Mobile: hide sidebar, show bottom bar ── */
@media (max-width: 768px) {
  :root {
    --vx-sidebar-width: 0px;
    --vx-topbar-height: 48px;
  }

  body.vx-app {
    margin-left: 0;
    padding-top: var(--vx-topbar-height);
    padding-bottom: 56px;
  }

  .vx-sidebar {
    display: none;
  }

  .vx-topbar {
    left: 0;
    padding: 0 12px;
    gap: 10px;
  }

  .vx-topbar__right {
    display: flex;
  }

  .vx-topbar__left {
    gap: 8px;
    min-width: 0;
  }

  .vx-topbar__badge {
    padding: 4px 8px;
    font-size: 9px;
    letter-spacing: 0.1em;
  }

  .vx-topbar__title {
    font-size: 19px;
  }

  .vx-topbar__alert-btn {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

  .vx-topbar__alert-btn svg {
    width: 18px;
    height: 18px;
  }

  .vx-topbar__alert-badge {
    top: -5px;
    right: -6px;
  }

  /* Mobile bottom nav */
  .vx-mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--vx-sidebar-bg);
    border-top: 1px solid var(--vx-border);
    z-index: 200;
    align-items: center;
    justify-content: space-around;
    padding: 0 4px;
  }

  .vx-mobile-nav__btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--vx-icon-inactive);
    text-decoration: none;
    padding: 4px 2px;
    border-radius: 8px;
    transition: color 0.15s;
    flex: 1;
    min-width: 0;
    justify-content: center;
  }

  .vx-mobile-nav__btn--active {
    color: var(--vx-gold);
  }

  .vx-mobile-nav__label {
    font-family: 'DM Mono', monospace;
    font-size: 7px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
  }
}

@media (min-width: 769px) {
  .vx-mobile-nav {
    display: none;
  }
}
