/* Story 154 — Assistente IA no Dashboard (modal central) */

.dash-ai-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.dash-ai-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.dash-ai-drawer {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 910;
  display: flex;
  flex-direction: column;
  width: min(920px, calc(100vw - 3rem));
  height: min(88vh, calc(100vh - 2rem));
  max-height: calc(100vh - 2rem);
  background: var(--surface, #fff);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: var(--radius, 8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  transform: translate(-50%, -48%) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.dash-ai-drawer.is-open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

body.dash-ai-open {
  overflow: hidden;
}

.dash-ai-drawer__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--color-border, #e2e8f0);
}

.dash-ai-drawer__brand {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
}

.dash-ai-drawer__icon {
  font-size: 1.35rem;
  line-height: 1;
}

.dash-ai-drawer__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.dash-ai-drawer__subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.8125rem;
  color: var(--color-muted, #64748b);
}

.dash-ai-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dash-ai-welcome {
  font-size: 0.875rem;
  color: var(--color-text, #0f172a);
  line-height: 1.5;
}

.dash-ai-suggestions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.dash-ai-suggestion {
  text-align: left;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: var(--radius, 8px);
  background: var(--surface-muted, #f8fafc);
  padding: 0.55rem 0.7rem;
  font-size: 0.8125rem;
  cursor: pointer;
}

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

.dash-ai-messages {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.dash-ai-msg {
  max-width: 85%;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.45;
}

.dash-ai-msg--user {
  align-self: flex-end;
  background: var(--accent, #2563eb);
  color: #fff;
}

.dash-ai-msg--assistant {
  align-self: flex-start;
  background: var(--surface-muted, #f1f5f9);
  color: var(--color-text, #0f172a);
}

.dash-ai-msg--assistant p {
  margin: 0 0 0.5rem;
}

.dash-ai-msg--assistant p:last-child {
  margin-bottom: 0;
}

.dash-ai-meta {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  font-size: 0.75rem;
}

.dash-ai-meta__label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--color-muted, #64748b);
}

.dash-ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.dash-ai-chip {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--color-border, #e2e8f0);
  font-size: 0.6875rem;
}

.dash-ai-chip--blocked {
  opacity: 0.65;
  text-decoration: line-through;
}

.dash-ai-ver-dados {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--accent, #2563eb);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

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

.dash-ai-error {
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius, 8px);
  background: #fef2f2;
  color: #991b1b;
  font-size: 0.8125rem;
}

.dash-ai-byok {
  padding: 0.85rem;
  border: 1px dashed var(--color-border, #e2e8f0);
  border-radius: var(--radius, 8px);
  font-size: 0.875rem;
}

.dash-ai-drawer__footer {
  border-top: 1px solid var(--color-border, #e2e8f0);
  padding: 0.75rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dash-ai-input-row {
  display: flex;
  gap: 0.45rem;
}

.dash-ai-input {
  flex: 1;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: var(--radius, 8px);
  padding: 0.55rem 0.65rem;
  font-size: 0.875rem;
}

.dash-ai-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.dash-ai-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 920;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.dash-ai-preview-modal[hidden] {
  display: none;
}

.dash-ai-preview-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
}

.dash-ai-preview-modal__panel {
  position: relative;
  width: min(100%, 360px);
  max-height: 80vh;
  overflow: auto;
  background: #fff;
  border-radius: var(--radius, 8px);
  padding: 1rem;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.15);
}

.dash-ai-preview-item {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--color-border, #e2e8f0);
  font-size: 0.8125rem;
}

.dash-ai-preview-item:last-child {
  border-bottom: none;
}

.dash-ai-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  padding: 0.55rem 1rem;
  border: 1px solid var(--accent, #2563eb);
  border-radius: 999px;
  background: linear-gradient(180deg, #fff 0%, #EDF4FF 100%);
  color: #1D4ED8;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.12), 0 4px 12px rgba(37, 99, 235, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dash-ai-open-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.18);
}

.dash-ai-open-btn__icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent, #2563eb);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  line-height: 1;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .dash-ai-open-btn__label {
    display: none;
  }

  .dash-ai-open-btn {
    padding: 0.55rem 0.7rem;
  }
}

.dash-head--with-ai {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

@media (max-width: 640px) {
  .dash-ai-drawer {
    width: calc(100vw - 1rem);
    height: calc(100vh - 1rem);
    max-height: calc(100vh - 1rem);
    border-radius: var(--radius, 8px);
  }
}
