
/* =========================================================
   PsySims shared authentication UI
   Keeps the existing PsySims visual language intact.
========================================================= */

.psysims-auth-lock-scroll{overflow:hidden}

.psysims-auth-overlay{
  position:fixed;inset:0;z-index:10000;
  display:grid;place-items:center;padding:24px;
  background:rgba(11,18,43,.50);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  opacity:0;pointer-events:none;transition:opacity .18s ease;
}
.psysims-auth-overlay.is-open{opacity:1;pointer-events:auto}

.psysims-auth-modal{
  position:relative;width:min(480px,100%);max-height:min(720px,calc(100vh - 48px));overflow-y:auto;overflow-x:hidden;
  scrollbar-width:none;-ms-overflow-style:none;overscroll-behavior:contain;
  border:1px solid rgba(214,216,229,.96);border-radius:22px;
  background:#fff;box-shadow:0 32px 90px rgba(17,26,56,.25);
  transform:translateY(12px) scale(.985);transition:transform .18s ease;
}
.psysims-auth-overlay.is-open .psysims-auth-modal{transform:none}
.psysims-auth-modal::-webkit-scrollbar{width:0;height:0;display:none}

.psysims-auth-close{
  position:absolute;right:18px;top:18px;z-index:2;
  width:34px;height:34px;border:1px solid #e1e3ec;border-radius:50%;
  background:#fff;color:#596078;font-size:19px;line-height:1;cursor:pointer;
}
.psysims-auth-close:hover{background:#f7f7fb;color:#111a38}

.psysims-auth-inner{padding:34px 36px 28px}
.psysims-auth-kicker{
  margin:0 0 9px;color:#7774d9;font-size:12px;font-weight:800;
  letter-spacing:.14em;text-transform:uppercase;text-align:center;
}
.psysims-auth-title{
  margin:0;text-align:center;color:#111a38;
  font-family:"Libre Caslon Text",serif;font-size:34px;line-height:1.15;font-weight:400;
}
.psysims-auth-subtitle{
  max-width:370px;margin:8px auto 18px;color:#6c7185;text-align:center;
  font-size:13px;line-height:1.55;
}

.psysims-auth-tabs{
  display:grid;grid-template-columns:1fr 1fr;gap:4px;padding:4px;margin-bottom:16px;
  border:1px solid #e0e2eb;border-radius:11px;background:#f6f6fa;
}
.psysims-auth-tab{
  min-height:36px;border:0;border-radius:7px;background:transparent;color:#74798b;
  font-size:12px;font-weight:800;cursor:pointer;
}
.psysims-auth-tab.is-active{background:#fff;color:#111a38;box-shadow:0 3px 12px rgba(17,26,56,.07)}

.psysims-auth-social{display:grid;gap:7px}
.psysims-auth-social-button{
  width:100%;min-height:42px;display:flex;align-items:center;justify-content:center;gap:9px;
  border:1px solid #d8dbe6;border-radius:8px;background:#fff;color:#202844;
  font-size:12px;font-weight:700;cursor:pointer;transition:.16s ease;
}
.psysims-auth-social-button:hover{border-color:#aaaed0;background:#fafaff;transform:translateY(-1px)}
.psysims-auth-provider-icon{
  width:18px;height:18px;display:grid;place-items:center;flex:0 0 18px;
}
.psysims-auth-provider-icon svg{
  width:18px;height:18px;display:block;
}
.psysims-auth-provider-google,
.psysims-auth-provider-microsoft{
  background:transparent;border:0;border-radius:0;
}

.psysims-auth-divider{display:flex;align-items:center;gap:10px;margin:16px 0;color:#9a9ead;font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.08em}
.psysims-auth-divider::before,.psysims-auth-divider::after{content:"";height:1px;flex:1;background:#e7e8ef}

.psysims-auth-form{display:grid;gap:11px}
.psysims-auth-field{display:grid;gap:7px}
.psysims-auth-field-row{display:flex;align-items:center;justify-content:space-between;gap:10px}
.psysims-auth-field label,.psysims-auth-field-row label{color:#303750;font-size:12px;font-weight:800}
.psysims-auth-forgot{
  border:0;background:transparent;padding:0;color:#6764c5;font-size:12px;font-weight:800;cursor:pointer;
}
.psysims-auth-input{
  width:100%;min-height:42px;border:1px solid #d8dae5;border-radius:8px;background:#fff;
  padding:0 12px;color:#111a38;outline:none;font-size:12px;transition:.15s ease;
}
.psysims-auth-input:focus{border-color:#8a87df;box-shadow:0 0 0 3px rgba(118,116,217,.11)}
.psysims-auth-input::placeholder{color:#a2a6b4}

.psysims-auth-submit{
  width:100%;min-height:43px;border:0;border-radius:8px;background:#7674d9;color:#fff;
  font-size:12px;font-weight:800;cursor:pointer;box-shadow:0 8px 18px rgba(118,116,217,.18);transition:.16s ease;
}
.psysims-auth-submit:hover{background:#6865cb;transform:translateY(-1px)}
.psysims-auth-submit:disabled{opacity:.55;cursor:not-allowed;transform:none}

.psysims-auth-message{
  display:none;padding:10px 12px;border-radius:9px;background:#f6f6fb;color:#656a7e;
  font-size:12px;line-height:1.5;text-align:center;
}
.psysims-auth-message.is-visible{display:block}
.psysims-auth-message.is-error{background:#fff1f1;color:#a34848}
.psysims-auth-message.is-success{background:#eef7f1;color:#3b7553}

.psysims-auth-legal{margin:14px 0 0;color:#999dac;font-size:12px;line-height:1.5;text-align:center}
.psysims-auth-legal a{color:#6267a7;text-decoration:underline;text-underline-offset:2px}

/* Header account state */
.psysims-profile-wrap{position:relative;display:flex;align-items:center}
.psysims-profile-wrap>summary{list-style:none}
.psysims-profile-wrap>summary::-webkit-details-marker{display:none}
.psysims-profile-button{
  min-height:43px;display:flex;align-items:center;gap:9px;padding:5px 10px 5px 6px;
  border:1px solid #d7d9e5;border-radius:999px;background:#fff;color:#222942;cursor:pointer;
  box-shadow:0 5px 18px rgba(28,35,76,.06);
}
.psysims-profile-button:hover{border-color:#bfc2d7;background:#fbfbff}
.psysims-profile-avatar{
  width:31px;height:31px;display:grid;place-items:center;overflow:hidden;flex:0 0 31px;
  border-radius:50%;background:linear-gradient(135deg,#172653,#8582dd);color:#fff;
  font-size:12px;font-weight:900;letter-spacing:.02em;
}
.psysims-profile-avatar img{width:100%;height:100%;object-fit:cover}
.psysims-profile-name{max-width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;font-weight:800}
.psysims-profile-chevron{color:#8a8fa0;font-size:12px}

.psysims-profile-menu{
  position:absolute;right:0;top:52px;width:270px;padding:9px;
  border:1px solid #dfe1eb;border-radius:15px;background:#fff;
  box-shadow:0 18px 50px rgba(30,38,83,.16);
  opacity:0;pointer-events:none;transform:translateY(7px);transition:.16s ease;
}
.psysims-profile-wrap.is-open .psysims-profile-menu,
.psysims-profile-wrap[open] .psysims-profile-menu{opacity:1;pointer-events:auto;transform:none}
.psysims-profile-summary{display:flex;align-items:center;gap:11px;padding:10px 10px 12px;border-bottom:1px solid #ececf2;margin-bottom:6px}
.psysims-profile-summary .psysims-profile-avatar{width:38px;height:38px;flex-basis:38px}
.psysims-profile-summary strong{display:block;max-width:175px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#202743;font-size:12px}
.psysims-profile-summary small{display:block;max-width:175px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:2px;color:#8a8fa0;font-size:12px}
.psysims-plan-pill{display:inline-flex;margin-top:5px;padding:3px 6px;border-radius:999px;background:#f0efff;color:#5e5ab7;font-size:12px;font-weight:900;letter-spacing:.06em;text-transform:uppercase}
.psysims-profile-menu a,.psysims-profile-signout{
  width:100%;min-height:38px;display:flex;align-items:center;padding:0 10px;border:0;border-radius:8px;
  background:transparent;color:#343a55;text-decoration:none;text-align:left;font-size:12px;font-weight:400;cursor:pointer;
}
.psysims-profile-menu a:hover,.psysims-profile-signout:hover{background:#f5f5fb}
.psysims-profile-separator{height:1px;margin:5px 7px;background:#ececf2}
.psysims-profile-signout{color:#8a4950}

.psysims-mobile-account{width:100%;display:grid;gap:8px}
.psysims-mobile-account-top{display:flex;align-items:center;gap:10px;padding:9px 3px}
.psysims-mobile-account-top strong{display:block;font-size:12px}
.psysims-mobile-account-top small{display:block;margin-top:2px;color:#898e9e;font-size:12px}
.psysims-mobile-account-links{display:grid;grid-template-columns:1fr 1fr;gap:7px}
.psysims-mobile-account-links a,.psysims-mobile-signout{min-height:40px;display:grid;place-items:center;border:1px solid #d9dbe6;border-radius:8px;background:#fff;color:#303750;font-size:12px;font-weight:400}
.psysims-mobile-signout{grid-column:1/-1;cursor:pointer}

@media(max-width:720px){
  .psysims-auth-overlay{padding:12px;align-items:end}
  .psysims-auth-modal{width:100%;max-height:92vh;border-radius:20px 20px 14px 14px}
  .psysims-auth-inner{padding:32px 20px 24px}
  .psysims-auth-title{font-size:29px}
  .psysims-profile-name{display:none}
}


/* V1.4 — robust Sign In / Sign Up visibility */
.psysims-auth-overlay [hidden]{
  display:none !important;
}

.psysims-auth-overlay[data-auth-mode="signin"] #psysimsConfirmField,
.psysims-auth-overlay[data-auth-mode="signin"] #psysimsAuthLegal{
  display:none !important;
}

.psysims-auth-overlay[data-auth-mode="signup"] #psysimsForgotButton{
  display:none !important;
}


/* V1.5 — Sign In spacing + clearer Sign Up legal copy */

/* Give the primary Sign In button a little breathing room
   from the password row without changing the overall compact layout. */
.psysims-auth-overlay[data-auth-mode="signin"] .psysims-auth-submit{
  margin-top:6px;
}

/* Terms / Privacy copy is only shown on Create Account.
   Increase readability while keeping it visually secondary. */
.psysims-auth-overlay[data-auth-mode="signup"] .psysims-auth-legal{
  margin-top:16px;
  color:#73798b;
  font-size:12px;
  line-height:1.65;
  font-weight:500;
}

.psysims-auth-overlay[data-auth-mode="signup"] .psysims-auth-legal a{
  color:#5754b5;
  font-weight:700;
  text-decoration-thickness:1px;
  text-underline-offset:2px;
}

.psysims-auth-overlay[data-auth-mode="signup"] .psysims-auth-legal a:hover{
  color:#46429f;
}


/* V1.6 — clear inline validation */
.psysims-auth-field-error{
  display:none;
  margin-top:5px;
  color:#b64c4c;
  font-size:12px;
  line-height:1.35;
  font-weight:600;
}

.psysims-auth-field-error.is-visible{
  display:block;
}

.psysims-auth-input.is-invalid{
  border-color:#c96b6b !important;
  background:#fffafa;
  box-shadow:0 0 0 3px rgba(182,76,76,.08);
}

.psysims-auth-input.is-invalid:focus{
  border-color:#b64c4c !important;
  box-shadow:0 0 0 3px rgba(182,76,76,.12);
}


/* V1.7 — native validation fallback */
.psysims-auth-input:user-invalid{
  border-color:#c96b6b;
  background:#fffafa;
}

/* Admin-only preview controls */
.psysims-profile-menu-label{padding:7px 14px 4px;color:#9296a8;font-size:12px;font-weight:800;letter-spacing:.12em;text-transform:uppercase}
.psysims-profile-view-button{width:100%;min-height:39px;padding:0 14px;border:0;border-radius:9px;background:transparent;color:#303750;text-align:left;font-size:12px;font-weight:700;cursor:pointer}
.psysims-profile-view-button:hover{background:#f5f5fb}
.psysims-mobile-view-button{min-height:40px;border:1px solid #d9dbe6;border-radius:8px;background:#fff;color:#303750;font-size:12px;font-weight:800;cursor:pointer}
.psysims-mobile-view-button:hover{background:#f5f5fb}
.psysims-preview-banner{position:fixed;z-index:99999;left:50%;bottom:18px;transform:translateX(-50%);display:flex;align-items:center;gap:12px;padding:10px 12px 10px 15px;border:1px solid rgba(105,99,196,.22);border-radius:999px;background:rgba(255,255,255,.96);box-shadow:0 12px 34px rgba(37,39,66,.16);backdrop-filter:blur(12px);font-size:12px;color:#555b70}
.psysims-preview-banner strong{color:#252a42}.psysims-preview-banner a{display:inline-flex;align-items:center;min-height:30px;padding:0 11px;border-radius:999px;background:#171b2f;color:#fff;text-decoration:none;font-weight:800}.psysims-preview-banner a:hover{opacity:.9}
@media(max-width:640px){.psysims-preview-banner{width:calc(100% - 24px);justify-content:space-between;border-radius:14px}.psysims-preview-banner span{font-size:12px}.psysims-mobile-account-links{grid-template-columns:1fr}.psysims-profile-menu-label{padding-left:4px}}


/* V2.1 — global admin preview status inside account button */
.psysims-profile-role-state,
.psysims-profile-preview-state{
  display:inline-flex;align-items:center;gap:5px;min-height:23px;padding:0 8px;border-radius:999px;
  font-size:12px;font-weight:900;letter-spacing:.08em;line-height:1;white-space:nowrap;
}
.psysims-profile-role-state{background:#f1f1f6;color:#6f7487}
.psysims-profile-preview-state{background:#f0efff;color:#5f5bb5}
.psysims-preview-eye{width:13px;height:13px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.psysims-profile-view-button{display:flex;align-items:center;justify-content:space-between;gap:10px}
.psysims-profile-view-button.is-active{background:#f2f1ff;color:#5551ad}
.psysims-preview-check{font-size:12px;font-weight:900}
.psysims-profile-return-button{
  width:100%;min-height:39px;margin-top:4px;padding:0 14px;border:0;border-radius:9px;background:transparent;
  color:#5f5bb5;text-align:left;font-size:12px;font-weight:850;cursor:pointer;
}
.psysims-profile-return-button:hover{background:#f2f1ff}
.psysims-mobile-view-button.is-active{border-color:#c9c6f1;background:#f2f1ff;color:#5551ad}
.psysims-mobile-return-button{
  min-height:40px;border:1px solid #c9c6f1;border-radius:8px;background:#f2f1ff;color:#5551ad;
  font-size:12px;font-weight:850;cursor:pointer;
}
/* The old floating preview banner is intentionally disabled. */
.psysims-preview-banner{display:none !important}
@media(max-width:720px){
  .psysims-profile-role-state,.psysims-profile-preview-state{padding:0 6px;font-size:12px}
  .psysims-preview-eye{width:12px;height:12px}
}

/* V2.5 — hide only an unverified guest account control while an older
   Supabase localStorage session is being synchronized to the Next.js server. */
html.psysims-auth-session-hint .nav-actions[data-psysims-server-viewer="guest"],
html.psysims-auth-session-hint .mobile-actions[data-psysims-server-viewer="guest"]{
  visibility:hidden;
}


/* V2.6 — teacher account menu parity + premium crown */
.psysims-avatar-wrap{position:relative;display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto}
.psysims-premium-crown{position:absolute;right:-4px;top:-8px;width:17px;height:17px;display:grid;place-items:center;color:#6f68d9;filter:drop-shadow(0 2px 3px rgba(69,62,151,.18));pointer-events:none}
.psysims-premium-crown svg{width:100%;height:100%;fill:#f2efff;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.psysims-profile-tier-state{display:inline-flex;align-items:center;min-height:23px;padding:0 8px;border-radius:999px;font-size:12px;font-weight:900;letter-spacing:.08em;line-height:1;white-space:nowrap}
.psysims-profile-tier-state.is-premium{background:#f0efff;color:#5f5bb5}
.psysims-profile-tier-state.is-free{background:#f1f1f6;color:#6f7487}
.psysims-profile-upgrade-link{color:#5f5bb5 !important}
.psysims-student-preview-button{padding-left:10px}
.psysims-student-preview-menu{width:220px}
.psysims-student-preview-menu .psysims-profile-return-button{margin-top:0}
@media(max-width:720px){
  .psysims-profile-tier-state{padding:0 6px;font-size:12px}
  .psysims-premium-crown{right:-3px;top:-7px;width:15px;height:15px}
}

/* Admin preview exit — intentionally prominent and limited to this action. */
.psysims-profile-return-button,
.psysims-mobile-return-button{
  background:#6c63c7 !important;
  color:#fff !important;
  font-weight:800 !important;
  border:1px solid #6c63c7 !important;
  border-radius:10px;
}
.psysims-profile-return-button:hover,
.psysims-mobile-return-button:hover{
  background:#5e55b8 !important;
  color:#fff !important;
}

/* Guest preview: preserve the real guest Sign In / Sign Up controls and add only the admin escape hatch. */
.psysims-guest-preview-actions{display:flex;align-items:center;gap:8px;flex-wrap:nowrap}
.psysims-guest-preview-actions .psysims-guest-return-button{width:auto;min-height:36px;margin:0;padding:0 12px;white-space:nowrap;text-align:center}
@media(max-width:900px){.psysims-guest-preview-actions{gap:6px}.psysims-guest-preview-actions .psysims-guest-return-button{padding:0 9px;font-size:12px}}


/* V2.9 — explicit Guest Preview state + reliable guest-preview controls */
.psysims-guest-preview-shell{display:flex;align-items:center;gap:10px;flex-wrap:nowrap}
.psysims-guest-preview-label{display:inline-flex;align-items:center;gap:5px;min-height:28px;padding:0 9px;border-radius:999px;background:#f0efff;color:#5f5bb5;font-size:12px;font-weight:900;letter-spacing:.08em;white-space:nowrap}
.psysims-guest-preview-label .psysims-preview-eye{width:13px;height:13px}
.psysims-guest-preview-actions button.btn{font:inherit;cursor:pointer}
.psysims-mobile-guest-preview-label{display:flex;align-items:center;gap:7px;padding:8px 4px 10px;color:#5f5bb5;font-size:12px;letter-spacing:.08em}
@media(max-width:1100px){.psysims-guest-preview-shell{gap:6px}.psysims-guest-preview-label{padding:0 6px;font-size:12px}}

/* V3.0 — Guest preview matches the real guest header; preview control lives at far right. */
.psysims-guest-preview-shell{display:flex;align-items:center;gap:10px;flex-wrap:nowrap}
.psysims-guest-preview-shell>a.btn{flex:0 0 auto}
.psysims-guest-preview-wrap{flex:0 0 auto}
.psysims-guest-preview-button{min-height:36px;padding:0 9px;gap:5px}
.psysims-guest-preview-button .psysims-profile-preview-state{min-height:23px}
.psysims-guest-preview-menu{width:210px;right:0;left:auto}
.psysims-guest-preview-menu .psysims-profile-return-button{margin-top:0}
@media(max-width:900px){.psysims-guest-preview-shell{gap:6px}.psysims-guest-preview-button{padding:0 6px}.psysims-guest-preview-menu{width:190px}}

/* V2.3 — account dropdown readability */
.psysims-profile-summary strong{font-size:14px}
.psysims-profile-summary small{font-size:12px;line-height:1.45}
.psysims-plan-pill{font-size:12px}
.psysims-profile-menu a,.psysims-profile-signout{min-height:42px;font-size:13px}
.psysims-profile-menu-label{font-size:12px}
.psysims-mobile-account-top strong{font-size:14px}
.psysims-mobile-account-top small{font-size:12px}
.psysims-mobile-account-links a,.psysims-mobile-signout{font-size:13px}

/* V6 — lighter account dropdown menu items */
.psysims-profile-menu a,.psysims-profile-signout{font-weight:600}
.psysims-mobile-account-links a,.psysims-mobile-signout{font-weight:600}
.psysims-profile-view-button,
.psysims-profile-return-button,
.psysims-mobile-view-button,
.psysims-mobile-return-button{font-weight:600!important}

/* V14 — View As remains text-only in account menus, including the active persona. */
.psysims-profile-view-button,
.psysims-profile-view-button:hover,
.psysims-profile-view-button.is-active{
  background:transparent !important;
}
.psysims-mobile-view-button,
.psysims-mobile-view-button:hover,
.psysims-mobile-view-button.is-active{
  background:transparent !important;
}
.psysims-mobile-view-button{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

/* V15 — View As label accent; Return to Admin follows Guest in preview menus. */
.psysims-view-as-label{color:#5f5bb5}


/* V16 — restore View As divider; active preview uses neutral text on blue highlight; Return to Admin is text-only. */
.psysims-profile-view-button.is-active{
  background:#e1f2fe !important;
  color:#303750 !important;
}
.psysims-mobile-view-button.is-active{
  background:#e1f2fe !important;
  color:#303750 !important;
  border-color:transparent !important;
}
.psysims-profile-return-button,
.psysims-mobile-return-button{
  background:transparent !important;
  color:#5f5bb5 !important;
  border-color:transparent !important;
}
.psysims-profile-return-button:hover,
.psysims-mobile-return-button:hover{
  background:transparent !important;
  color:#5f5bb5 !important;
}

/* P0 auth state: unresolved is visually silent, never fake Guest or gray skeleton. */
.psysims-account-unresolved{display:inline-block;width:172px;height:42px;visibility:hidden;pointer-events:none}
.psysims-account-unresolved.is-mobile{width:100%;height:42px}
