@import './design-tokens.css';
@import './fontes.css';

/* =============================================================================
   Lúmina — painel admin/professor
   Paleta, tipografia e componentes conforme design_handoff_lumina/
   Lumina_Design_Brief.md §1. Sem CSS inline: o CSP do painel não permite
   `unsafe-inline` (ADR-013).
   ============================================================================= */

.editor-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-block: 16px; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; }
.editor-page-number { max-width: 90px; }
.toc-children { padding-left: 16px; border-left: 2px solid #e5e7eb; }
#overlay-form details { margin-block: 16px; }
#overlay-form summary { cursor: pointer; }
#selection-page { font-weight: 600; }
.pdf-authoring-stage { position: relative; }
.pdf-authoring-stage canvas { display: block; width: 100%; }
#pdf-regions { position: absolute; inset: 0; height: 100%; touch-action: none; cursor: crosshair; }
.editor-coordinates { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.object-preview { width: min(1000px, 95vw); max-height: 95vh; border: 1px solid #d1d5db; border-radius: 12px; padding: 24px; }
.object-preview::backdrop { background: rgb(17 24 39 / 65%); }
.object-preview iframe { display: block; border: 0; width: 100%; height: 70vh; margin-top: 16px; }
.card + .card { margin-top: 20px; }
.card form + form { margin-top: 16px; }
[hidden] { display: none !important; }
@media (max-width: 900px) { .editor-grid { grid-template-columns: 1fr; } }

:root {
  /* Primárias — vermelho SÓ em ação e destaque (regra do brief §1.2) */
  --booknando-red: #b91c1c;
  --red-dark: #7f1d1d;
  --red-hover: #991b1b;
  --red-light: #fee2e2;
  --red-pale: #fef2f2;

  /* Neutros */
  --near-black: #111827;
  --dark-gray: #374151;
  --mid-gray: #6b7280;
  --light-gray: #d1d5db;
  --border: #e5e7eb;
  --surface: #f3f4f6;
  --off-white: #f9fafb;
  --white: #fff;
  --placeholder: #9ca3af;

  /* Semânticas — erro usa WARNING, nunca vermelho (brief §1.2) */
  --success: #166534;
  --success-light: #dcfce7;
  --warning: #92400e;
  --warning-light: #fef3c7;
  --info: #1e40af;
  --info-light: #dbeafe;

  --radius: 6px;
  --radius-card: 8px;
  --shadow-card: 0 1px 3px rgb(0 0 0 / 8%);
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --max-w: 1360px;

  --font-display: "Playfair Display", Georgia, serif;
  --font-ui: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--near-black);
  background: var(--off-white);
}

h1, h2, h3 { margin: 0; }

a { color: var(--booknando-red); }

/* Foco sempre visível — navegação por teclado é requisito de acessibilidade */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--booknando-red);
  outline-offset: 2px;
}

/* ============================== layout ==================================== */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--near-black);
  color: var(--white);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
}

.brand { padding: 0 8px 24px; }
.brand-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--white);
}
.brand-by { display: block; font-size: 11px; color: var(--mid-gray); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mid-gray);
  padding: 16px 8px 6px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: #9ca3af;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.nav-link:hover { background: rgb(255 255 255 / 8%); color: var(--white); }
.nav-link[aria-current="page"] { background: var(--booknando-red); color: var(--white); }
.nav-link--sub { padding-left: 30px; font-size: 13px; }
.nav-icon { width: 18px; height: 18px; flex: 0 0 18px; }

.sidebar-footer { padding-top: 16px; border-top: 1px solid rgb(255 255 255 / 10%); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
}
.topbar h1 { font-family: var(--font-display); font-size: 24px; font-weight: 700; }
.topbar-meta { font-size: 13px; color: var(--mid-gray); }
.topbar-spacer { flex: 1; }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--booknando-red);
  color: var(--white);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}

.content { padding: 24px; max-width: var(--max-w); width: 100%; }

.breadcrumb { font-size: 14px; color: var(--mid-gray); margin-bottom: 4px; }
.breadcrumb a { color: var(--mid-gray); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb strong { color: var(--near-black); }

/* ============================== abas ====================================== */

.tabs {
  display: flex;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 2px;
  font-size: 14px;
  font-weight: 500;
  color: var(--mid-gray);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--dark-gray); }
.tab[aria-current="page"] { color: var(--booknando-red); border-bottom-color: var(--booknando-red); }

