/*
 * SILP Psychology Theme
 * Global, role-agnostic layer. Loaded after page-specific styles so legacy
 * screens share the same palette, typography, density, badges, and navigation.
 */

:root {
  --psych-ink: #251d4b;
  --psych-sky: #cadffd;
  --psych-lilac: #c3beef;
  --psych-orchid: #cca9e8;
  --psych-ink-rgb: 37, 29, 75;
  --psych-sky-rgb: 202, 223, 253;
  --psych-lilac-rgb: 195, 190, 239;
  --psych-orchid-rgb: 204, 169, 232;

  --ui-font-sans: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ui-steel-950: var(--psych-ink);
  --ui-steel-900: #32275f;
  --ui-steel-800: #493d73;
  --ui-steel-700: #635b81;
  --ui-steel-600: #6b6484;
  --ui-steel-500: #928ca7;
  --ui-steel-300: #c7c3d4;
  --ui-steel-200: #dedbe8;
  --ui-steel-100: #f0eef6;
  --ui-paper: #f8f7fb;
  --ui-cloud: #f1eff8;
  --ui-mist: #e5e1ef;

  /* Legacy teal token names remain API-compatible but now use the brand. */
  --ui-psych-teal-800: #251d4b;
  --ui-psych-teal-700: #3b2f68;
  --ui-psych-teal-600: #584781;
  --ui-psych-teal-200: var(--psych-lilac);
  --ui-psych-teal-100: #eeebfb;

  --ui-surface-base: #f8f7fb;
  --ui-surface-raised: #fff;
  --ui-surface-soft: #f2f0f8;
  --ui-surface-contrast: var(--psych-ink);
  --ui-text-primary: var(--psych-ink);
  --ui-text-secondary: #493d73;
  --ui-text-muted: #6b6484;
  --ui-border-subtle: rgba(var(--psych-ink-rgb), .12);
  --ui-border-strong: rgba(var(--psych-ink-rgb), .22);
  --ui-border-soft: rgba(var(--psych-lilac-rgb), .62);
  --ui-focus-ring: 0 0 0 .22rem rgba(var(--psych-lilac-rgb), .48);
  --ui-hero-gradient: linear-gradient(135deg, #251d4b 0%, #51446f 58%, #735883 100%);
  --ui-surface-gradient-soft: linear-gradient(135deg, #f7f5fc 0%, #eef4fd 100%);

  --ui-tone-neutral-bg: rgba(var(--psych-lilac-rgb), .22);
  --ui-tone-neutral-text: #493d73;
  --ui-tone-neutral-border: rgba(var(--psych-lilac-rgb), .7);
  --ui-tone-info-bg: rgba(var(--psych-sky-rgb), .46);
  --ui-tone-info-text: #30436b;
  --ui-tone-info-border: rgba(125, 159, 211, .4);

  --bs-primary: var(--psych-ink);
  --bs-primary-rgb: var(--psych-ink-rgb);
  --bs-link-color: #4f3f7b;
  --bs-link-hover-color: var(--psych-ink);
  --bs-link-color-rgb: 79, 63, 123;
  --bs-link-hover-color-rgb: 37, 29, 75;
  --bs-body-font-family: var(--ui-font-sans);
  --bs-body-font-size: .9rem;
  --bs-body-line-height: 1.5;
  --bs-body-color: var(--ui-text-primary);
  --bs-body-bg: var(--ui-surface-base);
}

html { font-size: 16px; }

body {
  color: var(--ui-text-primary);
  font-family: var(--ui-font-sans);
  font-size: .9rem;
  line-height: 1.5;
}

code { font-size: .78rem; color: #9a245f; }

.ui-toast-stack {
  z-index: 1090;
  width: min(24rem, calc(100vw - 1rem));
  pointer-events: none;
}

.ui-toast {
  pointer-events: auto;
  border: 1px solid rgba(37, 29, 75, .18);
  border-left: .3rem solid #4f4678;
  border-radius: .85rem;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 1rem 2.25rem rgba(37, 29, 75, .2);
  color: #251d4b;
}

.ui-toast.ui-alert--success { border-left-color: #13795b; }
.ui-toast.ui-alert--danger { border-left-color: #b42318; }
.ui-toast.ui-alert--warning { border-left-color: #8a5700; }
.ui-toast.ui-alert--info { border-left-color: #31507a; }
.ui-toast .toast-header { color: #251d4b; background: transparent; border-bottom-color: rgba(37, 29, 75, .1); }
.ui-toast__icon { width: 1.45rem; color: #4f4678; }

@media (max-width: 575.98px) {
  .ui-toast-stack { top: .25rem !important; right: .25rem !important; padding: .25rem !important; }
}

body.ui-page-shell {
  background:
    radial-gradient(circle at 100% 0, rgba(var(--psych-sky-rgb), .22), transparent 25rem),
    var(--ui-surface-base);
  color: var(--ui-text-primary);
  font-size: .9rem;
  line-height: 1.5;
}

body.ui-page-shell h1 { font-size: clamp(1.28rem, 1.65vw, 1.7rem); }
body.ui-page-shell h2 { font-size: clamp(1.08rem, 1.3vw, 1.35rem); }
body.ui-page-shell h3 { font-size: 1.05rem; }
body.ui-page-shell h4,
body.ui-page-shell .h4 { font-size: 1.1rem; }
body.ui-page-shell h5,
body.ui-page-shell .h5 { font-size: 1rem; }
body.ui-page-shell h6,
body.ui-page-shell .h6 { font-size: .9rem; }

main.app-main-shell { margin-block: 1.1rem !important; }

.app-shell-navbar {
  background:
    radial-gradient(circle at 12% 0, rgba(var(--psych-sky-rgb), .2), transparent 32%),
    linear-gradient(135deg, #191333 0%, var(--psych-ink) 52%, #493d73 100%) !important;
  border-bottom-color: rgba(var(--psych-lilac-rgb), .3) !important;
  box-shadow: 0 8px 24px rgba(var(--psych-ink-rgb), .16) !important;
}

.app-shell-brand__mark {
  background: rgba(var(--psych-lilac-rgb), .16) !important;
  border-color: rgba(var(--psych-lilac-rgb), .32) !important;
}

.p-leftnav-standard,
.p-leftnav-standard.p-role-nav--institution {
  --p-nav-deep: #191333;
  --p-nav-primary: var(--psych-ink);
  --p-nav-soft: #efedfa;
  --p-nav-border: var(--psych-lilac);
  --p-nav-muted: #746e8d;
  color: var(--psych-ink);
  font-family: var(--ui-font-sans);
}

.p-leftnav-standard .offcanvas-body { background: #f8f7fb !important; }
.p-leftnav-standard .p-role-nav-user { border-bottom-color: rgba(var(--psych-ink-rgb), .1); }
.p-leftnav-standard .p-role-nav-section { color: #493d73; }
.p-leftnav-standard .p-role-nav-section small { color: #6b6484; }
.p-leftnav-standard .list-group-item,
.p-leftnav-standard .p-nav-link {
  min-height: 40px;
  color: #493d73 !important;
  font-size: .82rem;
}
.p-leftnav-standard .list-group-item > i,
.p-leftnav-standard .p-nav-link > i { color: #746e8d !important; }

.ui-hero,
.exam-hero,
.soft-header .hero,
.soft-header .hero-header,
.survey-dash-hero,
.survey-hero,
.survey-form-head {
  background: var(--ui-hero-gradient) !important;
  box-shadow: 0 10px 26px rgba(var(--psych-ink-rgb), .16) !important;
}

.survey-dash { --d-ink: var(--psych-ink) !important; --d-line: rgba(var(--psych-ink-rgb), .14) !important; }
.survey-dash-fill { background: linear-gradient(90deg, var(--psych-ink), var(--psych-orchid)) !important; }
.survey-dash-note { background: rgba(var(--psych-sky-rgb), .34) !important; border-color: var(--psych-lilac) !important; color: var(--psych-ink) !important; }

.ui-hero { padding: 1.15rem 1.35rem; }
.ui-hero--compact { padding-block: 1.05rem; }
.ui-hero__pill,
.hero-pill,
.exam-pill {
  background: rgba(255, 255, 255, .14) !important;
  border: 1px solid rgba(var(--psych-lilac-rgb), .32) !important;
  font-size: .7rem !important;
  letter-spacing: .035em;
  padding: .27rem .65rem !important;
}
.ui-hero__title,
.page-title,
.exam-hero h1,
.soft-header h1 {
  font-size: clamp(1.2rem, 1.5vw, 1.55rem) !important;
  line-height: 1.2;
}
.ui-hero__subtitle { font-size: .86rem; line-height: 1.5; }
.ui-stat-panel { min-width: 126px; padding: .7rem .8rem; }
.ui-stat-panel__value { font-size: clamp(1.05rem, 1.5vw, 1.4rem); }
.ui-stat-panel__hint { font-size: .72rem; }

.ui-card,
.admin-card,
.soft-card,
.soft-header,
.card {
  border-color: rgba(var(--psych-ink-rgb), .12) !important;
}
.ui-card,
.admin-card,
.soft-card { box-shadow: 0 6px 18px rgba(var(--psych-ink-rgb), .07) !important; }
.ui-panel-card { padding: 1.1rem; }
.ui-section-head { margin-bottom: .8rem; }
.ui-section-head__eyebrow { color: #6b6484; font-size: .68rem; }
.ui-section-head__title { font-size: 1.02rem; }
.ui-section-head__summary { color: #6b6484; font-size: .82rem; }
.ui-detail-item__label,
.himpsi-data-block__label,
.thumb-label,
.info-label { color: #6b6484 !important; }
code { color: #9a245f; }

.table { --bs-table-color: var(--psych-ink); }
.table > :not(caption) > * > * { padding: .68rem .75rem; }
.table thead th,
.table-custom thead th {
  background: #f3f1f9 !important;
  color: #635b81 !important;
  font-size: .7rem !important;
  letter-spacing: .045em;
}
.table tbody { font-size: .84rem; }

.form-label { color: #493d73; font-size: .78rem; }
.form-control,
.form-select,
.input-group-text {
  border-color: rgba(var(--psych-ink-rgb), .18);
  font-size: .85rem;
}
.form-control:focus,
.form-select:focus {
  border-color: #8d7dc0;
  box-shadow: var(--ui-focus-ring);
}

.btn { font-size: .82rem; }
.btn-primary {
  --bs-btn-bg: var(--psych-ink);
  --bs-btn-border-color: var(--psych-ink);
  --bs-btn-hover-bg: #3b2f68;
  --bs-btn-hover-border-color: #3b2f68;
  --bs-btn-active-bg: #191333;
  --bs-btn-active-border-color: #191333;
}
.btn-outline-primary {
  --bs-btn-color: var(--psych-ink);
  --bs-btn-border-color: #8d7dc0;
  --bs-btn-hover-bg: var(--psych-ink);
  --bs-btn-hover-border-color: var(--psych-ink);
}
.text-primary { color: #4f3f7b !important; }
.text-secondary { color: #635b81 !important; }
.text-muted { color: #6b6484 !important; }
.text-success { color: #16603f !important; }
.text-danger { color: #9d263c !important; }
.text-warning { color: #765000 !important; }
.text-info { color: #28547a !important; }
.bg-primary { background-color: var(--psych-ink) !important; }

.btn-outline-secondary {
  --bs-btn-color: #5d5676;
  --bs-btn-border-color: #746e8d;
  --bs-btn-hover-bg: #5d5676;
  --bs-btn-hover-border-color: #5d5676;
  --bs-btn-active-bg: #493d73;
  --bs-btn-active-border-color: #493d73;
}

.btn-outline-warning {
  --bs-btn-color: #765000;
  --bs-btn-border-color: #8a6300;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #765000;
  --bs-btn-hover-border-color: #765000;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #5f4100;
  --bs-btn-active-border-color: #5f4100;
}
.btn-outline-success {
  --bs-btn-color: #16603f;
  --bs-btn-border-color: #26724f;
  --bs-btn-hover-bg: #16603f;
  --bs-btn-hover-border-color: #16603f;
}
.btn-outline-danger {
  --bs-btn-color: #9d263c;
  --bs-btn-border-color: #ad3d50;
  --bs-btn-hover-bg: #9d263c;
  --bs-btn-hover-border-color: #9d263c;
}

.badge.bg-light,
.badge.text-bg-light {
  color: #493d73 !important;
}

.badge,
.ui-status-badge,
.ui-chip,
.p-role-nav-badge {
  border-radius: 999px;
  font-size: .7rem !important;
  font-weight: 700;
  letter-spacing: .015em;
  line-height: 1.2;
  max-width: 100%;
  padding: .28rem .55rem !important;
  text-transform: none;
  white-space: nowrap;
}

.ui-badge-cluster,
.candidate-badges {
  align-items: flex-start;
  display: flex !important;
  flex-flow: row wrap !important;
  gap: .35rem !important;
}

.ui-badge-cluster .ui-status-badge,
.candidate-badges .badge {
  overflow-wrap: anywhere;
  white-space: normal;
}

.ui-badge-cluster--compact {
  max-height: 5.25rem;
  overflow: auto;
  padding: .15rem .15rem .15rem 0;
  scrollbar-width: thin;
}

.ui-pagination-bar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  justify-content: space-between;
}
.ui-pagination-bar__summary { color: var(--ui-text-muted); font-size: .76rem; }
.pagination { --bs-pagination-color: #493d73; --bs-pagination-border-color: rgba(var(--psych-ink-rgb), .14); }
.pagination .page-link { font-size: .75rem; padding: .35rem .58rem; }
.pagination .page-item.active .page-link {
  background: var(--psych-ink);
  border-color: var(--psych-ink);
}

.status-pills { background: #efedfa !important; }
.status-pills .nav-link { color: #635b81 !important; font-size: .76rem !important; padding: .4rem .8rem !important; }
.status-pills .nav-link.active { color: var(--psych-ink) !important; }

.ui-dashboard-stack { gap: 1rem; }
.ui-process-grid { gap: .8rem; }

/* Compact, non-navigational process ribbon. */
.silp-ribbon {
  background: #fff;
  border: 1px solid rgba(var(--psych-ink-rgb), .12);
  border-radius: 1rem;
  box-shadow: 0 6px 18px rgba(var(--psych-ink-rgb), .07);
  padding: .9rem 1rem;
}
.silp-ribbon__head {
  align-items: end;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: .65rem;
}
.silp-ribbon__kicker {
  color: #746e8d;
  display: block;
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.silp-ribbon h2 { font-size: .92rem !important; margin: .1rem 0 0; }
.silp-ribbon__help { color: #584781; font-size: .72rem; font-weight: 700; text-decoration: none; }
.silp-ribbon__track {
  display: grid;
  gap: .26rem;
  grid-template-columns: repeat(8, minmax(4.4rem, 1fr));
  list-style: none;
  margin: 0;
  overflow-x: auto;
  padding: 0 0 .2rem;
  scrollbar-width: thin;
}
.silp-ribbon__stage {
  align-items: center;
  background: #f3f1f9;
  border: 1px solid rgba(var(--psych-ink-rgb), .12);
  border-radius: .42rem;
  color: #635b81;
  cursor: help;
  display: flex;
  gap: .35rem;
  min-height: 2rem;
  padding: .28rem .38rem;
}
.silp-ribbon__stage:focus-visible { box-shadow: var(--ui-focus-ring); outline: 0; }
.silp-ribbon__medal {
  align-items: center;
  background: #dedbe8;
  border-radius: .28rem;
  display: inline-flex;
  flex: 0 0 auto;
  color: #493d73;
  font-size: .68rem;
  font-weight: 850;
  height: 1.25rem;
  justify-content: center;
  width: 1.25rem;
}
.silp-ribbon__label { font-size: .7rem; font-weight: 750; line-height: 1.12; }
.silp-ribbon__stage--complete { background: rgba(var(--psych-sky-rgb), .42); color: #30436b; }
.silp-ribbon__stage--complete .silp-ribbon__medal { background: #607ead; color: #fff; }
.silp-ribbon__stage--current {
  background: var(--psych-ink);
  border-color: var(--psych-ink);
  box-shadow: 0 4px 12px rgba(var(--psych-ink-rgb), .2);
  color: #fff;
}
.silp-ribbon__stage--current .silp-ribbon__medal { background: var(--psych-orchid); color: var(--psych-ink); }
.silp-ribbon__stage--upcoming { color: #635b81; opacity: 1; }

/* A ribbon-board style indicator: icon first, full wording in tooltip/screen-reader text. */
.ui-process-ribbons { display: flex; flex-wrap: nowrap; gap: .28rem; }
.ui-process-ribbon {
  align-items: center;
  background: #efedfa;
  border: 1px solid rgba(var(--psych-ink-rgb), .14);
  border-radius: .35rem;
  color: #746e8d;
  display: inline-flex;
  height: 1.72rem;
  justify-content: center;
  position: relative;
  width: 1.72rem;
}
.ui-process-ribbon::after {
  border-left: .2rem solid transparent;
  border-right: .2rem solid transparent;
  border-top: .2rem solid currentColor;
  bottom: -.2rem;
  content: "";
  left: 50%;
  opacity: .45;
  position: absolute;
  transform: translateX(-50%);
}
.ui-process-ribbon--ok { background: rgba(var(--psych-sky-rgb), .58); color: #30436b; }
.ui-process-ribbon--active { background: var(--psych-ink); color: #fff; }
.ui-process-ribbon--warn { background: rgba(var(--psych-orchid-rgb), .32); color: #6c3768; }
.ui-process-ribbon i { font-size: .68rem; }
.ui-process-ribbon__count {
  align-items: center;
  background: #fff;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: inherit;
  display: inline-flex;
  font-size: .55rem;
  font-weight: 800;
  height: 1rem;
  justify-content: center;
  line-height: 1;
  min-width: 1rem;
  padding-inline: .18rem;
  position: absolute;
  right: -.4rem;
  top: -.42rem;
  z-index: 1;
}

.ui-governance-scope { display: flex; flex-wrap: wrap; gap: .55rem; }
.ui-governance-scope span {
  align-items: center;
  background: #f3f1f9;
  border: 1px solid rgba(var(--psych-ink-rgb), .1);
  border-radius: .6rem;
  color: #493d73;
  display: inline-flex;
  font-size: .76rem;
  gap: .45rem;
  padding: .5rem .65rem;
}

.ui-form-stepper {
  display: grid;
  gap: .3rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  list-style: none;
  margin: 0 0 1.1rem;
  padding: 0;
}
.ui-form-stepper li {
  align-items: center;
  background: #f3f1f9;
  border-radius: .45rem;
  color: #635b81;
  display: flex;
  font-size: .68rem;
  font-weight: 750;
  gap: .35rem;
  min-height: 2rem;
  padding: .3rem .45rem;
}
.ui-form-stepper li span {
  align-items: center;
  background: #dedbe8;
  color: #493d73;
  border-radius: .3rem;
  display: inline-flex;
  height: 1.2rem;
  justify-content: center;
  width: 1.2rem;
}
.ui-form-stepper li.complete { background: rgba(var(--psych-sky-rgb), .45); color: #30436b; }
.ui-form-stepper li.active { background: var(--psych-ink); color: #fff; }
.ui-form-stepper li.active span { background: var(--psych-orchid); color: var(--psych-ink); }
.ui-form-step__actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .9rem; padding-top: .8rem; border-top: 1px solid rgba(var(--psych-ink-rgb), .1); }

/* Authentication uses the same theme, with one clear task per screen. */
.ui-auth-body {
  background: radial-gradient(circle at 85% 10%, rgba(var(--psych-sky-rgb), .45), transparent 30rem), #f8f7fb;
  color: var(--psych-ink);
  font-family: var(--ui-font-sans);
}
.ui-auth-shell { grid-template-columns: minmax(0, 1fr) minmax(23rem, 29rem); max-width: 68rem; }
.ui-auth-shell__brand { background: var(--ui-hero-gradient); padding: clamp(1.4rem, 3vw, 2.5rem); }
.ui-auth-shell__panel { background: #f8f7fb; padding: clamp(1.15rem, 2.5vw, 2rem); }
.ui-auth-panel-card { border-color: rgba(var(--psych-ink-rgb), .12); box-shadow: 0 12px 30px rgba(var(--psych-ink-rgb), .09); padding: 1.35rem; }
.ui-auth-panel-card__title { color: var(--psych-ink); font-size: 1.2rem; }
.ui-auth-form .form-control { min-height: 2.75rem; }
.ui-auth-submit { background: var(--psych-ink); box-shadow: 0 8px 18px rgba(var(--psych-ink-rgb), .2); }
.ui-auth-help { border-top: 1px solid rgba(var(--psych-ink-rgb), .1); margin-top: 1rem; padding-top: .75rem; }
.ui-auth-help summary { color: #584781; cursor: pointer; font-size: .78rem; font-weight: 750; list-style: none; text-align: center; }
.ui-auth-help summary::-webkit-details-marker { display: none; }
.ui-auth-help__body { color: #746e8d; font-size: .74rem; padding-top: .7rem; text-align: center; }
.ui-auth-help__body p { margin-bottom: .65rem; }
.ui-auth-help__links { display: grid; gap: .35rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: .6rem; }
.ui-auth-help__links a { background: #f3f1f9; border-radius: .5rem; color: #493d73; padding: .45rem; text-decoration: none; }

@media (max-width: 767.98px) {
  body.ui-page-shell { font-size: .88rem; }
  main.app-main-shell { margin-top: .75rem !important; }
  .ui-hero, .exam-hero { padding: 1rem !important; }
  .ui-pagination-bar { justify-content: center; }
  .ui-pagination-bar__summary { flex-basis: 100%; text-align: center; }
  .pagination .page-link { padding-inline: .46rem; }
  .silp-ribbon__head { align-items: flex-start; flex-direction: column; gap: .25rem; }
  .silp-ribbon__track { grid-template-columns: repeat(8, 5.2rem); }
}

@media (max-width: 991.98px) {
  .ui-auth-shell {
    grid-template-columns: minmax(0, 1fr);
    max-width: 35rem;
  }
  .ui-auth-shell__brand { display: none; }
  .ui-auth-shell__panel { min-width: 0; padding: 1rem; width: 100%; }
  .ui-auth-panel-card,
  .ui-auth-form { min-width: 0; width: 100%; }
}

@media (max-width: 575.98px) {
  .ui-auth-page { padding: .75rem; }
  .ui-auth-shell { border-radius: 1rem; min-height: 0; }
  .ui-auth-panel-card { border: 0; border-radius: .85rem; box-shadow: none; padding: 1.05rem; }
  .ui-auth-shell__panel { background: #fff; padding: 0; }
  .ui-auth-help__links { grid-template-columns: 1fr; }
}
