/* ============================================================
   AfriTerminal Sidebar Navigation — Version 1.2
   Sidebar: LEFT  |  Utility bar: RIGHT
   Colors per AfriTerminal Dashboard Nav Brief (May 2026)
   ============================================================ */

/* ── Layout shell ─────────────────────────────────────────── */
.app-shell {
  display: flex;
}

/* ── Sidebar (LEFT, fixed) ───────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 240px;
  background: #0D1117;
  border-right: 1px solid #1F2937;
  display: flex;
  flex-direction: column;
  z-index: 300;
  transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar.collapsed {
  width: 60px;
}

/* ── Main content ─────────────────────────────────────────── */
.main-wrapper {
  margin-left: 240px;
  margin-right: 64px;
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  transition: margin-left 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body.sb-collapsed .main-wrapper {
  margin-left: 60px;
}

/* ── Sidebar header ──────────────────────────────────────── */
.sb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px;
  border-bottom: 1px solid #1F2937;
  min-height: 56px;
  flex-shrink: 0;
}

.sb-logo {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  min-width: 0;
}

.sb-logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 0.08em;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.15s;
  overflow: hidden;
  max-width: 160px;
}

.sidebar.collapsed .sb-logo-text {
  opacity: 0;
  max-width: 0;
}

.sb-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #6B7280;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s;
}

.sb-collapse-btn:hover { color: #FFFFFF; }

/* Left sidebar: default chevron points left (← = collapse leftward) */
.sidebar.collapsed .sb-collapse-btn svg {
  transform: rotate(180deg);
}

/* ── Greeting section ────────────────────────────────────── */
.sb-greeting {
  padding: 10px 14px 12px;
  flex-shrink: 0;
  overflow: hidden;
}

.sb-greeting-divider {
  height: 1px;
  background: #1F2937;
  margin: 0 10px;
  flex-shrink: 0;
}

.sidebar.collapsed .sb-greeting,
.sidebar.collapsed .sb-greeting-divider {
  display: none;
}

.gp-greeting-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 10px;
  color: #6B7280;
  font-weight: 500;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.gp-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.2;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gp-date {
  font-size: 10px;
  color: #4B5563;
  margin-bottom: 0;
}

/* ── Nav scrolling container ─────────────────────────────── */
.sb-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
}

.sb-nav::-webkit-scrollbar { width: 3px; }
.sb-nav::-webkit-scrollbar-track { background: transparent; }
.sb-nav::-webkit-scrollbar-thumb { background: #1F2937; border-radius: 2px; }

/* ── Parent (group header) items ─────────────────────────── */
.sb-parent {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
  color: #9CA3AF;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 6px;
  margin: 2px 6px;
  user-select: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  outline: none;
}

.sb-parent:hover,
.sb-parent:focus-visible {
  background: #1F2937;
  color: #E5E7EB;
}

.sb-parent.active {
  background: #1F2937;
  color: #FFFFFF;
  border-left: 3px solid #00E676;
  padding-left: 9px;
}

.sb-parent-icon {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
}

.sb-parent-label {
  flex: 1;
  overflow: hidden;
  max-width: 200px;
  transition: opacity 0.15s, max-width 0.2s;
}

.sidebar.collapsed .sb-parent-label,
.sidebar.collapsed .sb-chevron {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
}

.sidebar.collapsed .sb-parent {
  justify-content: center;
  padding: 9px;
}

.sidebar.collapsed .sb-parent.active {
  border-left: 3px solid #00E676;
  padding-left: 6px;
}

.sb-chevron {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: #6B7280;
  transition: transform 0.2s, opacity 0.15s;
}

.sb-parent.open .sb-chevron {
  transform: rotate(180deg);
}

/* ── Children accordion ──────────────────────────────────── */
.sb-children {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
}

.sb-children.open {
  max-height: 400px;
}

.sidebar.collapsed .sb-children {
  display: none;
}

/* ── Sub-items ───────────────────────────────────────────── */
.sb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 38px;
  cursor: pointer;
  color: #6B7280;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  margin: 1px 6px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  outline: none;
}