/* ============================== botões ==================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn--primary { background: var(--booknando-red); color: var(--white); }
.btn--primary:hover { background: var(--red-hover); }
.btn--secondary {
  background: var(--white);
  border: 1.5px solid var(--booknando-red);
  color: var(--booknando-red);
}
.btn--secondary:hover { background: var(--red-pale); }
.btn--ghost { background: transparent; color: var(--dark-gray); }
.btn--ghost:hover { background: var(--surface); }
.btn--danger { background: var(--red-dark); color: var(--white); }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn--link {
  background: none; border: none; padding: 0; height: auto;
  color: var(--booknando-red); font-weight: 600; font-size: 13px;
}
.btn--link:hover { text-decoration: underline; }
.inline-actions { display: inline; }
.btn:disabled, .btn[aria-disabled="true"] {
  background: var(--light-gray);
  border-color: var(--light-gray);
  color: var(--placeholder);
  cursor: not-allowed;
}

/* ============================== formulários =============================== */

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 14px; font-weight: 500; color: var(--dark-gray); }
.field .req { color: var(--booknando-red); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-hint { font-size: 12px; color: var(--mid-gray); }

.input, .select {
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  background: var(--white);
  color: var(--near-black);
  width: 100%;
}
.input::placeholder { color: var(--placeholder); }
.input:focus, .select:focus {
  border: 2px solid var(--booknando-red);
  box-shadow: 0 0 0 3px rgb(185 28 28 / 12%);
  outline: none;
}
.input--search { padding-left: 34px; }

.search-wrap { position: relative; flex: 1; }
.search-wrap .nav-icon {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--placeholder);
  pointer-events: none;
}

.radio-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.radio-row label { font-size: 14px; color: var(--dark-gray); font-weight: 400; }

/* Alternância "imediato × agendado" em CSS PURO (modal P-03).
   Por que não Alpine `x-show`: ele aplica `style="display:none"` inline, e o CSP
   do painel bloqueia atributo style (ADR-013). Assim também funciona antes de
   qualquer JS carregar. */
.quando {
  border: none;
  margin: 0 0 4px;
  padding: 0;
  display: grid;
  /* Radio + label na mesma linha, sem wrapper: o `~` precisa de irmãos. */
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px 8px;
}
.quando legend { display: none; }
.quando .radio-label { font-size: 14px; color: var(--dark-gray); }
.campos-agendamento { display: none; grid-column: 1 / -1; margin-top: 8px; }
#modo-agendado:checked ~ .campos-agendamento { display: grid; }

/* Mensagem de erro usa WARNING, não vermelho (brief §1.2) */
.form-error {
  background: var(--warning-light);
  color: var(--warning);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ============================== cards ===================================== */

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 24px;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}
.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mid-gray);
  font-weight: 600;
  margin-bottom: 12px;
}

.turma-card h3 { font-size: 16px; font-weight: 600; }
.turma-card .turma-alunos { font-size: 13px; color: var(--mid-gray); margin: 2px 0 16px; }

.progress-label {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--mid-gray); margin-bottom: 4px;
}
.progress-label strong { color: var(--near-black); font-size: 12px; }
.progress {
  height: 6px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar { height: 100%; background: var(--booknando-red); border-radius: 999px; width: 0; }

/* Largura da barra por CLASSE, em passos de 5%: o CSP do painel não permite
   `unsafe-inline`, o que inclui atributo `style` (nonce cobre <style>, não
   atributo). */
.progress-bar--w0 { width: 0%; }
.progress-bar--w5 { width: 5%; }
.progress-bar--w10 { width: 10%; }
.progress-bar--w15 { width: 15%; }
.progress-bar--w20 { width: 20%; }
.progress-bar--w25 { width: 25%; }
.progress-bar--w30 { width: 30%; }
.progress-bar--w35 { width: 35%; }
.progress-bar--w40 { width: 40%; }
.progress-bar--w45 { width: 45%; }
.progress-bar--w50 { width: 50%; }
.progress-bar--w55 { width: 55%; }
.progress-bar--w60 { width: 60%; }
.progress-bar--w65 { width: 65%; }
.progress-bar--w70 { width: 70%; }
.progress-bar--w75 { width: 75%; }
.progress-bar--w80 { width: 80%; }
.progress-bar--w85 { width: 85%; }
.progress-bar--w90 { width: 90%; }
.progress-bar--w95 { width: 95%; }
.progress-bar--w100 { width: 100%; }

/* ============================== tabelas =================================== */

.table-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--off-white);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mid-gray);
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:nth-child(odd) { background: var(--off-white); }
tbody tr:hover { background: var(--red-pale); }
tbody tr:last-child td { border-bottom: none; }
.col-right { text-align: right; }
.cell-mono { font-family: var(--font-mono); font-size: 13px; color: var(--mid-gray); }
.cell-title { font-weight: 500; }
.table-empty { padding: 32px 16px; text-align: center; color: var(--mid-gray); }

