/*
 * PSICOLE ↔ Web staging integration surface.
 * Institutional tokens only: no gradients, badges or data that are not
 * returned by the read-only PSICOLE integration contract.
 */
:root {
  --cpm-integration-navy: #1a2e4a;
  --cpm-integration-indigo: #4338ca;
  --cpm-integration-purple: #54277f;
  --cpm-integration-green: #059669;
  --cpm-integration-amber: #d97706;
  --cpm-integration-border: #e5e7eb;
  --cpm-integration-soft: #f8fafc;
}

/* The bridge hides the public login/fee actions once the PSICOLE session is
 * known. Keep the hidden state out of the flex width calculation as well, so
 * authenticated headers never introduce horizontal overflow. */
body .cpm-actions .cpm-login-link[hidden],
body .cpm-actions .cpm-button--primary[hidden] {
  display: none !important;
}

body .cpm-account-panel {
  width: min(336px, calc(100vw - 28px));
  z-index: 3220;
  padding: 10px;
  border-color: rgba(67, 56, 202, .16);
  border-radius: 18px;
  background: rgba(255, 255, 255, .985);
  box-shadow: 0 24px 64px rgba(15, 30, 49, .17), 0 4px 12px rgba(15, 30, 49, .08);
}

body .cpm-account-panel__identity {
  gap: 5px;
  padding: 12px 12px 13px;
  border-bottom: 1px solid var(--cpm-integration-border);
}

body .cpm-account-panel__identity strong {
  color: var(--cpm-integration-navy);
  font-size: 14px;
  font-weight: 800;
}

body .cpm-account-panel__identity > span {
  color: #64748b;
  font-size: 12px;
  font-weight: 650;
}

/* Desktop account menu uses the same visual language and data as PSICOLE's
 * digital credential: navy header, official mark, status, matrícula, expiry
 * and the verification QR returned by /credential. */
body .cpm-account-mini-card {
  display: block;
  margin: 10px 2px 8px;
  overflow: hidden;
  border: 1px solid rgba(26, 46, 74, .14);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(15, 30, 49, .1), 0 1px 2px rgba(15, 30, 49, .06);
}

body .cpm-account-mini-card[hidden] {
  display: none !important;
}

body .cpm-account-mini-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 43px;
  padding: 9px 11px;
  background: linear-gradient(135deg, #0e0620 0%, #180d42 35%, #1c1158 100%);
}

body .cpm-account-mini-card__header img {
  display: block;
  width: 116px;
  height: auto;
  max-height: 22px;
  object-fit: contain;
  object-position: left center;
  filter: brightness(0) invert(1);
  opacity: .96;
}

body .cpm-account-mini-card__header span {
  color: rgba(224, 213, 255, .86);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}

body .cpm-account-mini-card__body {
  padding: 12px;
}

body .cpm-account-mini-card__identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

