/* ═══════════════════════════════════════════════════════════════════════════
   FIDELIS UI — camada de tema sobre o Filament
   Aplica a linguagem visual do template (§7) ao painel.
   Sem build step: CSS puro com custom properties (ADR-0003).
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('./fidelis-tokens.css');

/* ── Tipografia auto-hospedada (lacuna L6 do doc 01) ───────────────────── */
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fidelis/fonts/inter-400-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fidelis/fonts/inter-500-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fidelis/fonts/space-600-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/fidelis/fonts/space-700-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fidelis/fonts/jetbrains-400-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fidelis/fonts/jetbrains-500-latin.woff2') format('woff2');
}

/* O Filament alterna tema pela classe .fi-theme-dark/.fi-theme-light no <html>.
   Espelhamos em data-theme para os tokens do Fidelis UI responderem junto. */
html.dark { color-scheme: dark; }

/* ── Marca na sidebar ──────────────────────────────────────────────────── */
.fi-logo {
  font-family: var(--f-font-display);
  font-weight: 700;
  letter-spacing: -.02em;
  font-size: var(--f-t-lg);
}

/* ── Números sempre tabulares — funcional num painel de operação ───────── */
.fi-wi-stats-overview-stat-value,
.fi-ta-text-item-label,
.f-num,
.fi-badge {
  font-variant-numeric: tabular-nums;
}

.fi-wi-stats-overview-stat-value {
  font-family: var(--f-font-display);
  font-weight: 700;
  letter-spacing: -.035em;
}

/* ── Hover eleva, não desloca (padrão do template) ─────────────────────── */
.fi-section {
  transition: border-color var(--f-dur-slow) var(--f-ease),
              box-shadow   var(--f-dur-slow) var(--f-ease);
}
.fi-section:hover { box-shadow: var(--f-e2); }

/* ── Foco visível de verdade ───────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--f-brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ═══ Health Score — §16 e §17 ════════════════════════════════════════════ */
.f-health { display: flex; flex-direction: column; align-items: center; gap: var(--f-s-4); }

.f-health__gauge { position: relative; width: 148px; height: 148px; }
.f-health__gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.f-health__track {
  fill: none; stroke: currentColor; stroke-width: 9;
  opacity: .12;
}
.f-health__value {
  fill: none; stroke: var(--f-gauge-color); stroke-width: 9; stroke-linecap: round;
  transition: stroke-dasharray .6s var(--f-ease);
}
.f-health__readout {
  position: absolute; inset: 0;
  display: flex; align-items: baseline; justify-content: center; gap: 2px;
  flex-direction: row; font-family: var(--f-font-display);
  font-variant-numeric: tabular-nums;
}
.f-health__readout strong { font-size: 34px; font-weight: 700; letter-spacing: -.04em; line-height: 1; }
.f-health__readout span   { font-size: var(--f-t-sm); opacity: .55; }

.f-health__label {
  font-family: var(--f-font-display);
  font-weight: 600; font-size: var(--f-t-base); margin: 0;
}

.f-health__summary {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: var(--f-s-3); width: 100%; margin: 0;
  padding-top: var(--f-s-5); border-top: 1px solid var(--f-line);
}
.f-health__summary div { text-align: center; }
.f-health__summary dt {
  font-size: var(--f-t-xs); opacity: .65; margin-bottom: 2px;
}
.f-health__summary dd {
  margin: 0; font-family: var(--f-font-display); font-weight: 600;
  font-size: var(--f-t-lg); font-variant-numeric: tabular-nums;
}
.f-health__summary dd.f-warn   { color: var(--f-warning); }
.f-health__summary dd.f-danger { color: var(--f-danger); }

