/* ========================================
   STORICA AI CHAT nas telas novas (Carteira e Cliente)
   Regras copiadas de storica.css, com as variáveis apontando para a IDV.
   ======================================== */
:root, .sx {
  --bg-input: #FFFFFF; --bg-surface: #FFFFFF; --border-subtle: #DBDBDB;
  --color-accent: #FF6F5E; --color-coral-dark: #E85A4A; --color-positive: #1B7A3D;
  --font-body: 'Open Sans', sans-serif; --font-display: 'Roboto Condensed', sans-serif;
  --hover-overlay: rgba(32, 32, 32, 0.06); --radius-lg: 12px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --text-base: 14px; --text-sm: 13px; --text-muted: #666666; --text-primary: #202020;
}
/* ========================================
   AI CHAT — Floating Button & Modal
   ======================================== */

.ai-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-accent);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(255, 111, 94, 0.4);
  z-index: 1000;
  transition: transform 0.2s, box-shadow 0.2s;
}

.ai-chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(255, 111, 94, 0.5);
}

.ai-chat-fab:active {
  transform: scale(0.95);
}

.ai-chat-fab--hidden {
  display: none !important;
}

/* Chat Modal */
.ai-chat-modal {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 420px;
  max-width: calc(100vw - 48px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: aiChatSlideUp 0.25s ease-out;
}

@keyframes aiChatSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-chat-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--color-accent);
  color: white;
  flex-shrink: 0;
}

.ai-chat-modal__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-base, 1rem);
  letter-spacing: 0.02em;
}

.ai-chat-modal__actions {
  display: flex;
  gap: var(--space-1);
}

.ai-chat-modal__btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 6px;
  color: white;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.ai-chat-modal__btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Messages Area */
.ai-chat-modal__messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.ai-chat-msg-wrap {
  display: flex;
  flex-direction: column;
  max-width: 95%;
}

.ai-chat-msg-wrap--ai {
  align-self: flex-start;
}

.ai-chat-msg-wrap--user {
  align-self: flex-end;
}

.ai-chat-msg {
  padding: var(--space-4);
  border-radius: 12px;
  font-size: var(--text-sm);
  line-height: 1.7;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.ai-chat-msg--ai {
  background: var(--bg-input, #F7F7F7);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.ai-chat-msg--user {
  background: var(--color-accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-chat-msg--ai p {
  margin: 0 0 0.9em 0;
}

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

.ai-chat-msg--ai strong {
  color: var(--color-accent);
  font-weight: 600;
}

.ai-chat-msg--ai ul,
.ai-chat-msg--ai ol {
  margin: 0.5em 0 0.9em 0;
  padding-left: 1.5em;
}

.ai-chat-msg--ai li {
  margin-bottom: 0.45em;
  line-height: 1.6;
}

.ai-chat-msg--ai li:last-child {
  margin-bottom: 0;
}

.ai-chat-msg--ai h4 {
  margin: 0.8em 0 0.3em 0;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-accent);
}

.ai-chat-msg--ai h4:first-child {
  margin-top: 0;
}

/* Copy button */
.ai-chat-copy-btn {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 3px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.ai-chat-copy-btn:hover {
  color: var(--text-primary);
  background: var(--hover-overlay);
}

.ai-chat-copy-btn--copied {
  color: var(--color-positive) !important;
}

/* Typing indicator */
.ai-chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: var(--space-3);
  background: var(--bg-input, #F7F7F7);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}

.ai-chat-typing__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: aiTypingBounce 1.2s ease-in-out infinite;
}

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

@keyframes aiTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Input Area */
.ai-chat-modal__input-area {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.ai-chat-modal__input {
  flex: 1;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  resize: none;
  max-height: 120px;
  outline: none;
  transition: border-color 0.15s;
}

.ai-chat-modal__input:focus {
  border-color: var(--color-accent);
}

.ai-chat-modal__send {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--color-accent);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.ai-chat-modal__send:hover {
  background: var(--color-coral-dark, #E85A4A);
}

.ai-chat-modal__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .ai-chat-modal {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .ai-chat-fab {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }
}
