/* Πλατφόρμα ομίλων — κοινό στυλ */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #1c2430;
  --muted: #5b6676;
  --border: #d7dce3;
  --primary: #1f4e78;
  --primary-ink: #ffffff;
  --primary-soft: #e3edf7;
  --ok: #1d6b3a;
  --ok-soft: #e2f3e8;
  --warn: #8a5a00;
  --warn-soft: #fff3d6;
  --err: #a32121;
  --err-soft: #fde6e6;
  --focus: #f0a500;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.08);
  /* Charts: ordinal blue ramp for 1st / 2nd / 3rd / 4th+ choice (validated:
     one hue, monotone lightness, light end ≥ 2:1 on the surface), gray = no club */
  --viz-1: #104281;
  --viz-2: #256abf;
  --viz-3: #3987e5;
  --viz-4: #86b6ef;
  --viz-none: #b9bcc2;
  --viz-grid: #e1e4e8;
  --viz-target: #1c2430;
  --viz-ink-1: #fff; --viz-ink-2: #fff; --viz-ink-3: #0b1a2e; --viz-ink-4: #0b1a2e; --viz-ink-none: #1c2430;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1a2029;
    --surface-2: #232b36;
    --text: #e6eaf0;
    --muted: #9aa5b4;
    --border: #334050;
    --primary: #6aa6de;
    --primary-ink: #0d1520;
    --primary-soft: #1f3348;
    --ok: #6fcf97;
    --ok-soft: #173325;
    --warn: #f2c14e;
    --warn-soft: #3a2f12;
    --err: #ff8a8a;
    --err-soft: #3d1b1b;
    --shadow: none;
    /* on dark, 1st choice is the lightest step (most prominent) */
    --viz-1: #9ec5f4;
    --viz-2: #5598e7;
    --viz-3: #2a78d6;
    --viz-4: #1c5cab;
    --viz-none: #59616d;
    --viz-grid: #2c3540;
    --viz-target: #e6eaf0;
    --viz-ink-1: #0b1a2e; --viz-ink-2: #0b1a2e; --viz-ink-3: #fff; --viz-ink-4: #fff; --viz-ink-none: #fff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
}

a { color: var(--primary); }

