/* Plataforma de Formações */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1d2939;
  --muted: #667085;
  --border: #e4e7ec;
  --primary: #1f5eff;
  --primary-dark: #1546c7;
  --dark: #101828;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --erro: #b42318;
  --erro-bg: #fef3f2;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --info: #175cd3;
  --info-bg: #eff8ff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, video, iframe { max-width: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; color: var(--dark); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.container.narrow { max-width: 560px; }
.main { flex: 1; padding-bottom: 48px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; font-weight: 600; color: var(--primary); margin: 0 0 .25em; }
.empty { color: var(--muted); padding: 24px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); text-align: center; }
.prose { overflow-wrap: anywhere; }

/* Topo */
.topbar { background: var(--dark); color: #fff; position: sticky; top: 0; z-index: 50; }
.topbar-inner { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.brand { color: #fff; font-weight: 700; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); display: grid; place-items: center; }
.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav a { color: #d0d5dd; padding: 8px 10px; border-radius: 6px; font-size: .92rem; }
.nav a:hover, .nav a.active { color: #fff; background: rgba(255, 255, 255, .08); text-decoration: none; }
.nav .btn { color: #fff; }
.nav-sep { width: 1px; height: 22px; background: rgba(255, 255, 255, .15); margin: 0 6px; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; color: #fff; font-size: 1.5rem; cursor: pointer; }

@media (max-width: 900px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 60px; background: var(--dark); flex-direction: column; align-items: stretch; padding: 8px 16px 16px; }
  .nav.open { display: flex; }
  .nav-sep { display: none; }
}

.footer { padding: 24px 0; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); background: var(--surface); }

/* Hero */
.hero { background: linear-gradient(135deg, #101828 0%, #1f3a8a 100%); color: #fff; padding: 48px 0 40px; margin-bottom: 32px; }
.hero h1 { color: #fff; font-size: 2.1rem; }
.hero p { color: #d0d5dd; }
.search { display: flex; gap: 8px; max-width: 560px; }
.search input { flex: 1; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--primary); color: #fff; border: 1px solid var(--primary);
  padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: #f2f4f7; }
.nav .btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .3); }
.btn-danger { background: var(--surface); color: var(--erro); border-color: #fda29b; }
.btn-danger:hover { background: var(--erro-bg); }
.btn-light { background: #fff; color: var(--dark); border-color: #fff; }
.btn-light:hover { background: #eaecf0; }
.btn-outline-light { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .5); }
.btn-outline-light:hover { background: rgba(255, 255, 255, .1); }
.btn-sm { padding: 6px 12px; font-size: .88rem; }
.btn-xs { padding: 4px 8px; font-size: .8rem; font-weight: 500; }
.btn-lg { padding: 12px 20px; font-size: 1rem; }
.btn-block { width: 100%; margin-bottom: 8px; }

/* Cartões */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin-bottom: 32px; }
.cards-sm { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card-formacao { padding: 0; display: flex; flex-direction: column; overflow: hidden; margin: 0; }
.card-formacao .card-media { display: block; }
.card-formacao .card-body { padding: 16px 18px 8px; flex: 1; }
.card-formacao h3 a { color: var(--dark); }
.card-actions { display: flex; align-items: center; gap: 8px; padding: 12px 18px 16px; flex-wrap: wrap; }
.card-actions form { margin: 0; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: .85rem; margin-bottom: 8px; }
.section-title { margin: 32px 0 16px; }

/* Media 16:9 */
.media-16-9 { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0b1220; overflow: hidden; }
@supports not (aspect-ratio: 1) {
  .media-16-9 { height: 0; padding-top: 56.25%; }
}
.media-16-9 > img, .media-16-9 > video, .media-16-9 > iframe, .media-16-9 > .media-placeholder {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: cover; display: block;
}
.media-16-9 > video { object-fit: contain; background: #000; }
.media-placeholder { display: grid; place-items: center; background: linear-gradient(135deg, #1f3a8a, #1f5eff); }
.media-placeholder span { color: rgba(255, 255, 255, .85); font-size: 3rem; font-weight: 700; }

/* Página da formação */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 20px 0 0; }
.formacao-header { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 24px; margin: 20px 0 24px; align-items: start; }
.formacao-media .media-16-9 { border-radius: var(--radius); box-shadow: var(--shadow); }
.formacao-info { margin: 0; }
.formacao-info h1 { font-size: 1.5rem; }
.info-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 16px 0 20px; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; font-weight: 500; }
.formacao-body { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 24px; }
.formador-card { display: flex; gap: 16px; align-items: flex-start; }
@media (max-width: 860px) {
  .formacao-header, .formacao-body { grid-template-columns: 1fr; }
  .formador-card { flex-direction: column; }
}

/* Avatares */
.avatar { border-radius: 50%; overflow: hidden; background: #dbe4ff; color: var(--primary-dark); display: inline-grid; place-items: center; flex-shrink: 0; font-weight: 700; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 26px; height: 26px; font-size: .75rem; }
.avatar-lg { width: 96px; height: 96px; font-size: 2rem; }
.avatar-xl { width: 110px; height: 110px; font-size: 2.4rem; }
.formador-mini { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--muted); }
.formador-tile { text-align: center; display: flex; flex-direction: column; align-items: center; margin: 0; }
.formador-tile .avatar { margin-bottom: 12px; }
.profile-banner { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin-top: 24px; }

/* Galeria */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-bottom: 32px; }
.gallery a { display: block; aspect-ratio: 1; overflow: hidden; border-radius: 8px; background: #eaecf0; }
.gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.gallery a:hover img { transform: scale(1.04); }
.gallery-admin figure { margin: 0; position: relative; }
.gallery-admin form { position: absolute; top: 6px; right: 6px; margin: 0; }

.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .9); z-index: 100; display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 6px; }
.lightbox button { position: absolute; background: rgba(255, 255, 255, .12); color: #fff; border: 0; cursor: pointer; font-size: 2rem; width: 48px; height: 48px; border-radius: 50%; line-height: 1; }
.lightbox button:hover { background: rgba(255, 255, 255, .25); }
.lightbox-close { top: 16px; right: 16px; }
.lightbox-nav.prev { left: 16px; }
.lightbox-nav.next { right: 16px; }

/* Formulários */
.form label, label { display: block; font-weight: 500; margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=search], input[type=datetime-local], input[type=file], select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 9px 12px; font: inherit; color: var(--text);
  background: #fff; border: 1px solid #d0d5dd; border-radius: 8px;
}
input[type=file] { padding: 7px; background: #f9fafb; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31, 94, 255, .25); border-color: var(--primary); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.check input { margin: 0; }
.hint { color: var(--muted); font-size: .82rem; margin: -8px 0 14px; display: block; font-weight: 400; }
label .hint { margin: 4px 0 0; }
.field-error { color: var(--erro); font-size: .85rem; margin: 6px 0 0; font-weight: 500; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; }
.fieldset legend { font-weight: 600; padding: 0 6px; }
.radio-row { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.foto-perfil-field { display: flex; gap: 20px; align-items: flex-start; }
@media (max-width: 520px) { .foto-perfil-field { flex-direction: column; } }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { flex: 1; min-width: 220px; margin: 0; }
form.inline { display: inline; margin: 0; }
.media-preview { margin-bottom: 14px; border-radius: var(--radius); overflow: hidden; }
.edit-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .edit-layout { grid-template-columns: 1fr; } }

.auth-card { margin-top: 40px; }
.auth-links { text-align: center; margin: 12px 0 0; font-size: .9rem; }

/* Cabeçalhos de página */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin: 28px 0 20px; }
.page-head h1 { margin: 0; }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--primary); border-color: var(--primary); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input, .filters select { width: auto; margin: 0; flex: 1; min-width: 160px; }
.admin-nav { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.admin-nav a { background: var(--surface); border: 1px solid var(--border); padding: 10px 16px; border-radius: 8px; color: var(--text); font-weight: 500; }
.admin-nav a:hover { border-color: var(--primary); text-decoration: none; }

/* Estatísticas */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 20px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; color: var(--muted); font-size: .88rem; }
.stat span { display: block; font-size: 1.8rem; font-weight: 700; color: var(--dark); line-height: 1.2; }

/* Tabelas */
.table-wrap { overflow-x: auto; padding: 0; }
.table-wrap.card { padding: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f9fafb; }
.table tr:last-child td { border-bottom: 0; }
.table select { margin: 0; min-width: 120px; padding: 6px 8px; }
.table-compact td { padding: 8px 6px; }
.actions { white-space: nowrap; }
.actions form { display: inline; margin: 0; }
.row-muted { opacity: .55; }

/* Lista do aluno */
.list-item { display: flex; gap: 16px; align-items: center; padding: 14px; flex-wrap: wrap; }
.list-thumb { width: 132px; flex-shrink: 0; border-radius: 8px; overflow: hidden; }
.list-item h3 { margin-bottom: 4px; }
.list-item .meta { margin-bottom: 2px; }
.list-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.list-actions form { margin: 0; }
@media (max-width: 560px) { .list-thumb { width: 100%; } .list-actions { align-items: flex-start; } }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border: 0; }

/* Alertas e badges */
.alert { padding: 12px 16px; border-radius: 8px; margin: 16px 0; border: 1px solid; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: #abefc6; }
.alert-erro { background: var(--erro-bg); color: var(--erro); border-color: #fecdca; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #b2ddff; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-erro { background: var(--erro-bg); color: var(--erro); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-muted { background: #f2f4f7; color: #475467; }

/* Utilitários */
.mt { margin-top: 20px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-between form { margin: 0; }
.container.narrow-lg { max-width: 820px; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #05603a; }
input.readonly, input[readonly] { background: #f2f4f7; color: var(--muted); }
code { background: #f2f4f7; padding: 1px 6px; border-radius: 4px; font-size: .88em; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; z-index: 5; border-top: 1px solid var(--border); }

/* Convite de formador */
.convite-formador { background: #f9fafb; border: 1px dashed var(--border); border-radius: 8px; padding: 12px; margin-bottom: 8px; }
.convite-formador input { margin: 0 0 8px; }
.convite-formador p { margin-top: 0; }

/* Código / QR */
.codigo-card { text-align: center; }
.codigo-grande { font: 700 2rem/1.2 ui-monospace, Consolas, monospace; letter-spacing: .2em; color: var(--dark); margin: 4px 0 12px; }
.qr { display: inline-block; padding: 10px; background: #fff; border-radius: 8px; }
.qr img, .qr canvas { display: block; }
.qr-screen { align-items: center; justify-content: center; text-align: center; padding: 24px; background: #fff; }
.qr-screen .codigo-grande { font-size: 4rem; margin-top: 16px; }
.input-codigo { text-transform: uppercase; letter-spacing: .2em; font-family: ui-monospace, Consolas, monospace; max-width: 200px; }

.aviso-cert { padding: 10px 14px; border-radius: 8px; background: #f2f4f7; color: #475467; margin-bottom: 14px; font-size: .92rem; }
.aviso-cert.ok { background: var(--ok-bg); color: var(--ok); }

/* Passos do aluno */
.passos { list-style: none; margin: 0; padding: 0; counter-reset: passo; }
.passo { position: relative; padding: 0 0 20px 44px; counter-increment: passo; }
.passo::before { content: counter(passo); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: #eaecf0; color: var(--muted); }
.passo:not(:last-child)::after { content: ''; position: absolute; left: 14px; top: 34px; bottom: 4px; width: 2px; background: var(--border); }
.passo.feito::before { content: '✓'; background: var(--ok); color: #fff; }
.passo.atual::before { background: var(--primary); color: #fff; }
.passo.bloqueado { opacity: .6; }
.passo-titulo { font-weight: 600; margin: 4px 0 6px; }
.passo .inline-form { margin-bottom: 6px; }

/* Questionários */
.pergunta { margin-bottom: 14px; }
.pergunta legend { font-weight: 600; padding: 0; margin-bottom: 10px; float: left; width: 100%; }
.pergunta legend + * { clear: both; }
.pergunta-n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; font-size: .8rem; margin-right: 6px; }
.req { color: var(--erro); }
.opcao { padding: 6px 0; margin: 0; }
.estrelas { display: inline-flex; flex-direction: row-reverse; gap: 4px; }
.estrelas input { position: absolute; opacity: 0; pointer-events: none; }
.estrelas label { font-size: 2rem; color: #d0d5dd; cursor: pointer; margin: 0; line-height: 1; }
.estrelas input:checked ~ label, .estrelas label:hover, .estrelas label:hover ~ label { color: #f5a524; }
.estrelas input:focus-visible + label { outline: 2px solid var(--primary); }
.estrelas-media { color: #f5a524; font-size: 1.1rem; }
.builder-pergunta { border-left: 3px solid var(--primary); }
.builder-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.builder-tools { display: flex; gap: 4px; }
.builder-obrig { margin-top: 30px; }
.builder-opcoes { background: #f9fafb; border-radius: 8px; padding: 10px 12px; }
.builder-opcao { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.builder-opcao input[type=text] { margin: 0; flex: 1; }
.builder-opcao .check { margin: 0; white-space: nowrap; font-size: .85rem; }
.opcao-valor { width: 80px !important; margin: 0 !important; }
.builder-add { margin-bottom: 20px; }
.resposta-item { border-bottom: 1px solid var(--border); padding: 12px 0; }
.resposta-item p { margin-bottom: 6px; }
.resposta-texto { background: #f9fafb; padding: 8px 12px; border-radius: 6px; margin-bottom: 8px; }
.inline-nota { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; }
.inline-nota input { width: 100px; margin: 0; }
.inline-nota input.pendente { border-color: var(--warn); background: var(--warn-bg); }
.barra { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr auto; gap: 10px; align-items: center; margin: 4px 0; font-size: .9rem; }
.barra-track { background: #eaecf0; border-radius: 99px; height: 10px; overflow: hidden; }
.barra-track span { display: block; height: 100%; background: var(--primary); }

/* Certificado */
.cert-page { position: relative; container-type: inline-size; border: 1px solid var(--border); margin: 12px 0; line-height: 0; }
.cert-page img, .cert-page canvas { width: 100%; height: auto; display: block; }
.cert-box { position: absolute; border: 2px solid var(--primary); background: rgba(31, 94, 255, .12); color: var(--primary); font: 600 11px/1.2 system-ui, sans-serif; padding: 1px 3px; overflow: hidden; white-space: nowrap; }
.cert-box.desconhecida, .cert-tag.desconhecida { border-color: var(--erro); color: var(--erro); background: rgba(180, 35, 24, .1); }
.cert-tag { position: absolute; line-height: 1.1; white-space: nowrap; font-family: Helvetica, Arial, sans-serif; outline: 1px dashed rgba(31, 94, 255, .6); }
.cert-tag-center { transform: translateX(-50%); }
.cert-tag-right { transform: translateX(-100%); }
