/* RC88 · Collaudo app: pannello laterale in sovraimpressione. */

.audit-page {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  justify-content: flex-end;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #1b1e26;
}

.audit-page[hidden] {
  display: none !important;
}

.audit-backdrop {
  flex: 1;
  min-width: 0;
  background: rgba(18, 20, 27, 0.34);
  pointer-events: auto;
}

.audit-panel {
  position: relative;
  display: flex;
  width: min(560px, 100%);
  height: 100%;
  flex-direction: column;
  gap: 16px;
  padding: 22px 22px 44px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #ffffff;
  border-left: 1px solid rgba(20, 24, 32, 0.1);
  box-shadow: -20px 0 48px rgba(12, 15, 22, 0.22);
  pointer-events: auto;
  transition: opacity 0.25s ease;
}

.is-audit-dim .audit-panel {
  opacity: 0.25;
}

.audit-head {
  display: grid;
  gap: 8px;
}

.audit-eyebrow {
  margin: 0;
  color: #b3223b;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.audit-title {
  margin: 0;
  font-size: clamp(1.5rem, 3.4vw, 2rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.audit-lead,
.audit-scope {
  margin: 0;
  color: #4b5261;
  font-size: 0.92rem;
  line-height: 1.5;
}

.audit-scope {
  color: #7a8291;
  font-size: 0.8rem;
}

.audit-scope-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: #f2f3f6;
}

.audit-scope-button {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #4b5261;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.audit-scope-button:hover {
  background: rgba(20, 24, 32, 0.06);
}

.audit-scope-button.is-active {
  background: #ffffff;
  color: #b3223b;
  box-shadow: 0 1px 3px rgba(12, 15, 22, 0.16);
}

.audit-scope-button:focus-visible {
  outline: 3px solid rgba(179, 34, 59, 0.45);
  outline-offset: 2px;
}

.audit-scope-hint {
  margin: 0;
  color: #7a8291;
  font-size: 0.76rem;
  line-height: 1.4;
}

.audit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.audit-button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(20, 24, 32, 0.16);
  border-radius: 11px;
  background: #f5f6f8;
  color: #1b1e26;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.audit-button:hover {
  background: #ebedf1;
  border-color: rgba(20, 24, 32, 0.28);
}

.audit-button:active {
  transform: translateY(1px);
}

.audit-button:focus-visible {
  outline: 3px solid rgba(179, 34, 59, 0.45);
  outline-offset: 2px;
}

.audit-button:disabled {
  opacity: 0.55;
  cursor: progress;
}

.audit-button-primary {
  background: #b3223b;
  border-color: #8f1a2f;
  color: #ffffff;
}

.audit-button-primary:hover {
  background: #9a1c32;
}

.audit-button-ghost {
  background: transparent;
}

.audit-button-small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.78rem;
}

.audit-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.audit-tile {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid rgba(20, 24, 32, 0.12);
  border-radius: 14px;
  background: #f8f9fb;
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.audit-tile:hover {
  transform: translateY(-1px);
  border-color: rgba(20, 24, 32, 0.24);
}

.audit-tile[aria-pressed='true'] {
  border-color: #b3223b;
  background: #fdf2f4;
}

.audit-tile.has-issues .audit-tile-count {
  color: #b3223b;
}

.audit-tile-count {
  font-size: 1.7rem;
  font-weight: 900;
  line-height: 1;
  color: #2f6f4f;
}

.audit-tile-title {
  font-size: 0.9rem;
  font-weight: 800;
}

.audit-tile-hint {
  color: #6b7280;
  font-size: 0.75rem;
  line-height: 1.35;
}

.audit-tile-checked {
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid rgba(20, 24, 32, 0.08);
  color: #2f6f4f;
  font-size: 0.72rem;
  font-weight: 700;
}

.audit-status {
  min-height: 22px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #f2f3f6;
  color: #4b5261;
  font-size: 0.8rem;
}

.audit-status-live {
  color: #2f6f4f;
  font-weight: 700;
}

.audit-status-ok {
  margin-right: 8px;
  color: #2f6f4f;
  font-weight: 700;
}

.audit-status-error {
  color: #a81530;
  font-weight: 700;
}

.audit-status-warn {
  margin-left: 8px;
  color: #a15c00;
  font-weight: 700;
}

.audit-results {
  display: grid;
  gap: 10px;
}

.audit-results-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6b7280;
}

.audit-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.audit-chip {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(20, 24, 32, 0.14);
  border-radius: 999px;
  background: #ffffff;
  color: #37404f;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.audit-chip span {
  margin-left: 4px;
  color: #8b93a1;
}

.audit-chip.is-active {
  background: #1b1e26;
  border-color: #1b1e26;
  color: #ffffff;
}

.audit-chip.is-active span {
  color: rgba(255, 255, 255, 0.72);
}

.audit-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.audit-empty {
  padding: 18px;
  border: 1px dashed rgba(20, 24, 32, 0.18);
  border-radius: 12px;
  color: #6b7280;
  font-size: 0.86rem;
  text-align: center;
}

.audit-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  padding: 13px;
  border: 1px solid rgba(20, 24, 32, 0.12);
  border-left-width: 4px;
  border-radius: 12px;
  background: #ffffff;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.audit-item[data-severity='high'] {
  border-left-color: #c62828;
}

.audit-item[data-severity='info'] {
  border-left-color: #d99100;
}

.audit-item:hover {
  background: #fafbfc;
}

.audit-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: #d99100;
}

.audit-item[data-severity='high'] .audit-dot {
  background: #c62828;
}

.audit-item-body {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.audit-item-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin: 0;
}

.audit-badge {
  padding: 2px 7px;
  border-radius: 999px;
  background: #f3f4f7;
  color: #4b5261;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.audit-item[data-severity='high'] .audit-badge {
  background: #fdeced;
  color: #a81530;
}

.audit-item[data-severity] .audit-badge-count {
  background: #eef1f8;
  color: #3a4468;
  letter-spacing: 0.02em;
}

.audit-item[data-severity='high'] .audit-badge-count {
  background: #fbe3e6;
  color: #8d1226;
}

.audit-item-title {
  font-size: 0.9rem;
  font-weight: 800;
}

.audit-item-detail {
  margin: 0;
  color: #4b5261;
  font-size: 0.83rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.audit-item-selector {
  display: block;
  padding: 5px 8px;
  border-radius: 7px;
  background: #f4f5f8;
  color: #5a6272;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}

.audit-item-actions {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.audit-highlight {
  outline: 3px solid #e0322f !important;
  outline-offset: 3px !important;
  border-radius: 8px !important;
  box-shadow: 0 0 0 8px rgba(224, 50, 47, 0.18) !important;
  animation: audit-pulse 1.1s ease-in-out infinite;
}

@keyframes audit-pulse {
  0%, 100% { box-shadow: 0 0 0 8px rgba(224, 50, 47, 0.16); }
  50% { box-shadow: 0 0 0 16px rgba(224, 50, 47, 0.06); }
}

@media (max-width: 760px) {
  .audit-backdrop {
    display: none;
  }

  .audit-panel {
    width: 100%;
    border-left: 0;
    box-shadow: none;
    padding: 18px 16px 40px;
  }

  .audit-summary {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .audit-highlight {
    animation: none;
  }

  .audit-panel,
  .audit-tile,
  .audit-button {
    transition: none;
  }
}
