/* Supabase-style profile menu in topbar */

.profile-menu {
  position: relative;
}

.profile-menu__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border-default);
  border-radius: 50%;
  background: var(--surface-elevated);
  color: var(--text-primary);
  cursor: pointer;
  transition:
    border-color var(--duration-fast) ease,
    background var(--duration-fast) ease,
    transform 0.15s ease;
}

.profile-menu__trigger:hover,
.profile-menu__trigger[aria-expanded="true"] {
  border-color: var(--border-strong);
  background: var(--surface-control-hover);
}

.profile-menu__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--avatar-bg);
  color: var(--avatar-fg);
  overflow: hidden;
}

.profile-menu__avatar svg {
  width: 15px;
  height: 15px;
  display: block;
}

.profile-menu__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1200;
  min-width: 280px;
  padding: 6px;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  background: var(--surface-dropdown);
  box-shadow: var(--shadow-dropdown);
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  pointer-events: none;
  transition:
    opacity 0.16s ease,
    transform 0.16s ease;
}

.profile-menu__dropdown[hidden] {
  display: block;
  visibility: hidden;
}

.profile-menu__dropdown.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

.profile-menu__dropdown.is-closing {
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  pointer-events: none;
  visibility: visible;
}

.profile-menu__identity {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
}

.profile-menu__name {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.profile-menu__email {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}

.profile-menu__section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}

.profile-menu__section--picker {
  padding: 8px 6px;
  border-top: 1px solid var(--border-subtle);
  gap: 6px;
}

.profile-menu__section-label {
  display: block;
  padding: 0 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.profile-menu__options {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-menu__option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: left;
  cursor: default;
  font-family: inherit;
}

button.profile-menu__option {
  cursor: pointer;
  transition:
    background var(--duration-fast) ease,
    color var(--duration-fast) ease;
}

button.profile-menu__option:hover,
button.profile-menu__option:focus {
  background: var(--surface-interactive-hover);
  color: var(--text-primary);
  outline: none;
}

.profile-menu__option.is-active {
  background: var(--surface-selected);
  color: var(--text-primary);
  font-weight: var(--font-weight-medium);
}

.profile-menu__option.is-active:hover {
  background: var(--surface-interactive-hover);
}

.profile-menu__option-label {
  flex: 1 1 auto;
  min-width: 0;
}

.profile-menu__option-check {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--color-phosphor-green);
  opacity: 0;
  transform: scale(0.92);
  transition: opacity var(--duration-fast) ease, transform var(--duration-fast) ease;
}

.profile-menu__option.is-active .profile-menu__option-check {
  opacity: 1;
  transform: scale(1);
}

.profile-menu__option-flag {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  border: 1px solid var(--border-default);
  box-shadow: none;
}

.profile-menu__option.is-active .profile-menu__option-flag {
  border-color: var(--border-strong);
  box-shadow: none;
}

.profile-menu__section--footer {
  border-top: 1px solid var(--border-subtle);
  margin-top: 4px;
  padding-top: 6px;
}

.profile-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--duration-fast) ease, color var(--duration-fast) ease;
}

.profile-menu__item:hover,
.profile-menu__item:focus {
  background: var(--surface-interactive-hover);
  color: var(--text-primary);
  outline: none;
}

.profile-menu__item--button {
  font-family: inherit;
}

.profile-menu__icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex: 0 0 auto;
}

.profile-menu__icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.profile-menu__logout {
  margin: 0;
}

.profile-lang {
  margin: 0;
}

/* Theme swatches in profile picker */
.profile-menu__theme-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border-default);
  flex: 0 0 auto;
  box-shadow: none;
}

.profile-menu__theme-swatch--light {
  background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
}

.profile-menu__theme-swatch--dark {
  background: linear-gradient(135deg, #2a2a2a 0%, #121212 100%);
}

.profile-menu__theme-swatch--ocean {
  background: linear-gradient(135deg, #eef4fa 0%, #3b82f6 100%);
}

.profile-menu__theme-swatch--sage {
  background: linear-gradient(135deg, #f2f6f2 0%, #5b9a6f 100%);
}

.profile-menu__theme-swatch--sand {
  background: linear-gradient(135deg, #fffdf9 0%, #c4895a 100%);
}

.profile-menu__option--theme.is-active .profile-menu__theme-swatch {
  border-color: var(--border-strong);
  box-shadow: none;
}
