/*
 * HomeKept — Dispatcher Sidebar
 * Companion to tooltips.css — handles sidebar layout and icon button styles.
 */

:root {
  --sidebar-w:     64px;
  --sidebar-bg:    #0a4744;       /* --teal-deep */
  --sidebar-hover: rgba(255,255,255,.08);
  --sidebar-active: rgba(255,255,255,.14);
  --sidebar-icon:  rgba(255,255,255,.55);
  --sidebar-icon-active: #ffffff;
  --sidebar-border: rgba(255,255,255,.10);
}

/* ── Shell ──────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0 16px;
  gap: 0;
  z-index: 200;
  box-shadow: 2px 0 12px rgba(10,71,68,.25);
}

/* ── Logo mark ──────────────────────────────────────────────────────── */
.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: #0f5e5a;
  color: #fff;
  margin-bottom: 20px;
  text-decoration: none;
  flex: none;
  transition: background .15s;
}
.sidebar-logo:hover { background: #14706b; }
.sidebar-logo-mark svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
}

/* ── Primary nav ────────────────────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  width: 100%;
}
.sidebar-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

/* ── Link / button shared ───────────────────────────────────────────── */
.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  color: var(--sidebar-icon);
  transition:
    background .14s ease,
    color .14s ease,
    transform .1s ease;
  /* needed for tooltip positioning */
  position: relative;
}

.sidebar-link:hover,
.sidebar-link:focus-visible {
  background: var(--sidebar-hover);
  color: var(--sidebar-icon-active);
  outline: none;
}

.sidebar-link:active {
  transform: scale(.94);
}

/* Active page state — set class="active" via server template */
.sidebar-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-icon-active);
}

.sidebar-link.active .sidebar-icon svg {
  stroke-width: 2.3;
}

/* Focus ring for keyboard nav */
.sidebar-link:focus-visible {
  box-shadow: 0 0 0 2px rgba(255,255,255,.5);
}

/* ── Icon wrapper ───────────────────────────────────────────────────── */
.sidebar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: none;
}
.sidebar-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

/* ── Divider ────────────────────────────────────────────────────────── */
.sidebar-nav::after {
  content: '';
  display: block;
  width: 32px;
  height: 1px;
  background: var(--sidebar-border);
  margin: 8px auto 0;
}

/* ── Bottom section ─────────────────────────────────────────────────── */
.sidebar-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--sidebar-border);
  width: 100%;
}

/* ── Avatar button ──────────────────────────────────────────────────── */
.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  padding: 0;
}
.sidebar-avatar-initials {
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  letter-spacing: -.01em;
  line-height: 1;
  pointer-events: none;
}

/* ── Touch-active state (from nav-tooltips.js) ──────────────────────── */
.sidebar-link.tooltip-touch-active {
  background: var(--sidebar-hover);
  color: var(--sidebar-icon-active);
}

/* ── Tooltip overrides for dark sidebar context ─────────────────────── */
.sidebar [data-tooltip]::after {
  font-size: 12px;
  padding: 5px 10px;
}

/* ── Page content offset ────────────────────────────────────────────── */
.with-sidebar {
  margin-left: var(--sidebar-w);
}

/* ── Responsive: collapse to bottom bar on mobile ───────────────────── */
@media (max-width: 640px) {
  .sidebar {
    width: 100%;
    height: 60px;
    top: auto;
    bottom: 0;
    flex-direction: row;
    padding: 0 12px;
    gap: 0;
    justify-content: space-around;
    box-shadow: 0 -2px 12px rgba(10,71,68,.22);
  }

  .sidebar-logo {
    display: none;
  }

  .sidebar-nav {
    flex: none;
    width: auto;
  }

  .sidebar-nav ul {
    flex-direction: row;
    gap: 0;
  }

  .sidebar-bottom {
    flex-direction: row;
    border-top: none;
    border-left: 1px solid var(--sidebar-border);
    padding-top: 0;
    padding-left: 10px;
    width: auto;
  }

  /* Bottom bar: use top tooltips instead of right */
  .sidebar [data-tooltip]:not([data-tooltip-pos])::before,
  .sidebar [data-tooltip]:not([data-tooltip-pos])::after {
    /* reset right-tooltip positions */
    left: auto;
    top: auto;
    right: auto;
    bottom: auto;
    border: var(--tt-arrow) solid transparent;
    transform: none;
  }
  .sidebar [data-tooltip]:not([data-tooltip-pos])::before {
    border-top-color: var(--tt-bg);
    bottom: calc(100% + var(--tt-offset) - var(--tt-arrow));
    left: 50%;
    transform: translateX(-50%) translateY(5px);
  }
  .sidebar [data-tooltip]:not([data-tooltip-pos])::after {
    bottom: calc(100% + var(--tt-offset) + var(--tt-arrow));
    left: 50%;
    transform: translateX(-50%) translateY(5px);
  }
  .sidebar [data-tooltip]:not([data-tooltip-pos]):hover::before,
  .sidebar [data-tooltip]:not([data-tooltip-pos]):focus-visible::before {
    transform: translateX(-50%) translateY(0);
  }
  .sidebar [data-tooltip]:not([data-tooltip-pos]):hover::after,
  .sidebar [data-tooltip]:not([data-tooltip-pos]):focus-visible::after {
    transform: translateX(-50%) translateY(0);
  }

  .with-sidebar {
    margin-left: 0;
    margin-bottom: 60px;
  }
}