header.site {
  background: var(--primary);
  color: var(--primary-ink);
}
header.site .inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
header.site a { color: inherit; text-decoration: none; font-weight: 600; }
header.site .school { opacity: 0.85; font-size: 0.9rem; }
header.site .spacer { flex: 1; }
header.site button { background: transparent; color: inherit; border-color: currentColor; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

h1 { font-size: 1.6rem; margin: 0.2em 0 0.6em; line-height: 1.25; }
h2 { font-size: 1.25rem; margin: 1.4em 0 0.6em; }
h3 { font-size: 1.05rem; margin: 1em 0 0.4em; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 14px 0;
}

.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.hidden { display: none !important; }

/* Forms */
label { display: block; font-weight: 600; margin: 12px 0 4px; }
label .hint { display: block; font-weight: 400; color: var(--muted); font-size: 0.88rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"],
input[type="datetime-local"], textarea, select {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
}
textarea { min-height: 90px; }
label > input:not([type="checkbox"]), label > textarea, label > select { display: block; margin-top: 4px; font-weight: 400; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.grid-2 { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
button.primary, .button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
button.danger { color: var(--err); border-color: var(--err); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.small { min-height: 34px; padding: 4px 10px; font-size: 0.9rem; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center; }

/* Messages */
.msg { border-radius: 8px; padding: 10px 14px; margin: 10px 0; border: 1px solid transparent; }
.msg.info { background: var(--primary-soft); }
.msg.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.msg.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.msg.err { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.msg ul { margin: 6px 0 0; padding-left: 20px; }

.badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }

/* Landing */
.roles { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .roles { grid-template-columns: repeat(3, 1fr); } }
.roles a.card { display: block; text-decoration: none; color: inherit; margin: 0; }
.roles a.card:hover { border-color: var(--primary); }
.roles h2 { margin-top: 0; color: var(--primary); }

/* Ranker */
.day { margin-top: 18px; }
.day h3 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
ol.ranker { list-style: none; margin: 8px 0; padding: 0; }
ol.ranker li {
  display: grid;
  grid-template-columns: 34px 64px 1fr auto;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 6px 0;
  touch-action: pan-y;
}
ol.ranker li.dragging { opacity: 0.9; box-shadow: 0 6px 18px rgb(0 0 0 / 0.18); border-color: var(--primary); position: relative; z-index: 2; }
.handle {
  width: 34px; height: 40px;
  display: grid; place-items: center;
  cursor: grab;
  color: var(--muted);
  border-radius: 6px;
  touch-action: none;
  user-select: none;
  font-size: 1.2rem;
}
.handle:active { cursor: grabbing; }
ol.ranker input.pos { min-height: 40px; padding: 6px 8px; text-align: center; font-weight: 700; }
ol.ranker .name { font-weight: 600; }
ol.ranker .desc { display: block; font-weight: 400; color: var(--muted); font-size: 0.88rem; }
ol.ranker .moves { display: flex; gap: 4px; }
ol.ranker .moves button { min-height: 36px; min-width: 36px; padding: 0; }
@media (max-width: 480px) {
  ol.ranker li { grid-template-columns: 30px 54px 1fr; }
  ol.ranker .moves { grid-column: 2 / -1; justify-content: flex-end; }
}

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 700; position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Admin phase stepper */
.steps { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 4px; padding: 0; list-style: none; }
.steps li { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 0.9rem; }
.steps li.done { background: var(--ok-soft); color: var(--ok); }
.steps li.current { background: var(--primary); color: var(--primary-ink); }

nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin: 16px 0 8px; }
nav.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; }
nav.tabs button[aria-selected="true"] { border-bottom-color: var(--primary); color: var(--primary); }

.pick-list { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.pick-list button { width: 100%; justify-content: flex-start; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; font-weight: 400; }

.summary-day { margin: 8px 0; }
.summary-day ol { margin: 4px 0; }

footer.site { max-width: 960px; margin: 0 auto; padding: 0 16px 32px; color: var(--muted); font-size: 0.85rem; }

/* Print: only the receipt */
@media print {
  body { background: #fff; color: #000; }
  header.site, footer.site, .no-print { display: none !important; }
  main > *:not(.receipt) { display: none !important; }
  .receipt { border: 1px solid #999; box-shadow: none; }
}


.phase-actions .spacer { flex: 1; }
nav.tabs.subtabs { margin-top: 12px; }
nav.tabs.subtabs button { font-size: 0.95rem; }
ul.help li { margin: 6px 0; }

/* Parent login: short boxes for the password and the ΑΜ, side by side */
label .hint.after { margin-top: 4px; }
.login-short { display: flex; flex-wrap: wrap; gap: 0 24px; align-items: flex-start; }
.login-short #password, .login-short #tcode { width: 14rem; max-width: 100%; }
.login-short #am { width: 9rem; max-width: 100%; }

/* Parent form: day tabs, locked multi-day clubs */
nav.day-tabs { margin-top: 4px; }
.day-intro { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin: 12px 0; }
ol.ranker .tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 0.8rem; font-weight: 600; }
/* Locked rows sit right above the day's list and continue its numbering */
ol.ranker li.locked { grid-template-columns: 34px 64px 1fr; background: var(--locked-bg, #fff4d6); border-color: var(--locked-border, #e8c66a); color: inherit; }
ol.ranker li.locked .handle { cursor: default; }
ol.ranker li.locked .lockpos { min-height: 40px; display: grid; place-items: center; font-weight: 700; border: 1px dashed var(--locked-border, #e8c66a); border-radius: 6px; }
ol.ranker li.locked .tag { background: rgb(0 0 0 / 0.06); }
ol.ranker .note { display: block; font-weight: 600; font-size: 0.88rem; color: var(--warn, #8a5a00); margin-top: 2px; }
.day-intro .block { display: block; margin-top: 6px; }
@media (max-width: 480px) { ol.ranker li.locked { grid-template-columns: 30px 54px 1fr; } }
details.receipt > summary { cursor: pointer; font-weight: 700; }
details.receipt[open] > summary { margin-bottom: 8px; }
@media (prefers-color-scheme: dark) {
  :root { --locked-bg: #3a3218; --locked-border: #8a7433; }
}
.summary-day ul.receipt-list { list-style: none; margin: 4px 0; padding-left: 1em; }

/* Teacher page: students with checkboxes */
.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 10px 0 6px; }
.filters input[type="search"] { flex: 1 1 220px; width: auto; }
.filters select { width: auto; }
label.inline { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; }
.check-list { max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 4px 0; }
label.check-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; padding: 6px 12px; font-weight: 400; margin: 0; cursor: pointer; }
label.check-row:hover { background: var(--surface-2); }
label.check-row input { width: 18px; height: 18px; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--surface-2); border-radius: 999px; padding: 1px 4px 1px 10px; margin: 2px 2px; }
button.link { border: 0; background: transparent; padding: 0 6px; min-height: 0; color: var(--muted); }

/* Teachers: in-page help above the lists */
#help-panel:not(.hidden) { margin-bottom: 24px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ---------- Charts (js/charts.js) ---------- */
.viz { margin: 8px 0 16px; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.875rem; color: var(--muted); margin-bottom: 8px; }
.viz-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.viz-legend i.viz-tick-key { width: 2px; height: 14px; border-radius: 0; background: var(--viz-target); margin: 0 8px 0 5px; vertical-align: -2px; }
.viz-rows { display: grid; gap: 8px; }
.viz-row { display: grid; grid-template-columns: minmax(80px, 11rem) 1fr auto; gap: 10px; align-items: center; }
.viz-label { font-size: 0.875rem; overflow-wrap: anywhere; }
.viz-total { min-width: 3.5em; text-align: right; font-variant-numeric: tabular-nums; }
.viz-stack { display: flex; gap: 2px; height: 22px; }
.viz-seg { min-width: 3px; display: flex; align-items: center; justify-content: center; overflow: visible; cursor: default; }
.viz-seg:last-child { border-radius: 0 4px 4px 0; }
.viz-seg b { font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.viz-track { position: relative; height: 18px; border-left: 1px solid var(--viz-grid); }
.viz-hbar { position: absolute; left: 0; top: 2px; bottom: 2px; border-radius: 0 4px 4px 0; min-width: 2px; max-width: 100%; }
.viz-target { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--viz-target); pointer-events: none; }
.viz-cols { display: flex; align-items: flex-end; gap: 2px; height: 180px; border-bottom: 1px solid var(--viz-grid); padding-top: 18px; }
.viz-col { flex: 1 1 0; max-width: 56px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.viz-colbar { width: min(24px, 80%); border-radius: 4px 4px 0 0; min-height: 0; }
.viz-cap { font-variant-numeric: tabular-nums; color: var(--muted); }
.viz-collabel { position: absolute; bottom: -1.6em; color: var(--muted); white-space: nowrap; }
.viz-cols + .viz-table { margin-top: 2em; }
[data-tip]:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.viz-tip { position: absolute; z-index: 50; max-width: 300px; padding: 6px 10px; border-radius: 6px; background: var(--text); color: var(--bg); font-size: 0.8125rem; pointer-events: none; box-shadow: var(--shadow); }
.viz-table summary { cursor: pointer; font-size: 0.875rem; color: var(--muted); }
.viz-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 8px 0 16px; }
.viz-tile { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.viz-tile strong { font-size: 1.6rem; line-height: 1.2; }
@media (max-width: 520px) { .viz-row { grid-template-columns: 1fr auto; } .viz-row > .viz-label { grid-column: 1 / -1; } }
.code-box { display: flex; gap: 6px; align-items: center; max-width: 100%; }
.code-box input { min-width: 0; }
.code-box .reveal { flex: none; margin: 0; }
label .hint.code-warn { color: var(--warn); font-weight: 600; margin-top: 4px; }
label .hint.code-warn:empty { display: none; }
