/* ═══════════════════════════════════════════════════════════════════════════
   CRONY — user-sidebar.css   v1.6.0
   Sidebar nav + mobile top-bar + user slide-over panel.
   Class names reconciled with index.html structure.
   ═══════════════════════════════════════════════════════════════════════════ */

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, color-mix(in oklch, var(--bg-card) 88%, white), var(--bg-card));
  border-right: 1px solid rgba(17,17,17,0.08);
  display: flex;
  flex-direction: column;
  z-index: 500;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition-smooth), width var(--transition-smooth);
  scrollbar-width: thin;
  scrollbar-color: var(--divider) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--divider); border-radius: 4px; }

.sidebar-header,
.sidebar-top {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-3);
  flex-shrink: 0;
  min-height: var(--header-height);
  border-bottom: 1px solid var(--divider);
}
.sidebar-brand {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.sidebar-logo {
  width: 28px; height: 28px;
  border-radius: 6px;
  object-fit: contain;
  flex-shrink: 0;
}
.sidebar-collapse-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--radius-md);
  border: 1px solid var(--nav-pill-border);
  background: transparent;
  color: var(--text-kicker);
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
  cursor: pointer;
}
.sidebar-collapse-btn:hover { background: var(--nav-pill-bg); color: var(--text-main); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3);
  flex: 1;
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  height: 38px;
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-nav);
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast);
  position: relative;
  overflow: hidden;
}
.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}
.sidebar-nav-item:hover { background: var(--nav-pill-bg); color: var(--text-main); }
.sidebar-nav-item.active,
.sidebar-nav-item[aria-current="page"] {
  background: var(--pill-active-bg);
  color: var(--pill-active-text);
  font-weight: 700;
}
.sidebar-nav-item.active .nav-icon,
.sidebar-nav-item[aria-current="page"] .nav-icon { opacity: 1; }
.sidebar-nav-item .nav-icon { opacity: 0.62; transition: opacity var(--transition-fast); }
.sidebar-nav-item:hover .nav-icon { opacity: 1; }

.sidebar-footer,
.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3);
  border-top: 1px solid var(--divider);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-lg);
  background: var(--nav-pill-bg);
  border: 1px solid var(--nav-pill-border);
  min-width: 0;
  margin: var(--space-2) 0 0;
}
.sidebar-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--text-main);
  color: var(--bg-cream);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.sidebar-user-details { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; overflow: hidden; }