.f-health__breakdown { width: 100%; font-size: var(--f-t-sm); }
.f-health__breakdown summary {
  cursor: pointer; opacity: .7; padding: var(--f-s-2) 0;
  list-style: none; display: flex; align-items: center; gap: var(--f-s-2);
}
.f-health__breakdown summary::before { content: '▸'; transition: transform var(--f-dur); }
.f-health__breakdown[open] summary::before { transform: rotate(90deg); }
.f-health__breakdown summary::-webkit-details-marker { display: none; }
.f-health__breakdown ul { list-style: none; padding: var(--f-s-2) 0 0; margin: 0; }
.f-health__breakdown li {
  display: flex; justify-content: space-between;
  padding: 3px 0; font-size: var(--f-t-xs); opacity: .8;
}
.f-health__breakdown b { font-variant-numeric: tabular-nums; }

/* ═══ Attribution — §35, §36, §37 ═════════════════════════════════════════ */
.f-attribution {
  text-align: center;
  padding: var(--f-s-8) var(--f-s-7) var(--f-s-9);
  font-size: var(--f-t-sm);
  opacity: .62;
}
.f-attribution a {
  font-weight: 600;
  color: var(--f-brand);
  text-decoration: none;
}
.f-attribution a:hover { text-decoration: underline; }
.f-heart { color: var(--f-danger); }

/* ═══ Indicadores de domínio ══════════════════════════════════════════════ */
.f-mono {
  font-family: var(--f-font-mono);
  font-size: var(--f-t-xs);
  letter-spacing: -.01em;
}

/* Pílula de ambiente — §112, sempre visível */
.f-env {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--f-font-mono); font-size: var(--f-t-xs);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 3px 9px; border-radius: var(--f-r-full);
}
.f-env::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
}
.f-env--production { color: var(--f-env-production); background: var(--f-success-soft); }
.f-env--staging    { color: var(--f-env-staging);    background: var(--f-warning-soft); }
.f-env--dev        { color: var(--f-env-dev);        background: var(--f-info-soft); }

/* Indicador de destino de backup — local vs Drive */
.f-storage { display: inline-flex; align-items: center; gap: var(--f-s-2); }
.f-storage__dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.f-storage__dot--ok      { background: var(--f-success); }
.f-storage__dot--pending { background: var(--f-warning); }
.f-storage__dot--missing { background: var(--f-line-3); }

/* Pulso "ao vivo" — respeita prefers-reduced-motion via fidelis-tokens.css */
.f-live { display: inline-flex; align-items: center; gap: 5px; }
.f-live__dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--f-success);
  animation: f-pulse 1.9s infinite;
}
@keyframes f-pulse { 0%, 100% { opacity: 1 } 50% { opacity: .28 } }

/* ═══ Responsividade — lacuna L1 do doc 01 ════════════════════════════════
   O template escondia a sidebar abaixo de 960px sem substituto. O Filament já
   entrega drawer no mobile; aqui só garantimos que nada estoure a viewport.   */
@media (max-width: 640px) {
  .f-health__gauge { width: 124px; height: 124px; }
  .f-health__readout strong { font-size: 28px; }
  .fi-wi-stats-overview-stat-value { font-size: var(--f-t-xl); }
}

/* ═══ Layout de páginas customizadas ═════════════════════════════════════ */
.f-grid { display: grid; gap: var(--f-s-5); margin-bottom: var(--f-s-5); }
.f-grid--3 { grid-template-columns: repeat(3, 1fr); }
.f-grid--4 { grid-template-columns: repeat(4, 1fr); }
.f-span-2 { grid-column: span 2; }

@media (max-width: 1024px) {
  .f-grid--3, .f-grid--4 { grid-template-columns: repeat(2, 1fr); }
  .f-span-2 { grid-column: span 2; }
}
@media (max-width: 640px) {
  .f-grid--3, .f-grid--4 { grid-template-columns: 1fr; }
  .f-span-2 { grid-column: span 1; }
}

/* ── Pares rótulo/valor ────────────────────────────────────────────────── */
.f-kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--f-s-6); margin: 0; }
.f-kv--stack { grid-template-columns: 1fr; gap: var(--f-s-5); }
.f-kv dt { font-size: var(--f-t-xs); opacity: .6; margin-bottom: 3px; }
.f-kv dd { margin: 0; font-size: var(--f-t-base); font-weight: 500; }

