/* ═══════════════════════════════════════════════════════════════
   Topbar user account — dropdown + profile modal
   EP design language: mono uppercase labels, hairline borders,
   pink accent on CTAs and avatar. Matches ep-dashboard-redesign
   Account.vue + Profile.vue + ChangePassword.vue.
   ═══════════════════════════════════════════════════════════════ */

/* Positioning context for the dropdown — sits next to the trigger. */
.tb-account-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* ── Account trigger button (topbar-right) ──────────────────── */
.tb-account {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 4px 0 0;
  background: transparent;
  border: none;
  color: var(--t2);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: none;
  cursor: pointer;
  transition: color 0.15s ease;
}
.tb-account:hover { color: var(--color-brand); }
.tb-account[aria-expanded="true"] { color: var(--color-brand); }

.tb-avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-brand);
  color: #000;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  line-height: 1;
  overflow: hidden;
}

.tb-account-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tb-account-chevron {
  width: 10px;
  height: 10px;
  opacity: 0.6;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.tb-account[aria-expanded="true"] .tb-account-chevron {
  transform: rotate(180deg);
  opacity: 1;
}

/* ── Dropdown panel ─────────────────────────────────────────── */
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  padding: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--hair-strong);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 9998;
}
.user-dropdown[hidden] { display: none; }

.user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 16px;
}
.user-dropdown-avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-brand);
  color: #000;
  font-family: 'Noto Sans Mono', ui-monospace, Menlo, monospace;
  font-size: 22px;
  font-weight: 700;
  flex-shrink: 0;
}
.user-dropdown-greeting {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.user-dropdown-hi {
  font-family: 'Noto Sans Mono', ui-monospace, Menlo, monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-dropdown-email {
  font-family: 'Noto Sans Mono', ui-monospace, Menlo, monospace;
  font-size: 10px;
  color: var(--t3);
  letter-spacing: 0.08em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--hair);
}
.user-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 0;
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: 'Noto Sans Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
  transition: color 0.2s ease;
}
.user-dropdown-btn:hover { color: var(--color-brand); }
.user-dropdown-btn svg { width: 14px; height: 14px; stroke-width: 1.4; }
.user-dropdown-btn--danger:hover { color: #FF5A5A; }

/* Full-viewport click-catcher behind dropdown */
.user-dropdown-overlay {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 9997;
}
.user-dropdown-overlay[hidden] { display: none; }

/* ── Modal (profile + change password share the same shell) ─── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.modal[hidden] { display: none; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-container {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 80px);
  background: var(--bg-elev);
  border: 1px solid var(--hair-strong);
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--hair);
}
.modal-title {
  font-family: 'Noto Sans Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
}
.modal-close {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--hair-strong);
  color: var(--t2);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.modal-close:hover { border-color: var(--color-brand); color: var(--color-brand); }
.modal-close svg { width: 12px; height: 12px; }

.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

/* ── Profile / password form layout ─────────────────────────── */
.profile-form { display: flex; flex-direction: column; gap: 18px; }

.profile-form .form-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.profile-form .form-section + .form-section {
  padding-top: 18px;
  border-top: 1px solid var(--hair);
}
.profile-form .form-section-title {
  font-family: 'Noto Sans Mono', ui-monospace, Menlo, monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-brand);
}

.profile-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.profile-field label {
  font-family: 'Noto Sans Mono', ui-monospace, Menlo, monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--t3);
}
.profile-field input {
  height: 40px;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--hair-strong);
  border-radius: var(--r-sm, 8px);
  color: var(--ink);
  font-family: 'Geist', 'Inter', sans-serif;
  font-size: 13px;
  letter-spacing: 0.02em;
  transition: border-color 0.2s ease;
}
.profile-field input:focus {
  outline: none;
  border-color: var(--color-brand);
}
.profile-field input[readonly] {
  background: transparent;
  color: var(--t3);
  cursor: not-allowed;
}

.profile-form-msg {
  font-family: 'Noto Sans Mono', ui-monospace, Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 10px 12px;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm, 8px);
}
.profile-form-msg[data-tone="ok"] {
  color: #4CD17A;
  border-color: rgba(76, 209, 122, 0.4);
  background: rgba(76, 209, 122, 0.06);
}
.profile-form-msg[data-tone="err"] {
  color: #FF5A5A;
  border-color: rgba(255, 90, 90, 0.4);
  background: rgba(255, 90, 90, 0.06);
}
.profile-form-msg[hidden] { display: none; }

