/* ==========================================================================
   Inteligência artificial — painel demonstrativo com 3 recursos
   (busca inteligente, distribuição de carga horária, assistente de comunicados).
   Dados fictícios; nenhuma chamada a APIs de IA (especificação, 23.3).
   ========================================================================== */

.ai {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  color: #fff;
  background: var(--deep-800);
}

/* ---------- Fundo ---------- */
.ai-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.ai-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
}

.ai-glow--1 {
  top: -18%;
  left: -10%;
  width: 55vw;
  height: 55vw;
  max-width: 760px;
  max-height: 760px;
  background: #235c8f;
}

.ai-glow--2 {
  right: -12%;
  bottom: -25%;
  width: 45vw;
  height: 45vw;
  max-width: 640px;
  max-height: 640px;
  background: #4a3f7d;
  opacity: 0.45;
}

.ai-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 35%, #000 20%, transparent 70%);
  mask-image: radial-gradient(ellipse at 50% 35%, #000 20%, transparent 70%);
}

.ai-inner {
  display: grid;
  gap: clamp(36px, 5vw, 56px);
  padding-block: clamp(72px, 10vw, 128px);
}

/* ---------- Cabeçalho ---------- */
.ai-head {
  display: grid;
  justify-items: center;
  gap: 16px;
  max-width: 820px;
  margin-inline: auto;
  text-align: center;
}

.ai .eyebrow {
  color: var(--brand-orange);
}

.ai-head h2 {
  color: #fff;
}

.ai-head h2 em {
  font-style: normal;
  background: linear-gradient(90deg, #8cc8f5, var(--brand-orange));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.ai-head p {
  max-width: 38em;
  font-size: 1.0625rem;
  color: #c3d7ea;
}

/* ---------- Layout ---------- */
.ai-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 0.75fr);
  gap: clamp(20px, 3vw, 36px);
  align-items: start;
  perspective: 1600px;
}

/* ---------- Painel ---------- */
.ai-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 700px;
  border-radius: 26px;
  background: #fff;
  color: var(--ink);
  /* Sem pseudo-elemento de brilho: com transform (GSAP) ele ficaria por cima do fundo. */
  box-shadow: 0 50px 120px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 80px rgba(140, 200, 245, 0.16);
  transform-origin: 50% 0;
}

.ai-panel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid #e6eef6;
  font-weight: 700;
  font-size: 0.875rem;
}

.ai-panel-top > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ai-panel-top svg {
  width: 16px;
  height: 16px;
  color: var(--brand-orange);
}

.ai-tag {
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff4e3;
  color: #9a5b00;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* Abas */
.ai-tabs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 16px 22px 0;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-2);
}

.ai-tabs button {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 10px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-2);
  font: 600 0.875rem/1.2 var(--f-body);
  cursor: pointer;
  transition: color 0.3s;
}

.ai-tabs button svg {
  flex: none;
  width: 16px;
  height: 16px;
}

.ai-tabs button[aria-selected="true"] {
  color: var(--action);
}

.ai-tabs-ink {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 3);
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(20, 52, 86, 0.1);
  transform: translateX(calc(var(--tab, 0) * 100%));
  transition: transform 0.5s var(--ease-out);
}

/* Painéis das abas */
.ai-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 22px 24px;
}

.js .ai-pane:not(.is-active) {
  display: none;
}

.ai-pane.is-entering {
  animation: ai-pane-in 0.5s var(--ease-out);
}

@keyframes ai-pane-in {
  from { opacity: 0; transform: translateY(10px); }
}

/* Campo de pergunta (visual: as perguntas vêm dos exemplos) */
.ai-prompt {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 8px 8px 16px;
  border-radius: 16px;
  border: 1.5px solid #d4e4f2;
  background: #fff;
  box-shadow: 0 8px 24px rgba(20, 52, 86, 0.06);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.ai-prompt.is-typing {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 4px rgba(83, 160, 221, 0.15);
}

.ai-prompt > svg {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--brand-orange);
}

