/**
 * NextChaat - Floating Caroline AI Assistant Styles (Sapphire Blue #5170ff & Luxury Black Theme)
 * Author: Ouzan (NextChaat.com)
 */

/* Main Widget Anchor Container */
.caroline-floating-widget {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

[dir="rtl"] .caroline-floating-widget {
  right: 2rem;
  left: auto;
  align-items: flex-end;
}

/* Callout Bubble Prompt */
.caroline-bubble-prompt {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(10, 14, 26, 0.94);
  border: 1px solid rgba(81, 112, 255, 0.4);
  backdrop-filter: blur(16px);
  padding: 0.65rem 1rem 0.65rem 0.75rem;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(81, 112, 255, 0.2);
  max-width: 310px;
  animation: carolineFloatBounce 3s ease-in-out infinite, carolineSlideIn 0.4s ease-out;
  cursor: pointer;
  position: relative;
  transition: all 0.25s ease;
}

.caroline-bubble-prompt:hover {
  transform: translateY(-3px);
  border-color: rgba(81, 112, 255, 0.8);
  box-shadow: 0 14px 35px rgba(81, 112, 255, 0.35);
}

.caroline-bubble-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid #5170ff;
}

.caroline-bubble-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.caroline-bubble-content {
  flex: 1;
}

.caroline-bubble-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: #8fa6ff;
  margin-bottom: 2px;
}

.caroline-bubble-text {
  font-size: 0.8rem;
  color: #f8fafc;
  line-height: 1.35;
}

.caroline-bubble-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
  transition: color 0.2s;
}

.caroline-bubble-close:hover {
  color: #708bff;
}

/* Floating Trigger Button */
.caroline-trigger-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(135deg, #0d1224, #141b36);
  border: 2px solid rgba(81, 112, 255, 0.6);
  color: #ffffff;
  padding: 0.5rem 1.2rem 0.5rem 0.5rem;
  border-radius: 40px;
  box-shadow: 0 8px 30px rgba(81, 112, 255, 0.35), 0 0 25px rgba(81, 112, 255, 0.25);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  position: relative;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: visible;
}

[dir="rtl"] .caroline-trigger-btn {
  padding: 0.5rem 0.5rem 0.5rem 1.2rem;
}

.caroline-trigger-btn:hover {
  transform: translateY(-4px) scale(1.04);
  border-color: #708bff;
  box-shadow: 0 12px 40px rgba(81, 112, 255, 0.55), 0 0 30px rgba(59, 91, 235, 0.4);
}

.caroline-btn-avatar-wrap {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  border: 2px solid #5170ff;
  box-shadow: 0 0 12px rgba(81, 112, 255, 0.5);
}

.caroline-btn-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.caroline-online-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background: #10b981;
  border: 2px solid #0d1224;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
}

[dir="rtl"] .caroline-online-badge {
  right: auto;
  left: 0;
}

.caroline-trigger-label {
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.caroline-ping-ring {
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: -4px;
  right: -4px;
  border-radius: 44px;
  border: 2px solid rgba(81, 112, 255, 0.6);
  opacity: 0;
  animation: carolinePing 2.5s cubic-bezier(0, 0, 0.2, 1) infinite;
  pointer-events: none;
}

/* Floating Chat Window */
.caroline-chat-window {
  position: fixed;
  bottom: 6rem;
  right: 2rem;
  width: 390px;
  max-width: calc(100vw - 2rem);
  height: 560px;
  max-height: calc(100vh - 8rem);
  background: rgba(10, 13, 22, 0.97);
  border: 1px solid rgba(81, 112, 255, 0.35);
  border-radius: 20px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(81, 112, 255, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

[dir="rtl"] .caroline-chat-window {
  right: 2rem;
  left: auto;
}

.caroline-chat-window.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.caroline-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, rgba(14, 21, 46, 0.95), rgba(12, 16, 32, 0.95));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.caroline-header-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.caroline-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  position: relative;
  border: 2px solid #5170ff;
  box-shadow: 0 0 10px rgba(81, 112, 255, 0.4);
  flex-shrink: 0;
}

.caroline-header-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.caroline-online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: #10b981;
  border: 2px solid #0a0d16;
  border-radius: 50%;
  box-shadow: 0 0 6px #10b981;
}

.caroline-header-info {
  display: flex;
  flex-direction: column;
}