.sb-item:hover,
.sb-item:focus-visible {
  background: #1F2937;
  color: #E5E7EB;
}

.sb-item.active {
  color: #E5E7EB;
  background: rgba(31, 41, 55, 0.5);
  border-left: 3px solid #00E676;
  padding-left: 35px;
}

/* ── PRO badge ───────────────────────────────────────────── */
.sb-pro-badge {
  background: #1D4ED8;
  color: #FFFFFF;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.3px;
  flex-shrink: 0;
  margin-left: auto;
}

/* ── Right utility bar (RIGHT, fixed) ────────────────────── */
.right-bar {
  position: fixed;
  top: 0;
  right: 0;
  width: 64px;
  height: 100vh;
  background: #0D1117;
  border-left: 1px solid #1F2937;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0 20px;
  gap: 6px;
}

.rb-clock-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px 10px;
  border-bottom: 1px solid #1F2937;
  width: 100%;
  margin-bottom: 2px;
}

.rb-clock-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: #E5E7EB;
  letter-spacing: -0.5px;
  line-height: 1.2;
  text-align: center;
}

.rb-clock-tz {
  font-size: 9px;
  color: #4B5563;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin-top: 3px;
  text-transform: uppercase;
}

.rb-btn-wrap {
  position: relative;
}

.rb-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: #6B7280;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  font-size: 13px;
  font-weight: 600;
}

.rb-btn:hover { background: #1F2937; color: #E5E7EB; }

.rb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1F2937;
  border: 2px solid #00E676;
  color: #00E676;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
  letter-spacing: 0;
}

.rb-avatar:hover { background: #374151; }

.rb-freshness {
  background: none;
  border: none;
  cursor: pointer;
  color: #6B7280;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px 6px;
  border-top: 1px solid #1F2937;
  width: 100%;
  transition: color 0.15s;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.4;
  word-break: break-word;
  border-radius: 0;
}

.rb-freshness:hover { color: #00E676; }

/* Notification dropdown opens LEFT from right bar */
.right-bar .notif-dropdown {
  top: 0;
  right: calc(100% + 8px);
  left: auto;
}

/* Profile avatar button (topbar — not used in right bar, but keep style) */
.profile-avatar-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #1F2937;
  border: 2px solid #00E676;
  color: #00E676;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  letter-spacing: 0;
  padding: 0;
}

.profile-avatar-btn:hover { background: #374151; }

/* ── Profile panel toggle ────────────────────────────────── */
.pp-toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}

.pp-toggle input { opacity: 0; width: 0; height: 0; }

.pp-toggle-track {
  position: absolute;
  inset: 0;
  background: #1F2937;
  border-radius: 11px;
  border: 1px solid #374151;
  cursor: pointer;
  transition: background 0.2s;
}

.pp-toggle-track::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: #6B7280;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.pp-toggle input:checked + .pp-toggle-track {
  background: rgba(0, 230, 118, 0.15);
  border-color: #00E676;
}

.pp-toggle input:checked + .pp-toggle-track::before {
  transform: translateX(16px);
  background: #00E676;
}

/* ── Hide original nav elements in sidebar mode ──────────── */
body.has-sidebar .tab-bar           { display: none !important; }
body.has-sidebar .bottom-nav        { display: none !important; }
body.has-sidebar .bottom-nav-toggle { display: none !important; }
body.has-sidebar .topbar            { display: none !important; }

/* ── Stock detail panel: hidden until a stock is selected ── */
@media (min-width: 768px) {
  #view-stock               { display: none !important; }
  #view-stock.has-stock     { display: flex !important; }
  #stock-detail-placeholder { display: none !important; }
}

/* ── Mobile: hide both panels, restore original nav ──────── */
@media (max-width: 767px) {
  .sidebar, .right-bar { display: none; }
  .main-wrapper {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  body.has-sidebar .bottom-nav  { display: flex !important; }
  body.has-sidebar .topbar      { display: flex !important; }
}