.profile-form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 10px;
}
.profile-btn {
  height: 40px;
  padding: 0 20px;
  background: transparent;
  border: 1px solid var(--hair-strong);
  border-radius: var(--r-sm, 8px);
  color: var(--ink);
  font-family: 'Noto Sans Mono', ui-monospace, Menlo, monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}
.profile-btn:hover { border-color: var(--color-brand); color: var(--color-brand); background: rgba(234,143,215,0.05); }
.profile-btn--primary {
  background: transparent;
  border-color: var(--color-brand);
  color: var(--ink);
}
.profile-btn--primary:hover {
  background: rgba(234,143,215,0.08);
  border-color: var(--color-brand);
  color: var(--color-brand);
}
.profile-btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════════
   PROFILE PAGE — adapted to the platform's native design system
   (uses .dp-bar, .ch, .row r2, .sl section labels)
   ══════════════════════════════════════════════════════════════ */

/* ── Profile DP-bar (mimics dashboard PERIODO bar) ──────────── */
.profile-dp-bar {
  margin-bottom: 28px;
}
.profile-dp-left {
  gap: 22px;
  align-items: center;
}
.profile-dp-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.profile-dp-name {
  font-family: 'Geist', 'Inter', sans-serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.15;
  margin-top: 4px;
}
.profile-dp-email {
  font-family: 'Noto Sans Mono', ui-monospace, Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--t3);
  margin-top: 2px;
}
.profile-dp-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.profile-role-pill {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.18em;
}

/* Avatar — large, lowercase Inter, brand pink with glow */
.profile-avatar-lg {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #EA8FD7 0%, #D76BBF 100%);
  color: #0A0A0A;
  font-family: 'Inter', sans-serif;
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -0.04em;
  text-transform: lowercase;
  flex-shrink: 0;
  box-shadow: 0 12px 32px rgba(234, 143, 215, 0.35),
              0 0 0 1px rgba(234, 143, 215, 0.15);
}

/* ── PG form (matches input/button look used elsewhere in portal) ── */
.pg-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 4px;
}
.pg-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pg-label {
  font-family: 'Noto Sans Mono', ui-monospace, Menlo, monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--t3);
}
.pg-input {
  height: 40px;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--hair-strong);
  border-radius: var(--r-sm, 8px);
  color: var(--ink);
  font-family: 'Geist', 'Inter', sans-serif;
  font-size: 13px;
  letter-spacing: 0.01em;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  width: 100%;
  box-sizing: border-box;
}
.pg-input:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(234, 143, 215, 0.12);
}
.pg-input[readonly] {
  background: rgba(255, 255, 255, 0.02);
  color: var(--t3);
  cursor: not-allowed;
  border-style: dashed;
  border-color: var(--hair);
}
.pg-hint {
  font-size: 10.5px;
  color: var(--t4, var(--t3));
  font-style: italic;
  letter-spacing: 0.02em;
  line-height: 1.35;
  margin-top: -2px;
}
.pg-msg {
  font-family: 'Noto Sans Mono', ui-monospace, Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 10px 12px;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm, 8px);
}
.pg-msg[data-tone="ok"] {
  color: #4CD17A;
  border-color: rgba(76, 209, 122, 0.45);
  background: rgba(76, 209, 122, 0.06);
}
.pg-msg[data-tone="err"] {
  color: #FF5A5A;
  border-color: rgba(255, 90, 90, 0.45);
  background: rgba(255, 90, 90, 0.06);
}
.pg-msg[hidden] { display: none; }
.pg-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--hair);
}
.pg-btn {
  height: 38px;
  padding: 0 18px;
  border-radius: var(--r-sm, 8px);
  font-family: 'Noto Sans Mono', ui-monospace, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pg-btn-ghost {
  background: transparent;
  border: 1px solid var(--hair-strong);
  color: var(--t2);
}
.pg-btn-ghost:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
  background: rgba(234, 143, 215, 0.05);
}
.pg-btn-primary {
  background: var(--color-brand);
  border: 1px solid var(--color-brand);
  color: #0A0A0A;
}
.pg-btn-primary:hover {
  background: transparent;
  color: var(--color-brand);
}
.pg-btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Mobile stack */
@media (max-width: 760px) {
  .profile-dp-left { flex-direction: column; align-items: flex-start; gap: 14px; }
  .profile-avatar-lg { width: 76px; height: 76px; font-size: 34px; }
  .profile-dp-name { font-size: 18px; }
  .pg-actions { flex-direction: column; align-items: stretch; }
  .pg-btn { justify-content: center; }
}

