/**
 * Ervio shared design system — import on all portals.
 * Pair with nav-shell.js for role-aware chrome.
 */

/* -------------------------------------------------------------------------- */
/* Design tokens                                                               */
/* -------------------------------------------------------------------------- */

:root {
  --erv-brand: #00a7b8;
  --erv-brand-strong: #17d7e6;
  --erv-brand-muted: rgba(0, 167, 184, 0.22);

  --erv-bg-deep: #020617;
  --erv-bg: #050814;
  --erv-panel: #0b1120;
  --erv-panel-elevated: #111827;
  --erv-line: #1f2937;
  --erv-line-soft: rgba(148, 163, 184, 0.25);

  --erv-text: #e5f7f7;
  --erv-text-secondary: #cbd5e1;
  --erv-muted: #94a3b8;
  --erv-muted-deep: #64748b;

  --erv-risk: #ef4444;
  --erv-warn: #f59e0b;
  --erv-ok: #16a34a;
  --erv-info: #60a5fa;

  --erv-radius-sm: 10px;
  --erv-radius-md: 14px;
  --erv-radius-lg: 16px;
  --erv-radius-pill: 999px;

  --erv-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  --erv-shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.35);
  --erv-focus-ring: 0 0 0 2px var(--erv-bg-deep), 0 0 0 4px rgba(23, 215, 230, 0.45);

  --erv-font-sans: Nunito, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --erv-font-display: Poppins, var(--erv-font-sans);

  --erv-space-1: 0.25rem;
  --erv-space-2: 0.5rem;
  --erv-space-3: 0.75rem;
  --erv-space-4: 1rem;
  --erv-space-5: 1.25rem;
  --erv-space-6: 1.5rem;
}

/* -------------------------------------------------------------------------- */
/* Typography scale                                                           */
/* -------------------------------------------------------------------------- */

.erv-text-display {
  font-family: var(--erv-font-display);
  font-weight: 700;
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--erv-text);
}

.erv-text-title {
  font-family: var(--erv-font-display);
  font-weight: 600;
  font-size: clamp(1.05rem, 0.95rem + 0.35vw, 1.2rem);
  line-height: 1.3;
  color: var(--erv-text);
}

.erv-text-body {
  font-family: var(--erv-font-sans);
  font-weight: 400;
  font-size: clamp(0.9rem, 0.85rem + 0.15vw, 1rem);
  line-height: 1.55;
  color: var(--erv-text-secondary);
}

.erv-text-small {
  font-family: var(--erv-font-sans);
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--erv-muted);
}

.erv-text-caption {
  font-family: var(--erv-font-sans);
  font-weight: 700;
  font-size: 0.72rem;
  line-height: 1.35;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--erv-muted-deep);
}

/* -------------------------------------------------------------------------- */
/* Layout helpers                                                             */
/* -------------------------------------------------------------------------- */

.erv-app-frame {
  display: flex;
  min-height: 100vh;
  background: radial-gradient(circle at top, #111827, var(--erv-bg-deep) 55%, #000 100%);
  color: var(--erv-text);
}

.erv-main {
  flex: 1;
  min-width: 0;
}

/* -------------------------------------------------------------------------- */
/* Nav shell (nav-shell.js)                                                   */
/* -------------------------------------------------------------------------- */

.erv-nav-shell {
  width: min(260px, 88vw);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--erv-space-4);
  padding: var(--erv-space-4) var(--erv-space-3);
  border-right: 1px solid var(--erv-line);
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.96), rgba(15, 23, 42, 0.65));
}

.erv-nav-shell__brand {
  display: flex;
  align-items: center;
  gap: var(--erv-space-3);
  padding-bottom: var(--erv-space-2);
  border-bottom: 1px solid var(--erv-line-soft);
}

.erv-nav-shell__logo {
  width: 36px;
  height: 36px;
  border-radius: var(--erv-radius-sm);
  background: radial-gradient(circle at 15% 15%, var(--erv-brand-strong), var(--erv-brand));
  display: grid;
  place-items: center;
  color: #e0f2fe;
  font-family: var(--erv-font-display);
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 0 18px rgba(23, 215, 230, 0.45);
}

.erv-nav-shell__titles {
  min-width: 0;
}

.erv-nav-shell__product {
  font-family: var(--erv-font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--erv-text);
}

.erv-nav-shell__role {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--erv-muted);
  margin-top: 2px;
}