.sidebar-user-name  { font-size: var(--text-xs); font-weight: 700; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-email { font-size: 0.68rem; color: var(--text-footer); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-signout {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-kicker);
  transition: color var(--transition-fast), background var(--transition-fast);
}
.sidebar-signout:hover { color: var(--color-error); background: var(--color-error-highlight); }
.sidebar-version { font-size: 0.68rem; color: var(--text-watermark); text-align: center; padding: var(--space-1) 0; letter-spacing: 0.04em; }

.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
  border-radius: var(--radius-lg);
  background: var(--nav-pill-bg);
  border: 1px solid var(--nav-pill-border);
  min-width: 0;
}
.s-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--text-main);
  color: var(--bg-cream);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
  text-transform: uppercase;
}
.s-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.s-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; overflow: hidden; }
.s-name { font-size: var(--text-xs); font-weight: 700; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-email { font-size: 0.65rem; color: var(--text-kicker); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Mobile top bar ────────────────────────────────────────────────────── */
.sidebar-hamburger {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 600;
  height: var(--mobile-header-height);
  background: color-mix(in oklch, var(--bg-card) 95%, transparent);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  border-bottom: 1px solid var(--divider);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  align-items: center;
  padding: 0 12px;
  gap: 10px;
}
.sidebar-hamburger-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--nav-pill-border);
  background: transparent;
  color: var(--text-main);
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  cursor: pointer;
}
.sidebar-hamburger-btn:hover,
.sidebar-hamburger.active .sidebar-hamburger-btn {
  background: var(--pill-active-bg);
  color: var(--pill-active-text);
  border-color: var(--pill-active-bg);
}
.sidebar-hamburger-brand {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0;
  pointer-events: none; user-select: none;
}
.sidebar-hamburger-logo { width: 26px; height: 26px; border-radius: 6px; object-fit: contain; flex-shrink: 0; }
.sidebar-hamburger-name {
  font-family: var(--font-display); font-size: 0.95rem; font-weight: 800;
  color: var(--text-main); letter-spacing: -0.03em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-hamburger-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--text-main); color: var(--bg-cream);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 700;
  flex-shrink: 0; overflow: hidden; cursor: pointer;
  border: 2px solid var(--nav-pill-border);
  transition: border-color var(--transition-fast);
}
.sidebar-hamburger-avatar:hover { border-color: var(--accent); }
.sidebar-hamburger-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  z-index: 499;
  background: rgba(17,17,17,0.38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

@media (max-width: 768px) {
  .sidebar {
    top: var(--mobile-header-height);
    height: calc(100dvh - var(--mobile-header-height));
    bottom: unset;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open, .sidebar.open { transform: translateX(0); }
  .sidebar-hamburger { display: flex; }
  .sidebar-user { display: none; }
  .sidebar-collapse-btn { display: none; }
  .sidebar-backdrop.open, .sidebar-backdrop.is-open { display: block; }
  .sidebar-nav-item { height: 44px; font-size: 0.85rem; border-radius: var(--radius-md); }
  .sidebar-header, .sidebar-top { padding: var(--space-3); min-height: auto; }
  .sidebar-brand, .sidebar-logo { display: none; }
  .user-sidebar-trigger { display: none !important; }
  .sidebar-user-card { display: none; }
}
@media (max-width: 480px) {
  .sidebar-nav-item { height: 42px; font-size: 0.82rem; }
  .sidebar-nav { padding: var(--space-2); }
  .sidebar-footer, .sidebar-bottom { padding: var(--space-2); }
}
@media (max-width: 360px) {
  .sidebar-nav-item { height: 40px; font-size: 0.78rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   USER SIDEBAR PANEL (slide-over account panel)
   ═══════════════════════════════════════════════════════════════════════════ */
.user-sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  z-index: 699;
  background: rgba(17,17,17,0.40);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.user-sidebar-backdrop.is-open { display: block; }

.user-sidebar-panel {
  position: fixed;
  top: 0; right: -340px; bottom: 0;
  width: 320px;
  max-width: calc(100vw - 48px);
  background: linear-gradient(180deg, color-mix(in oklch, var(--bg-card) 88%, white), var(--bg-card));
  border-left: 1px solid rgba(17,17,17,0.08);
  box-shadow: var(--shadow-lg);
  z-index: 700;
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  transition: right 260ms cubic-bezier(0.16,1,0.3,1);
}
.user-sidebar-panel.is-open { right: 0; }

@media (max-width: 480px) {
  .user-sidebar-panel { width: 100vw; max-width: 100vw; right: -100vw; }
  .user-sidebar-panel.is-open { right: 0; }
}

.user-sidebar-trigger {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--nav-pill-border);
  background: var(--bg-card); color: var(--text-body);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  flex-shrink: 0;
}
.user-sidebar-trigger:hover { background: var(--nav-pill-bg); color: var(--text-main); border-color: rgba(0,0,0,0.2); }

.usb-header { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-5) var(--space-4) var(--space-4); border-bottom: 1px solid var(--divider); flex-shrink: 0; }
.usb-avatar { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--text-main), color-mix(in oklch, var(--accent) 55%, var(--text-main))); color: var(--bg-cream); display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 1.1rem; font-weight: 800; flex-shrink: 0; overflow: hidden; }
.usb-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.usb-identity { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding-top: 2px; }
.usb-name { font-family: var(--font-display); font-size: var(--text-base); font-weight: 800; color: var(--text-main); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usb-email { font-size: var(--text-xs); color: var(--text-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usb-uid { font-size: 0.68rem; color: var(--text-kicker); font-family: var(--font-mono, monospace); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usb-provider { display: inline-flex; align-items: center; gap: 4px; font-size: 0.68rem; font-weight: 600; color: var(--tag-text); background: var(--tag-bg); border: 1px solid var(--tag-border); border-radius: var(--radius-full); padding: 1px 6px; width: fit-content; margin-top: 2px; }
.usb-close { flex-shrink: 0; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-md); color: var(--text-kicker); transition: color var(--transition-fast), background var(--transition-fast); margin-top: 2px; cursor: pointer; }
.usb-close:hover { color: var(--text-main); background: var(--nav-pill-bg); }

.usb-section { padding: var(--space-4); border-bottom: 1px solid var(--divider); display: flex; flex-direction: column; gap: var(--space-3); }
.usb-section:last-child { border-bottom: none; }
.usb-section-title { font-size: var(--text-xs); font-weight: 700; color: var(--text-kicker); text-transform: uppercase; letter-spacing: 0.07em; }

.usb-credits-row { display: flex; align-items: baseline; gap: var(--space-2); }
.usb-credits-balance { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 800; color: var(--text-main); line-height: 1; }
.usb-credits-label { font-size: var(--text-xs); color: var(--text-kicker); }
.usb-credits-meta { display: flex; gap: var(--space-3); font-size: var(--text-xs); color: var(--text-kicker); flex-wrap: wrap; }
.usb-topup { align-self: flex-start; }

.usb-stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--space-2); }
.usb-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; background: color-mix(in oklch, var(--color-surface) 96%, var(--bg-card)); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-1); }
.usb-stat-val { font-family: var(--font-display); font-size: var(--text-base); font-weight: 700; color: var(--text-main); line-height: 1; }
.usb-stat-lbl { font-size: 0.6rem; color: var(--text-kicker); text-transform: uppercase; letter-spacing: 0.05em; }

.usb-links { gap: var(--space-1); }
.usb-link { display: flex; align-items: center; width: 100%; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: 500; color: var(--text-body); background: transparent; border: none; cursor: pointer; text-align: left; transition: background var(--transition-fast), color var(--transition-fast); gap: var(--space-2); }
.usb-link:hover { background: var(--nav-pill-bg); color: var(--text-main); }

.usb-theme-row { flex-direction: row; align-items: center; justify-content: space-between; }
.usb-toggle { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.usb-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.usb-toggle-track { width: 36px; height: 20px; background: var(--color-border); border-radius: var(--radius-full); transition: background var(--transition-fast); position: relative; }
.usb-toggle input:checked + .usb-toggle-track { background: var(--accent); }
.usb-toggle-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2); transition: transform var(--transition-fast); }
.usb-toggle input:checked + .usb-toggle-track .usb-toggle-thumb { transform: translateX(16px); }

.usb-footer { margin-top: auto; padding: var(--space-4); border-top: 1px solid var(--divider); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.usb-version { font-size: 0.68rem; color: var(--text-watermark); letter-spacing: 0.04em; }
.usb-signout { flex-shrink: 0; }
