/* ==========================================================================
   Carola AI Chatbot Widget SDK - Experientia & dAImonion
   Styling driven by CSS Custom Properties (Variables) for full customization
   ========================================================================== */

:root {
  /* Colors */
  --cb-primary: #0E3E98;
  --cb-primary-light: #2563EB;
  --cb-accent: #FCAF3B;
  --cb-header-bg: linear-gradient(135deg, #535C87 0%, #40476E 100%);
  --cb-header-text: #FFFFFF;
  --cb-header-subtitle: rgba(255, 255, 255, 0.85);
  --cb-badge-bg: #FFFFFF;
  --cb-badge-text: #1E293B;

  /* Card & Body */
  --cb-container-bg: #50597E;
  --cb-body-bg: #FFFFFF;
  --cb-text-main: #1E293B;
  --cb-text-muted: #64748B;
  --cb-border-subtle: #E2E8F0;
  --cb-card-radius: 28px;

  /* Messages */
  --cb-user-bubble-bg: #2563EB;
  --cb-user-bubble-text: #FFFFFF;
  --cb-agent-bubble-bg: #F1F5F9;
  --cb-agent-bubble-text: #0F172A;

  /* Launcher Button */
  --cb-launcher-bg: linear-gradient(135deg, #2563EB, #FCAF3B);
  --cb-launcher-bubble-bg: #0A1329;
  --cb-launcher-bubble-text: #F8FAFC;
  --cb-launcher-bubble-border: rgba(59, 130, 246, 0.3);

  /* Avatar Border & Shape Customization */
  --cb-avatar-radius: 50%;
  --cb-avatar-border-width: 2px;
  --cb-avatar-border-style: solid;
  --cb-avatar-border-color: rgba(255, 255, 255, 0.85);
  --cb-avatar-glow: none;
  --cb-launcher-avatar-radius: 50%;
  --cb-launcher-border: linear-gradient(135deg, #2563EB, #FCAF3B);
}

/* Floating Launcher Button */
#carola-launcher-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

#carola-launcher-btn:hover {
  transform: scale(1.05);
}

.carola-launcher-avatar-wrap {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: var(--cb-launcher-avatar-radius);
  padding: var(--cb-avatar-border-width);
  background: var(--cb-launcher-border);
  box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  transition: border-radius 0.3s ease;
}

.carola-launcher-avatar {
  width: 100%;
  height: 100%;
  border-radius: var(--cb-launcher-avatar-radius);
  object-fit: cover;
  background: #3B4261;
  display: block;
  transition: border-radius 0.3s ease;
}

.carola-launcher-status-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 15px;
  height: 15px;
  background: #10B981;
  border: 2.5px solid #060B18;
  border-radius: 50%;
  animation: carola-pulse 2s infinite;
}

.carola-launcher-bubble {
  background: var(--cb-launcher-bubble-bg);
  color: var(--cb-launcher-bubble-text);
  border: 1px solid var(--cb-launcher-bubble-border);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  animation: carola-fadeIn 0.3s ease;
}

.carola-launcher-bubble span.badge {
  background: var(--cb-primary-light);
  color: #FFFFFF;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

@keyframes carola-pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

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

/* Chat Modal Container */
#carola-widget-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 680px;
  max-height: calc(100vh - 48px);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  background: var(--cb-container-bg);
  border-radius: var(--cb-card-radius);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.15);
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#carola-widget-container.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Widget Header */
.carola-header {
  background: var(--cb-header-bg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--cb-header-text);
  position: relative;
  flex-shrink: 0;
}

.carola-agent-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.carola-avatar-img {
  width: 46px;
  height: 46px;
  border-radius: var(--cb-avatar-radius);
  object-fit: cover;
  border: var(--cb-avatar-border-width) var(--cb-avatar-border-style) var(--cb-avatar-border-color);
  box-shadow: var(--cb-avatar-glow);
  background: #3B4261;
  transition: border-radius 0.3s ease, border 0.3s ease;
}

.carola-agent-meta {
  display: flex;
  flex-direction: column;
}

.carola-agent-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.carola-ai-badge {
  background: var(--cb-badge-bg);
  color: var(--cb-badge-text);
  font-size: 11px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.carola-agent-subtitle {
  font-size: 12.5px;
  color: var(--cb-header-subtitle);
  font-weight: 400;
  margin-top: 1px;
}

.carola-close-btn {
  background: #FFFFFF;
  color: #1E293B;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: background 0.2s, transform 0.2s;
}

.carola-close-btn:hover {
  background: #F1F5F9;
  transform: scale(1.05);
}

/* White Card Content Body */
.carola-body-card {
  flex: 1;
  background: var(--cb-body-bg);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Tab Views Container */
.carola-tab-view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.carola-tab-view.active {
  display: flex;
}

/* Messages Scroll Area */
.carola-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.carola-intro-text {
  font-size: 15px;
  line-height: 1.5;
  color: var(--cb-text-main);
  margin-bottom: 6px;
}

.carola-intro-text strong {
  font-weight: 700;
  color: #0F172A;
}

/* Quick Suggestion Chips */
.carola-chips-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.carola-chip {
  background: #F8FAFC;
  border: 1px solid var(--cb-border-subtle);
  color: var(--cb-text-main);
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.4;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.carola-chip:hover {
  background: #EEF2F6;
  border-color: #CBD5E1;
  transform: translateY(-1px);
  color: var(--cb-primary);
}

.carola-chip svg {
  width: 14px;
  height: 14px;
  opacity: 0.5;
}

/* Chat Message Bubbles */
.carola-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

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

.carola-msg.agent {
  align-self: flex-start;
}

.carola-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
}

.carola-msg.user .carola-msg-bubble {
  background: var(--cb-user-bubble-bg);
  color: var(--cb-user-bubble-text);
  border-bottom-right-radius: 4px;
}

.carola-msg.agent .carola-msg-bubble {
  background: var(--cb-agent-bubble-bg);
  color: var(--cb-agent-bubble-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--cb-border-subtle);
}

.carola-msg-bubble p {
  margin: 0 0 6px 0;
}
.carola-msg-bubble p:last-child {
  margin-bottom: 0;
}

.carola-msg-bubble ul {
  margin: 6px 0;
  padding-left: 18px;
}
.carola-msg-bubble li {
  margin-bottom: 4px;
}

.carola-msg-bubble strong {
  font-weight: 700;
  color: #091E42;
}

.carola-msg-bubble a {
  color: var(--cb-primary-light);
  text-decoration: underline;
  font-weight: 600;
}

/* Typing Indicator Animation */
.carola-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--cb-agent-bubble-bg);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  border: 1px solid var(--cb-border-subtle);
}

.carola-typing-dot {
  width: 6px;
  height: 6px;
  background: #64748B;
  border-radius: 50%;
  animation: carola-dot-pulse 1.4s infinite ease-in-out both;
}

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

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

/* File Attachment Preview Bar */
.carola-attachment-preview {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: #EEF2F6;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  padding: 6px 12px;
  margin: 0 16px 8px 16px;
  font-size: 12px;
  color: var(--cb-text-main);
}

.carola-attachment-preview.show {
  display: flex;
}

.carola-attachment-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #EF4444;
  padding: 2px;
  font-weight: bold;
}

