/* =========================================================================
   Treinamento POC — shared design system
   Used by the STUDENT SPA (web/) and the ADMIN SPA (admin/, via ../styles.css)
   Mobile-first. System fonts only. No external assets. Light + dark.
   Brand accent: green #1f7a4d
   ========================================================================= */

:root {
  --brand:      #1f7a4d;
  --brand-600:  #17603c;
  --brand-700:  #124d30;
  --brand-050:  #e8f3ee;
  --brand-text: #1f7a4d;

  --bg:      #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f0f3f1;
  --text:    #16201b;
  --muted:   #5b6b63;
  --border:  #e2e8e4;
  --shadow:  0 1px 3px rgba(16, 32, 24, .08), 0 1px 2px rgba(16, 32, 24, .04);

  --ok-bg:   #e7f4ec;  --ok-fg:   #14603a;  --ok-bd: #bfe3cd;
  --err-bg:  #fdeaea;  --err-fg:  #a52020;  --err-bd: #f3c6c6;
  --warn-bg: #fdf4e3;  --warn-fg: #8a5a12;  --warn-bd: #f0dcae;
  --info-bg: #eaf1fb;  --info-fg: #1f4f8a;  --info-bd: #cfe0f5;

  --radius: 14px;
  --radius-sm: 10px;
  --tap: 52px;
  --maxw: 640px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand:      #2f9e64;
    --brand-600:  #268a55;
    --brand-700:  #1f7a4d;
    --brand-050:  #16281f;
    --brand-text: #4fbe86;

    --bg:      #0f1613;
    --surface: #16211c;
    --surface-2: #1c2a23;
    --text:    #e8efe9;
    --muted:   #9fb0a7;
    --border:  #26362e;
    --shadow:  0 1px 3px rgba(0, 0, 0, .4);

    --ok-bg:   #14281d;  --ok-fg:   #6fd79c;  --ok-bd: #235a3c;
    --err-bg:  #2c1717;  --err-fg:  #f19a9a;  --err-bd: #5c2a2a;
    --warn-bg: #2b2312;  --warn-fg: #e6c073;  --warn-bd: #5a4820;
    --info-bg: #14202f;  --info-fg: #8db9ef;  --info-bd: #274a70;
  }
}

/* ---------- reset-ish ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
img, video { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 .8em; }
a { color: var(--brand-text); }

/* ---------- layout ---------- */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 16px 40px;
}
.center-screen {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
}
.center { text-align: center; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.sub { font-size: .9rem; font-weight: 400; opacity: .9; }
.section-title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); margin: 22px 4px 8px;
}

/* ---------- topbar / brand ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-in {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
}
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--brand); color: #fff;
  font-weight: 800; font-size: 1.05rem; flex: none;
}
.brand-mark.big { width: 64px; height: 64px; font-size: 2rem; border-radius: 16px; }
.brand-mark.warn { background: var(--warn-fg); }
.brand-name { font-weight: 700; font-size: 1.02rem; }

/* ---------- greeting ---------- */
.greet { margin: 8px 4px 4px; }
.greet h1 { margin-bottom: 2px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 12px 0;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

.t-card { display: flex; flex-direction: column; gap: 8px; }
.t-card .t-title { font-weight: 700; font-size: 1.08rem; }
.t-card .t-desc { color: var(--muted); font-size: .95rem; margin: 0; }
.t-card .t-status { font-size: .85rem; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .78rem; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid transparent;
}
.badge.done  { background: var(--ok-bg);  color: var(--ok-fg);  border-color: var(--ok-bd); }
.badge.todo  { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bd); }
.badge.info  { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-bd); }
.badge.fail  { background: var(--err-bg); color: var(--err-fg); border-color: var(--err-bd); }

/* ---------- buttons ---------- */
.btn {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap);
  padding: 12px 20px;
  font-family: inherit; font-size: 1rem; font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform .05s ease, background .15s ease, opacity .15s ease;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--brand-600); }

.btn-secondary {
  background: var(--surface); color: var(--text); border-color: var(--border);
}
.btn-secondary:not(:disabled):hover { background: var(--surface-2); }

.btn-ghost {
  background: transparent; color: var(--brand-text);
  min-height: 40px; padding: 8px 6px; font-weight: 600;
}

.btn-link {
  background: none; border: none; padding: 0; margin: 0;
  color: var(--brand-text); font: inherit; font-weight: 700;
  text-decoration: underline; cursor: pointer;
}

.back { margin: 4px 0 8px; }

/* ---------- banners ---------- */
.banner {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 10px 0;
  font-size: .95rem;
}
.banner.big { font-size: 1.15rem; font-weight: 700; padding: 20px 16px; }
.banner.success { background: var(--ok-bg);  color: var(--ok-fg);  border-color: var(--ok-bd); }
.banner.error   { background: var(--err-bg); color: var(--err-fg); border-color: var(--err-bd); }
.banner.warn    { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bd); }
.banner.info    { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-bd); }
.banner .btn-link { color: inherit; }

/* ---------- progress ---------- */
.progress {
  width: 100%; height: 12px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}
.progress-bar {
  height: 100%; width: 0%;
  background: var(--brand);
  border-radius: 999px;
  transition: width .4s ease;
}
.progress-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .85rem; color: var(--muted); margin-top: 8px;
}

/* ---------- video ---------- */
.video-wrap {
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  min-height: 200px; /* fallback if aspect-ratio is unsupported */
}
.video-wrap video { width: 100%; height: 100%; object-fit: contain; background: #000; }

/* ---------- quiz ---------- */
.question { margin: 4px 0 18px; }
.q-text { font-weight: 600; margin-bottom: 10px; }
.q-num { color: var(--brand-text); font-weight: 800; }
.options { display: flex; flex-direction: column; gap: 8px; }
.option {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--tap);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
.option:active { background: var(--surface-2); }
.option input {
  width: 22px; height: 22px; flex: none;
  accent-color: var(--brand);
}
.option span { flex: 1; }
.option:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-050);
}

/* ---------- forms (shared with admin) ---------- */
.field { margin: 12px 0; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
input[type=text], input[type=number], input[type=password],
input[type=email], input[type=url], textarea, select {
  width: 100%;
  font-family: inherit; font-size: 1rem;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  min-height: var(--tap);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-050);
}

/* ---------- table (shared with admin) ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.table th, table.table td {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.table th { color: var(--muted); font-weight: 700; font-size: .82rem; text-transform: uppercase; }

/* ---------- loading / spinner ---------- */
.loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 60px 16px; text-align: center;
}
.loading.small { padding: 24px 8px; }
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--surface-2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .progress-bar { transition: none; }
}

/* ---------- landing ---------- */
.landing { text-align: center; padding-top: 48px; }
.landing .brand-mark { margin: 0 auto 18px; }
.landing .lead { font-size: 1.05rem; color: var(--muted); max-width: 40ch; margin: 0 auto 18px; }
.landing .admin-link { display: inline-block; margin-top: 26px; font-size: .85rem; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: .92rem; font-weight: 600;
  max-width: 90vw; text-align: center;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- result ---------- */
.result { display: flex; flex-direction: column; gap: 10px; }

/* ---------- stack util ---------- */
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
