/*
 * Copyright 2026 ExcID
 * SPDX-License-Identifier: Apache-2.0
 *
 * Static frontend independently implemented for CRA Compliance Checker.
 */

:root {
  --blue: #0d47a1;
  --blue-2: #0b5ed7;

  --page-bg: #ffffff;
  --panel-bg: #f8f9fa;
  --card-bg: #ffffff;

  --text: #172033;
  --title: #08060d;
  --muted: #5f6b7a;
  --border: #d9dee6;

  --danger-bg: #fff1f1;
  --danger-text: #8a1f1f;
  --danger-border: #fecaca;

  --ok-bg: #ecfdf3;
  --ok-text: #166534;
  --ok-border: #bbf7d0;

  --warning-bg: #fffbeb;
  --warning-text: #854d0e;
  --warning-border: #fde68a;

  --notice-bg: #eff6ff;
  --notice-text: #1d4ed8;
  --notice-border: #bfdbfe;

  --footer-bg: #e9ecef;
  --footer-text: #4b5563;

  --shadow: 0 10px 28px rgba(20, 31, 56, 0.1);

  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

html[data-theme="dark"] {
  --page-bg: #0b1220;
  --panel-bg: #111b2f;
  --card-bg: #16233a;

  --text: #f8fafc;
  --title: #ffffff;
  --muted: #b7c2d4;
  --border: #31435f;

  --danger-bg: #431616;
  --danger-text: #fecaca;
  --danger-border: #7f1d1d;

  --ok-bg: #0f3320;
  --ok-text: #bbf7d0;
  --ok-border: #166534;

  --warning-bg: #422006;
  --warning-text: #fde68a;
  --warning-border: #a16207;

  --notice-bg: #10243f;
  --notice-text: #bfdbfe;
  --notice-border: #1d4ed8;

  --footer-bg: #e9ecef;
  --footer-text: #4b5563;

  color-scheme: dark;
}

html[data-theme="light"] {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.topbar__inner {
  width: min(1120px, calc(100% - 32px));
  height: 58px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  user-select: none;
  cursor: pointer;
}

.theme-toggle input {
  inline-size: 34px;
  block-size: 18px;
  cursor: pointer;
}

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0 120px;
  flex: 1;
}

.intro-card {
  margin-bottom: 24px;
}

.intro-card h2 {
  margin: 0 0 12px;
  color: var(--title);
  font-size: clamp(34px, 5vw, 52px);
  font-weight: 400;
  letter-spacing: -0.04em;
}

.intro-card p {
  max-width: 900px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.checker-card,
.results {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
}

.checker-card h2,
.results h2 {
  margin: 0 0 18px;
  color: var(--title);
  font-size: 24px;
}

.form {
  display: grid;
  gap: 16px;
}

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

.field {
  display: grid;
  gap: 8px;
  color: var(--title);
  font-weight: 700;
}

.field span {
  font-size: 14px;
}

.field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 9px 12px;
  background: var(--card-bg);
  color: var(--text);
  font: inherit;
}

.field input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.field input:focus {
  outline: 3px solid rgba(13, 71, 161, 0.22);
  border-color: var(--blue-2);
}

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

button {
  border-radius: 5px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.primary-button {
  border: 1px solid var(--blue-2);
  background: #0d6efd;
  color: #ffffff;
}

.primary-button:hover:not(:disabled) {
  background: #0b5ed7;
}

.secondary-button {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  margin-top: 14px;
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--blue-2);
}

.status {
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
}

.error-box {
  margin-top: 14px;
  border: 1px solid var(--danger-border);
  border-radius: 6px;
  padding: 12px;
  background: var(--danger-bg);
  color: var(--danger-text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.results {
  margin-top: 24px;
}

.compliance-banner {
  display: grid;
  gap: 4px;
  border: 1px solid;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.compliance-banner strong {
  font-size: 22px;
}

.compliance-banner span {
  font-size: 14px;
  line-height: 1.45;
}

.compliance-banner--pass {
  background: var(--ok-bg);
  color: var(--ok-text);
  border-color: var(--ok-border);
}

.compliance-banner--fail {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 4px;
}

.summary-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
}

.summary-card strong {
  display: block;
  color: var(--title);
  font-size: 22px;
}

.summary-card span {
  color: var(--muted);
}

.findings-container {
  margin-top: 18px;
}

.finding-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  padding: 16px;
  margin-top: 18px;
}

.finding-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.finding-panel__header h3 {
  margin: 0;
  color: var(--title);
  font-size: 20px;
}

.finding-panel__total {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.finding-group-list {
  display: grid;
  gap: 10px;
}

.finding-accordion {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  overflow: hidden;
}

.finding-accordion__summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  cursor: pointer;
  list-style-position: outside;
}

.finding-accordion__summary:hover {
  background: rgba(13, 110, 253, 0.08);
}

.finding-accordion__left {
  min-width: 0;
}

.finding-accordion__title {
  display: block;
  color: var(--title);
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.finding-accordion__meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.finding-accordion__right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.severity-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.severity-pill {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.severity-pill--critical,
.severity-pill--error,
.severity-pill--high {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.severity-pill--medium {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.severity-pill--warning {
  background: var(--notice-bg);
  color: var(--notice-text);
}

.severity-pill--low,
.severity-pill--other {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.finding-card-list {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px 34px;
}

.finding-card {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.finding-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.finding-card__title {
  color: var(--title);
  font-size: 15px;
  line-height: 1.35;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge--danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge--warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge--notice {
  background: var(--notice-bg);
  color: var(--notice-text);
}

.badge--ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.finding-card__meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.finding-card__message {
  margin: 8px 0 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.finding-card__references {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.finding-card__references summary {
  cursor: pointer;
  color: var(--title);
  font-weight: 700;
}

.finding-card__references ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.empty-state {
  margin: 0;
  color: var(--muted);
}

.footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--footer-bg);
  color: var(--footer-text);
}

.footer__inner {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
  text-align: center;
}

.footer__logos {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.footer__logos img {
  display: block;
  width: auto;
  max-height: 48px;
  object-fit: contain;
}

.footer__logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.footer p {
  margin: 0;
  color: var(--footer-text);
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 720px) {
  .field-grid,
  .summary {
    grid-template-columns: 1fr;
  }

  .action-row,
  .result-action-row {
    align-items: stretch;
    flex-direction: column;
  }


  button {
    width: 100%;
  }

  .finding-panel__header {
    align-items: flex-start;
    flex-direction: column;
  }

  .finding-accordion__summary {
    grid-template-columns: 1fr;
  }

  .finding-accordion__right,
  .severity-pills {
    justify-content: flex-start;
  }

  .finding-card-list {
    padding-left: 14px;
  }

  .footer__logos {
    gap: 14px;
  }

  .footer__logos img {
    max-height: 40px;
  }
}

.result-action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
