/* Account surfaces: the header's user dropdown and the passkey management
   modal. Split out of styles.css; loaded after app-header.css. Both surfaces are
   hidden inside the embed (embed.css), so nothing here targets [data-embed]. */


/* First-paint rules (passkey recovery, login email button, the dropdown's
   default display:none) live at the end of app-header.css: this sheet loads
   non-blocking. */

.dropdown-balance {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 10px 10px;
}

.dropdown-balance-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.dropdown-balance-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.dropdown-balance-amount {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.buy-credits-link {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.buy-credits-link:hover {
  background: rgba(34, 197, 94, 0.2);
}

[data-theme="dark"] .buy-credits-link { color: #4ade80; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .buy-credits-link { color: #4ade80; }
}

.dropdown-separator {
  height: 1px;
  margin: 6px 4px;
  background: var(--border-color);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.dropdown-item svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

.dropdown-item:hover,
.dropdown-item:focus-visible {
  background: var(--bg-tertiary);
  outline: none;
}

.dropdown-item:hover svg,
.dropdown-item:focus-visible svg {
  color: var(--text-primary);
}

@media (max-width: 600px) {
  .dropdown-item { min-height: 44px; }
  .buy-credits-link { padding: 11px 12px; }
}

/* ── Passkey management modal ──────────────────────────────────────────── */
/* Builds on the shared .passkey-modal / .passkey-modal-card rules in
   styles.css (also used by the post-login enrollment offer). */

.passkey-modal-card.passkey-manage-card {
  position: relative;
  box-sizing: border-box;
  max-width: 440px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: var(--dropdown-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 24px 64px var(--shadow-strong);
}

.passkey-manage-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.passkey-manage-badge {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

.passkey-manage-badge svg { width: 20px; height: 20px; }

.passkey-manage-card .passkey-manage-header h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.passkey-manage-close {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin: -4px -6px 0 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
}

.passkey-manage-close svg { width: 18px; height: 18px; }

.passkey-manage-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.passkey-manage-close:focus-visible,
.passkey-manage-card .login-btn:focus-visible,
.passkey-manage-btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.passkey-manage-card .passkey-manage-intro {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.passkey-manage-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-primary);
}

.passkey-manage-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 12px 12px 14px;
}

.passkey-manage-row + .passkey-manage-row {
  border-top: 1px solid var(--border-color);
}

.passkey-manage-row.is-confirming {
  background: var(--error-bg);
}

.passkey-manage-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.passkey-manage-icon svg { width: 16px; height: 16px; }

.passkey-manage-info {
  /* Low basis on purpose: at 360px the Remove button must stay on the row. */
  flex: 1 1 100px;
  min-width: 0;
}

.passkey-manage-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.passkey-manage-row.is-confirming .passkey-manage-label {
  color: var(--error-text);
}

.passkey-manage-meta {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.passkey-manage-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.passkey-manage-btn {
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.passkey-manage-btn:hover:not(:disabled) {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.passkey-manage-btn.is-remove:hover:not(:disabled) {
  background: var(--error-bg);
  color: var(--error-text);
}

.passkey-manage-btn.is-danger {
  background: var(--error-text);
  border-color: var(--error-text);
  color: #fff;
}

.passkey-manage-btn.is-danger:hover:not(:disabled) {
  background: var(--error-text);
  color: #fff;
  filter: brightness(1.1);
}

.passkey-manage-row.is-confirming .passkey-manage-btn:not(.is-danger) {
  border-color: var(--border-color);
  background: var(--dropdown-bg);
  color: var(--text-primary);
}

.passkey-manage-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.passkey-manage-card .passkey-manage-empty {
  margin: 0 0 16px;
  padding: 20px 16px;
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  color: var(--text-secondary);
}

.passkey-manage-card .passkey-manage-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* setStatus() rewrites className wholesale, hence the id. */
.passkey-manage-card #passkey-manage-status {
  margin: 0 0 12px;
  padding: 10px 12px;
  font-size: 13px;
  text-align: left;
}

.passkey-manage-card .login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 15px;
}

.passkey-manage-card .login-btn svg { width: 18px; height: 18px; }

@media (max-width: 600px) {
  .passkey-modal-card.passkey-manage-card { padding: 20px 16px; }
  .passkey-manage-btn { min-height: 40px; padding: 8px 14px; }
  .passkey-manage-close { width: 40px; height: 40px; }
  /* Stack the confirmation under the label instead of squeezing it beside. */
  .passkey-manage-row.is-confirming .passkey-manage-actions {
    flex-basis: 100%;
    justify-content: flex-end;
  }
}

/* ── plai Plus: account Plan section (inserted by js/plus.js) ─────────── */

.dropdown-plan {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 10px 10px;
}

.dropdown-plan-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.dropdown-plan-usage {
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.dropdown-plan-alert,
.plus-paywall-card .plus-payment-fix {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--error-bg);
  color: var(--error-text);
  font-size: 13px;
  line-height: 1.4;
}

.plus-upgrade-btn,
.plus-paywall-card button.buy-credits-link {
  width: 100%;
  border: 0;
  font-family: inherit;
  cursor: pointer;
}

.dropdown-plan .plus-manage-btn {
  margin: 0 -10px;
  width: calc(100% + 20px);
}

/* ── plai Plus: paywall modal (overlay reuses .passkey-modal) ─────────── */

.passkey-modal-card.plus-paywall-card {
  max-width: 460px;
  overflow-y: auto;
}

.plus-paywall-card:focus {
  outline: none;
}

.plus-paywall-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.plus-paywall-card .plus-paywall-body p {
  margin: 0;
  font-size: 14px;
}

.plus-option {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
}

.plus-option-primary {
  border-color: rgba(34, 197, 94, 0.5);
  background: rgba(34, 197, 94, 0.06);
}

.plus-perks {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
}

.plus-perks li + li {
  margin-top: 4px;
}

.plus-estimates {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-secondary);
}

.plus-paywall-card .plus-paywall-body .plus-fineprint {
  font-size: 12px;
  color: var(--text-secondary);
}

.plus-paywall-card .login-btn {
  display: block;
  box-sizing: border-box;
  text-align: center;
  text-decoration: none;
  font-size: 15px;
}

.plus-paywall-card .login-btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.plus-paywall-card .plus-topup-link.buy-credits-link {
  font-size: 13.5px;
}

.plus-dismiss-btn {
  align-self: center;
  padding: 6px 4px;
  font-size: 14px;
}

.plus-paywall-card .login-btn:focus-visible,
.plus-paywall-card .plus-topup-link:focus-visible,
.plus-dismiss-btn:focus-visible,
.plus-signin-topup-btn:focus-visible,
.plus-support-link:focus-visible,
.plus-fix-payment-btn:focus-visible,
.plus-upgrade-btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .plus-option { padding: 12px; }
  .plus-dismiss-btn { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .dropdown.show { animation: none; }
}
