/* =============================================================================
   Phase 9 — User chip (Perplexity-style sidebar footer)

   Lives at the bottom-left of the sidebar, beside the collapse toggle. Mirrors
   Perplexity's pattern: avatar + truncated name, click to open a menu that pops
   UP (since chip is at the bottom of the page).

   Collapsed sidebar: only the avatar is visible.
   Mobile: footer is hidden (style.css line 1787 — `.sidebarFooter { display: none; }`),
   so we don't need a mobile fallback here.
   ============================================================================= */

.userChip {
  position: relative;
  flex: 1 1 auto;
  min-width: 0; /* allow text to truncate inside flex */
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.userChipBtn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-900, #0F172A);
  font-size: 12px;
  line-height: 1.15;
  text-align: left;
  transition: background .12s ease, border-color .12s ease;
}
.userChipBtn:hover {
  background: var(--ink-50, #F8FAFC);
  border-color: var(--ink-100, #E2E8F0);
}

.userChipAvatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #64748B;
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
}

.userChipText {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
  flex: 1 1 auto;
}
.userChipName {
  font-weight: 600;
  font-size: 12px;
  color: var(--ink-900, #0F172A);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  width: 100%;
}
.userChipRole {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-500, #64748B);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Menu pops UPWARD from chip. Anchored to chip via position: absolute. */
.userChipMenu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 240px;
  background: #FFFFFF;
  border: 1px solid var(--ink-100, #E2E8F0);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14), 0 2px 6px rgba(15, 23, 42, 0.06);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}
.userChipMenu[hidden] { display: none !important; }

.userChipMenuHeader {
  padding: 4px 6px 10px;
  border-bottom: 1px solid var(--ink-50, #F1F5F9);
}
.userChipMenuName {
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-900, #0F172A);
}
.userChipMenuEmail {
  font-size: 12px;
  color: var(--ink-500, #64748B);
  margin-top: 2px;
  word-break: break-all;
}
.userChipMenuRole {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-600, #475569);
}

.userChipLogout {
  width: 100%;
  padding: 8px 12px;
  background: var(--ink-50, #F8FAFC);
  color: #DC2626;
  border: 1px solid var(--ink-100, #E2E8F0);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  text-align: center;
  transition: background .12s ease, border-color .12s ease;
}
.userChipLogout:hover {
  background: #FEF2F2;
  border-color: #FECACA;
}

/* Collapsed sidebar: hide name/role text, keep avatar centered. */
body.sidebarCollapsed .userChipText { display: none; }
body.sidebarCollapsed .userChipBtn {
  justify-content: center;
  padding: 4px;
}
body.sidebarCollapsed .userChipMenu {
  /* When collapsed, sidebar is 64px wide — anchor menu so it doesn't cut off. */
  left: calc(100% + 8px);
  bottom: 0;
}

/* =========================================================================
   Phase 10 — Treatment-note failure pill (sits above user chip in sidebar)
   ========================================================================= */
.tnFailurePill {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.tnFailurePill[data-severity="transient"] {
  background: #FFFBEB;          /* amber-50 */
  color: #B45309;               /* amber-700 */
  border-color: #FDE68A;
}
.tnFailurePill[data-severity="transient"]:hover { background: #FEF3C7; }
.tnFailurePill[data-severity="permanent"] {
  background: #FEF2F2;          /* red-50 */
  color: #B91C1C;               /* red-700 */
  border-color: #FECACA;
}
.tnFailurePill[data-severity="permanent"]:hover { background: #FEE2E2; }

.tnFailureDot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: tnFailurePulse 1.6s ease-in-out infinite;
}
@keyframes tnFailurePulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}

.tnFailureLabel { line-height: 1.2; }

body.sidebarCollapsed .tnFailureLabel { display: none; }
body.sidebarCollapsed .tnFailurePill { justify-content: center; padding: 6px; }
