/* ==========================================================================
   Plataforma Hugo — Área do aluno
   Tema escuro imersivo, estilo área de membros premium.
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg: #0c0d11;
  --surface: #15171e;
  --surface-2: #1c1f28;
  --border: #262a36;
  --border-strong: #333849;
  --ink: #f1f3f8;
  --muted: #9aa2b5;
  --faint: #6b7284;

  /* Acento harmonizado com a paleta nova do painel (css/tokens.css) */
  --primary: oklch(0.585 0.215 277);
  --primary-bright: oklch(0.72 0.15 277);
  --primary-strong: oklch(0.52 0.24 277);
  --success: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;

  --radius: 14px;
  --radius-sm: 9px;
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14.5px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary-bright); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.015em; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- primitivas ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 570;
  font-size: 13.5px;
  white-space: nowrap;
  text-decoration: none !important;
  transition: background 0.15s, border-color 0.15s, transform 0.06s;
}
.btn:active { transform: translateY(1px); }
.btn.lg { padding: 13px 18px; font-size: 14.5px; border-radius: 11px; }
.btn.sm { padding: 7px 12px; font-size: 12.5px; }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 4px 18px rgba(99, 102, 241, 0.35); }
.btn.primary:hover { background: var(--primary-strong); }
.btn.ghost { background: var(--surface-2); color: var(--ink); border-color: var(--border-strong); }
.btn.ghost:hover { background: #232734; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 550; color: var(--muted); }
.field input, textarea.input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, textarea.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2); }
.field input::placeholder, textarea.input::placeholder { color: var(--faint); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 620;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.badge.green { background: rgba(52, 211, 153, 0.12); color: var(--success); border-color: transparent; }
.badge.indigo { background: rgba(129, 140, 248, 0.14); color: var(--primary-bright); border-color: transparent; }

.toast {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  max-width: 400px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #f1f3f8;
  color: #14161c;
  font-size: 13.5px;
  font-weight: 550;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 0.2s;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- login ---------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(720px 420px at 20% -5%, rgba(99, 102, 241, 0.22), transparent 60%),
    radial-gradient(600px 380px at 90% 10%, rgba(139, 92, 246, 0.12), transparent 55%),
    var(--bg);
}
.login-card {
  width: min(420px, 100%);
  padding: 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}
.login-eyebrow { margin: 18px 0 4px; color: var(--primary-bright); font-size: 12px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; }
.login-card h1 { font-size: 26px; }
.login-sub { margin-top: 6px; color: var(--muted); }
.login-form { display: grid; gap: 14px; margin: 24px 0 4px; }
.login-alt { display: inline-block; margin-top: 16px; font-weight: 550; font-size: 13.5px; }
.brand-mark {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4);
}
.brand-mark .icon { width: 24px; height: 24px; }
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; }
.brand-mark.small .icon { width: 20px; height: 20px; }