/* Input Area */
.carola-input-wrapper {
  padding: 10px 16px;
  background: var(--cb-body-bg);
}

.carola-input-pill {
  display: flex;
  align-items: center;
  background: #F1F5F9;
  border-radius: 28px;
  padding: 4px 6px 4px 12px;
  border: 1px solid var(--cb-border-subtle);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.carola-input-pill:focus-within {
  border-color: var(--cb-primary-light);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
  background: #FFFFFF;
}

.carola-attach-btn {
  background: transparent;
  border: none;
  color: #475569;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.2s, background 0.2s;
}

.carola-attach-btn:hover {
  color: var(--cb-primary);
  background: #E2E8F0;
}

.carola-text-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 14px;
  color: #0F172A;
  padding: 8px 10px;
}

.carola-text-input::placeholder {
  color: #94A3B8;
}

.carola-mic-btn {
  background: var(--cb-primary-light);
  color: #FFFFFF;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}

.carola-mic-btn:hover {
  background: var(--cb-primary);
  transform: scale(1.05);
}

.carola-mic-btn.recording {
  background: #EF4444;
  animation: carola-mic-pulse 1.2s infinite;
}

@keyframes carola-mic-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); box-shadow: 0 0 12px rgba(239, 68, 68, 0.6); }
  100% { transform: scale(1); }
}

