/**
 * ==============================================================================
 * Roar Projects - Lightweight Portfolio AI Assistant Stylesheet
 * File: css/chat.css
 * Palette: Deep Imperial Violet (#412475) Accents & Glassy Industrial Container
 * Zero Framework Dependencies
 * ==============================================================================
 */

/* ------------------------------------------------------------------------------
   1. Floating Trigger Button
   ------------------------------------------------------------------------------ */
.roar-chat-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #412475 0%, #5d34a4 100%);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 24px rgba(65, 36, 117, 0.45), 0 0 16px rgba(65, 36, 117, 0.3);
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease, background 0.3s ease;
  outline: none;
  padding: 0;
}

.roar-chat-trigger:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 30px rgba(65, 36, 117, 0.6), 0 0 20px rgba(93, 52, 164, 0.5);
  background: linear-gradient(135deg, #4d2b8a 0%, #6b3bbd 100%);
}

.roar-chat-trigger:active {
  transform: scale(0.96);
}

.roar-chat-trigger .trigger-icon {
  width: 26px;
  height: 26px;
  fill: currentColor;
  transition: transform 0.3s ease, opacity 0.2s ease;
}

.roar-chat-trigger .icon-close {
  display: none;
}

.roar-chat-trigger.is-open .icon-chat {
  display: none;
}

.roar-chat-trigger.is-open .icon-close {
  display: block;
}

/* Online Pulse Badge on Trigger */
.roar-chat-trigger .trigger-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #10B981;
  border: 2px solid #0E1013;
  border-radius: 50%;
}

.roar-chat-trigger .trigger-badge::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid #10B981;
  animation: chatBadgePulse 2s infinite ease-out;
}

@keyframes chatBadgePulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* ------------------------------------------------------------------------------
   2. Chat Window Container
   ------------------------------------------------------------------------------ */
.roar-chat-widget {
  position: fixed;
  bottom: 94px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 120px);
  background: var(--bg-card, #1A1D23);
  border: 1px solid rgba(65, 36, 117, 0.45);
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55), 0 0 24px rgba(65, 36, 117, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
}

.roar-chat-widget.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ------------------------------------------------------------------------------
   3. Chat Header & Quick Action Links
   ------------------------------------------------------------------------------ */
.roar-chat-header {
  background: linear-gradient(135deg, #412475 0%, #321b5c 100%);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.chat-header-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.chat-title-wrap {
  display: flex;
  flex-direction: column;
}

.chat-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin: 0;
  color: #ffffff;
  line-height: 1.2;
}

.chat-status-text {
  font-size: 11px;
  color: #d8c8fc;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.chat-status-indicator {
  width: 7px;
  height: 7px;
  background: #10B981;
  border-radius: 50%;
  display: inline-block;
}

.chat-header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
}

.chat-header-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  text-decoration: none;
}

.chat-close-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 18px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s, background 0.2s;
  padding: 0;
  line-height: 1;
}

.chat-close-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

/* ------------------------------------------------------------------------------
   4. Chat Messages Scroll Area
   ------------------------------------------------------------------------------ */
.roar-chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-card, #1A1D23);
  scrollbar-width: thin;
  scrollbar-color: rgba(65, 36, 117, 0.5) transparent;
}

.roar-chat-messages::-webkit-scrollbar {
  width: 5px;
}

.roar-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(65, 36, 117, 0.5);
  border-radius: 4px;
}

/* Message Rows */
.chat-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: chatMsgFadeIn 0.25s ease-out;
}

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

.chat-msg-row.bot-row {
  align-self: flex-start;
}

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

