/* ── Reset & Variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Paleta monocromática preto/branco/cinza */
  --green-900: #000000;
  --green-800: #1A1A1A;
  --green-700: #2D2D2D;
  --green-600: #404040;
  --green-100: #F2F2F2;
  --green-50:  #FAFAFA;

  --gold-600:  #555555;
  --gold-500:  #D4D4D4;
  --gold-100:  #F2F2F2;

  --red-600:   #1A1A1A;
  --red-50:    #F5F5F5;

  --gray-900:  #000000;
  --gray-700:  #1A1A1A;
  --gray-500:  #6B6B6B;
  --gray-400:  #9E9E9E;
  --gray-200:  #D4D4D4;
  --gray-100:  #F2F2F2;
  --gray-50:   #FAFAFA;

  --bg:        #F8F8F8;
  --surface:   #FFFFFF;
  --border:    #E0E0E0;
  --border-focus: #1A1A1A;

  --font-display: 'Lora', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'DM Mono', 'Courier New', monospace;

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:     0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--gray-900);
  min-height: 100vh;
}

/* ── Brand ── */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: flex; flex-shrink: 0; }
.brand-name {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--green-800);
  letter-spacing: -.01em;
}

/* ── Buttons ── */
.btn-primary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--green-800);
  color: #fff;
  border-color: var(--green-800);
}
.btn-primary:hover  { background: var(--green-700); border-color: var(--green-700); box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.btn-primary:active { transform: translateY(1px); }

.btn-ghost {
  background: transparent;
  color: var(--gray-700);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--gray-50); border-color: var(--gray-200); }

.btn-full  { width: 100%; justify-content: center; }
.btn-sm    { padding: 8px 14px; font-size: .82rem; }

.btn-download {
  background: var(--gold-500);
  border-color: var(--gold-500);
  color: var(--green-900);
  font-weight: 600;
}
.btn-download:hover { background: var(--gold-600); border-color: var(--gold-600); color: #fff; }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { animation: spin .8s linear infinite; }

/* ── Form Elements ── */
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: .85rem;
  font-weight: 500;
  color: var(--gray-700);
  letter-spacing: .01em;
}
.field-input, .field-select, .field-textarea {
  width: 100%;
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--gray-900);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.field-input::placeholder, .field-textarea::placeholder { color: var(--gray-400); }
.field-input:focus, .field-select:focus, .field-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0,0,0,.08);
}
.field-textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.field-hint { font-size: .8rem; color: var(--gray-500); }

.input-wrapper { position: relative; }
.input-wrapper .field-input { padding-right: 42px; }
.input-icon {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--gray-400); pointer-events: none;
}

.select-wrapper { position: relative; }
.select-wrapper .field-select { padding-right: 38px; cursor: pointer; }
.select-arrow {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--gray-400); pointer-events: none;
}

/* Code input style */
.code-input {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* Checkboxes / Radios */
.checkbox-group, .radio-group {
  display: flex; flex-wrap: wrap; gap: 10px;
}
.checkbox-item, .radio-item {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.checkbox-item input, .radio-item input { accent-color: var(--green-800); width: 16px; height: 16px; cursor: pointer; }
.checkbox-label, .radio-label { font-size: .875rem; color: var(--gray-700); }

/* Error message */
.error-message {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--red-50);
  border: 1px solid #F5C6C2;
  border-radius: var(--radius);
  color: var(--red-600);
  font-size: .85rem;
}

/* ── Entry Page ── */
.page-entry .entry-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  min-height: 100vh;
}

