/* ==========================================================================
   CASAP MARIKINA - AI Inquiry Chatbot Design System
   Rich Glassmorphism, Floating Trigger, Interactive Chat Bubble & Animations
   ========================================================================== */

/* --------------------------------------------------------------------------
   Floating Action Button (FAB Launcher)
   -------------------------------------------------------------------------- */
.ai-fab-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
}

.ai-fab-btn {
  pointer-events: auto;
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--casap-navy-900) 0%, var(--casap-blue-600) 60%, var(--casap-gold-500) 100%);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 10px 25px -3px rgba(37, 99, 235, 0.45), 0 0 20px rgba(245, 158, 11, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

.ai-fab-btn:hover {
  transform: scale(1.08) translateY(-3px);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.6), 0 0 28px rgba(245, 158, 11, 0.5);
}

.ai-fab-btn:active {
  transform: scale(0.96);
}

/* Pulsing radar ring */
.ai-fab-pulse {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid var(--casap-gold-400);
  opacity: 0;
  animation: ai-pulse 2.8s infinite cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: none;
}

@keyframes ai-pulse {
  0% {
    transform: scale(0.95);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.35);
    opacity: 0;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

/* Notification badge */
.ai-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--danger-500);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  border: 2px solid #fff;
  box-shadow: var(--shadow-sm);
  animation: bounce 2s infinite;
}

/* Floating tooltip */
.ai-fab-tooltip {
  pointer-events: auto;
  position: absolute;
  right: 76px;
  bottom: 12px;
  background: var(--casap-navy-950);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: var(--radius-lg);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(7, 21, 43, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: float-slide 4s ease-in-out infinite;
  cursor: pointer;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.ai-fab-tooltip::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 6px 0 6px 6px;
  border-style: solid;
  border-color: transparent transparent transparent var(--casap-navy-950);
}

.ai-fab-tooltip .sparkle-icon {
  color: var(--casap-gold-400);
  font-size: 0.85rem;
}

@keyframes float-slide {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* --------------------------------------------------------------------------
   Chat Dialog Window
   -------------------------------------------------------------------------- */
.ai-chat-window {
  pointer-events: auto;
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 420px;
  max-width: calc(100vw - 32px);
  height: 640px;
  max-height: calc(100vh - 120px);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 40px -10px rgba(7, 21, 43, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10000;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0;
  transform: scale(0.92) translateY(24px);
  visibility: hidden;
}

.ai-chat-window.active {
  opacity: 1;
  transform: scale(1) translateY(0);
  visibility: visible;
}

.ai-chat-window.minimized {
  height: 64px !important;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.ai-chat-window.maximized {
  width: 720px;
  height: 820px;
  max-height: calc(100vh - 80px);
}

/* --------------------------------------------------------------------------
   Chat Header
   -------------------------------------------------------------------------- */
.ai-chat-header {
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--casap-navy-950) 0%, var(--casap-navy-900) 50%, var(--casap-navy-800) 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  user-select: none;
}

.ai-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-avatar-wrapper {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--casap-blue-600), var(--casap-gold-500));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
}

.ai-avatar-wrapper img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.ai-status-indicator {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--success-500);
  border: 2px solid var(--casap-navy-950);
}

.ai-header-meta {
  display: flex;
  flex-direction: column;
}

.ai-header-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.01em;
}

.ai-header-title .tag-ai {
  font-size: 0.62rem;
  background: rgba(245, 158, 11, 0.25);
  color: var(--casap-gold-400);
  border: 1px solid rgba(245, 158, 11, 0.45);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 700;
  text-transform: uppercase;
}

.ai-header-sub {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-ctrl-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.78rem;
}

.ai-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transform: translateY(-1px);
}

.ai-ctrl-btn.active {
  background: var(--casap-gold-500);
  color: #fff;
  border-color: var(--casap-gold-400);
}

/* --------------------------------------------------------------------------
   Quick Inquiry Chips
   -------------------------------------------------------------------------- */
.ai-chips-wrapper {
  padding: 10px 14px;
  background: var(--bg-surface-alt);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
  flex-shrink: 0;
}

.ai-chips-wrapper::-webkit-scrollbar {
  height: 4px;
}

.ai-chips-wrapper::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 4px;
}

.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.ai-chip:hover {
  background: var(--casap-blue-50);
  border-color: var(--casap-blue-500);
  color: var(--casap-blue-600);
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
}

[data-theme="dark"] .ai-chip:hover {
  background: rgba(37, 99, 235, 0.15);
  color: var(--casap-blue-400);
}

.ai-chip i {
  color: var(--casap-gold-500);
  font-size: 0.75rem;
}

/* --------------------------------------------------------------------------
   Chat Messages Body
   -------------------------------------------------------------------------- */
.ai-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-surface);
  scroll-behavior: smooth;
}

.ai-chat-body::-webkit-scrollbar {
  width: 6px;
}

.ai-chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.ai-chat-body::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 4px;
}

/* Message groups */
.ai-msg {
  display: flex;
  gap: 10px;
  max-width: 90%;
  animation: msg-fade-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes msg-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

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

.ai-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  box-shadow: var(--shadow-xs);
}