.ai-prompt-text {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}

.ai-caret {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin-left: 2px;
  vertical-align: -3px;
  background: var(--action);
  opacity: 0;
}

.is-typing .ai-caret {
  opacity: 1;
  animation: ai-blink 0.8s steps(1) infinite;
}

@keyframes ai-blink {
  50% { opacity: 0; }
}

.ai-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--action);
  color: #fff;
  transition: transform 0.3s var(--ease-out), background 0.3s;
}

.ai-send svg {
  width: 17px;
  height: 17px;
}

.ai-prompt.is-sent .ai-send {
  animation: ai-send 0.5s var(--ease-out);
}

@keyframes ai-send {
  40% { transform: translateX(4px) scale(0.9); background: var(--brand-orange); }
}

/* Exemplos */
.ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-chips button {
  padding: 8px 13px;
  border: 1px solid #cfe0ef;
  border-radius: 999px;
  background: #fff;
  color: var(--action);
  font: 600 0.8125rem/1.25 var(--f-body);
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
}

.ai-chips button:hover {
  border-color: var(--brand-blue);
  background: #f1f8fe;
  transform: translateY(-1px);
}

.ai-chips button[aria-pressed="true"] {
  border-color: var(--action);
  background: var(--action);
  color: #fff;
}

/* Resposta */
.ai-out {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: 16px;
  background: linear-gradient(180deg, #f3f8fd, #eef5fc);
}

.ai-thinking {
  display: none;
  align-items: center;
  gap: 5px;
  color: var(--ink-3);
  font-size: 0.8125rem;
}

.ai-thinking span {
  margin-left: 6px;
}

.ai-thinking i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-blue);
  animation: ai-dot 1s infinite;
}

.ai-thinking i:nth-child(2) { animation-delay: 0.15s; }
.ai-thinking i:nth-child(3) { animation-delay: 0.3s; }

@keyframes ai-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.ai-out.is-thinking .ai-thinking {
  display: flex;
}

.ai-out.is-thinking .ai-text,
.ai-out.is-thinking .ai-result,
.ai-out.is-thinking .ai-source {
  display: none;
}

.ai-text {
  min-height: 3.2em;
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.6;
}

.ai-source {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: auto 0 0;
  font-size: 0.75rem;
  color: var(--ink-3);
  transition: opacity 0.4s;
}

.ai-source svg {
  width: 13px;
  height: 13px;
}

.ai-out.is-streaming .ai-source {
  opacity: 0;
}

/* Resultados */
.ai-result > * {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
}

.ai-result.is-in > * {
  opacity: 1;
  transform: none;
}

.ai-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 6px;
  font-size: 0.875rem;
}

