/* ═══════════════════════════════════════════════════════════════════════
   Cape Town Dental Studio — Chatbot Widget Styles
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── Variables ───────────────────────────────────────────────────────── */
:root {
  --chat-primary: #F28C28;
  --chat-primary-dark: #D97720;
  --chat-primary-light: #FFF4E6;
  --chat-bg: #FFF8F0;
  --chat-white: #FFFFFF;
  --chat-text: #333333;
  --chat-text-light: #777777;
  --chat-border: #E8E0D8;
  --chat-shadow: rgba(0, 0, 0, 0.15);
  --chat-radius: 16px;
  --chat-font: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ─── Floating Bubble Button ──────────────────────────────────────────── */
.ctds-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--chat-primary);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--chat-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99998;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), 
              box-shadow 0.3s ease,
              background 0.2s ease;
  animation: ctds-bounce-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: 1s;
}
.ctds-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(242, 140, 40, 0.4);
  background: var(--chat-primary-dark);
}
.ctds-chat-bubble:active {
  transform: scale(0.95);
}
.ctds-chat-bubble svg {
  width: 28px;
  height: 28px;
  fill: var(--chat-white);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ctds-chat-bubble .ctds-icon-close {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}
.ctds-chat-bubble.active .ctds-icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}
.ctds-chat-bubble.active .ctds-icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Notification badge */
.ctds-chat-bubble .ctds-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #e74c3c;
  border-radius: 50%;
  border: 2px solid var(--chat-white);
  font-size: 10px;
  color: var(--chat-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--chat-font);
  font-weight: 700;
  animation: ctds-pulse 2s infinite;
}

@keyframes ctds-bounce-in {
  0% { opacity: 0; transform: scale(0) translateY(40px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes ctds-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ─── Chat Window ─────────────────────────────────────────────────────── */
.ctds-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 130px);
  border-radius: var(--chat-radius);
  background: var(--chat-bg);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--chat-font);
}
.ctds-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ─── Chat Header ─────────────────────────────────────────────────────── */
.ctds-chat-header {
  background: var(--chat-primary);
  color: var(--chat-white);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-radius: var(--chat-radius) var(--chat-radius) 0 0;
}
.ctds-chat-header-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}
.ctds-chat-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 12px;
  opacity: 0.9;
}
.ctds-chat-header-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ADE80;
  display: inline-block;
  flex-shrink: 0;
}
.ctds-chat-close {
  background: none;
  border: none;
  color: var(--chat-white);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ctds-chat-close:hover {
  background: rgba(255, 255, 255, 0.2);
}
.ctds-chat-close svg {
  width: 20px;
  height: 20px;
  fill: var(--chat-white);
}

/* ─── Messages Area ───────────────────────────────────────────────────── */
.ctds-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.ctds-chat-messages::-webkit-scrollbar {
  width: 5px;
}
.ctds-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.ctds-chat-messages::-webkit-scrollbar-thumb {
  background: var(--chat-border);
  border-radius: 4px;
}

/* Timestamp divider */
.ctds-msg-time {
  text-align: center;
  font-size: 11px;
  color: var(--chat-text-light);
  padding: 4px 12px;
  background: var(--chat-border);
  border-radius: 10px;
  align-self: center;
  margin: 4px 0;
}

/* Message bubbles */
.ctds-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: ctds-msg-in 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}
@keyframes ctds-msg-in {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}
.ctds-msg.bot {
  background: var(--chat-white);
  color: var(--chat-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.ctds-msg.visitor {
  background: var(--chat-primary);
  color: var(--chat-white);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.ctds-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
  background: var(--chat-white);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.ctds-typing span {
  width: 7px;
  height: 7px;
  background: var(--chat-border);
  border-radius: 50%;
  animation: ctds-typing-dot 1.4s infinite ease-in-out;
}
.ctds-typing span:nth-child(2) { animation-delay: 0.2s; }
.ctds-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ctds-typing-dot {
  0%, 60%, 100% { transform: translateY(0); background: var(--chat-border); }
  30% { transform: translateY(-5px); background: var(--chat-primary); }
}

/* ─── Contact Form (inside chat) ──────────────────────────────────────── */
.ctds-contact-form {
  background: var(--chat-white);
  padding: 14px 16px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  max-width: 82%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  animation: ctds-msg-in 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.ctds-contact-form label {
  display: block;
  font-size: 13px;
  color: var(--chat-text);
  font-weight: 500;
  margin-top: 10px;
  margin-bottom: 4px;
}
.ctds-contact-form label:first-child {
  margin-top: 0;
}
.ctds-contact-form input {
  width: 100%;
  border: none;
  border-bottom: 1.5px solid var(--chat-border);
  padding: 8px 0;
  font-size: 14px;
  font-family: var(--chat-font);
  color: var(--chat-text);
  background: transparent;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.ctds-contact-form input:focus {
  border-bottom-color: var(--chat-primary);
}
.ctds-contact-form input::placeholder {
  color: #bbb;
}
.ctds-contact-form button {
  width: 100%;
  margin-top: 14px;
  padding: 10px;
  background: #222;
  color: var(--chat-white);
  border: none;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--chat-font);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.ctds-contact-form button:hover {
  background: #444;
}
.ctds-contact-form button:active {
  transform: scale(0.97);
}
.ctds-contact-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.ctds-contact-form .ctds-form-error {
  color: #e74c3c;
  font-size: 12px;
  margin-top: 4px;
}

/* ─── Input Area ──────────────────────────────────────────────────────── */
.ctds-chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--chat-white);
  border-top: 1px solid var(--chat-border);
  flex-shrink: 0;
}
.ctds-chat-input input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: var(--chat-font);
  color: var(--chat-text);
  background: transparent;
  padding: 6px 0;
}
.ctds-chat-input input::placeholder {
  color: #aaa;
}
.ctds-chat-input button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
}
.ctds-chat-input button:hover {
  background: var(--chat-primary-light);
}
.ctds-chat-input button:active {
  transform: scale(0.9);
}
.ctds-chat-input button svg {
  width: 22px;
  height: 22px;
  fill: var(--chat-primary);
}
.ctds-chat-input button:disabled svg {
  fill: #ccc;
}

/* ─── Error toast ─────────────────────────────────────────────────────── */
.ctds-error-toast {
  position: absolute;
  top: 70px;
  left: 16px;
  right: 16px;
  background: #e74c3c;
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 10;
  animation: ctds-toast-in 0.3s ease, ctds-toast-out 0.3s ease 3.7s both;
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}
@keyframes ctds-toast-in {
  0% { opacity: 0; transform: translateY(-10px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes ctds-toast-out {
  0% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px); }
}
 
/* ─── Mobile Responsive ───────────────────────────────────────────────── */
@media (max-width: 480px) {
  .ctds-chat-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    max-width: 100vw;
    border-radius: 0;
  }
  .ctds-chat-header {
    border-radius: 0;
  }
  .ctds-chat-bubble {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }
  .ctds-chat-bubble svg {
    width: 24px;
    height: 24px;
  }
}