/* ═══════════════════════════════════════════════════════════════
   CNTCT Sidebar Navigation — v53
   Tevah-style auto-hide left rail. Icons collapsed, expand on hover.
   ═══════════════════════════════════════════════════════════════ */

/* Hide old top nav */
.top-nav { display: none !important; }

/* Sidebar rail */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 60px;
  background: rgba(9, 9, 13, 0.95);
  border-right: 1px solid rgba(201, 169, 110, 0.08);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}
.sidebar:hover,
.sidebar.expanded {
  width: 220px;
}

/* Logo */
.sb-logo {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  text-decoration: none;
}
.sb-logo-mark {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--gold-bright));
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: #0a0a0f;
  flex-shrink: 0;
}
.sb-logo-text {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--accent);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease 0.1s;
}
.sidebar:hover .sb-logo-text,
.sidebar.expanded .sb-logo-text {
  opacity: 1;
}

/* Nav items */
.sb-nav {
  flex: 1;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sb-nav::-webkit-scrollbar { display: none; }

.sb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 40px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  position: relative;
  flex-shrink: 0;
}
.sb-item:hover {
  background: rgba(255, 255, 255, 0.04);
}
.sb-item.active {
  background: rgba(201, 169, 110, 0.08);
}
.sb-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.sb-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.4);
  font-size: 16px;
  transition: color 0.15s ease;
}
.sb-item:hover .sb-icon {
  color: rgba(255, 255, 255, 0.7);
}
.sb-item.active .sb-icon {
  color: var(--accent);
}
.sb-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sb-label {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease 0.1s;
}
.sidebar:hover .sb-label,
.sidebar.expanded .sb-label {
  opacity: 1;
}
.sb-item:hover .sb-label {
  color: rgba(255, 255, 255, 0.85);
}
.sb-item.active .sb-label {
  color: var(--accent);
  font-weight: 600;
}

/* Section divider */
.sb-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.04);
  margin: 8px 16px;
  flex-shrink: 0;
}

/* Section label */
.sb-section {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.15);
  padding: 12px 16px 4px;
  white-space: nowrap;
  opacity: 0;
  height: 0;
  overflow: hidden;
  transition: opacity 0.2s ease 0.1s, height 0.25s ease;
}
.sidebar:hover .sb-section,
.sidebar.expanded .sb-section {
  opacity: 1;
  height: 28px;
}

/* Bottom section */
.sb-bottom {
  padding: 8px 0 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

/* Client badge */
.sb-client {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.sb-client:hover {
  background: rgba(255, 255, 255, 0.04);
}
.sb-client-dot {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--gold-deep));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #0a0a0f;
  flex-shrink: 0;
}
.sb-client-info {
  opacity: 0;
  transition: opacity 0.2s ease 0.1s;
  white-space: nowrap;
}
.sidebar:hover .sb-client-info,
.sidebar.expanded .sb-client-info {
  opacity: 1;
}
.sb-client-name {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
}
.sb-client-sub {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 0.5px;
}

/* ═══ LAYOUT SHIFT — content moves right ═══ */
.app {
  padding-left: 60px !important;
  padding-top: 16px !important;
  max-width: none !important;
  margin: 0 !important;
  padding-right: 32px !important;
}

/* Auth gate stays full-screen */
#authGate {
  padding-left: 0 !important;
}
/* Sidebar hidden until auth complete (JS adds .sb-ready) */
.sidebar { display: none; }
.sidebar.sb-ready { display: flex; }
body:not(.sb-authed) .app { padding-left: 32px !important; }

/* Dashboard adjustments — fix full-bleed sections for sidebar offset */
.sb-authed .sa-hero,
.sb-authed .settings-hero,
.sb-authed .dash-noir,
.sb-authed .rv-noir,
.sb-authed .dash-intel-graph,
.sb-authed .scc-hero {
  width: calc(100vw - 60px) !important;
  margin-left: -60px !important;
}
.dash-noir {
  margin-left: 0;
  margin-right: 0;
}

/* ═══ DASHBOARD TABS ═══ */
.dash-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin: 0 0 24px;
  padding: 0;
}
.dash-tab {
  padding: 12px 24px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}
.dash-tab:hover {
  color: rgba(255, 255, 255, 0.7);
}
.dash-tab.active {
  color: var(--accent);
}
.dash-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}

.dash-tab-panel {
  display: none;
}
.dash-tab-panel.active {
  display: block;
}

/* ═══ POWER TABLE ═══ */
.power-table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.power-table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.power-table-search {
  flex: 1;
  max-width: 320px;
  padding: 7px 12px 7px 32px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.2s;
}
.power-table-search:focus {
  border-color: rgba(201, 169, 110, 0.3);
}
.power-table-search-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.power-table-search-wrap::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: 50%;
}
.power-table-search-wrap::after {
  content: '';
  position: absolute;
  left: 22px;
  top: 60%;
  width: 4px;
  height: 1.5px;
  background: rgba(255,255,255,0.3);
  transform: rotate(45deg);
  transform-origin: left center;
}

