/* ── User menu dropdown ── */

.user-menu {
  position: relative;
}

/* Trigger styles come from .btn--primary; only override what's specific to the menu */
.user-menu-trigger[aria-expanded="true"] {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

/* Avatar circle (header only) */
.user-menu-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-text);
  color: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
  user-select: none;
}

/* Panel */
.user-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card), 0 8px 32px rgba(0,0,0,.10);
  z-index: 200;
  overflow: hidden;
}

/* Mobile backdrop */
.mobile-backdrop {
  display: none;
}

@media (max-width: 639px) {
  .mobile-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    z-index: 90;
    pointer-events: none;
    transition: background 0.25s ease, backdrop-filter 0.25s ease, -webkit-backdrop-filter 0.25s ease;
  }

  .mobile-backdrop--visible {
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    pointer-events: auto;
  }
}

/* Bottom sheet on mobile */
@media (max-width: 639px) {
  .user-menu-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
    border-left: none;
    border-right: none;
    max-height: 85dvh;
    overflow-y: auto;
    /* Extra room so the assistant button (bottom: 1.5rem + 3.25rem ≈ 76px) never overlaps content */
    padding-bottom: calc(1.5rem + 3.25rem + 1rem);
  }
}

/* Header: gray card with avatar + identity */
.user-menu-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px;
  padding: 14px;
  background: var(--color-bg);
  border-radius: var(--radius-md);
}

.user-menu-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.user-menu-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu-email {
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Divider */
.user-menu-divider {
  height: 1px;
  background: var(--color-border);
}

/* Section with label */
.user-menu-section {
  padding: 6px 0;
}

.user-menu-section-label {
  display: block;
  padding: 4px 16px 2px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

/* Menu items */
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--color-text);
  text-decoration: none;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}

.user-menu-item:hover { background: var(--color-bg); }

.user-menu-item > span { flex: 1; }

.user-menu-item--danger { color: var(--color-danger); }
.user-menu-item--danger:hover { background: var(--color-danger-bg); }

/* button_to wraps sign-out in a <form>; make it transparent */
.user-menu-signout-form { display: contents; }
