/* Classter IDP Portal — components. Depends on brand.css. */

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-body);
  line-height: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

h1, h2, h3, h4 {
  color: var(--text-heading);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 var(--space-4);
}
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }

p { margin: 0 0 var(--space-4); }
small { color: var(--text-muted); }
hr { border: 0; border-top: 1px solid var(--border-default); margin: var(--space-5) 0; }

/* ---- Layout ---- */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.container {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 var(--space-5);
}
.container--wide { max-width: var(--content-max-width-wide); }
.main { flex: 1; padding: var(--space-6) 0; }

/* ---- Navbar ---- */
.navbar {
  background: var(--bg-nav);
  color: var(--text-on-dark);
  box-shadow: var(--shadow-nav);
}
.navbar__inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.navbar__brand {
  display: flex; align-items: center; gap: var(--space-3);
  color: var(--text-on-dark); font-weight: 700; font-size: 17px;
  letter-spacing: 0.2px;
}
.navbar__brand:hover { text-decoration: none; color: var(--text-on-dark); }
.navbar__brand-mark {
  display: inline-block;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--classter-crimson);
  box-shadow: 0 0 0 4px rgba(208, 34, 34, 0.18);
}
.navbar__nav { display: flex; align-items: center; gap: var(--space-5); }
.navbar__nav a { color: var(--text-on-dark); font-weight: 500; opacity: 0.85; }
.navbar__nav a:hover { opacity: 1; text-decoration: none; }
.navbar__user {
  display: flex; align-items: center; gap: var(--space-3);
  color: var(--text-on-dark); font-size: 14px;
}
.navbar__avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--classter-crimson);
  color: var(--text-on-crimson);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}

/* ---- Footer ---- */
.footer {
  background: var(--bg-footer);
  color: var(--text-on-dark);
  padding: var(--space-5) 0;
  font-size: 13px;
  opacity: 0.85;
}
.footer__inner { display: flex; justify-content: space-between; align-items: center; }

/* ---- Page header ---- */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-5);
  flex-wrap: wrap; gap: var(--space-3);
}
.page-header h1 { margin: 0; }

/* ---- Cards ---- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
}
.card + .card { margin-top: var(--space-5); }
.card__title {
  display: flex; justify-content: space-between; align-items: center;
  margin: 0 0 var(--space-4);
}
.card__title h2 { margin: 0; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center; justify-content: center;
  gap: var(--space-2);
  padding: 10px 18px;
  font-family: var(--font-sans);
  font-weight: 600; font-size: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--cta-bg); color: var(--cta-text); }
.btn--primary:hover { background: var(--cta-hover-bg); color: var(--cta-text); }
.btn--secondary {
  background: var(--bg-surface);
  color: var(--text-heading);
  border-color: var(--border-strong);
}
.btn--secondary:hover { background: var(--bg-surface-alt); color: var(--text-heading); }
.btn--ghost {
  background: transparent;
  color: var(--text-on-dark);
  border-color: rgba(237, 239, 239, 0.4);
}
.btn--ghost:hover { background: rgba(237, 239, 239, 0.1); color: var(--text-on-dark); }
.btn--danger { background: var(--classter-crimson); color: var(--text-on-crimson); }
.btn:disabled, .btn[aria-disabled="true"] {
  background: var(--cta-disabled-bg);
  cursor: not-allowed;
  opacity: 0.7;
}
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--lg { padding: 14px 22px; font-size: 15px; }
.btn--block { width: 100%; }

/* ---- Form controls ---- */
.form-group { margin-bottom: var(--space-4); }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
.form-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600; font-size: 14px;
  color: var(--text-heading);
}
.form-help {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
}
.form-control, select.form-control {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-body);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.form-control:focus, select.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(208, 34, 34, 0.12);
}
.form-control[readonly], .form-control:disabled {
  background: var(--bg-surface-alt);
  color: var(--text-muted);
}
textarea.form-control { min-height: 100px; resize: vertical; }

.form-check {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: 14px; color: var(--text-heading);
}
.form-check input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--classter-crimson);
  cursor: pointer;
}

.form-actions {
  display: flex; gap: var(--space-3); align-items: center;
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-default);
}

