/* Credit Letter MVP AI Assistant Styles */

/* ── Floating button ── */
#asst-bubble {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #2563eb;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  z-index: 9990;
  box-shadow: 0 4px 16px rgba(37,99,235,.45);
  transition: transform .2s, box-shadow .2s;
}
#asst-bubble:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(37,99,235,.5); }
#asst-bubble:focus-visible,
.asst-header-btn:focus-visible,
.asst-action-btn:focus-visible,
.asst-suggestion-btn:focus-visible,
#asst-send:focus-visible,
#asst-input:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 3px;
}
#asst-bubble svg { width: 26px; height: 26px; }
#asst-bubble-badge {
  position: absolute;
  top: -2px; right: -2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  display: none;
}

/* ── Panel ── */
#asst-panel {
  position: fixed;
  right: 20px;
  bottom: 88px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 110px);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.16);
  display: none;
  flex-direction: column;
  z-index: 9991;
  overflow: hidden;
}
#asst-panel.open { display: flex; }

@media (max-width: 480px) {
  #asst-panel {
    right: 8px; left: 8px;
    bottom: 80px;
    width: auto;
    max-width: none;
    height: 72vh;
    max-height: 72vh;
    border-radius: 20px;
  }
  #asst-bubble { right: 16px; bottom: 16px; }
}

/* ── Header ── */
.asst-header {
  flex-shrink: 0;
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 16px 16px 0 0;
}
.asst-header-icon {
  width: 32px; height: 32px;
  background: rgba(255,255,255,.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.asst-header-icon svg { width: 18px; height: 18px; }
.asst-header-title { flex: 1; }
.asst-header-title strong { display: block; font-size: 14px; font-weight: 700; }
.asst-header-title span { font-size: 11px; opacity: .8; }
.asst-header-actions { display: flex; gap: 4px; }
.asst-header-btn {
  background: rgba(255,255,255,.15);
  border: none; color: #fff;
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: background .15s;
}
.asst-header-btn:hover { background: rgba(255,255,255,.28); }

/* ── Messages ── */
.asst-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.asst-messages::-webkit-scrollbar { width: 4px; }
.asst-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.asst-msg { display: flex; gap: 8px; max-width: 100%; }
.asst-msg.asst-msg-user { flex-direction: row-reverse; }

.asst-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  margin-top: 2px;
}
.asst-msg-assistant .asst-avatar { background: #dbeafe; color: #1d4ed8; }
.asst-msg-user .asst-avatar { background: #2563eb; color: #fff; }

.asst-bubble-text {
  max-width: calc(100% - 40px);
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
}
.asst-msg-assistant .asst-bubble-text {
  background: #f3f4f6;
  color: #111827;
  border-bottom-left-radius: 4px;
}
.asst-msg-user .asst-bubble-text {
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.asst-bubble-text strong { font-weight: 600; }
.asst-bubble-text ul, .asst-bubble-text ol { margin: 6px 0; padding-left: 18px; }
.asst-bubble-text li { margin-bottom: 3px; }
.asst-bubble-text p { margin: 0 0 6px; }
.asst-bubble-text p:last-child { margin-bottom: 0; }

/* Action buttons inside messages */
.asst-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;
}
.asst-action-btn {
  background: #fff;
  border: 1.5px solid #2563eb;
  color: #2563eb;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.asst-action-btn:hover { background: #2563eb; color: #fff; }
.asst-action-btn.secondary { border-color: #9ca3af; color: #4b5563; }
.asst-action-btn.secondary:hover { background: #4b5563; color: #fff; }
.asst-action-btn.escalate { border-color: #6b7280; color: #6b7280; }
.asst-action-btn.escalate:hover { background: #6b7280; color: #fff; }

/* Typing indicator */
.asst-typing {
  display: flex; align-items: center; gap: 8px;
}
.asst-typing-dots {
  display: flex; gap: 4px; padding: 10px 13px;
  background: #f3f4f6; border-radius: 14px; border-bottom-left-radius: 4px;
}
.asst-typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #9ca3af; animation: asst-bounce .9s infinite;
}
.asst-typing-dots span:nth-child(2) { animation-delay: .2s; }
.asst-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes asst-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* ── Suggested questions ── */
.asst-suggestions {
  padding: 0 16px 12px;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.asst-suggestion-btn {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.asst-suggestion-btn:hover { background: #dbeafe; }

/* ── Input area ── */
.asst-input-wrap {
  flex-shrink: 0;
  border-top: 1px solid #e5e7eb;
  padding: 12px;
  display: flex; gap: 8px; align-items: flex-end;
  background: #fff;
  border-radius: 0 0 16px 16px;
}
#asst-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  line-height: 1.4;
  resize: none;
  max-height: 100px;
  outline: none;
  font-family: inherit;
  transition: border-color .15s;
}
#asst-input:focus { border-color: #2563eb; }
#asst-input::placeholder { color: #9ca3af; }
#asst-send {
  background: #2563eb;
  border: none; color: #fff;
  width: 38px; height: 38px;
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
#asst-send:hover { background: #1d4ed8; }
#asst-send:active { transform: scale(.95); }
#asst-send svg { width: 18px; height: 18px; }
#asst-send:disabled { background: #9ca3af; cursor: not-allowed; }

/* ── Limit notice ── */
.asst-limit-notice {
  text-align: center;
  padding: 8px 16px 12px;
  font-size: 12px;
  color: #6b7280;
}

/* Highlighted element */
.asst-highlight {
  position: relative;
  z-index: 9993 !important;
  outline: 3px solid #f59e0b !important;
  outline-offset: 3px !important;
  border-radius: 6px;
  box-shadow: 0 0 0 6px rgba(245,158,11,.25) !important;
}

@media (prefers-reduced-motion: reduce) {
  #asst-bubble,
  .asst-header-btn,
  .asst-action-btn,
  .asst-suggestion-btn,
  #asst-send,
  .asst-messages {
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .asst-typing-dots span { animation: none !important; }
}

@media print {
  #asst-bubble,
  #asst-panel {
    display: none !important;
  }
}