.entry-aside {
  background: var(--green-800);
  position: relative;
  overflow: hidden;
}
.entry-aside::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(212,168,67,.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(64,145,108,.2) 0%, transparent 50%);
}
.aside-content {
  position: relative;
  display: flex; flex-direction: column;
  height: 100%; padding: 48px 44px;
}
.entry-aside .brand-name { color: #fff; }
.aside-hero { margin-top: auto; margin-bottom: auto; }
.aside-title {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  margin-bottom: 16px;
}
.aside-title em { color: var(--gold-500); font-style: italic; }
.aside-subtitle {
  font-size: .95rem;
  color: rgba(255,255,255,.75);
  line-height: 1.65;
  max-width: 300px;
}

.aside-steps {
  list-style: none;
  display: flex; flex-direction: column; gap: 4px;
  margin-top: auto; padding-top: 40px;
}
.step {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 0;
  opacity: .45;
  transition: opacity .2s;
}
.step.active { opacity: 1; }
.step-num {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.12);
  border: 1.5px solid rgba(255,255,255,.25);
  border-radius: 50%;
  font-size: .8rem; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.step.active .step-num { background: var(--gold-500); border-color: var(--gold-500); color: var(--green-900); }
.step-label { font-size: .875rem; color: rgba(255,255,255,.9); }

.aside-footer {
  padding-top: 32px;
  font-size: .75rem;
  color: rgba(255,255,255,.4);
}

.entry-main {
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.entry-card {
  width: 100%; max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}
.card-header { margin-bottom: 32px; }
.card-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 8px;
}
.card-desc { font-size: .9rem; color: var(--gray-500); line-height: 1.6; }

.access-form { display: flex; flex-direction: column; gap: 20px; }
.card-divider { height: 1px; background: var(--border); margin: 24px 0; }
.card-footer-note { text-align: center; font-size: .82rem; color: var(--gray-500); }
.card-footer-note a { color: var(--green-700); text-decoration: none; }
.card-footer-note a:hover { text-decoration: underline; }

/* ── Form Page ── */
.page-form { display: flex; flex-direction: column; }

.form-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.header-inner {
  max-width: 900px; margin: 0 auto;
  padding: 16px 32px;
  display: flex; align-items: center; justify-content: space-between;
}
.header-progress { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.progress-bar {
  width: 180px; height: 4px;
  background: var(--gray-200);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--green-700);
  border-radius: 999px;
  transition: width .35s ease;
}
.progress-label { font-size: .75rem; color: var(--gray-500); }

.form-main { flex: 1; padding: 48px 32px; }
.form-container { max-width: 760px; margin: 0 auto; }

.form-step { animation: fadeUp .3s ease; }
.form-step.hidden { display: none; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.step-header { margin-bottom: 36px; }
.step-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--green-50);
  color: var(--green-700);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.step-badge.success { background: var(--green-100); color: var(--green-800); }
.step-title {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 8px;
}
.step-desc { font-size: .9rem; color: var(--gray-500); line-height: 1.6; }

.fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 32px;
}
.col-full { grid-column: 1 / -1; }

.step-actions {
  display: flex; justify-content: flex-end; align-items: center;
  gap: 12px; padding-top: 8px;
}

/* Discipline extras */
.discipline-extras {
  border-top: 1px solid var(--border);
  padding-top: 24px;
  margin-bottom: 32px;
}
.discipline-extras:empty { display: none; }
.extras-title { font-weight: 600; font-size: .9rem; color: var(--green-800); margin-bottom: 16px; }

/* ── Generating State ── */
.generating-layout {
  display: flex; flex-direction: column; align-items: center;
  padding: 80px 32px; text-align: center;
}
.generating-animation {
  position: relative; width: 80px; height: 80px;
  margin-bottom: 32px;
}
.gen-pulse {
  position: absolute; inset: 0;
  background: var(--green-50);
  border-radius: 50%;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: .4; }
}
.gen-icon {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border-radius: 50%;
  border: 2px solid var(--green-100);
  box-shadow: var(--shadow);
}
.generating-title {
  font-family: var(--font-display);
  font-size: 1.5rem; font-weight: 600;
  margin-bottom: 10px;
}
.generating-desc { font-size: .9rem; color: var(--gray-500); max-width: 400px; margin-bottom: 32px; }

.generating-steps {
  display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 340px; text-align: left;
}
.gen-step {
  display: flex; align-items: center; gap: 12px;
  font-size: .875rem; color: var(--gray-400);
  transition: color .3s;
}
.gen-step.active { color: var(--gray-700); }
.gen-step.done { color: var(--green-700); }
.gen-step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gray-300);
  flex-shrink: 0;
  transition: background .3s;
}
.gen-step.active .gen-step-dot { background: var(--gold-500); animation: pulse .8s ease-in-out infinite; }
.gen-step.done .gen-step-dot { background: var(--green-600); animation: none; }