.ai-table th {
  padding: 0 12px 2px;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.ai-table td {
  padding: 10px 12px;
  background: #fff;
}

.ai-table td:first-child {
  border-radius: 10px 0 0 10px;
  font-weight: 600;
}

.ai-table td:last-child {
  border-radius: 0 10px 10px 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ai-table tbody tr {
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.45s var(--ease-out), transform 0.45s var(--ease-out);
  transition-delay: calc(var(--i) * 0.09s + 0.1s);
}

.ai-result.is-in .ai-table tbody tr {
  opacity: 1;
  transform: none;
}

.ai-meter {
  display: inline-block;
  width: 64px;
  height: 6px;
  margin-right: 10px;
  border-radius: 3px;
  background: #fde7c6;
  vertical-align: middle;
  overflow: hidden;
}

.ai-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f0a23a, #e3762a);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.9s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 0.09s + 0.3s);
}

.ai-result.is-in .ai-meter i {
  transform: scaleX(var(--p));
}

.ai-table tr:nth-child(1) .ai-meter i { --i: 0; }
.ai-table tr:nth-child(2) .ai-meter i { --i: 1; }
.ai-table tr:nth-child(3) .ai-meter i { --i: 2; }
.ai-table tr:nth-child(4) .ai-meter i { --i: 3; }

.ai-stat {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.ai-stat strong {
  font: 800 3.4rem/1 var(--f-display);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--action);
}

.ai-stat span {
  color: var(--ink-2);
}

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

.ai-bars li {
  display: grid;
  grid-template-columns: 8.5em 1fr auto;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
}

.ai-bars span {
  font-weight: 600;
}

.ai-bars b {
  min-width: 5.5em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ai-bars i {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--brand-blue), #3d8ccc);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 1s var(--ease-out);
  transition-delay: calc(var(--i) * 0.1s + 0.15s);
}

.ai-bars--alert i {
  background: linear-gradient(90deg, #f6c46c, #e3762a);
}

.ai-result.is-in .ai-bars i {
  transform: scaleX(var(--p));
}

/* ---------- Carga horária ---------- */
.ai-pane-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.ai-pane-head > div {
  display: grid;
  gap: 2px;
}

.ai-pane-head span {
  font-size: 0.8125rem;
  color: var(--ink-3);
}

.ai-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--action);
  color: #fff;
  font: 600 0.875rem/1 var(--f-body);
  cursor: pointer;
  transition: background 0.25s, transform 0.25s var(--ease-out), box-shadow 0.25s;
}

.ai-action svg {
  width: 15px;
  height: 15px;
  color: var(--brand-orange);
}

.ai-action:hover {
  background: var(--action-hover);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(33, 108, 169, 0.28);
}

.ai-action:disabled {
  opacity: 0.6;
  cursor: progress;
  transform: none;
  box-shadow: none;
}

.ai-sched {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface-2);
}

.ai-sched-row {
  display: grid;
  grid-template-columns: 3.4em repeat(5, minmax(0, 1fr));
  gap: 6px;
  align-items: center;
}

.ai-sched-row small {
  font-size: 0.6875rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.ai-sched-row--head span {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-2);
}

.ai-cell {
  --c: #dbe7f2;
  --t: var(--ink-2);
  display: grid;
  place-items: center;
  height: 40px;
  border-radius: 9px;
  background: var(--c);
  color: var(--t);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: background-color 0.3s, color 0.3s, box-shadow 0.3s;
}