/* ── Estatística isolada ───────────────────────────────────────────────── */
.f-stack { display: flex; flex-direction: column; gap: var(--f-s-7); }
.f-stat { display: flex; flex-direction: column; gap: 2px; }
.f-stat__value {
  font-family: var(--f-font-display); font-size: var(--f-t-2xl); font-weight: 700;
  letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums;
}
.f-stat__label { font-size: var(--f-t-sm); opacity: .6; }

/* ── Medidor de cota ───────────────────────────────────────────────────── */
.f-meter__bar {
  height: 6px; border-radius: 3px; overflow: hidden;
  background: color-mix(in srgb, currentColor 12%, transparent);
}
.f-meter__bar span {
  display: block; height: 100%; border-radius: 3px; background: var(--f-brand);
  transition: width .5s var(--f-ease);
}
.f-meter__label { font-size: var(--f-t-xs); opacity: .6; margin-top: var(--f-s-2); }

/* ── Chaves de configuração (§62) ──────────────────────────────────────── */
.f-toggles { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--f-s-2) var(--f-s-9); }
.f-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: var(--f-s-5);
  padding: var(--f-s-4) 0; font-size: var(--f-t-md);
  border-bottom: 1px solid var(--f-line);
}
.f-toggle__pill {
  font-family: var(--f-font-mono); font-size: var(--f-t-xs); font-weight: 500;
  padding: 3px 10px; border-radius: var(--f-r-full);
  background: color-mix(in srgb, currentColor 10%, transparent); opacity: .5;
}
.f-toggle__pill.is-on {
  background: var(--f-success-soft); color: var(--f-success); opacity: 1;
}
@media (max-width: 768px) { .f-toggles { grid-template-columns: 1fr; } }

/* ── Árvore de pastas ──────────────────────────────────────────────────── */
.f-tree {
  font-family: var(--f-font-mono); font-size: var(--f-t-sm); line-height: 1.75;
  margin: 0; white-space: pre; overflow-x: auto;
  padding: var(--f-s-6); border-radius: var(--f-r);
  background: color-mix(in srgb, currentColor 5%, transparent);
}

/* ── Texto auxiliar ────────────────────────────────────────────────────── */
.f-muted { font-size: var(--f-t-md); opacity: .6; }
.f-note {
  font-size: var(--f-t-sm); opacity: .65; line-height: 1.6;
  margin-top: var(--f-s-6); padding-top: var(--f-s-5);
  border-top: 1px solid var(--f-line);
}

/* ═══ Site Agent — §43 a §48 ══════════════════════════════════════════════ */
.f-mode {
  display: inline-block; font-family: var(--f-font-mono); font-size: var(--f-t-xs);
  font-weight: 500; letter-spacing: .1em; padding: 4px 10px;
  border-radius: var(--f-r-sm);
  background: var(--f-info-soft); color: var(--f-info);
}

.f-chat { display: flex; flex-direction: column; gap: var(--f-s-7); min-height: 220px; }
.f-chat__msg { display: flex; gap: var(--f-s-5); }
.f-chat__avatar {
  width: 30px; height: 30px; border-radius: var(--f-r-sm); flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--f-brand); color: var(--f-on-brand);
  font-family: var(--f-font-display); font-weight: 700; font-size: var(--f-t-md);
}
.f-chat__body { font-size: var(--f-t-md); line-height: 1.65; }

.f-chat__examples {
  display: flex; flex-direction: column; gap: var(--f-s-2);
  padding-top: var(--f-s-6); border-top: 1px solid var(--f-line);
}
.f-chat__examples-title {
  font-size: var(--f-t-xs); opacity: .55; margin-bottom: var(--f-s-2);
  text-transform: uppercase; letter-spacing: .08em; font-family: var(--f-font-mono);
}
.f-chat__example {
  text-align: left; font-size: var(--f-t-md); padding: var(--f-s-4) var(--f-s-5);
  border: 1px solid var(--f-line); border-radius: var(--f-r-sm);
  background: none; color: inherit; opacity: .55; cursor: not-allowed;
}

