/* Shared header profile menu (button with avatar + name, dropdown with account, theme, tools, log out).
   Linked by tools/build-frontend.js when app.json has profileMenu (AMS links it itself). Colors fall back across the app palettes. */
.pl-profile {
  --plm-surface: var(--bg-surface, var(--surface, #ffffff));
  --plm-hover: var(--bg-surface-light, var(--surface-lt, #f1f5f9));
  --plm-text: var(--text-main, var(--text, #0b1c30));
  --plm-muted: var(--text-muted, var(--muted, #64748b));
  --plm-border: var(--border, #e2e8f0);
  --plm-primary: var(--primary, #0a444a);
  --plm-on-primary: var(--primary-contrast, #ffffff);
  --plm-danger: var(--danger, #dc2626);
  position: relative;
  font-family: 'Outfit', ui-sans-serif, system-ui, sans-serif;
}

/* Dark: the WMS palette in every app (app variables do not all exist and fall back to light values). */
body.dark .pl-profile {
  --plm-surface: #1a1a1a;
  --plm-hover: #242424;
  --plm-text: #ececec;
  --plm-muted: #9c9c9c;
  --plm-border: #2e2e2e;
  --plm-primary: #a8b4b5;
  --plm-on-primary: #111111;
  --plm-danger: #e07a7a;
}

.pl-profile .pl-profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: auto;
  min-width: 0;
  height: 38px;
  max-width: 240px;
  margin: 0;
  justify-content: flex-start;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--plm-border);
  border-radius: 999px;
  background: var(--plm-hover);
  color: var(--plm-text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.pl-profile .pl-profile-btn:hover,
.pl-profile.open .pl-profile-btn {
  border-color: var(--plm-primary);
}

.pl-profile .pl-profile-avatar {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--plm-primary);
  color: var(--plm-on-primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.pl-profile .pl-profile-avatar--lg {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

.pl-profile .pl-profile-name {
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pl-profile .pl-profile-caret {
  font-size: 10px;
  color: var(--plm-muted);
  transition: transform 0.15s;
}

.pl-profile.open .pl-profile-caret { transform: rotate(180deg); }

.pl-profile .pl-profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 3000;
  width: 250px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 6px;
  background: var(--plm-surface);
  border: 1px solid var(--plm-border);
  border-radius: 14px;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.35), 0 4px 12px -4px rgba(0, 0, 0, 0.15);
}

.pl-profile .pl-profile-menu[hidden],
.pl-profile .pl-profile-menu [hidden] { display: none !important; }

.pl-profile .pl-profile-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--plm-border);
}

.pl-profile .pl-profile-who { min-width: 0; }

.pl-profile .pl-profile-user {
  font-size: 14px;
  font-weight: 700;
  color: var(--plm-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pl-profile .pl-profile-role {
  font-size: 11px;
  font-weight: 600;
  color: var(--plm-muted);
}

.pl-profile .pl-profile-menu > button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 38px;
  margin: 0;
  justify-content: flex-start;
  padding: 0 10px;
  border: 0;
  box-shadow: none;
  border-radius: 8px;
  background: transparent;
  color: var(--plm-text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.pl-profile .pl-profile-menu > button:hover { background: var(--plm-hover); }

.pl-profile .pl-profile-menu > button > i {
  width: 18px;
  flex: none;
  text-align: center;
  font-size: 14px;
  color: var(--plm-muted);
}

.pl-profile .pl-profile-menu > button > span:first-of-type { flex: 1; }

.pl-profile .pl-profile-menu > button.pl-danger,
.pl-profile .pl-profile-menu > button.pl-danger > i { color: var(--plm-danger); }

.pl-profile .pl-profile-label {
  padding: 10px 10px 4px;
  margin-top: 4px;
  border-top: 1px solid var(--plm-border);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--plm-muted);
}

.pl-profile .pl-profile-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--plm-border);
}

.pl-profile .pl-switch {
  position: relative;
  width: 30px;
  height: 18px;
  flex: none;
  border-radius: 999px;
  background: var(--plm-border);
  transition: background 0.15s;
}

.pl-profile .pl-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.15s;
}

body.dark .pl-profile .pl-switch { background: var(--plm-primary); }
body.dark .pl-profile .pl-switch::after { transform: translateX(12px); background: var(--plm-on-primary); }

@media (max-width: 1023px) {
  .pl-profile .pl-profile-btn { padding: 4px 8px 4px 4px; }
  .pl-profile .pl-profile-name { display: none; }
}