/* ---- Status pills ---- */
.pill {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.3px;
  white-space: nowrap;
}
.pill--draft     { background: var(--status-draft-bg);     color: var(--status-draft-fg); }
.pill--submitted { background: var(--status-submitted-bg); color: var(--status-submitted-fg); }
.pill--review    { background: var(--status-review-bg);    color: var(--status-review-fg); }
.pill--approved  { background: var(--status-approved-bg);  color: var(--status-approved-fg); }
.pill--active    { background: var(--status-active-bg);    color: var(--status-active-fg); }
.pill--completed { background: var(--status-completed-bg); color: var(--status-completed-fg); }
.pill--inactive  { background: var(--status-inactive-bg);  color: var(--status-inactive-fg); }

/* ---- Role badges ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 600;
  background: var(--classter-snow);
  color: var(--text-heading);
  text-transform: uppercase; letter-spacing: 0.3px;
  margin-left: var(--space-2);
}
.badge--hr  { background: var(--classter-crimson); color: var(--text-on-crimson); }
.badge--mgr { background: var(--classter-vista); color: white; }

/* ---- Login screen ---- */
.login {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--classter-black) 0%, var(--classter-eerie) 60%, #3a1414 100%);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-5);
  position: relative; overflow: hidden;
}
.login::before, .login::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.login::before {
  width: 360px; height: 360px;
  background: var(--classter-crimson);
  top: -120px; right: -120px;
  opacity: 0.85;
}
.login::after {
  width: 220px; height: 220px;
  background: #FFFFFF;
  bottom: -80px; left: -60px;
  opacity: 0.08;
}
.login__card {
  position: relative; z-index: 1;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-6);
  max-width: 440px; width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.login__brand { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-5); }
.login__mark { width: 36px; height: 36px; border-radius: 50%; background: var(--classter-crimson); }
.login__brand-name { font-weight: 700; font-size: 18px; color: var(--text-heading); letter-spacing: 0.2px; }
.login h1 { margin-bottom: var(--space-3); font-size: 26px; }
.login p { color: var(--text-muted); margin-bottom: var(--space-5); }

/* ---- Tables ---- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-default);
  vertical-align: middle;
}
.table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--bg-surface-alt);
}
.table tbody tr:hover { background: var(--bg-surface-alt); }
.table .nowrap { white-space: nowrap; }

/* ---- Alerts / flash ---- */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: var(--space-4);
}
.alert--error    { background: #FBEAEA; color: #8E1818; border-left: 4px solid var(--classter-crimson); }
.alert--info     { background: #E7EEFA; color: #234E96; border-left: 4px solid var(--classter-vista); }
.alert--success  { background: #DFF1E5; color: #226A3C; border-left: 4px solid #3CA86B; }

/* ---- Empty state ---- */
.empty {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--text-muted);
}
.empty h3 { color: var(--text-heading); margin-bottom: var(--space-2); }

/* ---- Utility ---- */
.row { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.row > * { flex: 1 1 240px; }
.stack-2 > * + * { margin-top: var(--space-2); }
.stack-3 > * + * { margin-top: var(--space-3); }
.stack-4 > * + * { margin-top: var(--space-4); }
.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.flex-row { display: flex; gap: var(--space-3); align-items: center; }
.flex-spacer { flex: 1; }

/* =========================================================================
   IDP form
   ========================================================================= */
.idp-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-5);
  align-items: start;
}
.idp-toc {
  position: sticky;
  top: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: 14px;
}
.idp-toc h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 0 0 var(--space-3);
}
.idp-toc ol {
  margin: 0; padding: 0 0 0 18px;
  display: flex; flex-direction: column;
  gap: var(--space-2);
}
.idp-toc a { color: var(--text-body); }
.idp-toc a:hover { color: var(--classter-crimson); text-decoration: none; }

.idp-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding-bottom: 80px; /* leave room for sticky action bar */
}
.idp-section {
  scroll-margin-top: 80px;
}

/* Scoring tables */
.scoring-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.scoring-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--bg-surface-alt);
  border-bottom: 1px solid var(--border-default);
}
.scoring-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border-default);
  vertical-align: middle;
}
.scoring-table tbody tr:last-child td { border-bottom: 0; }
.scoring-table__total td {
  background: var(--bg-surface-alt);
  border-top: 2px solid var(--border-default);
}
.criterion-desc {
  font-size: 13px;
  margin-top: 4px;
  line-height: 1.45;
}

