/* ═══════════════════════════════════════════════════════════════
   YBees — Shared Left Sidebar
   ═══════════════════════════════════════════════════════════════ */

/* ── Global Scrollbars for Light Theme ── */
html[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: #c8c2b5;
  border-radius: 4px;
}
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: #b0a89a;
}

/* ── Shell layout: sidebar + main content side by side ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.ybees-sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--surface-2, #1c1723);
  border-right: 1px solid var(--border, rgba(245,241,232,.1));
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  flex-shrink: 0;
  transition: width .15s ease;
}

/* ── Collapsed (icons-only) state ── */
.ybees-sidebar.collapsed { width: 64px; min-width: 64px; }
.ybees-sidebar.collapsed .sb-brand,
.ybees-sidebar.collapsed .sb-nav-label,
.ybees-sidebar.collapsed .sb-section-label,
.ybees-sidebar.collapsed .sb-channel-name,
.ybees-sidebar.collapsed .sb-user-name,
.ybees-sidebar.collapsed .sb-theme-btn span,
.ybees-sidebar.collapsed .sb-action-btn { display: none; }
.ybees-sidebar.collapsed .sb-logo { justify-content: center; padding: 20px 0 16px; }
.ybees-sidebar.collapsed .sb-nav-item { justify-content: center; padding: 9px; }
.ybees-sidebar.collapsed .sb-nav-item.active::before { left: 50%; top: auto; bottom: 4px; width: 60%; height: 2px; transform: translateX(-50%); }
.ybees-sidebar.collapsed .sb-live-dot { position: absolute; top: 6px; right: 10px; }
.ybees-sidebar.collapsed .sb-channel { justify-content: center; }
.ybees-sidebar.collapsed .sb-profile-row { justify-content: center; padding: 6px; }
.ybees-sidebar.collapsed .sb-profile { justify-content: center; flex: none; }
.ybees-sidebar.collapsed .sb-theme-row { flex-direction: column; }

/* ── Collapse toggle button - icon-only, same visual language as the
   Settings gear (.sb-action-btn) rather than a full-width text bar ── */
