/* ============================================================
   Apurei — style-etapa2.css
   Adiciona ao style.css da Etapa 1.
   Elementos: tabela de resultado, overrides, classificações,
              toast, camada 2, estabilidade, footer de resultado.
   ============================================================ */

/* ── Tabela header ───────────────────────────────────────────── */
.apurei-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--c-border);
  background: #fafaf8;
}

.apurei-table-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.apurei-table-file {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--c-muted);
}

.apurei-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Linhas especiais ────────────────────────────────────────── */
.apurei-table tr.system-excluded td {
  color: var(--c-muted);
  background: #fafaf8;
}

.apurei-table tr.overridden {
  background: #fefdf5;
}

.apurei-table tr.overridden td {
  background: #fefdf5;
}

.apurei-table tr.excluded td {
  opacity: 0.38;
  text-decoration: line-through;
  text-decoration-color: rgba(0,0,0,0.2);
}

/* ── Classificação badges ────────────────────────────────────── */
.apurei-classif {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 2px;
}

.apurei-classif--estavel {
  background: var(--c-ok-bg);
  color: var(--c-ok);
}

.apurei-classif--variancia {
  background: var(--c-warn-bg);
  color: var(--c-warn);
}

.apurei-classif--circular,
.apurei-classif--propria {
  background: #f0f0f0;
  color: #555;
}

.apurei-classif--other {
  background: #f0f0f0;
  color: #888;
}

/* ── Valor na tabela ─────────────────────────────────────────── */
.apurei-valor {
  font-weight: 500;
  white-space: nowrap;
}

/* ── Override toggle ─────────────────────────────────────────── */
.apurei-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
}

.apurei-toggle-input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.apurei-toggle-track {
  position: absolute;
  inset: 0;
  background: #d0d0cc;
  border-radius: 20px;
  transition: background 0.2s;
}

.apurei-toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform 0.2s;
}

.apurei-toggle-input:checked + .apurei-toggle-track {
  background: var(--c-ok);
}

.apurei-toggle-input:checked + .apurei-toggle-track::after {
  transform: translateX(16px);
}

.apurei-toggle-input:focus-visible + .apurei-toggle-track {
  outline: 2px solid var(--c-ink);
  outline-offset: 2px;
}

/* ── Justificativa ───────────────────────────────────────────── */
.apurei-justification {
  font-size: 12px;
  color: var(--c-ink);
  border: none;
  border-bottom: 1px solid var(--c-border);
  background: transparent;
  outline: none;
  width: 130px;
  padding: 2px 0;
  font-family: inherit;
  transition: border-color 0.15s, opacity 0.15s;
}

.apurei-justification:focus {
  border-color: var(--c-ink);
}

.apurei-justification::placeholder { color: #bbb; }

/* ── Override ícone ──────────────────────────────────────────── */
.apurei-override-icon {
  font-size: 11px;
  color: var(--c-warn);
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Result footer ───────────────────────────────────────────── */
.apurei-result-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.apurei-result-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ── Camada 2 ────────────────────────────────────────────────── */
.apurei-layer2 {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: apurei-fade-in 0.3s ease both;
}

.apurei-layer2-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.apurei-layer2-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-muted);
  margin-bottom: 16px;
}

.apurei-layer2-placeholder {
  font-size: 14px;
  color: var(--c-muted);
  padding: 24px;
  text-align: center;
  border: 1px dashed var(--c-border);
  border-radius: var(--radius);
}

/* ── Composição ──────────────────────────────────────────────── */
.apurei-comp-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.apurei-comp-item:last-child { margin-bottom: 0; }

.apurei-comp-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
}

.apurei-comp-name {
  font-weight: 500;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.apurei-comp-bar-wrap {
  height: 5px;
  background: var(--c-border);
  border-radius: 3px;
  overflow: hidden;
}

.apurei-comp-bar {
  height: 100%;
  background: var(--c-ink);
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(.4,0,.2,1);
}

/* ── Estabilidade detalhe ────────────────────────────────────── */
.apurei-estab-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.apurei-estab-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.apurei-estab-name {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.apurei-estab-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 2px;
  flex-shrink: 0;
}

.apurei-estab-badge--alta  { background: var(--c-ok-bg);   color: var(--c-ok); }
.apurei-estab-badge--media { background: var(--c-warn-bg);  color: var(--c-warn); }
.apurei-estab-badge--baixa { background: var(--c-error-bg); color: var(--c-error); }

.apurei-estab-cv {
  font-size: 12px;
  color: var(--c-muted);
  flex-shrink: 0;
}

/* ── Card valor pequeno ──────────────────────────────────────── */
.apurei-card-value--sm {
  font-size: 22px;
}

/* ── Toast ───────────────────────────────────────────────────── */
#apurei-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--c-ink);
  color: #fff;
  font-size: 13px;
  padding: 11px 20px;
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
  z-index: 99999;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  white-space: nowrap;
  max-width: calc(100vw - 48px);
  text-align: center;
}

#apurei-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#apurei-toast.apurei-toast-error {
  background: var(--c-error);
}

#apurei-toast.apurei-toast-info {
  background: #444;
}

/* ── Responsividade Etapa 2 ──────────────────────────────────── */
@media (max-width: 640px) {
  .apurei-result-actions {
    flex-direction: column;
  }

  .apurei-comp-header {
    flex-direction: column;
    gap: 2px;
  }

  .apurei-comp-name { max-width: 100%; }

  .apurei-estab-item {
    flex-wrap: wrap;
    gap: 6px;
  }

  .apurei-justification {
    width: 90px;
  }

  #apurei-toast {
    bottom: 16px;
    font-size: 12px;
    padding: 10px 16px;
  }
}