/* ---------- estrutura ---------- */
.student-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 66px;
  padding: 0 max(20px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(12, 13, 17, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; }
.sidebar-brand strong { display: block; font-size: 15px; }
.sidebar-brand span { display: block; font-size: 11.5px; color: var(--muted); }
.header-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), oklch(0.72 0.16 300));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}
.user-name { font-size: 13.5px; font-weight: 550; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Perfil (Fase 4): a foto no topo é um botão de trocar imagem. */
.avatar-button { position: relative; border: 0; padding: 0; background: none; cursor: pointer; flex: none; border-radius: 50%; }
.avatar.has-photo { background-size: cover; background-position: center; }
.avatar-camera {
  position: absolute; right: -3px; bottom: -3px;
  width: 16px; height: 16px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface-2, #1b1d26);
  border: 1px solid var(--border);
  color: var(--muted);
}
.avatar-camera .icon { width: 9px; height: 9px; }
.avatar-button:hover .avatar-camera { color: var(--primary-bright); }
.avatar-img { object-fit: cover; width: 32px; height: 32px; border-radius: 50%; flex: none; }
.avatar.sm, .avatar-img.sm { width: 26px; height: 26px; font-size: 11px; }
.student-main { width: min(1180px, calc(100% - 40px)); margin: 36px auto 80px; }

/* ---------- biblioteca ---------- */
#library h1 { font-size: clamp(26px, 4vw, 34px); }
.library-sub { margin: 6px 0 26px; color: var(--muted); }
.course-library { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.course-tile {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.course-tile:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45); }
.course-cover {
  position: relative;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.course-cover .cover-initials { font-size: 44px; font-weight: 760; color: rgba(255, 255, 255, 0.92); letter-spacing: -0.02em; }
.course-cover .play-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 11, 15, 0.35);
  opacity: 0;
  transition: opacity 0.18s;
}
.course-tile:hover .play-hint { opacity: 1; }
.play-hint i {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #14161c;
}
.play-hint .icon { width: 22px; height: 22px; margin-left: 3px; }
.course-body { display: flex; flex-direction: column; gap: 10px; flex: 1; padding: 18px; }
.course-body h2 { font-size: 17px; }
.course-body .desc { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.course-progress { display: grid; gap: 7px; margin-top: auto; padding-top: 6px; }
.progress-track { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), #a78bfa); }
.course-progress small { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.course-footer { padding: 0 18px 18px; }
.course-footer .btn { width: 100%; }
.course-library .empty { grid-column: 1 / -1; }
.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 56px 24px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  text-align: center;
  color: var(--muted);
}
.empty strong { color: var(--ink); font-size: 15px; }

/* ---------- sala do curso ---------- */
.room-topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.room-topbar .back { display: inline-flex; align-items: center; gap: 8px; padding: 8px 13px; border: 1px solid var(--border-strong); border-radius: 99px; background: var(--surface); color: var(--muted); font-weight: 550; font-size: 13px; }
.room-topbar .back:hover { color: var(--ink); background: var(--surface-2); }
.room-topbar h1 { font-size: clamp(19px, 3vw, 24px); flex: 1; min-width: 200px; }
.room-progress { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.room-progress .progress-track { width: 130px; }

.room-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }

/* player e conteúdo da aula */
.lesson-stage { display: grid; gap: 20px; min-width: 0; }
.player-shell { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; border: 1px solid var(--border); }
.lesson-player { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.player-message {
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background: linear-gradient(135deg, #14161e, #1a1626);
  color: var(--muted);
}
.lesson-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.lesson-head-info { display: grid; gap: 5px; min-width: 0; }
.lesson-head-info .lesson-module { color: var(--primary-bright); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.lesson-head h2 { font-size: 21px; }
.lesson-head-info .desc { color: var(--muted); }
.complete-lesson { flex: none; }
.complete-lesson.done { background: rgba(52, 211, 153, 0.12); color: var(--success); border-color: transparent; box-shadow: none; }
.lesson-nav { display: flex; justify-content: space-between; gap: 10px; }
.lesson-body-text { color: #c9cede; white-space: pre-wrap; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.lesson-extras { display: flex; flex-wrap: wrap; gap: 10px; }
.material-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 550;
  text-decoration: none !important;
}
.material-btn:hover { background: var(--surface-2); }
.material-btn .icon { color: var(--primary-bright); width: 16px; height: 16px; }

/* certificado */
.certificate-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: linear-gradient(120deg, rgba(99, 102, 241, 0.18), rgba(139, 92, 246, 0.12));
  border: 1px solid rgba(129, 140, 248, 0.35);
}
.certificate-panel .cert-info { display: flex; align-items: center; gap: 14px; }
.certificate-panel .cert-info .icon { width: 26px; height: 26px; color: var(--primary-bright); }
.certificate-panel strong { display: block; }
.certificate-panel p { color: var(--muted); font-size: 13px; }

/* comentários */
.lesson-comments { display: grid; gap: 14px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.lesson-comments h3 { font-size: 16px; }
.comment-form { display: grid; gap: 10px; }
.comment-form textarea { min-height: 84px; resize: vertical; }
.comment-form .btn { justify-self: end; }
.comment-list { display: grid; gap: 10px; }
.student-comment { display: grid; gap: 10px; padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.student-comment header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.student-comment header strong { font-size: 13.5px; }
.student-comment header small { color: var(--faint); font-size: 12px; }
.student-comment p { color: #c9cede; white-space: pre-wrap; font-size: 13.5px; }
/* Fase 4: fio da conversa — avatar, resposta aninhada e coração do autor. */
.comment-main { display: flex; align-items: flex-start; gap: 10px; }
.comment-main-body { display: grid; gap: 5px; min-width: 0; }
.author-badge {
  padding: 1.5px 8px;
  border-radius: 99px;
  background: rgba(129, 140, 248, 0.14);
  color: var(--primary-bright);
  font-size: 11px;
  font-weight: 700;
}
.author-like { display: inline-flex; align-items: center; gap: 6px; margin-top: 2px; color: #f472b6; font-size: 12px; font-weight: 600; }
.author-like .icon { width: 13px; height: 13px; fill: currentColor; }
.comment-replies { display: grid; gap: 10px; margin-left: 20px; padding-left: 14px; border-left: 2px solid var(--border); }
.comment-reply { display: flex; align-items: flex-start; gap: 9px; }
.comment-reply-body { display: grid; gap: 4px; min-width: 0; }
.comment-reply-body p { color: #c9cede; white-space: pre-wrap; font-size: 13px; }

/* currículo lateral */
.curriculum {
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 106px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.curriculum-head { padding: 15px 17px; border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.module-group { border-bottom: 1px solid var(--border); }
.module-group:last-child { border-bottom: 0; }
.module-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 17px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 600;
  font-size: 13.5px;
}
.module-toggle:hover { background: var(--surface-2); }
.module-toggle .module-meta { display: block; color: var(--faint); font-size: 11.5px; font-weight: 500; }
.module-toggle > div { flex: 1; min-width: 0; }
.module-toggle .chev { transition: transform 0.18s; color: var(--faint); }
.module-group.open .module-toggle .chev { transform: rotate(180deg); }
.module-group.locked .module-toggle { color: var(--faint); cursor: default; }
.locked-note { padding: 0 17px 13px 17px; color: var(--faint); font-size: 12.5px; }
.module-lessons { display: none; padding: 2px 8px 10px; }
.module-group.open .module-lessons { display: grid; gap: 2px; }
.lesson-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-size: 13px;
  transition: background 0.12s, color 0.12s;
}
.lesson-button:hover { background: var(--surface-2); color: var(--ink); }
.lesson-button.active { background: rgba(99, 102, 241, 0.15); color: var(--ink); }
.lesson-button.active .lesson-state { color: var(--primary-bright); }
.lesson-state {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  color: var(--faint);
  flex: none;
}
.lesson-state .icon { width: 12px; height: 12px; }
.lesson-button.done .lesson-state { background: var(--success); border-color: var(--success); color: #0c221a; }
.lesson-button span.title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- responsivo ---------- */
@media (max-width: 960px) {
  .room-layout { grid-template-columns: 1fr; }
  .curriculum { position: static; max-height: none; order: 2; }
  .lesson-stage { order: 1; }
}
@media (max-width: 620px) {
  .student-header { padding: 0 16px; }
  .student-main { width: calc(100% - 28px); margin-top: 24px; }
  .user-name { display: none; }
  .room-topbar h1 { min-width: 0; width: 100%; order: 3; }
  .room-progress { width: 100%; justify-content: space-between; order: 4; }
  .room-progress .progress-track { flex: 1; width: auto; }
  .lesson-head { flex-direction: column; }
  .complete-lesson { width: 100%; }
  .certificate-panel { flex-direction: column; align-items: stretch; text-align: center; }
  .certificate-panel .cert-info { flex-direction: column; }
  .login-card { padding: 28px 22px; }
}

/* Primeiro acesso por link */
.login-hint { margin: -4px 0 2px; font-size: 12px; color: var(--muted); }
