/* Assistente Analitico (Fase 9): gaveta lateral + botoes "Analisar com IA". Reaproveita .badge, .primary-action/.secondary-action e as variaveis de tema. */

/* --- botoes --------------------------------------------------------------- */
.as-topbar-btn { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; margin-right: 10px; border: 1px solid var(--color-accent, #0e7c86); border-radius: 999px; background: var(--color-surface); color: var(--color-accent, #0e7c86); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.as-topbar-btn:hover { background: var(--color-accent-ring, rgba(14, 124, 134, 0.13)); }
.as-topbar-btn:focus-visible, .as-chip:focus-visible, .as-icon-btn:focus-visible, .as-open-btn:focus-visible { outline: 3px solid var(--color-accent-ring, #7cc3c9); outline-offset: 2px; }
.as-topbar-btn.is-hidden, .as-open-btn.is-hidden { display: none; }
.as-open-btn { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; align-self: flex-start; color: var(--color-accent, #0e7c86); border-color: var(--color-accent, #0e7c86); }
.panel-heading .as-open-btn + .panel-heading-actions, .panel-heading .panel-heading-actions + .as-open-btn { margin-left: 0; }

/* --- gaveta ---------------------------------------------------------------- */
body.as-open { overflow: hidden; }
.as-backdrop { position: fixed; inset: 0; z-index: 210; background: rgba(15, 23, 42, 0.4); }
.as-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 211; display: flex; flex-direction: column; width: min(540px, 100vw); background: var(--color-surface); border-left: 1px solid var(--color-border); box-shadow: -12px 0 32px rgba(15, 23, 42, 0.18); }
.as-backdrop.is-hidden, .as-drawer.is-hidden { display: none; }
.as-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 12px; border-bottom: 1px solid var(--color-border); }
.as-head h3 { margin: 0; font-size: 18px; }
.as-sub { margin: 2px 0 0; color: var(--color-muted); font-size: 13px; }
.as-sub:empty { display: none; }
.as-icon-btn { width: 36px; height: 36px; border: 1px solid var(--color-border); border-radius: 50%; background: var(--color-surface); color: var(--color-text); font-size: 22px; line-height: 1; cursor: pointer; }
.as-icon-btn:hover { background: var(--color-surface-soft, #f3f6f8); }
.as-body { flex: 1; overflow-y: auto; padding: 14px 18px 24px; display: grid; gap: 12px; align-content: start; }
.as-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.as-scope { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.as-scope label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--color-muted); min-width: 0; }
.as-scope select, .as-scope input { width: 100%; min-width: 0; }
.as-scope.is-hidden, .as-form.is-hidden, .as-history-tools.is-hidden, #as-company-wrap.is-hidden { display: none; }

.as-shortcuts { display: flex; flex-wrap: wrap; gap: 8px; }
.as-shortcuts:empty { display: none; }
.as-chip { padding: 7px 12px; border: 1px solid var(--color-border-strong, #cbd5e1); border-radius: 999px; background: var(--color-surface-soft, #f3f6f8); color: var(--color-text); font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.as-chip:hover:not(:disabled) { border-color: var(--color-accent, #0e7c86); background: var(--color-accent-ring, rgba(14, 124, 134, 0.13)); }
.as-chip:disabled { opacity: 0.55; cursor: not-allowed; }

.as-form { display: flex; gap: 8px; }
.as-form input { flex: 1; min-width: 0; }
.as-hint, .as-fine { margin: 0; color: var(--color-muted); font-size: 12px; }

/* --- resultado ------------------------------------------------------------- */
.as-result:empty { display: none; }
.as-loading { display: flex; align-items: center; gap: 10px; padding: 16px; border: 1px dashed var(--color-border-strong, #cbd5e1); border-radius: 12px; color: var(--color-muted); }
.as-spinner { width: 18px; height: 18px; border: 3px solid var(--color-border); border-top-color: var(--color-accent, #0e7c86); border-radius: 50%; animation: as-spin 0.8s linear infinite; }
@keyframes as-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .as-spinner { animation-duration: 2.4s; } }

.as-state { padding: 14px 16px; border-radius: 12px; border: 1px solid var(--color-border); background: var(--color-surface-soft, #f3f6f8); }
.as-state p { margin: 6px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.as-state-error { background: #fdf0ee; border-color: #f0c2bb; color: #7a1f14; }
.as-state .as-shortcuts, .as-state .as-actions { margin-top: 10px; }

.as-answer { display: grid; gap: 12px; padding: 14px 16px; border: 1px solid var(--color-border); border-radius: 12px; background: var(--color-surface); }
.as-answer > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.as-answer h4 { margin: 0; font-size: 16px; }
.as-answer h5 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-muted); }
.as-summary { margin: 0; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.as-note { margin: 0; padding: 8px 12px; border-radius: 10px; background: #fff8e6; border: 1px solid #f5d9a0; color: #7a4a00; font-size: 13px; }
.as-answer.is-empty .as-summary { color: var(--color-muted); }

.as-evidence { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.as-ev { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--color-border); border-left-width: 4px; border-radius: 10px; background: var(--color-surface-soft, #f3f6f8); min-width: 0; }
.as-ev-label { font-size: 12px; color: var(--color-muted); overflow-wrap: anywhere; }
.as-ev-value { font-size: 17px; overflow-wrap: anywhere; }
.as-ev-detail { font-size: 12px; color: var(--color-text-soft, #334155); overflow-wrap: anywhere; }
.as-tone-good { border-left-color: var(--color-success, #1f8a4c); }
.as-tone-warn { border-left-color: var(--color-warning, #b7791f); }
.as-tone-bad { border-left-color: var(--color-danger, #c0392b); }
.as-tone-neutral { border-left-color: var(--color-border-strong, #cbd5e1); }

.as-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; overflow-wrap: anywhere; }
.as-limits .as-list { color: var(--color-text-soft, #334155); }
.as-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.as-source summary, .as-history summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--color-accent, #0e7c86); }
.as-source[open] summary, .as-history[open] summary { margin-bottom: 8px; }

/* --- historico ------------------------------------------------------------- */
.as-history { padding-top: 8px; border-top: 1px solid var(--color-border); }
.as-check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 8px; }
.as-h-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.as-h-item { display: grid; gap: 2px; padding: 8px 10px; border: 1px solid var(--color-border); border-radius: 10px; }
.as-h-item > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.as-h-item small { color: var(--color-muted); }
.as-h-q { overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .as-topbar-btn { margin-right: 6px; padding: 0; width: 40px; justify-content: center; }
  .as-topbar-btn span { display: none; }
  .as-drawer { width: 100vw; border-left: 0; }
  .as-scope label:nth-child(-n+2) { grid-column: 1 / -1; }
  .as-evidence { grid-template-columns: 1fr 1fr; }
  .as-form { flex-direction: column; }
  .as-open-btn { margin-left: 0; }
}
@media (max-width: 480px) { .as-evidence { grid-template-columns: 1fr; } }