/* ── Document Preview ── */
.preview-toolbar {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.doc-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 48px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
  min-height: 400px;
  font-size: .9rem;
  line-height: 1.7;
}

.doc-section { margin-bottom: 24px; }
.doc-section-title {
  font-weight: 600; font-size: .8rem;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--green-700);
  border-bottom: 1.5px solid var(--green-100);
  padding-bottom: 6px;
  margin-bottom: 12px;
}
.doc-field {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 16px;
  padding: 4px 0;
}
.doc-field-label { font-size: .82rem; color: var(--gray-500); }
.doc-field-value { color: var(--gray-900); }
[contenteditable="true"] {
  outline: none;
  border-bottom: 1.5px dashed var(--green-200);
  padding: 2px 4px;
  border-radius: 3px;
  transition: background .15s, border-color .15s;
}
[contenteditable="true"]:hover { background: var(--green-50); }
[contenteditable="true"]:focus { background: var(--green-50); border-color: var(--green-700); }

.doc-plan-table {
  width: 100%; border-collapse: collapse; margin-top: 8px;
}
.doc-plan-table th {
  background: var(--green-50);
  font-size: .8rem; font-weight: 600; color: var(--green-800);
  padding: 8px 12px; text-align: left; border: 1px solid var(--border);
}
.doc-plan-table td {
  padding: 10px 12px; border: 1px solid var(--border);
  font-size: .875rem; vertical-align: top;
}
.doc-plan-table tr:hover td { background: var(--gray-50); }

/* ── Error / Success States ── */
.error-layout, .success-layout {
  display: flex; flex-direction: column; align-items: center;
  padding: 80px 32px; text-align: center;
}
.error-icon, .success-icon { margin-bottom: 24px; }
.error-title, .success-title {
  font-family: var(--font-display);
  font-size: 1.4rem; margin-bottom: 10px;
}
.error-desc, .success-desc {
  font-size: .9rem; color: var(--gray-500); max-width: 400px; margin-bottom: 28px;
}

/* ── Toast ── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--gray-900); color: #fff;
  border-radius: var(--radius);
  font-size: .875rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease;
  max-width: 340px;
}
.toast.success { background: var(--green-800); }
.toast.error   { background: var(--red-600); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Responsive ── */
@media (max-width: 900px) {
  .page-entry .entry-layout { grid-template-columns: 1fr; }
  .entry-aside { display: none; }
  .entry-main { padding: 24px 16px; }
  .fields-grid { grid-template-columns: 1fr; }
  .header-inner { padding: 14px 20px; }
  .doc-preview { padding: 24px; }
  .doc-field { grid-template-columns: 1fr; }
  .guia-header-row { grid-template-columns: 1fr 1fr; }
  .ae-card { padding: 14px; }
}

/* ── AE Picker ── */
.ae-picker { display: flex; flex-direction: column; gap: 12px; }