/* Voice Mode View */
.carola-voice-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 24px;
  text-align: center;
  gap: 20px;
}

.carola-voice-orb-wrap {
  position: relative;
  width: 130px;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.carola-voice-orb {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-primary-light), #60A5FA);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.4);
  cursor: pointer;
  transition: transform 0.2s;
  z-index: 2;
}

.carola-voice-orb.listening {
  animation: carola-voice-pulse 1.5s infinite;
  background: linear-gradient(135deg, #10B981, #34D399);
}

.carola-voice-orb.speaking {
  animation: carola-voice-pulse 1.2s infinite;
  background: linear-gradient(135deg, #F59E0B, #FBBF24);
}

@keyframes carola-voice-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); }
  70% { transform: scale(1.08); box-shadow: 0 0 0 20px rgba(37, 99, 235, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

.carola-voice-status {
  font-size: 15px;
  font-weight: 700;
  color: #0F172A;
}

.carola-voice-transcript {
  font-size: 13.5px;
  color: #475569;
  min-height: 48px;
  background: #F8FAFC;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--cb-border-subtle);
  width: 100%;
  line-height: 1.4;
}

.carola-voice-action-btn {
  background: var(--cb-primary-light);
  color: #FFFFFF;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.carola-voice-action-btn:hover {
  background: var(--cb-primary);
}

/* History View */
.carola-history-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.carola-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.carola-history-header h4 {
  font-size: 15px;
  font-weight: 700;
  color: #0F172A;
  margin: 0;
}

.carola-clear-history-btn {
  background: transparent;
  border: none;
  color: #EF4444;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.carola-history-item {
  background: #F8FAFC;
  border: 1px solid var(--cb-border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.carola-history-item:hover {
  border-color: var(--cb-primary-light);
  background: #F1F5F9;
}

.carola-history-item-date {
  font-size: 11px;
  color: #64748B;
  margin-bottom: 4px;
}

.carola-history-item-preview {
  font-size: 13px;
  color: var(--cb-text-main);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tab Navigation Bar */
.carola-nav-tabs {
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-top: 1px solid var(--cb-border-subtle);
  background: var(--cb-body-bg);
  padding: 8px 12px 4px 12px;
}

.carola-tab-btn {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #64748B;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 16px;
  position: relative;
  transition: color 0.2s;
}

.carola-tab-btn svg {
  width: 20px;
  height: 20px;
}

.carola-tab-btn:hover {
  color: var(--cb-primary);
}

.carola-tab-btn.active {
  color: var(--cb-primary);
}

.carola-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 20%;
  width: 60%;
  height: 2.5px;
  background: var(--cb-primary);
  border-radius: 2px;
}

/* Legal & Footer Area */
.carola-footer-legal {
  padding: 8px 16px 6px 16px;
  font-size: 11px;
  text-align: center;
  color: #64748B;
  background: #FAFAFC;
  line-height: 1.4;
}

.carola-footer-legal a {
  color: var(--cb-primary);
  text-decoration: underline;
}

.carola-footer-brand {
  padding: 6px 16px 10px 16px;
  font-size: 11px;
  text-align: center;
  color: #94A3B8;
  background: #FAFAFC;
  border-top: 1px solid #F1F5F9;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.carola-footer-brand strong {
  color: var(--cb-primary-light);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  #carola-widget-container {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  
  .carola-header {
    border-radius: 0;
    padding: 14px 16px;
  }

  .carola-body-card {
    border-radius: 20px 20px 0 0;
  }

  #carola-launcher-btn {
    bottom: 16px;
    right: 16px;
  }
}