/* ── Theme toggle (sun / moon) ─────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--ink);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}
.theme-toggle .theme-track {
  position: relative;
  width: 50px;
  height: 26px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--hair-strong);
  display: inline-flex;
  align-items: center;
  padding: 0 2px;
  transition: background 0.2s ease, border-color 0.2s ease;
}
body.theme-light .theme-toggle .theme-track {
  background: rgba(0, 0, 0, 0.04);
}
.theme-toggle .theme-thumb {
  width: 20px;
  height: 20px;
  background: var(--ink);
  color: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(.22,1,.36,1),
              background 0.2s ease,
              color 0.2s ease;
}
.theme-toggle .theme-icon { width: 12px; height: 12px; }
.theme-toggle .theme-icon-sun { display: none; }
.theme-toggle .theme-icon-moon { display: block; }

/* Dark mode (default) — thumb on the RIGHT, brand-accent fill */
body:not(.theme-light) .theme-toggle .theme-track {
  background: rgba(234, 143, 215, 0.1);
  border-color: var(--color-brand);
}
body:not(.theme-light) .theme-toggle .theme-thumb {
  transform: translateX(22px);
  background: var(--color-brand);
  color: #000;
}

/* Light mode — thumb on the LEFT, show sun */
body.theme-light .theme-toggle .theme-thumb {
  transform: translateX(0);
  background: #0A0A0A;
  color: #FFFFFF;
}
body.theme-light .theme-toggle .theme-icon-moon { display: none; }
body.theme-light .theme-toggle .theme-icon-sun { display: block; }

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .tb-account-name { max-width: 90px; }
  .user-dropdown {
    width: calc(100vw - 24px);
    right: -8px;
  }
  .modal { padding: 0; }
  .modal-container {
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
    border: none;
  }
  .modal-body { padding: 18px; }
  .theme-toggle { height: 30px; }
  .theme-toggle .theme-track { width: 44px; height: 22px; }
  .theme-toggle .theme-thumb { width: 16px; height: 16px; }
  .theme-toggle .theme-icon { width: 10px; height: 10px; }
  body:not(.theme-light) .theme-toggle .theme-thumb { transform: translateX(22px); }
}

/* ── System status pill in topbar ────────────────────────────
   Tiny pill with a coloured dot driven by /api/health. Polled
   every 60s by status-pill.js. Click navigates to Admin → Health
   when the user has admin access; non-admins still see the dot
   as a passive signal. */
.tb-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--hair, rgba(255,255,255,0.08));
  background: rgba(255,255,255,0.02);
  text-decoration: none;
  transition: border-color .15s ease, background .15s ease;
}
.tb-status:hover { border-color: rgba(234,143,215,0.4); background: rgba(234,143,215,0.08); }
.tb-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--t4);
  box-shadow: 0 0 0 0 rgba(0,0,0,0);
  transition: background .2s ease, box-shadow .2s ease;
}
.tb-status-dot[data-status="ok"]       { background: #4ADE80; box-shadow: 0 0 8px rgba(74,222,128,.55); }
.tb-status-dot[data-status="degraded"] { background: #FBBF24; box-shadow: 0 0 8px rgba(251,191,36,.55); }
.tb-status-dot[data-status="error"]    { background: #FCA5A5; box-shadow: 0 0 8px rgba(252,165,165,.55); }
.tb-status-dot[data-status="loading"]  { background: var(--t4); animation: tb-status-pulse 1.4s ease-in-out infinite; }
@keyframes tb-status-pulse {
  0%, 100% { opacity: .35; }
  50% { opacity: 1; }
}

/* Hide for unauthenticated views — login overlay covers the topbar
   anyway, but be explicit so the dot doesn't flash before login. */
body.is-login-overlay-on .tb-status { display: none; }