.ae-loading {
  display: flex; align-items: center; gap: 10px;
  padding: 20px; color: var(--gray-500); font-size: .9rem;
}
.ae-loading-spinner {
  width: 20px; height: 20px; border: 2px solid var(--border);
  border-top-color: var(--green-800); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ae-list { display: flex; flex-direction: column; gap: 10px; }

.ae-card {
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 16px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.ae-card:hover { border-color: var(--green-600); box-shadow: var(--shadow-sm); }
.ae-card.selected { border-color: var(--green-800); background: #F5F5F5; }

.ae-card-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.ae-check {
  width: 22px; height: 22px; border: 2px solid var(--border);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s, border-color .15s; color: #fff;
}
.ae-card.selected .ae-check { background: var(--green-800); border-color: var(--green-800); }
.ae-card:not(.selected) .ae-check svg { display: none; }

.ae-code { font-weight: 700; font-size: .9rem; color: var(--green-800); }
.ae-habilidade-tag {
  font-size: .78rem; background: var(--gray-100); color: var(--gray-500);
  padding: 2px 8px; border-radius: 99px; border: 1px solid var(--border);
}
.ae-descricao { font-size: .88rem; color: var(--gray-700); line-height: 1.5; margin-bottom: 8px; }

.ae-conteudos { font-size: .82rem; color: var(--gray-500); }
.ae-conteudos-label { font-weight: 600; margin-right: 4px; }
.ae-conteudos ul { padding-left: 16px; margin-top: 4px; }
.ae-conteudos li { margin-bottom: 2px; }
.ae-mais { color: var(--green-800); font-style: italic; }

.ae-unavailable {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 20px; background: #F5F5F5; border-radius: var(--radius);
  border: 1px solid #D4D4D4; color: var(--gray-700); font-size: .9rem;
}
.ae-unavailable p { line-height: 1.5; }
.ae-unavailable svg { flex-shrink: 0; margin-top: 2px; }

.selected-ae-info { margin-top: 8px; }
.habilidades-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.hab-tag {
  font-size: .82rem; background: var(--green-100); border: 1px solid #D4D4D4;
  padding: 4px 10px; border-radius: 99px; color: var(--gray-700);
}

/* ── Guia Preview ── */
.guia-preview { font-size: .9rem; }

.guia-header-table {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 20px;
}
.guia-header-row {
  display: grid; grid-template-columns: 2fr 2fr 1.5fr 1fr;
}
.guia-header-labels > div {
  padding: 8px 12px; background: #1A1A1A; color: #FFFFFF; font-weight: 700;
  font-size: .8rem; border-right: 1px solid rgba(0,0,0,.08);
}
.guia-header-values > div {
  padding: 10px 12px; background: #fff; border-right: 1px solid var(--border);
  border-top: 1px solid var(--border);
}
.guia-header-labels > div:last-child,
.guia-header-values > div:last-child { border-right: none; }

.guia-section { margin-bottom: 20px; }
.guia-section-title {
  font-weight: 700; font-size: .85rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--green-800);
  border-bottom: 2px solid var(--green-800); padding-bottom: 6px; margin-bottom: 12px;
}
.guia-ae-list { display: flex; flex-direction: column; gap: 8px; }
.guia-ae-item { font-size: .88rem; line-height: 1.5; padding: 8px 0; }
.guia-hab-code { font-size: .8rem; color: var(--gray-500); margin-left: 4px; }

.guia-conteudos-table {
  width: 100%; border-collapse: collapse; font-size: .85rem;
}
.guia-conteudos-table th, .guia-conteudos-table td {
  border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top;
}
.guia-conteudos-table th { background: var(--gray-100); font-weight: 600; }
.guia-conteudos-table tr:nth-child(even) td { background: var(--gray-50); }

.guia-notice {
  display: flex; align-items: flex-start; gap: 8px;
  margin-top: 20px; padding: 12px 14px;
  background: #F5F5F5; border-radius: var(--radius);
  border: 1px solid #D4D4D4; font-size: .82rem; color: var(--gray-700);
  line-height: 1.5;
}
.guia-notice svg { flex-shrink: 0; margin-top: 2px; }

.spin { animation: spin .8s linear infinite; }

/* ── Access (Code Entry) Page ── */
.page-access {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.access-layout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.access-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.access-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.access-brand-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gray-900);
}
.access-brand-sub {
  font-size: .75rem;
  color: var(--gray-500);
  margin-top: 2px;
}
.access-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.access-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 2px;
}
.access-desc {
  font-size: .875rem;
  color: var(--gray-500);
  line-height: 1.55;
}
.access-field { display: flex; flex-direction: column; gap: 6px; }
.access-code-input {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
}
.access-error {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: #F5F5F5;
  border: 1px solid #D4D4D4;
  border-radius: var(--radius);
  font-size: .82rem;
  color: var(--gray-700);
}
.btn-access {
  width: 100%;
  justify-content: center;
  padding: 14px;
  font-size: .95rem;
  gap: 8px;
}
.btn-spinner { display: inline-block; }
.btn-spinner.hidden { display: none; }