.power-table-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.pt-btn {
  padding: 6px 12px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-body);
  white-space: nowrap;
}
.pt-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border2);
  color: var(--text);
}
.pt-btn.active {
  background: var(--accent-soft);
  border-color: rgba(201, 169, 110, 0.3);
  color: var(--accent);
}

.pt-count {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Table itself */
.power-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.power-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.power-table th {
  padding: 10px 12px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  position: relative;
}
.power-table th:hover {
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.06);
}
.power-table th.sorted-asc::after,
.power-table th.sorted-desc::after {
  margin-left: 4px;
  font-size: 8px;
  color: var(--accent);
}
.power-table th.sorted-asc::after { content: '▲'; }
.power-table th.sorted-desc::after { content: '▼'; }

/* Column resize handle */
.power-table th .col-resize {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
}
.power-table th .col-resize:hover,
.power-table th .col-resize.resizing {
  background: var(--accent);
}

.power-table td {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.power-table tbody tr {
  transition: background 0.1s ease;
}
.power-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}
.power-table tbody tr.selected {
  background: rgba(201, 169, 110, 0.06);
}

/* Scrollable body */
.power-table-body {
  max-height: calc(100vh - 280px);
  overflow-y: auto;
  overflow-x: auto;
}

/* Grade badges */
.grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
}
.grade-badge.grade-a { background: rgba(16, 185, 129, 0.15); color: #10B981; }
.grade-badge.grade-b { background: rgba(79, 172, 254, 0.15); color: #4FACFE; }
.grade-badge.grade-c { background: rgba(245, 158, 11, 0.12); color: #F59E0B; }
.grade-badge.grade-d { background: rgba(239, 68, 68, 0.12); color: #EF4444; }

/* Contact type pills */
.type-pill {
  display: inline-block;
  padding: 2px 8px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text2);
}
.type-pill.executive { background: rgba(124, 58, 237, 0.15); color: #A78BFA; }
.type-pill.sales_rep { background: rgba(16, 185, 129, 0.12); color: #34D399; }
.type-pill.distributor_contact { background: rgba(79, 172, 254, 0.12); color: #93C5FD; }
.type-pill.buyer { background: rgba(245, 158, 11, 0.1); color: #FBBF24; }
.type-pill.regional_manager { background: rgba(236, 72, 153, 0.12); color: #F472B6; }
.type-pill.manufacturers_rep { background: rgba(201, 169, 110, 0.15); color: #c9a96e; }
.type-pill.marketing { background: rgba(244, 63, 94, 0.12); color: #FB7185; }
.type-pill.business_dev { background: rgba(14, 165, 233, 0.12); color: #38BDF8; }

/* Column picker dropdown */
.col-picker {
  position: fixed;
  background: var(--card-raised);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 8px 0;
  min-width: 200px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 1100;
  box-shadow: var(--shadow-lg);
}
.col-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  transition: background 0.1s;
}
.col-picker-item:hover {
  background: rgba(255, 255, 255, 0.04);
}
.col-picker-check {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border2);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: transparent;
  transition: all 0.15s;
  flex-shrink: 0;
}
.col-picker-item.checked .col-picker-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0f;
}

/* Filter dropdown */
.pt-filter-dropdown {
  position: fixed;
  background: var(--card-raised);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 12px;
  min-width: 240px;
  z-index: 1100;
  box-shadow: var(--shadow-lg);
}
.pt-filter-group {
  margin-bottom: 12px;
}
.pt-filter-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.pt-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.pt-filter-pill {
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.pt-filter-pill:hover {
  background: rgba(255, 255, 255, 0.08);
}
.pt-filter-pill.active {
  background: var(--accent-soft);
  border-color: rgba(201, 169, 110, 0.3);
  color: var(--accent);
}

/* Pagination */
.power-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}
.pt-page-info {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}
.pt-page-btns {
  display: flex;
  gap: 4px;
}
.pt-page-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.pt-page-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}
.pt-page-btn.active {
  background: var(--accent-soft);
  border-color: rgba(201, 169, 110, 0.3);
  color: var(--accent);
}
.pt-page-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 768px) {
  .sidebar {
    width: 0;
    border-right: none;
  }
  .sidebar.expanded {
    width: 220px;
    box-shadow: var(--shadow-xl);
  }
  .app {
    padding-left: 0 !important;
  }
  /* Show mobile hamburger */
  .sb-mobile-toggle {
    display: flex !important;
  }
}

.sb-mobile-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: rgba(9, 9, 13, 0.9);
  border: 1px solid var(--border);
  border-radius: 6px;
  z-index: 999;
  cursor: pointer;
  color: var(--accent);
  font-size: 18px;
}

/* D5: Hide errorVaultBadge from non-admin users (Sarah, Syl) */
body:not(.is-admin):not(.is-owner) #errorVaultBadge { display: none !important; }