.caroline-header-name {
  font-size: 1rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.caroline-bot-badge {
  font-size: 0.65rem;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, #5170ff, #253cb8);
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  text-transform: uppercase;
}

.caroline-header-status {
  font-size: 0.75rem;
  color: #8fa6ff;
  font-weight: 600;
}

.caroline-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.caroline-action-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.caroline-action-btn:hover {
  background: rgba(81, 112, 255, 0.25);
  border-color: #5170ff;
  color: #fff;
}

/* Chat Messages Stream */
.caroline-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  background: rgba(8, 10, 18, 0.85);
  scroll-behavior: smooth;
}

.caroline-chat-messages::-webkit-scrollbar {
  width: 5px;
}
.caroline-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(81, 112, 255, 0.3);
  border-radius: 4px;
}

.caroline-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: carolineFadeUp 0.3s ease-out;
}

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

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

.caroline-msg-bubble {
  padding: 0.8rem 1.05rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.55;
  word-break: break-word;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.caroline-msg-bot .caroline-msg-bubble {
  background: rgba(18, 22, 34, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
  border-bottom-left-radius: 4px;
}

[dir="rtl"] .caroline-msg-bot .caroline-msg-bubble {
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 4px;
}

.caroline-msg-user .caroline-msg-bubble {
  background: linear-gradient(135deg, #5170ff, #253cb8);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

[dir="rtl"] .caroline-msg-user .caroline-msg-bubble {
  border-bottom-right-radius: 14px;
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.caroline-typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0.75rem 1rem;
}

.caroline-typing-dot {
  width: 7px;
  height: 7px;
  background: #5170ff;
  border-radius: 50%;
  animation: carolineDotPulse 1.4s infinite ease-in-out both;
}

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

/* Quick Action Suggestion Chips */
.caroline-chat-chips {
  padding: 0.5rem 1rem;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  background: rgba(10, 13, 22, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.caroline-chat-chips::-webkit-scrollbar {
  display: none;
}

.caroline-chip-btn {
  background: rgba(81, 112, 255, 0.1);
  border: 1px solid rgba(81, 112, 255, 0.3);
  color: #c4d0ff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.caroline-chip-btn:hover {
  background: rgba(81, 112, 255, 0.25);
  border-color: #5170ff;
  color: #ffffff;
  transform: translateY(-2px);
}

/* Input Bar */
.caroline-chat-input-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  background: #090c14;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.caroline-chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 25px;
  padding: 0.65rem 1.15rem;
  color: #ffffff;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

.caroline-chat-input:focus {
  border-color: #5170ff;
  background: rgba(81, 112, 255, 0.06);
}

.caroline-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5170ff, #253cb8);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.caroline-chat-send:hover {
  transform: scale(1.08);
  box-shadow: 0 0 15px rgba(81, 112, 255, 0.6);
}

/* Animations */
@keyframes carolinePing {
  0% { transform: scale(1); opacity: 0.8; }
  75%, 100% { transform: scale(1.35); opacity: 0; }
}

@keyframes carolineFloatBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

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

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

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

/* Mobile Responsive */
@media (max-width: 640px) {
  .caroline-floating-widget {
    bottom: 1.25rem;
    right: 1.25rem;
  }
  [dir="rtl"] .caroline-floating-widget {
    right: 1.25rem;
    left: auto;
  }
  .caroline-trigger-label {
    display: none;
  }
  .caroline-trigger-btn {
    padding: 0;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(81, 112, 255, 0.45);
  }
  .caroline-btn-avatar-wrap {
    width: 44px;
    height: 44px;
    border: none;
    box-shadow: none;
  }
  .caroline-bubble-prompt {
    max-width: 250px;
    padding: 0.5rem 0.85rem 0.5rem 0.65rem;
    border-radius: 14px;
  }
  .caroline-bubble-avatar {
    width: 32px;
    height: 32px;
  }
  .caroline-bubble-title {
    font-size: 0.75rem;
  }
  .caroline-bubble-text {
    font-size: 0.75rem;
  }
  .caroline-chat-window {
    right: 10px;
    left: 10px;
    bottom: 5.25rem;
    width: auto;
    max-width: 440px;
    height: 74vh;
    max-height: calc(100vh - 6.5rem);
    border-radius: 18px;
  }
  [dir="rtl"] .caroline-chat-window {
    right: 10px;
    left: 10px;
  }
  .caroline-chat-messages {
    padding: 1rem 0.85rem;
  }
  .caroline-msg {
    max-width: 90%;
  }
  .caroline-msg-bubble {
    padding: 0.7rem 0.95rem;
    font-size: 0.86rem;
  }
  .caroline-chat-input-bar {
    padding: 0.65rem 0.75rem;
  }
  .caroline-chat-input {
    padding: 0.55rem 0.95rem;
    font-size: 0.85rem;
  }
  .caroline-chip-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
  }
}
