/* Story 139 — Página Análise IA */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ai-page {
  min-width: 0;
}

.ai-page__body.panel {
  padding: 1.15rem 1.25rem 1.35rem;
}

.ai-page__privacy {
  margin: 0.75rem 0 0;
  font-size: 0.8125rem;
  color: var(--color-muted, #64748b);
  line-height: 1.45;
}

.ai-intro {
  margin-top: 0;
}

.ai-intro__title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
}

.ai-intro__desc {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-muted, #64748b);
  line-height: 1.5;
  max-width: 42rem;
}

.ai-intents__title {
  margin: 1.25rem 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.ai-intents__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

@media (min-width: 768px) {
  .ai-intents__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
  }
}

.ai-intent-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: var(--radius, 8px);
  background: var(--surface, #fff);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-width: 0;
}

.ai-intent-card:hover {
  border-color: var(--accent, #2563eb);
}

.ai-intent-card:focus-visible {
  outline: 2px solid var(--accent, #2563eb);
  outline-offset: 2px;
}

.ai-intent-card--selected {
  border-color: var(--accent, #2563eb);
  box-shadow: 0 0 0 1px var(--accent, #2563eb);
  background: #f8fbff;
}

.ai-intent-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
  flex-shrink: 0;
}

.ai-intent-card--selected .ai-intent-card__icon {
  background: #dbeafe;
  color: #1d4ed8;
}

.ai-intent-card__svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

.ai-intent-card__title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: inherit;
}

.ai-intent-card__subtitle {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--color-muted, #64748b);
  line-height: 1.35;
}

.ai-question {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border, #e2e8f0);
}

.ai-question__title {
  margin: 0 0 0.65rem;
  font-size: 1rem;
  font-weight: 600;
}

.ai-question__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: stretch;
}

.ai-question__input {
  flex: 1 1 14rem;
  min-width: 0;
}

.ai-question__actions {
  display: flex;
  align-items: stretch;
}

.ai-result-panel {
  margin-top: 1.25rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius, 8px);
  background: #f8fafc;
  border: 1px solid var(--color-border, #e2e8f0);
}

.ai-result-panel__title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text, #0f172a);
}

.ai-result-panel__body {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-muted, #64748b);
  line-height: 1.5;
}

.ai-answer-card {
  margin-top: 0.35rem;
}

.ai-answer-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.ai-answer-card__summary,
.ai-history__summary {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  color: var(--color-muted, #64748b);
  line-height: 1.45;
}

.ai-answer-card__body {
  font-size: 0.875rem;
  color: var(--color-text, #0f172a);
  line-height: 1.55;
}

.ai-collapse-toggle {
  flex-shrink: 0;
  font-size: 0.8125rem;
  color: var(--color-muted, #64748b);
}

.ai-md p,
.ai-md__p {
  margin: 0 0 0.75rem;
}

.ai-md p:last-child,
.ai-md__p:last-child {
  margin-bottom: 0;
}

.ai-md__h {
  margin: 0.85rem 0 0.35rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text, #0f172a);
}

.ai-md__h:first-child {
  margin-top: 0;
}

.ai-md strong {
  font-weight: 600;
}

.ai-md em {
  font-style: italic;
}

.ai-md__ul,
.ai-md__ol {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
}

.ai-md__ul li,
.ai-md__ol li {
  margin: 0.25rem 0;
}

.ai-md__pre {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.75rem;
  overflow-x: auto;
  font-size: 0.8125rem;
  background: #f1f5f9;
  border-radius: var(--radius, 8px);
}

.ai-md__table-wrap {
  overflow-x: auto;
  margin: 0 0 0.75rem;
}

.ai-md__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.ai-md__table th,
.ai-md__table td {
  border: 1px solid var(--color-border, #e2e8f0);
  padding: 0.35rem 0.5rem;
  text-align: left;
}

.ai-md__table th {
  background: #f1f5f9;
  font-weight: 600;
}

.ai-loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  font-size: 0.875rem;
  color: var(--color-muted, #64748b);
}

.ai-loading__spinner {
  width: 0.875rem;
  height: 0.875rem;
  border: 2px solid #cbd5e1;
  border-top-color: #64748b;
  border-radius: 50%;
  animation: ai-spin 0.8s linear infinite;
}

@keyframes ai-spin {
  to { transform: rotate(360deg); }
}

.ai-loading[hidden] {
  display: none !important;
}

.ai-empty {
  margin-top: 1.25rem;
}

.ai-data-used {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: var(--radius, 8px);
  background: #f8fafc;
}

.ai-data-used__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0;
}

.ai-data-used.is-expanded .ai-data-used__head {
  margin-bottom: 0.65rem;
}

.ai-data-used__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.15rem 0.35rem;
}

.ai-data-used__summary {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--color-muted, #64748b);
  line-height: 1.45;
}

.ai-data-used.is-expanded .ai-data-used__summary[hidden] {
  display: none;
}

.ai-data-used__title {
  margin: 0;
  font-size: 0.95rem;
}

.ai-data-used__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ai-data-used__item {
  display: grid;
  grid-template-columns: 1.25rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.25rem 0;
  font-size: 0.875rem;
  color: var(--color-muted, #64748b);
}

.ai-data-used__item--on {
  color: inherit;
}

.ai-data-used__check {
  font-weight: 700;
}

.ai-data-used__level {
  font-size: 0.75rem;
  color: var(--color-muted, #64748b);
}

.ai-data-analyzed {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--color-primary, #2563eb);
  background: #f0f9ff;
  border-radius: 0 var(--radius, 8px) var(--radius, 8px) 0;
}

.ai-data-analyzed__title {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.ai-data-analyzed__list {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.8125rem;
  color: var(--color-muted, #64748b);
}

.ai-usage-bar {
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--color-muted, #64748b);
  background: #f8fafc;
  border-radius: var(--radius, 8px);
}

.ai-history {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border, #e2e8f0);
}

.ai-history__title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.ai-history__empty {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-muted, #64748b);
}

.ai-history__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ai-history__item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border, #e2e8f0);
}

.ai-history__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.35rem;
}

.ai-history__question {
  flex: 1 1 12rem;
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
}

.ai-history__aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  flex-shrink: 0;
}

.ai-history__date {
  font-size: 0.75rem;
  color: var(--color-muted, #64748b);
  white-space: nowrap;
}

.ai-history__toggle {
  flex-shrink: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-primary, #2563eb);
  border: 1px solid var(--color-primary, #2563eb);
  border-radius: var(--radius, 8px);
  padding: 0.2rem 0.65rem;
  background: rgba(37, 99, 235, 0.06);
}

.ai-history__toggle:hover:not(:disabled) {
  background: rgba(37, 99, 235, 0.12);
}

.ai-history__toggle:disabled {
  opacity: 0.6;
  cursor: wait;
}

.ai-history__body {
  margin-bottom: 0.35rem;
}

.ai-history__loading {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  color: var(--color-muted, #64748b);
  font-style: italic;
}

.ai-history__full {
  margin-top: 0.25rem;
}

.ai-history__footer {
  display: flex;
  justify-content: flex-end;
}

.ai-history__delete {
  font-size: 0.75rem;
  color: var(--color-muted, #64748b);
}