.erv-nav-shell__links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.erv-nav-shell__link {
  display: block;
  padding: 0.5rem 0.65rem;
  border-radius: var(--erv-radius-md);
  border: 1px solid transparent;
  color: var(--erv-text-secondary);
  font-family: var(--erv-font-sans);
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
  transition:
    background 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease;
}

.erv-nav-shell__link:hover {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.85);
  color: var(--erv-text);
}

.erv-nav-shell__link:focus-visible {
  outline: none;
  box-shadow: var(--erv-focus-ring);
}

.erv-nav-shell__link--active {
  border-color: rgba(23, 215, 230, 0.45);
  background: linear-gradient(135deg, var(--erv-brand-muted), rgba(15, 23, 42, 0.92));
  color: var(--erv-text);
}

@media (max-width: 720px) {
  .erv-nav-shell {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--erv-line);
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .erv-nav-shell__brand {
    border-bottom: none;
    flex: 1 1 auto;
  }

  .erv-nav-shell__links {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }

  .erv-nav-shell__link {
    flex: 1 1 auto;
    text-align: center;
    min-width: 120px;
  }
}

/* -------------------------------------------------------------------------- */
/* Card                                                                       */
/* -------------------------------------------------------------------------- */

.erv-card {
  background: var(--erv-panel);
  border: 1px solid var(--erv-line);
  border-radius: var(--erv-radius-lg);
  padding: var(--erv-space-4);
  box-shadow: var(--erv-shadow);
}

.erv-card--flat {
  box-shadow: var(--erv-shadow-soft);
}

.erv-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--erv-space-3);
  margin-bottom: var(--erv-space-3);
}

.erv-card__title {
  margin: 0;
  font-family: var(--erv-font-display);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--erv-text);
}

/* -------------------------------------------------------------------------- */
/* Badges                                                                     */
/* -------------------------------------------------------------------------- */

.erv-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--erv-radius-pill);
  font-family: var(--erv-font-sans);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  border: 1px solid var(--erv-line-soft);
  background: rgba(15, 23, 42, 0.85);
  color: var(--erv-text-secondary);
}

.erv-badge--neutral {
  border-color: rgba(148, 163, 184, 0.35);
}

.erv-badge--info {
  border-color: rgba(96, 165, 250, 0.45);
  color: #bfdbfe;
}

.erv-badge--success {
  border-color: rgba(22, 163, 74, 0.45);
  color: #bbf7d0;
}

.erv-badge--warn {
  border-color: rgba(245, 158, 11, 0.45);
  color: #fde68a;
}

.erv-badge--risk {
  border-color: rgba(239, 68, 68, 0.5);
  color: #fecaca;
}

/* -------------------------------------------------------------------------- */
/* Buttons                                                                    */
/* -------------------------------------------------------------------------- */

.erv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: var(--erv-radius-pill);
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.92);
  color: #e0f2fe;
  font-family: var(--erv-font-sans);
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.erv-btn:hover {
  border-color: rgba(23, 215, 230, 0.45);
}

.erv-btn:focus-visible {
  outline: none;
  box-shadow: var(--erv-focus-ring);
}

.erv-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.erv-btn--primary {
  border-color: rgba(23, 215, 230, 0.55);
  background: linear-gradient(135deg, var(--erv-brand-muted), rgba(15, 23, 42, 0.92));
  box-shadow: 0 0 0 1px rgba(23, 215, 230, 0.15);
}

.erv-btn--ghost {
  background: transparent;
  border-color: var(--erv-line);
}

.erv-btn--sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
}

.erv-btn--lg {
  padding: 0.65rem 1.2rem;
  font-size: 0.95rem;
}

/* -------------------------------------------------------------------------- */
/* Readiness check-in — likert ticks (shared gate + legacy pattern)           */
/* -------------------------------------------------------------------------- */

.erv-likert-card {
  padding: var(--erv-space-3);
  border: 1px solid var(--erv-line);
  border-radius: var(--erv-radius-md);
  background: var(--erv-bg-deep);
}

.erv-likert-card strong {
  font-size: 0.9rem;
  color: var(--erv-text);
  font-weight: 700;
}

.erv-likert-card p.sub,
.likert-card.erv-likert-card p.sub {
  margin: 0.15rem 0 0.4rem;
  font-size: 0.8rem;
  color: var(--erv-muted);
}