/* Rating segmented control */
.rating-group {
  display: inline-flex;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-surface);
}
.rating-option {
  position: relative;
  display: inline-flex;
  align-items: center; justify-content: center;
  min-width: 40px;
  padding: 8px 14px;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-heading);
  transition: background 120ms ease, color 120ms ease;
}
.rating-option + .rating-option {
  border-left: 1px solid var(--border-default);
}
.rating-option input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.rating-option:hover { background: var(--bg-surface-alt); }
.rating-option:has(input:checked) {
  background: var(--classter-crimson);
  color: var(--cta-text);
}
.rating-group:has(input:disabled) {
  opacity: 0.7;
}
.rating-option:has(input:disabled) {
  cursor: default;
}
.rating-option:has(input:disabled):hover {
  background: transparent;
}
.rating-option:has(input:checked:disabled) {
  background: var(--classter-jet);
  color: var(--text-on-dark);
}

/* Score summary pill */
.score-pill {
  display: inline-block;
  min-width: 64px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 16px;
  text-align: center;
  background: var(--classter-snow);
  color: var(--classter-jet);
  letter-spacing: 0.5px;
}
.score-pill--sm {
  min-width: 36px;
  padding: 4px 10px;
  font-size: 14px;
}

/* =========================================================================
   Overall Performance Marking matrix
   ========================================================================= */
.matrix-wrap {
  display: flex;
  gap: var(--space-3);
  align-items: stretch;
  justify-content: center;
}
.matrix-axis-y-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-2);
  font-weight: 600;
  color: var(--text-heading);
  font-size: 13px;
}
.matrix-axis-x-label {
  text-align: center;
  font-weight: 600;
  margin-top: var(--space-2);
  font-size: 13px;
  color: var(--text-heading);
}
.matrix-table {
  border-collapse: collapse;
  margin: 0;
}
.matrix-table th {
  padding: 6px 10px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  border: 1px solid var(--border-default);
  background: var(--bg-surface-alt);
}
.matrix-row-label, .matrix-col-label {
  width: 36px;
  text-align: center;
}
.matrix-cell {
  width: 88px;
  height: 52px;
  text-align: center;
  border: 1px solid var(--border-default);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-body);
  padding: 4px;
}
.matrix-cell--bad        { background: #FBEAEA; color: #8E1818; font-weight: 600; }
.matrix-cell--warn       { background: #FFF8E5; color: #8A5A12; }
.matrix-cell--neutral    { background: #FFFFFF; }
.matrix-cell--good       { background: #E8F4EC; color: #226A3C; }
.matrix-cell--great      { background: #D6F0DF; color: #16633E; font-weight: 600; }
.matrix-cell--excellent  { background: #BFE7CC; color: #14583A; font-weight: 700; }
.matrix-cell--current {
  outline: 3px solid var(--classter-crimson);
  outline-offset: -3px;
  position: relative;
}
.matrix-cell--current::after {
  content: "▸ You are here";
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--classter-crimson);
  color: var(--cta-text);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  font-weight: 600;
}

/* Read-only blocks for free-text content (reviewer view) */
.readonly-block {
  background: var(--bg-surface-alt);
  border-left: 3px solid var(--border-strong);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-body);
  margin-bottom: var(--space-3);
}

/* Corporate goals body — preserves newlines and supports basic bold */
.corporate-goals-body {
  background: var(--bg-surface-alt);
  border-left: 4px solid var(--classter-crimson);
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 15px;
}

/* Appendix */
.appendix__summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-heading);
}
details summary { padding: 4px 0; }
details[open] summary { margin-bottom: var(--space-2); }

/* Sticky action bar */
.idp-actions {
  position: sticky;
  bottom: 0;
  left: 0; right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-default);
  padding: var(--space-3) 0;
  margin: var(--space-4) calc(var(--space-5) * -1) 0;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.04);
  z-index: 10;
}
.idp-actions .container { padding: 0 var(--space-5); }

/* ---- Responsive ---- */
@media (max-width: 960px) {
  .idp-layout { grid-template-columns: 1fr; }
  .idp-toc {
    position: static;
    display: none; /* mobile: hide TOC, rely on scroll */
  }
}
@media (max-width: 720px) {
  .navbar__nav { display: none; }
  .navbar__inner { height: 56px; }
  h1 { font-size: 24px; }
  .form-row { grid-template-columns: 1fr; }
  .scoring-table thead { display: none; }
  .scoring-table td { display: block; padding: 8px 12px; }
  .scoring-table tr {
    display: block;
    border-bottom: 1px solid var(--border-default);
    padding: 8px 0;
  }
  .rating-option { padding: 8px 10px; min-width: 36px; }
}
