/* Validator-specific styles — extends app.css */

/* ── Block selection fieldset ────────────────────────────────────────────────── */

.blocks-fieldset {
  border: 1px solid rgba(0, 105, 62, 0.2);
  border-radius: 8px;
  padding: 10px 14px 6px;
  margin: 0;
}

.blocks-fieldset legend {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 6px;
}

.blocks-fieldset .toggle-row {
  padding: 4px 0;
}

.blocks-fieldset input[type="checkbox"]:disabled + span {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Layout ─────────────────────────────────────────────────────────────────── */

.validator-layout {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 24px;
}

/* ── Navigation ─────────────────────────────────────────────────────────────── */

.page-nav {
  margin-top: 18px;
}

.nav-link {
  color: var(--accent-light);
  text-decoration: none;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  transition: color 160ms;
}

.nav-link:hover {
  color: var(--ink);
}

/* ── Optional label ─────────────────────────────────────────────────────────── */

.optional {
  font-style: normal;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
}

/* ── Loading spinner ─────────────────────────────────────────────────────────── */

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(0, 105, 62, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

/* ── Laudo header ────────────────────────────────────────────────────────────── */

.laudo-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  border-radius: 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--panel-border);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.laudo-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.secondary-action {
  border: 1px solid rgba(0, 105, 62, 0.45);
  background: rgba(0, 105, 62, 0.12);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.84rem;
}

.secondary-action:hover {
  background: rgba(0, 105, 62, 0.2);
}

.laudo-meta {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}

.laudo-meta > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Result badge ────────────────────────────────────────────────────────────── */

.resultado-badge {
  font-size: 1rem;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 14px;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-conforme {
  background: rgba(0, 105, 62, 0.2);
  color: #4ade80;
  border: 1px solid rgba(0, 105, 62, 0.4);
}

.badge-ressalvas {
  background: rgba(234, 179, 8, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.badge-nao-conforme {
  background: rgba(239, 68, 68, 0.15);
  color: var(--warn);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ── Audit blocks (details/summary) ─────────────────────────────────────────── */

.audit-block {
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  margin-bottom: 16px;
  overflow: hidden;
}

.audit-block > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  cursor: pointer;
  list-style: none;
  background: var(--bg-tertiary);
  flex-wrap: wrap;
}

.audit-block > summary::-webkit-details-marker {
  display: none;
}

.audit-block > summary::before {
  content: "▶";
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 200ms;
  flex-shrink: 0;
}

.audit-block[open] > summary::before {
  transform: rotate(90deg);
}

.block-label {
  font-weight: 600;
  flex: 1;
  min-width: 0;
}

.block-badge {
  font-size: 0.82rem;
  font-weight: 600;
}

.block-stats {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Check list ─────────────────────────────────────────────────────────────── */

.check-list {
  list-style: none;
  margin: 0;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 22, 20, 0.6);
}

.check-item.conforme {
  border-left: 3px solid rgba(0, 105, 62, 0.5);
}

.check-item.atencao {
  border-left: 3px solid rgba(234, 179, 8, 0.6);
}

.check-item.nao-conforme {
  border-left: 3px solid rgba(239, 68, 68, 0.6);
}

.check-icon {
  font-size: 1rem;
  line-height: 1.4;
}

.check-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.check-desc {
  font-size: 0.9rem;
  color: var(--ink);
}

.check-justificativa {
  font-size: 0.82rem;
  color: var(--muted);
}

.check-severity {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 8px;
  margin-top: 4px;
}

.sev-critica {
  background: rgba(239, 68, 68, 0.2);
  color: var(--warn);
}

.sev-alta {
  background: rgba(249, 115, 22, 0.2);
  color: #fb923c;
}

.sev-media {
  background: rgba(234, 179, 8, 0.2);
  color: #fbbf24;
}

.sev-baixa {
  background: rgba(0, 105, 62, 0.15);
  color: var(--accent-light);
}

/* ── Non-conformidades table ─────────────────────────────────────────────────── */

#nonConformSection h3,
#recsSection h3 {
  margin-bottom: 14px;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  margin-bottom: 24px;
}

.nc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.nc-table th {
  padding: 12px 14px;
  text-align: left;
  background: var(--bg-tertiary);
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.75rem;
  border-bottom: 1px solid var(--panel-border);
}

.nc-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(0, 105, 62, 0.08);
  vertical-align: top;
}

.nc-table tr:last-child td {
  border-bottom: none;
}

/* ── Recommendations list ────────────────────────────────────────────────────── */

.recs-list {
  padding-left: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recs-list li {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Section drill-down ────────────────────────────────────────────────────── */

#sectionsSection h3 {
  margin-bottom: 14px;
}

.sections-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
  margin-top: 8px;
}

.sections-nav {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: rgba(15, 22, 20, 0.42);
  max-height: 520px;
  overflow: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section-nav-btn {
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.section-nav-btn:hover {
  background: rgba(0, 105, 62, 0.08);
  border-color: rgba(0, 105, 62, 0.2);
}

.section-nav-btn.active {
  background: rgba(0, 105, 62, 0.14);
  border-color: rgba(0, 105, 62, 0.35);
}

.section-nav-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.section-nav-title {
  font-size: 0.86rem;
  font-weight: 600;
}

.section-nav-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.sections-detail {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px;
  background: rgba(15, 22, 20, 0.42);
}

.section-detail-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.section-detail-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.section-detail-card .check-list {
  padding-left: 0;
  padding-right: 0;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .validator-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 800px) {
  .validator-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .laudo-header {
    flex-direction: column;
  }

  .laudo-actions {
    align-items: flex-start;
  }

  .resultado-badge {
    align-self: flex-start;
  }

  .sections-layout {
    grid-template-columns: 1fr;
  }

  .sections-nav {
    max-height: 260px;
  }

  .validator-layout {
    grid-template-columns: 1fr;
  }
}

/* ── Audit blocking overlay ─────────────────────────────────────────────────── */

.audit-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 12, 24, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: audit-overlay-fade 200ms ease-out;
}

.audit-overlay[hidden] {
  display: none;
}

@keyframes audit-overlay-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.audit-overlay__panel {
  background: var(--panel-bg, #0d2435);
  border: 1px solid rgba(0, 200, 130, 0.18);
  border-radius: 14px;
  padding: 32px 40px;
  max-width: 480px;
  width: calc(100% - 48px);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}

.audit-overlay__spinner {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  border: 4px solid rgba(0, 200, 130, 0.18);
  border-top-color: var(--accent-light, #00c882);
  border-radius: 50%;
  animation: audit-overlay-spin 900ms linear infinite;
}

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

.audit-overlay__title {
  font-size: 1.4rem;
  margin: 0 0 6px;
  letter-spacing: 0.02em;
}

.audit-overlay__subtitle {
  margin: 0 0 20px;
  color: var(--muted, #a8b8c4);
  font-size: 0.95rem;
}

.audit-overlay__checklist {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.audit-overlay__checklist li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.92rem;
  transition: background 200ms, border-color 200ms;
}

.audit-overlay__checklist li.is-running {
  background: rgba(0, 200, 130, 0.08);
  border-color: rgba(0, 200, 130, 0.25);
}

.audit-overlay__checklist li.is-done {
  background: rgba(0, 200, 130, 0.16);
  border-color: rgba(0, 200, 130, 0.4);
  color: #d4ffec;
}

.audit-overlay__checklist .audit-overlay__icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.audit-overlay__checklist li.is-running .audit-overlay__icon {
  animation: audit-overlay-pulse 1.4s ease-in-out infinite;
}

@keyframes audit-overlay-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

.audit-overlay__elapsed {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted, #a8b8c4);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