.erv-likert-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
  margin: 0.4rem 0 0.25rem;
}

.erv-likert-scale--kss {
  grid-template-columns: repeat(3, 1fr);
}

@media (min-width: 720px) {
  .erv-likert-scale--kss {
    grid-template-columns: repeat(9, 1fr);
  }
}

.erv-likert-tick {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 0.35rem 0.25rem;
  border-radius: var(--erv-radius-sm);
  background: var(--erv-panel);
  border: 1px solid var(--erv-line);
  font-size: 0.78rem;
  color: var(--erv-text-secondary);
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition:
    background 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease,
    transform 0.12s ease;
}

.erv-likert-tick:hover {
  border-color: rgba(148, 163, 184, 0.45);
  color: var(--erv-text);
}

.erv-likert-tick span.num {
  font-weight: 800;
  display: block;
  margin-bottom: 2px;
  font-size: 0.85rem;
}

.erv-likert-tick small {
  font-size: 0.65rem;
  line-height: 1.2;
  display: block;
}

/* Selected: brand teal emphasis */
.erv-likert-tick.active {
  box-shadow: 0 0 0 2px var(--erv-brand), 0 4px 16px rgba(0, 167, 184, 0.35);
  border-color: var(--erv-brand-strong);
  color: #f0fdfa;
  transform: scale(1.02);
  z-index: 1;
}

/* KSS bands: green 1–3, amber 4–6, red 7–9 (idle state) */
.erv-kss-scale .erv-likert-tick[data-val="1"],
.erv-kss-scale .erv-likert-tick[data-val="2"],
.erv-kss-scale .erv-likert-tick[data-val="3"] {
  background: rgba(22, 163, 74, 0.22);
  border-color: rgba(34, 197, 94, 0.45);
  color: #bbf7d0;
}

.erv-kss-scale .erv-likert-tick[data-val="4"],
.erv-kss-scale .erv-likert-tick[data-val="5"],
.erv-kss-scale .erv-likert-tick[data-val="6"] {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fde68a;
}

.erv-kss-scale .erv-likert-tick[data-val="7"],
.erv-kss-scale .erv-likert-tick[data-val="8"],
.erv-kss-scale .erv-likert-tick[data-val="9"] {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(248, 113, 113, 0.55);
  color: #fecaca;
}

/* Selected KSS tick: teal emphasis overrides band tint */
.erv-kss-scale .erv-likert-tick.active {
  background: linear-gradient(145deg, rgba(0, 167, 184, 0.42), rgba(14, 116, 144, 0.58)) !important;
  border-color: var(--erv-brand-strong) !important;
  color: #f0fdfa !important;
}

.erv-readiness-likerts-wrap {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.erv-kss-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--erv-muted);
  margin-bottom: 0.25rem;
}

.erv-kss-legend {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--erv-muted);
}

.erv-kss-warning {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: #fecaca;
  line-height: 1.4;
}

.erv-readiness-region-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.erv-readiness-region-chip {
  min-height: 44px;
  padding: 0.45rem 0.75rem;
  border-radius: var(--erv-radius-pill);
  border: 1px solid var(--erv-line);
  background: var(--erv-bg-deep);
  color: var(--erv-text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.erv-readiness-region-chip.is-on {
  border-color: rgba(245, 158, 11, 0.75);
  background: rgba(217, 119, 6, 0.22);
  color: #fef3c7;
}

.erv-readiness-region-none {
  border-style: dashed;
}

.erv-readiness-submit {
  width: 100%;
  min-height: 48px;
  margin-top: 1rem;
  padding: 0.65rem 1rem;
  border-radius: var(--erv-radius-md);
  border: none;
  font-weight: 800;
  font-size: 1rem;
  font-family: var(--erv-font-sans);
  cursor: pointer;
  background: linear-gradient(135deg, var(--erv-brand), #0e7490);
  color: #f0fdfa;
  box-shadow: 0 4px 20px rgba(0, 167, 184, 0.3);
}

.erv-readiness-submit:hover:not(:disabled) {
  filter: brightness(1.06);
}

.erv-readiness-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* After successful same-day submission — prevents accidental double POST via history/back */
.readiness-v2.erv-readiness-submitted {
  border-color: rgba(34, 197, 94, 0.28);
}

.readiness-v2.erv-readiness-submitted .erv-readiness-submit {
  cursor: not-allowed;
}
