/* ==========================================================================
   ComplyTax AI Agent Chatbot Styles (Brand Matching Theme)
   ========================================================================== */

:root {
  --ct-primary: #059669;
  --ct-primary-light: #10b981;
  --ct-primary-dark: #047857;
  --ct-primary-darker: #064e3b;
  --ct-primary-subtle: #ecfdf5;
  --ct-border-subtle: #a7f3d0;
  
  --ct-bg-pill: rgba(240, 253, 244, 0.96);
  --ct-border-pill: #6ee7b7;
  --ct-text-dark: #1e293b;
  --ct-text-muted: #475569;
  --ct-text-subtle: #64748b;
  
  --ct-gradient-btn: linear-gradient(135deg, #059669 0%, #10b981 100%);
  --ct-gradient-header: linear-gradient(135deg, #059669 0%, #0d9488 100%);
  --ct-gradient-card: linear-gradient(180deg, #ecfdf5 0%, #ffffff 42%, #f0fdf4 100%);
  
  --ct-shadow-pill: 0 10px 25px -3px rgba(5, 150, 105, 0.22), 0 4px 6px -4px rgba(5, 150, 105, 0.1);
  --ct-shadow-card: 0 20px 35px -5px rgba(5, 150, 105, 0.18), 0 10px 15px -5px rgba(0, 0, 0, 0.06);
  --ct-radius-pill: 9999px;
  --ct-radius-card: 24px;
  --ct-font: 'Poppins', 'Urbanist', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Floating Widget Root */
#ct-chatbot-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: var(--ct-font);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* ==========================================
   1. Floating Pill Launcher
   ========================================== */
.eva-pill-launcher {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 20px 6px 8px;
  background: var(--ct-bg-pill);
  border: 1.5px solid var(--ct-border-pill);
  border-radius: var(--ct-radius-pill);
  box-shadow: var(--ct-shadow-pill);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
  user-select: none;
}

.eva-pill-launcher:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 14px 28px -2px rgba(5, 150, 105, 0.32);
  border-color: #34d399;
}

.eva-pill-launcher:active {
  transform: scale(0.97);
}

.eva-pill-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid #a7f3d0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.15);
  overflow: hidden;
  padding: 6px;
  box-sizing: border-box;
}

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

.eva-pill-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.eva-pill-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--ct-primary);
  line-height: 1.2;
  letter-spacing: 0.2px;
}

.eva-pill-subtitle {
  font-size: 12px;
  font-weight: 500;
  color: #334155;
  margin-top: 1px;
  white-space: nowrap;
}

#ct-chatbot-widget.is-open .eva-pill-launcher {
  display: none;
}

/* ==========================================
   Chat Main Container Window
   ========================================== */
.ct-chat-window {
  width: 375px;
  max-width: calc(100vw - 32px);
  height: 530px;
  max-height: calc(100vh - 100px);
  background: #ffffff;
  border-radius: var(--ct-radius-card);
  box-shadow: var(--ct-shadow-card);
  border: 1.5px solid #a7f3d0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 8px;
  position: relative;
  transform-origin: bottom right;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0;
  transform: scale(0.85) translateY(20px);
  pointer-events: none;
  visibility: hidden;
}

#ct-chatbot-widget.is-open .ct-chat-window {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
  visibility: visible;
}

/* ==========================================
   2. Welcome Intro Card View
   ========================================== */
.eva-welcome-view {
  width: 100%;
  height: 100%;
  background: var(--ct-gradient-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 24px;
  position: relative;
  box-sizing: border-box;
}

.eva-close-btn-round {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(100, 116, 139, 0.7);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  z-index: 10;
}

.eva-close-btn-round:hover {
  background: #475569;
  transform: scale(1.08);
}

.eva-close-btn-round svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.eva-welcome-avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #6ee7b7;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  box-shadow: 0 8px 20px rgba(5, 150, 105, 0.18);
  padding: 16px;
  box-sizing: border-box;
  animation: ctFloat 3.5s ease-in-out infinite;
}

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

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

.eva-greeting-intro {
  font-size: 16px;
  color: var(--ct-text-muted);
  font-weight: 500;
  margin: 0;
}

.eva-greeting-title {
  font-size: 34px;
  font-weight: 800;
  color: var(--ct-primary);
  letter-spacing: 0.5px;
  margin: 4px 0 8px 0;
  line-height: 1.15;
}

.eva-greeting-desc {
  font-size: 14.5px;
  color: var(--ct-text-muted);
  margin: 0 0 6px 0;
  font-weight: 500;
}

.eva-greeting-prompt {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ct-text-dark);
  margin: 0 0 28px 0;
  line-height: 1.4;
}

.eva-chat-start-btn {
  background: var(--ct-gradient-btn);
  color: #ffffff;
  font-size: 15.5px;
  font-weight: 700;
  padding: 12px 38px;
  border-radius: var(--ct-radius-pill);
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(5, 150, 105, 0.35);
  transition: all 0.25s ease;
  outline: none;
}