/* Message Bubbles */
.chat-bubble {
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg-row.bot-row .chat-bubble {
  background: var(--bg-surface, #14171D);
  color: var(--text-body, #CFD6DF);
  border: 1px solid var(--border-card, #2B313C);
  border-top-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.chat-msg-row.user-row .chat-bubble {
  background: linear-gradient(135deg, #412475 0%, #522d92 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(65, 36, 117, 0.35);
}

.chat-timestamp {
  font-size: 10px;
  color: var(--text-muted, #808A9A);
  margin-top: 4px;
  align-self: flex-start;
}

.chat-msg-row.user-row .chat-timestamp {
  align-self: flex-end;
}

/* ------------------------------------------------------------------------------
   5. Quick Prompt Chips
   ------------------------------------------------------------------------------ */
.chat-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.quick-chip-btn {
  background: rgba(65, 36, 117, 0.2);
  color: #d4c2fc;
  border: 1px solid rgba(65, 36, 117, 0.5);
  border-radius: 14px;
  padding: 6px 11px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  line-height: 1.3;
}

.quick-chip-btn:hover {
  background: #412475;
  color: #ffffff;
  border-color: #6b3bbd;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(65, 36, 117, 0.4);
}

.quick-chip-btn:active {
  transform: scale(0.97);
}

/* ------------------------------------------------------------------------------
   6. Typing Indicator
   ------------------------------------------------------------------------------ */
.chat-typing-indicator {
  display: none;
  align-self: flex-start;
  background: var(--bg-surface, #14171D);
  border: 1px solid var(--border-card, #2B313C);
  border-radius: 12px;
  border-top-left-radius: 4px;
  padding: 10px 14px;
  gap: 5px;
  align-items: center;
}

.chat-typing-indicator.is-active {
  display: flex;
}

.chat-typing-indicator span {
  width: 6px;
  height: 6px;
  background: #8b68cb;
  border-radius: 50%;
  animation: chatDotBlink 1.4s infinite both;
}

.chat-typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.chat-typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes chatDotBlink {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* ------------------------------------------------------------------------------
   7. Chat Input Area
   ------------------------------------------------------------------------------ */
.roar-chat-input-wrap {
  padding: 10px 14px;
  background: var(--bg-surface, #14171D);
  border-top: 1px solid var(--border-subtle, #242933);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.roar-chat-input-wrap input {
  flex: 1;
  background: var(--bg-card-elevated, #22262E);
  border: 1px solid var(--border-card, #2B313C);
  color: var(--text-primary, #ffffff);
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.roar-chat-input-wrap input:focus {
  border-color: #5d34a4;
  box-shadow: 0 0 0 3px rgba(65, 36, 117, 0.25);
}

.roar-chat-input-wrap input::placeholder {
  color: var(--text-muted, #808A9A);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #412475;
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

.chat-send-btn:hover:not(:disabled) {
  background: #5d34a4;
  transform: scale(1.05);
}

.chat-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-send-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* ------------------------------------------------------------------------------
   8. Chat Footer Fallback Bar
   ------------------------------------------------------------------------------ */
.roar-chat-footer-bar {
  background: rgba(14, 16, 19, 0.95);
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-muted, #808A9A);
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
}

.roar-chat-footer-bar a {
  color: #b79bf0;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.roar-chat-footer-bar a:hover {
  color: #ffffff;
  text-decoration: underline;
}

/* ------------------------------------------------------------------------------
   9. Light Mode Adjustments (body[data-theme="light"])
   ------------------------------------------------------------------------------ */
body[data-theme="light"] .roar-chat-widget {
  background: #ffffff;
  border-color: rgba(65, 36, 117, 0.35);
  box-shadow: 0 16px 40px rgba(65, 36, 117, 0.15), 0 0 16px rgba(65, 36, 117, 0.08);
}

body[data-theme="light"] .roar-chat-messages {
  background: #fafafc;
}

body[data-theme="light"] .chat-msg-row.bot-row .chat-bubble {
  background: #ffffff;
  color: #1f2328;
  border-color: #e1e4e8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

body[data-theme="light"] .quick-chip-btn {
  background: rgba(65, 36, 117, 0.08);
  color: #412475;
  border-color: rgba(65, 36, 117, 0.25);
}

body[data-theme="light"] .quick-chip-btn:hover {
  background: #412475;
  color: #ffffff;
}

body[data-theme="light"] .chat-typing-indicator {
  background: #ffffff;
  border-color: #e1e4e8;
}

body[data-theme="light"] .roar-chat-input-wrap {
  background: #ffffff;
  border-top-color: #e8ebf0;
}

body[data-theme="light"] .roar-chat-input-wrap input {
  background: #f4f5f8;
  border-color: #d0d7de;
  color: #1f2328;
}

body[data-theme="light"] .roar-chat-footer-bar {
  background: #f4f5f8;
  border-top-color: #e1e4e8;
  color: #57606a;
}

body[data-theme="light"] .roar-chat-footer-bar a {
  color: #412475;
}

/* ------------------------------------------------------------------------------
   10. Mobile Responsiveness
   ------------------------------------------------------------------------------ */
@media (max-width: 480px) {
  .roar-chat-trigger {
    bottom: 18px;
    right: 18px;
    width: 52px;
    height: 52px;
  }

  .roar-chat-widget {
    bottom: 80px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
    height: calc(100vh - 100px);
    border-radius: 14px;
  }

  .chat-header-btn {
    padding: 4px 6px;
    font-size: 10px;
  }
}

