/* ============================================================
   Whiteout — backoffice styles (light theme, red nav)
   ============================================================ */

:root {
  --bo-bg:          #efefef;
  --bo-surface:     #ffffff;
  --bo-border:      #d4d4d4;
  --bo-text:        #171717;
  --bo-muted:       #666666;
  --bo-primary:     #232323;
  --bo-primary-h:   #0f0f0f;
  --bo-danger:      #c0392b;
  --bo-danger-bg:   #fdecea;
  --bo-success:     #276749;
  --bo-success-bg:  #edfaf2;
  --bo-warn:        #9a6700;
  --bo-warn-bg:     #fffbea;
  --bo-nav-bg:      #7b1d1d;
  --bo-nav-h:       56px;

  --radius-sm: 5px;
  --radius:    8px;
  --radius-lg: 12px;
  --shadow-card: 0 1px 6px rgba(0,0,0,.07);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); color: var(--bo-text); background: var(--bo-bg); line-height: 1.5; }
a { color: var(--bo-primary); }

/* ── Nav ── */
.bo-nav {
  height: var(--bo-nav-h);
  background: var(--bo-nav-bg);
  color: #fff;
  display: flex; align-items: center;
  padding: 0 1.5rem;
  gap: 2rem;
  position: sticky; top: 0; z-index: 100;
}
.bo-nav__brand {
  display: inline-flex; align-items: center; gap: 8px;
  color: #fff; font-weight: 700; font-size: .95rem;
  text-decoration: none; flex-shrink: 0;
}
.bo-nav__logo { height: 26px; width: auto; }
.bo-nav__links { display: flex; gap: 1.25rem; flex: 1; }
.bo-nav__links a {
  color: rgba(255,255,255,.82); text-decoration: none;
  font-size: .88rem; font-weight: 500; transition: color .15s;
}
.bo-nav__links a:hover, .bo-nav__links a.active { color: #fff; text-decoration: none; }
.bo-nav__user { display: flex; align-items: center; gap: .9rem; flex-shrink: 0; }
.bo-nav__username { color: rgba(255,255,255,.7); font-size: .82rem; }
.bo-nav__action {
  color: rgba(255,255,255,.82); text-decoration: none;
  font-size: .82rem; font-weight: 500;
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: inherit; line-height: 1; transition: color .15s;
}
.bo-nav__action:hover { color: #fff; }

/* ── Layout ── */
.bo-layout { display: flex; flex-direction: column; min-height: 100dvh; }
.bo-content { flex: 1; max-width: 1200px; margin: 0 auto; width: 100%; padding: 1.75rem 1.5rem; }

/* ── Footer ── */
.bo-footer {
  text-align: center;
  padding: 1rem;
  font-size: .75rem;
  color: var(--bo-muted);
  border-top: 1px solid var(--bo-border);
}
.bo-footer nav {
  display: flex; justify-content: center; align-items: center;
  gap: .35rem .5rem; flex-wrap: wrap; margin-bottom: .2rem;
}
.bo-footer a { color: var(--bo-muted); text-decoration: none; }
.bo-footer a:hover { color: var(--bo-primary); text-decoration: underline; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .5rem 1.1rem;
  border: none; border-radius: var(--radius-sm);
  font: 600 .875rem/1 var(--font);
  cursor: pointer; text-decoration: none;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:active { opacity: .85; }
.btn-primary   { background: var(--bo-primary); color: #fff; }
.btn-primary:hover { background: var(--bo-primary-h); color: #fff; text-decoration: none; }
.btn-secondary { background: transparent; color: var(--bo-primary); border: 1.5px solid var(--bo-primary); }
.btn-secondary:hover { background: #f0f0f0; text-decoration: none; }
.btn-danger    { background: var(--bo-danger); color: #fff; }
.btn-danger:hover { background: #a93226; text-decoration: none; }
.btn-ghost     { background: transparent; color: var(--bo-muted); border: 1.5px solid var(--bo-border); }
.btn-ghost:hover { border-color: #999; }
.btn-sm        { padding: .3rem .75rem; font-size: .8rem; }
.btn-full      { width: 100%; }
.btn-link      { background: none; border: none; color: var(--bo-muted); font: inherit; cursor: pointer; padding: 0; }
.btn-link:hover { color: var(--bo-primary); text-decoration: underline; }
.btn:disabled  { opacity: .4; cursor: not-allowed; pointer-events: none; }

/* ── Alerts ── */
.alert {
  padding: .7rem 1rem; border-radius: var(--radius-sm);
  margin-bottom: 1rem; font-size: .875rem;
  border-left: 3px solid;
}
.alert-error   { background: var(--bo-danger-bg);  color: var(--bo-danger);  border-color: var(--bo-danger); }
.alert-success { background: var(--bo-success-bg); color: var(--bo-success); border-color: var(--bo-success); }

/* ── Form fields ── */
.field { margin-bottom: 1rem; }
.field label {
  display: block; font-weight: 600; font-size: .82rem;
  color: var(--bo-muted); margin-bottom: .3rem;
  text-transform: uppercase; letter-spacing: .03em;
}
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-row .field { flex: 1 1 180px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: .5rem .75rem;
  border: 1.5px solid var(--bo-border);
  border-radius: var(--radius-sm);
  font: .9rem/1.4 var(--font);
  background: var(--bo-surface);
  color: var(--bo-text);
  transition: border-color .15s;
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
}
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23666' d='M0 1.5l6 5 6-5L10.5 0 6 4 1.5 0z'/></svg>");
  background-repeat: no-repeat; background-position: right .75rem center;
  padding-right: 2rem; cursor: pointer;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--bo-primary);
  box-shadow: 0 0 0 3px rgba(0,0,0,.08);
}
.hint { color: var(--bo-muted); font-size: .8rem; margin-top: .2rem; }

/* ── Login ── */
.bo-body--login {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; background: var(--bo-bg);
}
.login-card {
  background: var(--bo-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(0,0,0,.1);
  padding: 2.5rem 2rem;
  width: 100%; max-width: 400px;
}
.login-card h1 { font-size: 1.5rem; font-weight: 800; color: var(--bo-primary); margin-bottom: .25rem; }
.login-card .sub { color: var(--bo-muted); font-size: .875rem; margin-bottom: 1.75rem; }

/* ── Page header ── */
.bo-page-header {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.bo-page-header h1 { font-size: 1.4rem; font-weight: 700; flex: 1; }
.back-link { color: var(--bo-muted); text-decoration: none; font-size: .875rem; }
.back-link:hover { color: var(--bo-primary); }

/* ── Table ── */
.bo-table-wrap { overflow-x: auto; }
.bo-table {
  width: 100%; border-collapse: collapse; font-size: .875rem;
  background: var(--bo-surface);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-card);
}
.bo-table thead { background: #f3f3f3; }
.bo-table th {
  padding: .65rem .9rem; text-align: left;
  font-weight: 600; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--bo-muted); border-bottom: 1.5px solid var(--bo-border);
}
.bo-table td {
  padding: .65rem .9rem; border-bottom: 1px solid var(--bo-border);
  vertical-align: middle;
}
.bo-table tr:last-child td { border-bottom: none; }
.bo-table tr:hover td { background: #f7f7f7; }
.bo-table .row-inactive td { opacity: .55; }
.bo-table .row-test td { background: #fdfaf5; }
.bo-table .text-right { text-align: right; }
.bo-table .col-narrow { width: 1%; white-space: nowrap; }
.bo-table .col-name   { min-width: 12rem; }
.row-actions { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.row-actions form { display: inline-flex; margin: 0; }

/* ── Chips ── */
code, .code-chip {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: .82rem; background: #f1f1f1; color: #2f2f2f;
  padding: .15rem .45rem; border-radius: 4px;
}

/* ── Badges ── */
.state-badge {
  display: inline-block; padding: .2rem .55rem;
  border-radius: 999px; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
}
/* Phase states */
.state-waiting      { background: #f0f0f0; color: #888; }
.state-individual   { background: #dbeafe; color: #1e40af; }
.state-group        { background: #dcfce7; color: #166534; }
.state-reveal       { background: #fef9c3; color: #854d0e; }
.state-second_stage { background: #ede9fe; color: #5b21b6; }
.state-complete     { background: #d1fae5; color: #065f46; }
/* User states */
.state-active   { background: var(--bo-success-bg); color: var(--bo-success); }
.state-inactive { background: #f0f1f4; color: var(--bo-muted); }
/* Test badge */
.badge-test { background: #efefef; color: #4f4f4f; border: 1px solid #d7d7d7; font-size: .7rem; }

/* ── Role badges ── */
.role-badge { display: inline-block; padding: .15rem .5rem; border-radius: 4px; font-size: .75rem; font-weight: 700; }
.role-admin    { background: #fdecea; color: #c0392b; }
.role-educator { background: #edfaf2; color: var(--bo-success); }

/* ── Forms (card) ── */
.bo-form-card {
  background: var(--bo-surface); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: 1.5rem; margin-bottom: 1.5rem;
}
.bo-form-card h2 { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; color: var(--bo-primary); }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.25rem; }

/* Code input row with regen button */
.code-input-wrap { display: flex; gap: .4rem; align-items: stretch; }
.code-input-wrap input { flex: 1; min-width: 0; }
.btn-regen {
  flex: 0 0 auto; cursor: pointer; white-space: nowrap;
  border: 1.5px solid var(--bo-border); background: #f4f5f7;
  border-radius: var(--radius-sm); padding: 0 .75rem;
  font-size: 1rem; color: var(--bo-muted); line-height: 1;
  transition: background .15s;
}
.btn-regen:hover { background: #e9ebef; }

/* Test session fieldset */
.test-fieldset {
  border: 1.5px solid #f1d9a3; background: #fffaf1;
  border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem;
}
.test-fieldset legend { font-weight: 700; font-size: .9rem; padding: 0 .4rem; color: var(--bo-warn); }
.checkbox-label {
  display: flex; align-items: flex-start; gap: .5rem;
  font-size: .9rem; cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  margin-top: .25rem; width: 1rem; height: 1rem;
  accent-color: var(--bo-warn); flex-shrink: 0;
  -webkit-appearance: auto; appearance: auto;
}

/* ── Generic card (session detail) ── */
.card {
  background: var(--bo-surface); border: 1px solid var(--bo-border);
  border-radius: var(--radius); padding: 1.25rem;
  box-shadow: var(--shadow-card); margin-bottom: .75rem;
}
.card h2 { font-size: 1rem; font-weight: 700; margin-bottom: .75rem; }

/* ── Empty state ── */
.bo-empty { text-align: center; padding: 3rem 1rem; color: var(--bo-muted); font-size: .95rem; }
.bo-empty a { color: var(--bo-primary); }

/* ── Session detail ── */
.session-title {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  font-size: 1.3rem; font-weight: 700;
}
.session-code-big {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 1.5rem; font-weight: 800; letter-spacing: .15em;
  background: #f1f1f1; padding: .2rem .6rem; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .12s;
}
.session-code-big:hover { background: #e5e5e5; }
.session-meta-row { font-size: .85rem; color: var(--bo-muted); margin-top: .3rem; }
.session-meta-row code { font-size: .8rem; }

.phase-controls {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  margin-bottom: 1.25rem; padding: 1rem 1.25rem;
  background: var(--bo-surface); border: 1px solid var(--bo-border);
  border-radius: var(--radius); box-shadow: var(--shadow-card);
}
.current-phase-label { font-size: .78rem; color: var(--bo-muted); }
.current-phase-name  { font-weight: 700; font-size: 1rem; }
.phase-sep { flex: 1; }

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .6rem; margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--bo-surface); border: 1px solid var(--bo-border);
  border-radius: var(--radius-sm); padding: .85rem 1rem; text-align: center;
  box-shadow: var(--shadow-card);
}
.stat-card__value { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.stat-card__label { font-size: .72rem; color: var(--bo-muted); margin-top: .2rem; }

.participants-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.participants-table th {
  text-align: left; color: var(--bo-muted); font-size: .72rem;
  text-transform: uppercase; letter-spacing: .06em;
  padding: .4rem .6rem; border-bottom: 1.5px solid var(--bo-border);
}
.participants-table td { padding: .5rem .6rem; border-bottom: 1px solid var(--bo-border); }
.participants-table tr:last-child td { border-bottom: none; }
.status-done    { color: var(--bo-success); font-weight: 600; }
.status-pending { color: var(--bo-muted); }

.score-bar-wrap { display: flex; align-items: center; gap: .6rem; }
.score-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--bo-border); overflow: hidden; }
.score-bar__fill { height: 100%; border-radius: 3px; background: var(--bo-primary); }

.ranking-preview { display: flex; flex-wrap: wrap; gap: .3rem; }
.rp-item {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .15rem .4rem; background: #f1f1f1;
  border: 1px solid var(--bo-border); border-radius: 4px; font-size: .75rem;
}
.rp-num { font-weight: 700; color: var(--bo-primary); }
.rp-letter { color: var(--bo-muted); }

@media (max-width: 600px) {
  .bo-nav { gap: 1rem; padding: 0 1rem; }
  .bo-nav__links { gap: .75rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .phase-controls { flex-direction: column; align-items: flex-start; }
}