.ai-cell[data-s="MAT"] { --c: #d6eafb; --t: #1d5f95; }
.ai-cell[data-s="POR"] { --c: #fdeacb; --t: #8a5200; }
.ai-cell[data-s="CIE"] { --c: #d7f1e4; --t: #17734b; }
.ai-cell[data-s="HIS"] { --c: #e7e1f7; --t: #54408f; }
.ai-cell[data-s="GEO"] { --c: #d5f0f2; --t: #156a72; }
.ai-cell[data-s="ING"] { --c: #fbdfe3; --t: #9a2f45; }
.ai-cell[data-s="EDF"] { --c: #e4eccf; --t: #556b14; }
.ai-cell[data-s="ART"] { --c: #f6e2f1; --t: #8b2f78; }

.ai-cell.is-empty {
  background: #fff;
  color: transparent;
  box-shadow: inset 0 0 0 1.5px #dfe8f1;
}

.ai-cell.is-placed {
  animation: ai-pop 0.45s var(--ease-out);
}

@keyframes ai-pop {
  from { transform: scale(0.6); opacity: 0; }
}

.ai-cell.is-conflict {
  background: #fff;
  color: #c2410c;
  box-shadow: inset 0 0 0 2px #f97316, 0 0 0 4px rgba(249, 115, 22, 0.15);
  animation: ai-shake 0.45s;
}

@keyframes ai-shake {
  20%, 60% { transform: translateX(-3px); }
  40%, 80% { transform: translateX(3px); }
}

.ai-cell.is-fixed {
  box-shadow: 0 0 0 3px rgba(31, 138, 91, 0.35);
}

.ai-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 1.6em;
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-2);
}

.ai-status svg {
  flex: none;
  width: 16px;
  height: 16px;
  opacity: 0;
}

.ai-status.is-done {
  color: var(--ok);
}

.ai-status.is-done svg {
  opacity: 1;
}

.ai-status.is-warn {
  color: #c2410c;
}

/* ---------- Comunicados ---------- */
.ai-letter {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #e3edf5;
  box-shadow: 0 12px 30px rgba(20, 52, 86, 0.07);
}

.ai-letter header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.ai-letter header b {
  font-family: var(--f-display);
  font-size: 1.125rem;
}

.ai-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 0.6875rem;
  font-weight: 700;
}

.ai-pill.is-writing {
  background: #fff4e3;
  color: #9a5b00;
}

.ai-letter p {
  min-height: 7.5em;
  margin: 0;
  color: var(--ink);
}

.ai-letter footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px dashed #dfe8f1;
}

.ai-letter footer > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-2);
}

.ai-letter footer svg {
  width: 13px;
  height: 13px;
}

.ai-note {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--ink-3);
}

/* ---------- Garantias ---------- */
.ai-trust {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  display: grid;
  gap: 18px;
  padding: 28px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.ai-trust h3 {
  color: #fff;
}

.ai-trust ul {
  display: grid;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ai-trust li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
}

.ai-trust b {
  color: #fff;
}

.ai-trust li p {
  margin: 2px 0 0;
  font-size: 0.875rem;
  line-height: 1.55;
  color: #b4c9dd;
}

.ai-trust-ico {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(83, 160, 221, 0.16);
  color: #8cc8f5;
}

.ai-trust-ico svg {
  width: 19px;
  height: 19px;
}

.ai-trust-foot {
  margin: 4px 0 0;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.8125rem;
  color: #9fb6cc;
}

/* ---------- Responsivo ---------- */
@media (max-width: 1000px) {
  .ai-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .ai-trust {
    position: static;
  }

  .ai-trust ul {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .ai-panel {
    min-height: 0;
    border-radius: 20px;
  }

  .ai-tabs,
  .ai-pane,
  .ai-panel-top {
    margin-inline: 0;
    padding-inline: 14px;
  }

  .ai-tabs {
    margin: 12px 14px 0;
    padding: 4px;
  }

  .ai-tabs button {
    flex-direction: column;
    gap: 3px;
    min-height: 52px;
    font-size: 0.75rem;
  }

  .ai-tag {
    font-size: 0.625rem;
  }

  .ai-out,
  .ai-letter {
    padding: 14px;
  }

  .ai-table td,
  .ai-table th {
    padding-inline: 8px;
  }

  .ai-meter {
    display: none;
  }

  .ai-bars li {
    grid-template-columns: 6.5em 1fr auto;
    gap: 8px;
  }

  .ai-sched {
    padding: 8px;
    gap: 4px;
  }

  .ai-sched-row {
    grid-template-columns: 2.8em repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .ai-cell {
    height: 32px;
    font-size: 0.625rem;
  }

  .ai-trust ul {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-tabs-ink,
  .ai-result > *,
  .ai-table tbody tr,
  .ai-meter i,
  .ai-bars i {
    transition: none;
  }

  .ai-pane.is-entering,
  .ai-cell.is-placed,
  .ai-cell.is-conflict,
  .ai-prompt.is-sent .ai-send,
  .ai-thinking i,
  .is-typing .ai-caret {
    animation: none;
  }
}

/* A grade ocupa a altura disponível do painel (mesma altura nas três abas) */
.ai-sched {
  flex: 1;
  grid-template-rows: auto repeat(5, minmax(40px, 1fr));
}

.ai-sched-row {
  align-items: stretch;
}

.ai-sched-row small,
.ai-sched-row--head span {
  align-self: center;
}

.ai-cell {
  height: auto;
  min-height: 32px;
}