/* ============================== badges ==================================== */

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 8px;
  white-space: nowrap;
}
.badge--ativo, .badge--liberado, .badge--active, .badge--published { background: var(--success-light); color: var(--success); }
.badge--inativo, .badge--pendente, .badge--programado, .badge--scheduled { background: var(--warning-light); color: var(--warning); }
.badge--rascunho, .badge--bloqueado, .badge--blocked, .badge--draft, .badge--archived { background: var(--surface); color: var(--mid-gray); }
.badge--erro, .badge--suspended, .badge--expired { background: var(--red-light); color: var(--booknando-red); }
.badge--trial { background: var(--info-light); color: var(--info); }

/* ============================== avisos ==================================== */

.alert {
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}
.alert--warning { background: var(--warning-light); color: var(--warning); }
.alert--success { background: var(--success-light); color: var(--success); }
.alert--info { background: var(--info-light); color: var(--info); }
.alert-spacer { flex: 1; }
.alert code { font-family: var(--font-mono); font-size: 12px; }

.texto-alerta { color: var(--warning); font-weight: 500; }

/* ============================== filtros =================================== */

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-select {
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  background: var(--white);
  font-family: inherit;
  font-size: 13px;
  color: var(--dark-gray);
}

/* ============================== modal ===================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(17 24 39 / 45%);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
}
.modal {
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: 0 10px 40px rgb(0 0 0 / 20%);
  width: 100%;
  max-width: 420px;
  padding: 24px;
}
.modal-header { display: flex; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 16px; font-weight: 600; flex: 1; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--mid-gray); padding: 4px; line-height: 0;
}
.modal-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 20px; }

/* ============================== importação ================================ */

.import-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.step { display: flex; gap: 12px; margin-bottom: 20px; }
.step-num {
  width: 24px; height: 24px; flex: 0 0 24px;
  border-radius: 50%;
  background: var(--booknando-red);
  color: var(--white);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.step-body { flex: 1; }
.step-body p { margin: 2px 0 10px; font-weight: 500; }
.dropzone {
  border: 1.5px dashed var(--light-gray);
  border-radius: var(--radius-card);
  padding: 28px;
  text-align: center;
  color: var(--mid-gray);
  display: grid;
  gap: 10px;
  justify-items: center;
}
.dropzone input[type="file"] { font-family: inherit; font-size: 13px; }

/* ============================== login ===================================== */

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { text-align: center; padding-bottom: 20px; }
.login-card .brand-name { color: var(--booknando-red); font-size: 32px; }

/* ============================== HTMX ====================================== */

/* Indicador de carregamento: HTMX liga `.htmx-request` no elemento */
.htmx-indicator { opacity: 0; transition: opacity 120ms ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-request .btn-label { opacity: 0.6; }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgb(255 255 255 / 40%);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
.spinner--dark { border-color: rgb(0 0 0 / 20%); border-top-color: var(--booknando-red); }

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ============================== responsivo ================================ */

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; flex-direction: row; align-items: center; gap: 8px; overflow-x: auto; padding: 12px; }
  .sidebar .nav { flex-direction: row; }
  .nav-group-label, .sidebar-footer { display: none; }
  .import-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Autoria e acompanhamento de avaliações. */
.assessment-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.assessment-filters select { width: auto; max-width: 100%; }
.assessment-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.assessment-metrics strong { font-size: 2rem; }
.assessment-metrics .card { margin: 0; }
.assessment-table { overflow-x: auto; }
.assessment-choice { display: flex; align-items: start; gap: 12px; padding: 16px 8px; }
.assessment-choice input { margin-top: 5px; }
.assessment-question-stat { padding: 12px 0; border-bottom: 1px solid #e5e7eb; }
.assessment-question-stat meter { width: min(320px, 100%); height: 24px; }

/* Dados de acesso entregues com a senha temporária e links de login. */
.acesso { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0; }
.acesso dt { font-weight: 600; }
.acesso dd { margin: 0; overflow-wrap: anywhere; }
.link-acesso { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; overflow-wrap: anywhere; }
