/* Assessment Portal - hand-written design system.
   Custom properties + clean cards. No framework. */

:root {
  --brand:        #1d6f99;
  --brand-600:    #165d83;
  --brand-700:    #114a68;
  --brand-ink:    #0d3a4f;

  --bg:           #eef2f6;
  --surface:      #ffffff;
  --surface-2:    #f6f8fb;

  --text:         #1f2933;
  --text-muted:   #5b6876;
  --border:       #dde3ea;

  --ok:           #1f9d57;
  --ok-bg:        #e7f6ee;
  --warn:         #b8730a;
  --warn-bg:      #fbefdc;
  --bad:          #cf3a3a;
  --bad-bg:       #fbe9e9;
  --locked:       #8b97a4;
  --locked-bg:    #eef1f4;

  --radius:       14px;
  --radius-sm:    9px;
  --shadow:       0 1px 2px rgba(16,24,40,.06), 0 4px 12px rgba(16,24,40,.06);
  --shadow-lg:    0 12px 34px rgba(16,24,40,.14);
  --ring:         0 0 0 3px rgba(22,93,131,.30);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-600); }

h1 { font-size: 1.7rem; margin: 0 0 .35rem; color: var(--brand-ink); }
h2 { font-size: 1.2rem; margin: 0; color: var(--brand-ink); }

.lead { color: var(--text-muted); margin: 0; line-height: 1.55; }

/* --- Header / footer ---------------------------------------------------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .7rem 1.6rem;
}

.brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; }
.brand img { height: 38px; width: auto; display: block; }
.brand-text {
  font-weight: 700; color: var(--brand-ink); font-size: 1.05rem;
  letter-spacing: .2px;
}

.header-meta { display: flex; align-items: center; gap: .9rem; }
.header-email { color: var(--text-muted); font-size: .9rem; }

.site-main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 2.2rem 1.6rem 3rem;
}
.site-main.full { max-width: none; padding: 0; }

.site-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: .8rem;
  padding: 1.1rem;
  border-top: 1px solid var(--border);
}

/* --- Buttons ----------------------------------------------------------- */