.f-chat__composer { display: flex; gap: var(--f-s-3); margin-top: var(--f-s-7); }
.f-chat__composer input {
  flex: 1; padding: var(--f-s-4) var(--f-s-5); font: inherit; font-size: var(--f-t-md);
  border: 1px solid var(--f-line-2); border-radius: var(--f-r-sm);
  background: transparent; color: inherit;
}
.f-chat__composer button {
  padding: var(--f-s-4) var(--f-s-7); font-size: var(--f-t-md); font-weight: 600;
  border: none; border-radius: var(--f-r-sm);
  background: var(--f-brand); color: var(--f-on-brand); opacity: .45;
}

.f-scopes { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--f-s-3); }
.f-scope {
  display: flex; align-items: center; gap: var(--f-s-3);
  padding: var(--f-s-4) var(--f-s-5); font-size: var(--f-t-sm);
  border: 1px solid var(--f-line); border-radius: var(--f-r-sm); opacity: .5;
}
.f-scope.is-on { opacity: 1; border-color: var(--f-line-2); }
.f-scope code { font-family: var(--f-font-mono); font-size: var(--f-t-xs); }
.f-scope__state { margin-left: auto; font-size: var(--f-t-xs); opacity: .6; }
.f-scope__dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.f-scope__dot--safe     { background: var(--f-success); }
.f-scope__dot--medium   { background: var(--f-warning); }
.f-scope__dot--critical { background: var(--f-danger); }
@media (max-width: 1024px) { .f-scopes { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .f-scopes { grid-template-columns: 1fr; } }

/* ═══ Tabela simples e consumo de IA ══════════════════════════════════════ */
.f-table { width: 100%; border-collapse: collapse; font-size: var(--f-t-md); }
.f-table th {
  text-align: left; padding: var(--f-s-3) var(--f-s-4);
  font-size: var(--f-t-xs); font-weight: 500; opacity: .55;
  border-bottom: 1px solid var(--f-line); white-space: nowrap;
}
.f-table td { padding: var(--f-s-4); border-bottom: 1px solid var(--f-line); }
.f-table tr:last-child td { border-bottom: none; }
.f-table .f-num { font-variant-numeric: tabular-nums; text-align: right; }

.f-model {
  display: flex; align-items: center; gap: var(--f-s-4);
  padding: var(--f-s-4) 0; border-bottom: 1px solid var(--f-line);
  font-size: var(--f-t-md);
}
.f-model code { font-family: var(--f-font-mono); font-size: var(--f-t-xs); }
.f-model span { margin-left: auto; opacity: .6; font-size: var(--f-t-sm); }
.f-model b { font-variant-numeric: tabular-nums; }

.f-guard { margin-top: var(--f-s-7); font-size: var(--f-t-md); }
.f-guard p { margin-bottom: var(--f-s-2); }

/* ═══ Decomposição do Health Score — §17 ══════════════════════════════════ */
.f-hb__score {
  font-family: var(--f-font-display); font-size: 40px; font-weight: 700;
  letter-spacing: -.045em; line-height: 1; font-variant-numeric: tabular-nums;
  margin-bottom: var(--f-s-6);
}
.f-hb__score small { font-size: var(--f-t-base); opacity: .5; font-weight: 500; }
.f-hb__list { list-style: none; padding: 0; margin: 0; }
.f-hb__row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px var(--f-s-4);
  padding: var(--f-s-3) 0; border-bottom: 1px solid var(--f-line);
  font-size: var(--f-t-sm);
}
.f-hb__row:last-child { border-bottom: none; }
.f-hb__row span { font-weight: 500; }
.f-hb__row em {
  grid-column: 1; font-style: normal; font-size: var(--f-t-xs); opacity: .55;
}
.f-hb__row b {
  grid-row: 1 / 3; grid-column: 2; align-self: center;
  font-variant-numeric: tabular-nums; font-size: var(--f-t-sm);
}
.f-hb__row--ok b       { color: var(--f-success); }
.f-hb__row--warning b  { color: var(--f-warning); }
.f-hb__row--critical b { color: var(--f-danger); }