.ai-msg.bot .ai-msg-avatar {
  background: linear-gradient(135deg, var(--casap-navy-900), var(--casap-blue-600));
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.ai-msg.user .ai-msg-avatar {
  background: linear-gradient(135deg, var(--casap-gold-500), var(--casap-gold-600));
  color: #fff;
}

.ai-msg-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 0.82rem;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}

.ai-msg.bot .ai-bubble {
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-top-left-radius: 2px;
  box-shadow: var(--shadow-xs);
}

.ai-msg.user .ai-bubble {
  background: linear-gradient(135deg, var(--casap-blue-600) 0%, var(--casap-navy-800) 100%);
  color: #ffffff;
  border-top-right-radius: 2px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.ai-msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  padding: 0 4px;
}

.ai-msg.user .ai-msg-time {
  text-align: right;
}

/* Rich message formatting inside Bot Bubble */
.ai-bubble h4 {
  font-size: 0.88rem;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: var(--casap-blue-600);
}

[data-theme="dark"] .ai-bubble h4 {
  color: var(--casap-blue-400);
}

.ai-bubble ul {
  margin: 6px 0 8px 18px;
  padding: 0;
}

.ai-bubble li {
  margin-bottom: 4px;
}

.ai-bubble strong {
  color: var(--text-primary);
  font-weight: 700;
}

[data-theme="dark"] .ai-bubble strong {
  color: #f8fafc;
}

.ai-bubble p {
  margin: 0 0 6px 0;
}

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

/* Highlight boxes inside Bot replies */
.ai-highlight-box {
  background: var(--bg-surface);
  border-left: 3px solid var(--casap-gold-500);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin: 8px 0;
  font-size: 0.78rem;
  border-top: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

/* Action button inside bot response */
.ai-action-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ai-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: var(--casap-blue-50);
  color: var(--casap-blue-600);
  border: 1px solid var(--casap-blue-500);
  border-radius: var(--radius-md);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.ai-action-btn:hover {
  background: var(--casap-blue-600);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(37, 99, 235, 0.25);
}

.ai-action-btn.gold {
  background: var(--casap-gold-50);
  color: var(--casap-gold-600);
  border-color: var(--casap-gold-500);
}

.ai-action-btn.gold:hover {
  background: var(--casap-gold-500);
  color: #fff;
}

[data-theme="dark"] .ai-action-btn {
  background: rgba(37, 99, 235, 0.18);
  color: var(--casap-blue-400);
  border-color: rgba(37, 99, 235, 0.4);
}

[data-theme="dark"] .ai-action-btn:hover {
  background: var(--casap-blue-600);
  color: #fff;
}

[data-theme="dark"] .ai-action-btn.gold {
  background: rgba(245, 158, 11, 0.18);
  color: var(--casap-gold-400);
  border-color: rgba(245, 158, 11, 0.4);
}

[data-theme="dark"] .ai-action-btn.gold:hover {
  background: var(--casap-gold-500);
  color: #fff;
}

/* Bot Response Feedback & Speech Toolbar */
.ai-bubble-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.ai-tool-icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-xs);
  transition: color 0.2s ease;
}

.ai-tool-icon-btn:hover {
  color: var(--casap-blue-600);
}

/* --------------------------------------------------------------------------
   Typing Indicator
   -------------------------------------------------------------------------- */
.ai-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  border-top-left-radius: 2px;
  width: fit-content;
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--casap-blue-500);
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }

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

/* --------------------------------------------------------------------------
   Chat Input Footer
   -------------------------------------------------------------------------- */
.ai-chat-footer {
  padding: 12px 14px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.ai-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 4px 8px 4px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ai-input-row:focus-within {
  border-color: var(--casap-blue-500);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.ai-input-field {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  outline: none;
  padding: 6px 0;
}

.ai-input-field::placeholder {
  color: var(--text-muted);
}

.ai-input-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-send-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--casap-navy-900) 0%, var(--casap-blue-600) 100%);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.ai-send-btn:hover {
  background: linear-gradient(135deg, var(--casap-navy-800) 0%, var(--casap-blue-500) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

.ai-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ai-mic-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.ai-mic-btn:hover {
  color: var(--casap-blue-600);
  background: var(--border-subtle);
}

.ai-mic-btn.listening {
  color: var(--danger-500);
  background: var(--danger-100);
  animation: pulse-mic 1.2s infinite;
}

@keyframes pulse-mic {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.ai-footer-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 0 4px;
}

.ai-clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.68rem;
  cursor: pointer;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 3px;
}

.ai-clear-btn:hover {
  color: var(--danger-500);
}

/* --------------------------------------------------------------------------
   Mobile Adaptations
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .ai-fab-container {
    bottom: 16px;
    right: 16px;
  }

  .ai-fab-btn {
    width: 56px;
    height: 56px;
    font-size: 1.4rem;
  }

  .ai-fab-tooltip {
    display: none;
  }

  .ai-chat-window {
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0;
    border: none;
  }

  .ai-chat-window.minimized {
    bottom: 0 !important;
    height: 60px !important;
    border-top: 1px solid var(--border-medium);
  }
}