.btn-primary, .btn-secondary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 600; cursor: pointer;
  border-radius: var(--radius-sm); padding: .7rem 1.25rem;
  border: 1px solid transparent; text-decoration: none;
  transition: background .15s, box-shadow .15s, transform .05s;
}
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary { background: var(--surface); color: var(--brand-700); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost {
  background: transparent; color: var(--text-muted);
  padding: .45rem .8rem; font-weight: 500; font-size: .9rem;
}
.btn-ghost:hover { color: var(--brand-700); }
.btn-block { width: 100%; }
.btn-primary:disabled, .btn-primary[disabled] { background: var(--locked); cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: none; box-shadow: var(--ring); }

/* --- Flash + banners --------------------------------------------------- */

.flash-stack { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.4rem; }
.flash {
  padding: .8rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-size: .92rem; line-height: 1.5;
}
.flash-error   { background: var(--bad-bg);  border-color: #f0c4c4; color: #8f2222; }
.flash-success { background: var(--ok-bg);   border-color: #bfe6cf; color: #126c3c; }
.flash-info    { background: var(--warn-bg); border-color: #ecd6ac; color: #855107; }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.25rem; border-radius: var(--radius);
  margin-bottom: 1.6rem;
}
.banner-success { background: var(--ok-bg); border: 1px solid #bfe6cf; }
.banner strong { display: block; color: #126c3c; }
.banner span { color: #2c7a4f; font-size: .92rem; }

/* --- Centered pages (login) -------------------------------------------- */

.page-centered .site-main {
  display: flex; align-items: center; justify-content: center;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--brand-600);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2.6rem 2.4rem;
  width: 100%;
  max-width: 430px;
  text-align: center;
}
.auth-logo { display: block; height: 52px; width: auto; margin: 0 auto 1.3rem; }
.auth-card h1 { font-size: 1.5rem; }
.auth-card .lead { margin: .5rem 0 1.7rem; font-size: .95rem; }
.auth-help {
  margin: 1.6rem 0 0;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  font-size: .85rem;
  color: var(--text-muted);
  line-height: 1.55;
}
.auth-form { display: flex; flex-direction: column; gap: .45rem; text-align: left; }
.auth-form label { font-weight: 600; font-size: .88rem; }
.auth-form input[type="email"],
.auth-form input[type="text"],
.auth-form input[type="password"] {
  font: inherit; padding: .7rem .8rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: .8rem;
}

/* --- Page head --------------------------------------------------------- */

.page-head { margin-bottom: 1.6rem; }
.page-head .lead { margin-top: .3rem; }

/* --- Dashboard cards --------------------------------------------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.2rem;
}

.assess-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem;
  display: flex; flex-direction: column; gap: .65rem;
  border-top: 4px solid var(--brand-600);
}
.assess-card.state-locked  { border-top-color: var(--locked); }
.assess-card.state-complete { border-top-color: var(--ok); }
.assess-card.state-awaiting_result,
.assess-card.state-retake  { border-top-color: var(--warn); }

.card-top { display: flex; align-items: center; justify-content: space-between; }
.card-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; color: var(--brand-700);
}
.card-desc { color: var(--text-muted); font-size: .9rem; line-height: 1.5; margin: 0; flex: 1; }
.card-score { font-size: .88rem; color: var(--text-muted); margin: 0; }
.card-score strong { color: var(--brand-ink); }
.card-action { margin-top: .4rem; }
.card-note { font-size: .88rem; color: var(--text-muted); margin: 0; }
.card-note.ok  { color: #126c3c; font-weight: 600; }
.card-note.bad { color: #8f2222; font-weight: 600; }

/* --- Status pills ------------------------------------------------------ */

.pill {
  font-size: .73rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; padding: .28rem .6rem; border-radius: 999px;
}
.pill-grey  { background: var(--locked-bg); color: var(--locked); }
.pill-blue  { background: #e6eef7; color: var(--brand-600); }
.pill-amber { background: var(--warn-bg); color: var(--warn); }
.pill-green { background: var(--ok-bg); color: var(--ok); }
.pill-red   { background: var(--bad-bg); color: var(--bad); }

/* --- Assessment split screen ------------------------------------------ */

.split {
  display: flex;
  height: calc(100vh - 71px - 49px); /* viewport minus header & footer */
  min-height: 480px;
}
.study-pane { flex: 6 1 0; background: var(--surface-2); border-right: 1px solid var(--border); }
.study-pane iframe { width: 100%; height: 100%; border: 0; display: block; }
.launch-pane {
  flex: 4 1 0; min-width: 320px; max-width: 460px;
  background: var(--surface); padding: 1.8rem; overflow-y: auto;
}
.launch-pane.solo { max-width: 560px; margin: 0 auto; border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow); }

.launch-pane h1 { font-size: 1.3rem; }
.launch-pane .lead { font-size: .92rem; margin-bottom: 1.2rem; }

.step-list { padding-left: 1.1rem; margin: 1.1rem 0; color: var(--text-muted); font-size: .9rem; }
.step-list li { margin-bottom: .4rem; line-height: 1.5; }

/* --- Credential copy fields ------------------------------------------- */

.cred-block { display: flex; flex-direction: column; gap: .7rem; margin: 1.2rem 0; }
.cred {
  display: flex; flex-direction: column; gap: .25rem;
}
.cred-label { font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--text-muted); }
.cred-row {
  display: flex; align-items: stretch;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-2);
}
.cred-value {
  flex: 1; padding: .6rem .7rem; font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: .9rem; color: var(--brand-ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.copy-btn {
  border: 0; border-left: 1px solid var(--border);
  background: var(--surface); color: var(--brand-600);
  font: inherit; font-weight: 600; font-size: .82rem; padding: 0 .9rem;
  cursor: pointer;
}
.copy-btn:hover { background: var(--surface-2); }
.copy-btn.copied { color: var(--ok); }

.callout {
  background: var(--warn-bg); border: 1px solid #ecd6ac;
  border-radius: var(--radius-sm); padding: .8rem .9rem;
  font-size: .87rem; color: #855107; line-height: 1.5; margin: 1rem 0;
}
.divider { border: 0; border-top: 1px solid var(--border); margin: 1.4rem 0; }
.back-link { font-size: .9rem; }

/* --- Completion page --------------------------------------------------- */

.complete-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 3rem 2.6rem; max-width: 540px; text-align: center;
}
.complete-mark {
  width: 68px; height: 68px; border-radius: 50%;
  background: var(--ok-bg); color: var(--ok);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 2rem; margin-bottom: 1.2rem;
}
.complete-card h1 { font-size: 1.6rem; }
.complete-card p { color: var(--text-muted); line-height: 1.6; margin: .6rem 0 0; }

/* --- Admin ------------------------------------------------------------- */

.admin-section { margin-bottom: 2.4rem; }
.admin-section h2 { margin-bottom: .8rem; }

.data-table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; font-size: .88rem;
}
.data-table th, .data-table td {
  text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--border);
}
.data-table th {
  background: var(--surface-2); color: var(--text-muted);
  text-transform: uppercase; font-size: .72rem; letter-spacing: .4px;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table code { font-size: .82rem; }

.tag {
  display: inline-block; font-size: .73rem; font-weight: 700;
  padding: .15rem .5rem; border-radius: 999px;
}
.tag-ok   { background: var(--ok-bg); color: var(--ok); }
.tag-wait { background: var(--warn-bg); color: var(--warn); }
.tag-none { background: var(--locked-bg); color: var(--locked); }
.tag-bad  { background: var(--bad-bg); color: var(--bad); }

.inline-form { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.inline-form input[type="text"], .inline-form input[type="email"] {
  font: inherit; padding: .4rem .55rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: .85rem;
}
.inline-form button {
  font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
  padding: .42rem .8rem; border-radius: 6px;
  border: 1px solid var(--brand-600); background: var(--brand-600); color: #fff;
}
.empty-note { color: var(--text-muted); font-size: .9rem; font-style: italic; }

/* --- Responsive -------------------------------------------------------- */

@media (max-width: 720px) {
  .split { flex-direction: column; height: auto; }
  .study-pane { height: 60vh; border-right: 0; border-bottom: 1px solid var(--border); }
  .launch-pane { max-width: none; }
  .site-header { padding: .7rem 1rem; }
  .header-email { display: none; }
}