.eva-chat-start-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 12px 24px rgba(5, 150, 105, 0.45);
}

.eva-chat-start-btn:active {
  transform: scale(0.97);
}

/* ==========================================
   3. Active Chat View
   ========================================== */
.eva-chat-view {
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
}

.ct-chat-window.in-chat .eva-welcome-view {
  display: none;
}

.ct-chat-window.in-chat .eva-chat-view {
  display: flex;
}

/* Active Chat Header */
.ct-chat-header {
  background: var(--ct-gradient-header);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  user-select: none;
}

.ct-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ct-bot-avatar-header {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  padding: 5px;
  box-sizing: border-box;
}

.ct-bot-avatar-header img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ct-status-dot {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 10px;
  height: 10px;
  background-color: #22c55e;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

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

.ct-header-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
  color: #ffffff;
}

.ct-header-status {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.9);
  margin-top: 2px;
}

.ct-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ct-header-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.ct-header-btn:hover {
  background: rgba(255, 255, 255, 0.35);
}

.ct-header-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Chat Messages Area */
.ct-chat-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

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

.ct-chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.ct-chat-divider {
  text-align: center;
  margin: 2px 0;
}

.ct-chat-divider span {
  font-size: 11px;
  font-weight: 600;
  color: var(--ct-text-subtle);
  background: #e2e8f0;
  padding: 2px 10px;
  border-radius: var(--ct-radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Message Item */
.ct-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: ctMsgSlideIn 0.3s ease-out;
}

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

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

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

.ct-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #a7f3d0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
  padding: 4px;
  box-sizing: border-box;
}

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

.ct-msg-content {
  display: flex;
  flex-direction: column;
}

.ct-msg-bubble {
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  border-radius: 14px;
  word-wrap: break-word;
  word-break: break-word;
}

.ct-msg-user .ct-msg-bubble {
  background: var(--ct-gradient-btn);
  color: #ffffff;
  border-bottom-right-radius: 3px;
  box-shadow: 0 3px 8px rgba(5, 150, 105, 0.2);
}

.ct-msg-bot .ct-msg-bubble {
  background: #ffffff;
  color: var(--ct-text-dark);
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.ct-msg-bubble p {
  margin: 0 0 6px 0;
}
.ct-msg-bubble p:last-child {
  margin-bottom: 0;
}
.ct-msg-bubble strong {
  font-weight: 700;
}
.ct-msg-bubble ul, .ct-msg-bubble ol {
  margin: 4px 0;
  padding-left: 18px;
}
.ct-msg-bubble li {
  margin-bottom: 3px;
}
.ct-msg-bubble code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
}
.ct-msg-user .ct-msg-bubble code {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}
.ct-msg-bubble a {
  color: var(--ct-primary);
  text-decoration: underline;
  font-weight: 600;
}
.ct-msg-user .ct-msg-bubble a {
  color: #ffffff;
}

.ct-msg-time {
  font-size: 10px;
  color: var(--ct-text-subtle);
  margin-top: 3px;
  padding: 0 4px;
}
.ct-msg-user .ct-msg-time {
  text-align: right;
}

/* Copy button */
.ct-msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 3px;
}

.ct-msg-action-btn {
  background: none;
  border: none;
  color: var(--ct-text-subtle);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
  transition: all 0.2s ease;
}

.ct-msg-action-btn:hover {
  background: #e2e8f0;
  color: var(--ct-text-dark);
}

.ct-msg-action-btn svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

/* Typing Indicator */
.ct-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  border-bottom-left-radius: 3px;
  width: fit-content;
}

.ct-typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--ct-primary);
  border-radius: 50%;
  animation: ctTypingBounce 1.4s infinite ease-in-out both;
}

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

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

/* Chat Input Footer */
.ct-chat-footer {
  padding: 10px 14px 12px 14px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
}

.ct-input-container {
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 3px 6px 3px 12px;
  transition: all 0.2s ease;
}

.ct-input-container:focus-within {
  border-color: var(--ct-primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.ct-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13.5px;
  color: var(--ct-text-dark);
  outline: none;
  font-family: inherit;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
  padding: 6px 0;
}

.ct-chat-input::placeholder {
  color: #94a3b8;
}

.ct-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--ct-primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  outline: none;
  flex-shrink: 0;
}

.ct-send-btn:hover:not(:disabled) {
  background: var(--ct-primary-dark);
  transform: scale(1.04);
}

.ct-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  opacity: 0.7;
}

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

.ct-footer-disclaimer {
  font-size: 10px;
  color: #94a3b8;
  text-align: center;
  margin-top: 6px;
  margin-bottom: 0;
}

/* Retry / Error Button */
.ct-retry-btn {
  background: #ef4444;
  color: #ffffff;
  border: none;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

/* Mobile Responsiveness */
@media (max-width: 576px) {
  #ct-chatbot-widget {
    bottom: 16px;
    right: 16px;
  }
  
  .ct-chat-window {
    width: calc(100vw - 32px);
    height: calc(100vh - 90px);
    border-radius: var(--ct-radius-card);
  }
}