.sb-collapse-btn-new {
  margin-top: 10px;
  width: 100%;
  background: var(--surface-2, #1c1723);
  border: 1px solid var(--border, rgba(245,241,232,.1));
  border-radius: 7px;
  color: var(--text-sec, #b6afa1);
  font-size: 12px; font-weight: 600; font-family: inherit;
  padding: 8px 0;
  cursor: pointer;
  transition: .12s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  position: relative;
  z-index: 101;
}
.sb-collapse-btn-new:hover { border-color: var(--border-strong, rgba(245,241,232,.18)); color: var(--text, #f5f1e8); }
.sb-collapse-btn-new svg { transition: transform .15s ease; }
.ybees-sidebar.collapsed .sb-collapse-btn-new svg { transform: rotate(180deg); }
.ybees-sidebar.collapsed .sb-collapse-btn-new span { display: none; }

/* ── Logo ── */
.sb-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border, rgba(245,241,232,.1));
  text-decoration: none;
  flex-shrink: 0;
}
.sb-logo-icon {
  font-size: 22px;
  animation: sb-waggle 2.4s ease-in-out infinite;
  transform-origin: bottom center;
  line-height: 1;
}
@keyframes sb-waggle {
  0%,100% { transform: rotate(0deg); }
  15% { transform: rotate(-14deg); }
  30% { transform: rotate(12deg); }
  45% { transform: rotate(-8deg); }
  60% { transform: rotate(6deg); }
}
.sb-brand {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text, #f5f1e8);
}
.sb-brand span { color: var(--amber, #f5a623); }

/* ── Nav sections ── */
.sb-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sb-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-light, #7d7669);
  padding: 12px 10px 4px;
  margin-top: 4px;
}
.sb-section-label:first-child { margin-top: 0; }

/* ── Nav items ── */
.sb-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sec, #b6afa1);
  text-decoration: none;
  cursor: pointer;
  transition: background .12s, color .12s;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
}
.sb-nav-item:hover {
  background: rgba(245,241,232,.06);
  color: var(--text, #f5f1e8);
}
.sb-nav-item.active {
  background: rgba(245,166,35,.1);
  color: var(--amber, #f5a623);
  font-weight: 600;
}
.sb-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 3px;
  border-radius: 2px;
  background: var(--amber, #f5a623);
}
.sb-nav-icon {
  font-size: 15px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}
.sb-nav-label { flex: 1; }

/* Live dot on Live item */
.sb-live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--red, #ff3b30);
  animation: sb-pulse 1.6s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes sb-pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(.75); }
}

/* ── Bottom: channel + theme ── */
.sb-bottom {
  border-top: 1px solid var(--border, rgba(245,241,232,.1));
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

/* Channel row */
.sb-channel {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.sb-channel-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--amber, #f5a623);
  color: var(--amber-ink, #1a1206);
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.sb-channel-avatar img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.sb-channel-name {
  font-size: 12px; font-weight: 600;
  color: var(--text, #f5f1e8);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}

/* Profile row */
.sb-profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface-2, #1c1723);
  border: 1px solid var(--border, rgba(245,241,232,.1));
  border-radius: 8px;
  padding: 6px 10px;
}
.sb-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.sb-user-avatar {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(245,241,232,.1);
  color: var(--text-sec, #b6afa1);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sb-user-name {
  font-size: 12px; font-weight: 500;
  color: var(--text, #f5f1e8);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb-action-btn {
  background: transparent;
  border: none;
  color: var(--text-sec, #b6afa1);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 4px;
  border-radius: 4px;
  transition: .12s;
  flex-shrink: 0;
}
.sb-action-btn:hover {
  background: rgba(245,241,232,.1);
  color: var(--text, #f5f1e8);
}

/* Theme toggle row */
.sb-theme-row {
  display: flex;
  gap: 6px;
}
.sb-theme-btn {
  flex: 1;
  background: var(--surface-2, #1c1723);
  border: 1px solid var(--border, rgba(245,241,232,.1));
  border-radius: 7px;
  color: var(--text-sec, #b6afa1);
  font-size: 12px; font-weight: 600; font-family: inherit;
  padding: 5px 0;
  cursor: pointer;
  transition: .12s;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.sb-collapse-btn-new {
  position: relative;
  z-index: 101;
}
.sb-theme-btn:hover { border-color: var(--border-strong, rgba(245,241,232,.18)); color: var(--text, #f5f1e8); }
.sb-theme-btn.active { background: rgba(245,166,35,.12); border-color: var(--amber, #f5a623); color: var(--amber, #f5a623); }

/* ── Main content next to sidebar ── */
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ── Responsive: hide sidebar on mobile ── */
@media (max-width: 768px) {
  .ybees-sidebar { display: none; }
  .app-shell { display: block; }
}

/* ── Filter bar (filter-bar.js): removable pills + "+ Add filter" flyout ── */
.fb-bar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-bottom: 20px; }
.fb-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-chip {
  position: relative; display: flex; align-items: center; gap: 8px;
  background: var(--surface-2, #1c1723); border: 1px solid var(--border-strong, rgba(245,241,232,.18));
  border-radius: 16px; padding: 6px 8px 6px 12px; font-size: 12px; color: var(--text, #f5f1e8);
  cursor: pointer; white-space: nowrap;
}
.fb-chip:hover { border-color: var(--amber, #f5a623); }
.fb-chip-label strong { font-weight: 700; }
.fb-chip-remove {
  font-family: inherit; background: none; border: none; color: var(--text-light, #7d7669);
  font-size: 12px; line-height: 1; cursor: pointer; padding: 3px 5px; border-radius: 50%;
}
.fb-chip-remove:hover { background: var(--border, rgba(245,241,232,.1)); color: var(--text, #f5f1e8); }
.fb-add-wrap { position: relative; }
.fb-add-btn {
  font-family: inherit; font-size: 12px; font-weight: 700; color: var(--amber, #f5a623);
  background: rgba(245,166,35,.1); border: 1px dashed rgba(245,166,35,.4); border-radius: 16px;
  padding: 6px 14px; cursor: pointer;
}
.fb-add-btn:hover { background: rgba(245,166,35,.18); }
.fb-add-menu {
  position: absolute; top: 100%; left: 0; margin-top: 6px; min-width: 180px; z-index: 60;
  background: var(--surface-2, #1c1723); border: 1px solid var(--border-strong, rgba(245,241,232,.18));
  border-radius: 10px; padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.fb-add-item { font-size: 13px; padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--text-sec, #b6afa1); }
.fb-add-item:hover { background: var(--surface, #16121c); color: var(--text, #f5f1e8); }
.fb-add-empty { font-size: 12px; color: var(--text-light, #7d7669); padding: 7px 10px; }
.fb-popover {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 70; width: 260px;
  background: var(--surface-2, #1c1723); border: 1px solid var(--border-strong, rgba(245,241,232,.18));
  border-radius: 12px; padding: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.45);
  display: flex; flex-direction: column; gap: 12px; cursor: default; white-space: normal;
}
.fb-op-row { display: flex; flex-direction: column; gap: 8px; }
.fb-op-option { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text, #f5f1e8); cursor: pointer; }
.fb-op-option input { accent-color: var(--amber, #f5a623); cursor: pointer; }
.fb-value-wrap { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fb-value-input, .fb-value-input2 {
  font-family: inherit; font-size: 13px; color: var(--text, #f5f1e8); background: var(--surface, #16121c);
  border: 1px solid var(--border, rgba(245,241,232,.1)); border-radius: 8px; padding: 7px 10px; outline: none;
  flex: 1; min-width: 0;
}
.fb-value-input:focus, .fb-value-input2:focus { border-color: var(--amber, #f5a623); }
.fb-input-wrap { position: relative; flex: 1; min-width: 0; }
.fb-suggest-list {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; width: 100%; max-height: 220px;
  overflow-y: auto; z-index: 80; background: var(--surface, #16121c); border: 1px solid var(--border-strong, rgba(245,241,232,.18));
  border-radius: 10px; padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.fb-suggest-list.open { display: block; }
.fb-suggest-item { font-size: 13px; padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--text-sec, #b6afa1); }
.fb-suggest-item:hover { background: var(--surface-2, #1c1723); color: var(--text, #f5f1e8); }
.fb-btn-row { display: flex; justify-content: flex-end; gap: 8px; }
.fb-cancel-btn, .fb-apply-btn {
  font-family: inherit; font-size: 12px; font-weight: 700; border-radius: 8px; padding: 7px 14px; cursor: pointer; border: none;
}
.fb-cancel-btn { background: var(--surface, #16121c); color: var(--text-sec, #b6afa1); }
.fb-cancel-btn:hover { color: var(--text, #f5f1e8); }
.fb-apply-btn { background: var(--red, #ff3b30); color: #fff; }
.fb-apply-btn:hover { background: var(--red-dark, #e0281e); }