body .cpm-account-mini-card__avatar {
  display: grid;
  width: 47px;
  height: 47px;
  flex: 0 0 47px;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  background: linear-gradient(135deg, #4338ca 0%, #7c3aed 70%, #c026d3 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

body .cpm-account-mini-card__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body .cpm-account-mini-card__person {
  display: grid;
  min-width: 0;
  gap: 2px;
}

body .cpm-account-mini-card__person strong {
  overflow: hidden;
  color: #0b1120;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.16;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body .cpm-account-mini-card__person > span:last-child {
  color: #4338ca;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .03em;
}

body .cpm-account-mini-card__status {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border: 1px solid #6ee7b7;
  border-radius: 999px;
  background: #d1fae5;
  color: #047857;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

body .cpm-account-mini-card__status.is-inactive {
  border-color: #cbd5e1;
  background: #f1f5f9;
  color: #64748b;
}

body .cpm-account-mini-card__status i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

body .cpm-account-mini-card__footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid #ece8f3;
}

body .cpm-account-mini-card__footer > div:first-child {
  display: grid;
  gap: 3px;
}

body .cpm-account-mini-card__footer > div:first-child span {
  color: #94a3b8;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

body .cpm-account-mini-card__footer > div:first-child strong {
  color: #0f172a;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 800;
}

body .cpm-account-mini-card__qr-wrap {
  flex: 0 0 auto;
  padding: 3px;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(12, 7, 40, .1), 0 0 0 1px rgba(0, 0, 0, .05);
}

body .cpm-account-mini-card__qr-wrap[hidden] {
  display: none !important;
}

body .cpm-account-mini-card__qr-wrap img {
  display: block;
  width: 58px;
  height: 58px;
  image-rendering: pixelated;
}

/* This action is intentionally present only inside the mobile menu. */
body .cpm-mobile-session-link {
  display: none !important;
}

body .cpm-account-panel__status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 5px;
}

body .cpm-account-status-chip {
  display: inline-flex;
  min-height: 23px;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid rgba(5, 150, 105, .16);
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
}

body .cpm-account-status-chip--muted {
  border-color: #e2e8f0;
  background: #f8fafc;
  color: #64748b;
}

body .cpm-account-status-chip--warning {
  border-color: rgba(217, 119, 6, .2);
  background: #fff7ed;
  color: #b45309;
}

body .cpm-account-status-chip--inactive {
  border-color: #e2e8f0;
  background: #f1f5f9;
  color: #64748b;
}

body .cpm-account-panel__section-label {
  margin: 11px 11px 4px;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

body .cpm-account-panel__section-label--secondary {
  margin-top: 8px;
}

body .cpm-account-panel > a,
body .cpm-account-panel__logout {
  min-height: 42px;
  border-radius: 10px;
  font-size: 13px;
}

body .cpm-account-panel > a.cpm-account-panel__primary-link {
  border: 1px solid rgba(67, 56, 202, .12);
  background: #f7f5ff;
  color: var(--cpm-integration-purple);
  font-weight: 800;
}

body .cpm-account-panel > a.cpm-account-panel__primary-link:hover,
body .cpm-account-panel > a.cpm-account-panel__primary-link:focus-visible {
  border-color: rgba(67, 56, 202, .24);
  background: #f0ecff;
}

body .cpm-account-panel__status {
  margin: 4px 11px 1px;
}

/* Keep the approved compact header rhythm through the scrollbar-adjusted
 * medium desktop range. At 1180–1200px the layout viewport can lose 15–17px
 * to the vertical scrollbar, so the fee action must collapse before it can
 * create horizontal scrolling. */
@media (min-width: 981px) and (max-width: 1200px) {
  body .cpm-header__inner {
    gap: 14px !important;
  }

  body .cpm-header .cpm-nav {
    gap: 2px !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }

  body .cpm-header .cpm-nav a {
    padding-inline: 9px !important;
  }

  body .cpm-header .cpm-actions {
    flex: 0 1 auto !important;
    min-width: 0 !important;
    gap: 8px !important;
  }

  body .cpm-header .cpm-login-link {
    white-space: nowrap !important;
  }

  body .cpm-header .cpm-actions .cpm-button--primary {
    max-width: 44px !important;
    min-width: 44px !important;
    width: 44px !important;
    padding-inline: 0 !important;
    overflow: hidden !important;
    color: transparent !important;
    white-space: nowrap !important;
  }

  body .cpm-header .cpm-actions .cpm-button--primary svg {
    margin: 0 !important;
    color: #fff !important;
  }
}

@media (max-width: 700px) {
  :root {
    --cpm-integration-mobile-dock: calc(76px + env(safe-area-inset-bottom));
  }

  body .cpm-account-panel {
    position: fixed;
    top: auto;
    right: 12px;
    bottom: calc(var(--cpm-integration-mobile-dock) + 12px);
    left: 12px;
    width: auto;
    max-height: min(72vh, 590px);
    overflow: auto;
    overscroll-behavior: contain;
    border-radius: 22px;
    transform-origin: bottom center;
    animation: cpm-account-sheet-in 160ms ease-out both;
  }

  body .cpm-account-panel[hidden] {
    display: none !important;
  }

  body.cpm-account-sheet-open .cpm-mobile-dock {
    pointer-events: none;
    opacity: .55;
  }

  body .cpm-account-panel__identity {
    padding: 15px 14px 14px;
  }

  body .cpm-header .cpm-nav .cpm-mobile-session-link {
    display: flex !important;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    margin-top: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    color: var(--cpm-integration-purple);
    font-weight: 750;
  }

  body .cpm-header .cpm-nav .cpm-mobile-session-link[hidden] {
    display: none !important;
  }

  body .cpm-account-mini-card {
    margin-inline: 2px;
  }

  body .cpm-account-panel__section-label {
    margin-inline: 13px;
  }

  body .cpm-account-panel > a,
  body .cpm-account-panel__logout {
    min-height: 46px;
    padding-inline: 13px;
    font-size: 14px;
  }
}

@keyframes cpm-account-sheet-in {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  body .cpm-account-panel { animation: none; }
}
