/* ui/profile-menu.css — account dropdown anchored under the header's
   avatar pill, plus the Edit-profile modal. Deliberately matches the
   bell panel (ui/notifications-ui.css) and the settings popover
   (ui/settings-panel.css): same fixed top:56px/right:16px anchor, same
   card radius/shadow/z-index, so the three header popovers read as one
   family. */

.mg-profile-menu {
  position: fixed;
  top: 56px;
  right: 16px;
  width: 300px;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  z-index: 1500;
}
.mg-profile-menu.hidden {
  display: none;
}

/* ---- header card ---- */

.mg-profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--mg-border);
}

.mg-profile-avatar {
  flex: 0 0 auto;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--mg-accent-tint);
  color: var(--mg-accent);
  font-weight: 800;
  letter-spacing: 0.3px;
}
.mg-profile-avatar--lg {
  width: 44px;
  height: 44px;
  font-size: 16px;
}
.mg-profile-avatar--xl {
  width: 72px;
  height: 72px;
  font-size: 24px;
}
.mg-profile-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mg-profile-head-text {
  min-width: 0;
  flex: 1 1 auto;
}
.mg-profile-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--mg-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mg-profile-email {
  font-size: 12px;
  color: var(--mg-text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mg-profile-provider {
  margin-top: 2px;
  font-size: 11px;
  color: var(--mg-text-3);
}

/* ---- plan row ---- */

.mg-profile-plan {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--mg-border);
}
.mg-profile-plan-text {
  flex: 1 1 auto;
  min-width: 0;
}
.mg-profile-plan-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--mg-text);
}
.mg-profile-plan-sub {
  font-size: 11px;
  color: var(--mg-text-3);
}
.mg-profile-plan-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--mg-border);
  background: var(--mg-surface-3);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--mg-text-2);
  cursor: not-allowed;
  opacity: 0.75;
}
.mg-profile-soon {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mg-text-3);
  background: var(--mg-well-2);
  border-radius: 4px;
  padding: 1px 4px;
}

/* ---- menu items ---- */

.mg-profile-items {
  padding: 6px;
}
.mg-profile-item {
  width: 100%;
  display: grid;
  grid-template-columns: 24px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 0 8px;
  padding: 9px 8px;
  border: none;
  background: none;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.mg-profile-item:hover {
  background: var(--mg-well);
}
.mg-profile-item-ico {
  grid-row: 1 / span 2;
  font-size: 15px;
  color: var(--mg-text-2);
  text-align: center;
}
.mg-profile-item-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--mg-text);
}
.mg-profile-item-sub {
  font-size: 11px;
  color: var(--mg-text-3);
}
.mg-profile-item--danger .mg-profile-item-label,
.mg-profile-item--danger .mg-profile-item-ico {
  color: var(--mg-danger);
}

.mg-profile-foot {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--mg-border);
  font-size: 11px;
  color: var(--mg-text-3);
  text-align: center;
}

/* ---- edit-profile modal ---- */

.mg-profile-overlay {
  position: fixed;
  inset: 0;
  background: var(--mg-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1600;   /* above the dropdown, which lives at 1500 */
}

.mg-profile-sheet {
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--mg-surface);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.mg-profile-sheet-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  border-bottom: 1px solid var(--mg-border);
  font-size: 14px;
  font-weight: 700;
  color: var(--mg-text);
}
.mg-profile-sheet-x {
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--mg-text-3);
  cursor: pointer;
  padding: 0 4px;
}

.mg-profile-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
}

.mg-profile-photo-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.mg-profile-photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.mg-profile-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--mg-text-3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 12px 0 6px;
}

.mg-profile-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--mg-border);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13.5px;
  color: var(--mg-text);
  background: var(--mg-surface);
  margin-bottom: 8px;
}
.mg-profile-input:focus {
  outline: none;
  border-color: var(--mg-accent);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.14);
}
.mg-profile-input:disabled {
  background: var(--mg-bg);
  color: var(--mg-text-2);
}

.mg-profile-hint {
  font-size: 11px;
  color: var(--mg-text-3);
  line-height: 1.4;
  flex-basis: 100%;
}

.mg-profile-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--mg-border);
}
.mg-profile-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--mg-text-3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 10px;
}

.mg-profile-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mg-profile-kv {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--mg-text-2);
  padding: 4px 0;
}
.mg-profile-kv span:last-child {
  color: var(--mg-text-2);
}

.mg-profile-btn {
  border: 1px solid var(--mg-border);
  background: var(--mg-surface-3);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--mg-text);
  cursor: pointer;
}
.mg-profile-btn:hover:not(:disabled) {
  background: var(--mg-surface-2);
}
.mg-profile-btn:disabled {
  opacity: 0.6;
  cursor: default;
}
.mg-profile-btn--primary {
  background: var(--mg-accent);
  border-color: var(--mg-accent);
  color: var(--mg-on-accent);
}
.mg-profile-btn--primary:hover:not(:disabled) {
  background: var(--mg-accent-deep);
}
.mg-profile-btn--quiet {
  background: var(--mg-surface);
  color: var(--mg-text-2);
}

.mg-profile-msg {
  margin-top: 14px;
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 12.5px;
  line-height: 1.4;
}
.mg-profile-msg.hidden {
  display: none;
}
.mg-profile-msg.is-ok {
  background: var(--mg-success-tint);
  color: var(--mg-success);
}
.mg-profile-msg.is-error {
  background: var(--mg-danger-tint);
  color: var(--mg-danger);
}

.mg-profile-sheet-footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--mg-border);
  background: var(--mg-bg-2);
}

/* The header pill already collapses to just the avatar under 420px
   (ui/ui.css) — the dropdown has to stop being a fixed 300px card there
   too, or it overhangs the viewport on a small phone. */
@media (max-width: 420px) {
  .mg-profile-menu {
    left: 8px;
    right: 8px;
    width: auto;
  }
  .mg-profile-photo-row {
    flex-direction: column;
    align-items: flex-start;
  }
}
