/* ═══════════════════════════════════════════════════════════
   CLEAR SMILE CHAT WIDGET - CSS
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

/* ── CSS Variables ──────────────────────────────────────── */
:root {
  --cs-primary: #1aa6a1;
  --cs-primary-dark: #148a86;
  --cs-primary-light: #e8f8f7;
  --cs-secondary: #0d6e69;
  --cs-accent: #5dd8d3;
  --cs-white: #ffffff;
  --cs-gray-50: #f8fffe;
  --cs-gray-100: #f0fafa;
  --cs-gray-200: #e2f5f4;
  --cs-gray-500: #6b7280;
  --cs-gray-700: #374151;
  --cs-gray-900: #111827;
  --cs-shadow-sm: 0 2px 8px rgba(26,166,161,0.12);
  --cs-shadow-md: 0 8px 32px rgba(26,166,161,0.18);
  --cs-shadow-lg: 0 20px 60px rgba(26,166,161,0.22);
  --cs-shadow-xl: 0 30px 80px rgba(0,0,0,0.18);
  --cs-radius: 16px;
  --cs-radius-msg: 14px;
  --widget-width: 350px;
  --widget-height: 520px;
  --z-widget: 99999;
}

/* ── Widget Container ────────────────────────────────────── */
#cs-chat-widget {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: var(--z-widget);
  font-family: 'Outfit', 'Segoe UI', Arial, sans-serif;
  direction: rtl;
}

/* ── Floating Toggle Button ──────────────────────────────── */
#cs-chat-toggle {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--cs-primary), var(--cs-secondary));
  box-shadow: 0 4px 12px rgba(26,166,161,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

#cs-chat-toggle:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: var(--cs-shadow-md);
}

#cs-chat-toggle:active {
  transform: scale(0.96);
}

@keyframes cs-pulse {
  0%, 100% { box-shadow: var(--cs-shadow-md), 0 0 0 0 rgba(26,166,161,0.4); }
  50% { box-shadow: var(--cs-shadow-md), 0 0 0 12px rgba(26,166,161,0); }
}

/* Toggle icons */
#cs-chat-toggle .cs-icon-chat,
#cs-chat-toggle .cs-icon-close {
  position: absolute;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#cs-chat-toggle .cs-icon-chat {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

#cs-chat-toggle .cs-icon-close {
  opacity: 0;
  transform: scale(0.3) rotate(-90deg);
}

#cs-chat-widget.cs-open #cs-chat-toggle .cs-icon-chat {
  opacity: 0;
  transform: scale(0.3) rotate(90deg);
}

#cs-chat-widget.cs-open #cs-chat-toggle .cs-icon-close {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* Notification badge */
#cs-notification-badge {
  position: absolute;
  top: -3px;
  left: -3px;
  width: 20px;
  height: 20px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid white;
  font-size: 11px;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#cs-notification-badge.visible {
  opacity: 1;
  transform: scale(1);
}

/* Tooltip */
#cs-chat-tooltip {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  background: var(--cs-gray-900);
  color: white;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.25s ease;
  pointer-events: none;
}

#cs-chat-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 20px;
  border: 6px solid transparent;
  border-top-color: var(--cs-gray-900);
}

#cs-chat-widget:not(.cs-open) #cs-chat-toggle:hover + #cs-chat-tooltip {
  opacity: 1;
  transform: translateY(0);
}

/* ── Chat Window ─────────────────────────────────────────── */
#cs-chat-window {
  position: absolute;
  bottom: calc(100% + 16px);
  right: 0;
  width: var(--widget-width);
  height: var(--widget-height);
  background: var(--cs-white);
  border-radius: var(--cs-radius);
  box-shadow: var(--cs-shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.88) translateY(20px);
  transform-origin: bottom right;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid rgba(26,166,161,0.12);
}

#cs-chat-widget.cs-open #cs-chat-window {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

/* ── Chat Header ─────────────────────────────────────────── */
#cs-chat-header {
  background: linear-gradient(135deg, var(--cs-primary) 0%, var(--cs-secondary) 100%);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

#cs-chat-header::before {
  content: '';
  position: absolute;
  top: -30px;
  left: -30px;
  width: 120px;
  height: 120px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}

#cs-chat-header::after {
  content: '';
  position: absolute;
  bottom: -40px;
  right: 20px;
  width: 100px;
  height: 100px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}

.cs-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.cs-header-info {
  flex: 1;
  position: relative;
  z-index: 1;
}

.cs-header-name {
  font-size: 15px;
  font-weight: 700;
  color: white;
  margin: 0 0 3px;
}

.cs-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: rgba(255,255,255,0.85);
}

.cs-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(74,222,128,0.3);
  animation: cs-blink 2s infinite;
}

@keyframes cs-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.cs-header-actions {
  display: flex;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.cs-header-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.cs-header-btn:hover {
  background: rgba(255,255,255,0.25);
}

/* ── FAQ Quick Access ────────────────────────────────────── */
#cs-faq-bar {
  background: var(--cs-gray-50);
  border-bottom: 1px solid var(--cs-gray-200);
  padding: 10px 14px;
  flex-shrink: 0;
  transition: max-height 0.3s ease;
}

#cs-faq-bar.cs-expanded {
  overflow-y: auto;
}

.cs-faq-bar-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--cs-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.cs-faq-bar-label svg {
  transition: transform 0.3s;
}

#cs-faq-bar.cs-expanded .cs-faq-bar-label svg {
  transform: rotate(180deg);
}

.cs-faq-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transition: all 0.3s ease;
}

#cs-faq-bar.cs-expanded .cs-faq-chips {
  max-height: 300px;
  opacity: 1;
  pointer-events: all;
}

.cs-faq-chip {
  background: white;
  border: 1px solid var(--cs-primary);
  color: var(--cs-primary-dark);
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.cs-faq-chip:hover {
  background: var(--cs-primary);
  color: white;
  transform: translateY(-1px);
}

/* ── Messages Area ───────────────────────────────────────── */
#cs-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background:
    radial-gradient(ellipse at top left, rgba(26,166,161,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(26,166,161,0.03) 0%, transparent 50%),
    white;
}

#cs-messages::-webkit-scrollbar {
  width: 4px;
}

#cs-messages::-webkit-scrollbar-track {
  background: transparent;
}

#cs-messages::-webkit-scrollbar-thumb {
  background: var(--cs-gray-200);
  border-radius: 2px;
}

/* ── Message Bubbles ─────────────────────────────────────── */
.cs-message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: cs-msg-appear 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 88%;
}

@keyframes cs-msg-appear {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.cs-message.cs-bot {
  align-self: flex-start;
  flex-direction: row-reverse;
}

.cs-message.cs-user {
  align-self: flex-end;
}

.cs-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cs-primary), var(--cs-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cs-msg-bubble {
  padding: 10px 14px;
  border-radius: var(--cs-radius-msg);
  font-size: 14px;
  line-height: 1.6;
  max-width: 100%;
  word-break: break-word;
  white-space: pre-line;
}

.cs-message.cs-bot .cs-msg-bubble {
  background: var(--cs-gray-100);
  color: var(--cs-gray-900);
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.cs-message.cs-user .cs-msg-bubble {
  background: linear-gradient(135deg, var(--cs-primary), var(--cs-secondary));
  color: white;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(26,166,161,0.2);
}

.cs-message.cs-pending .cs-msg-bubble {
  background: #fef9c3;
  color: #92400e;
  border: 1px solid #fde68a;
}

.cs-msg-time {
  font-size: 10px;
  color: var(--cs-gray-500);
  margin-top: 3px;
  text-align: left;
}

.cs-message.cs-bot .cs-msg-time { text-align: right; }

/* ── Typing Indicator ────────────────────────────────────── */
#cs-typing {
  display: none;
  align-self: flex-start;
  flex-direction: row-reverse;
  align-items: flex-end;
  gap: 8px;
}

#cs-typing.cs-visible {
  display: flex;
  animation: cs-msg-appear 0.3s ease;
}

.cs-typing-bubble {
  background: var(--cs-gray-100);
  border-radius: var(--cs-radius-msg);
  border-bottom-right-radius: 6px;
  padding: 12px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
  box-shadow: var(--cs-shadow-sm);
}

.cs-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cs-primary);
  opacity: 0.4;
  animation: cs-typing-bounce 1.2s infinite;
}

.cs-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.cs-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes cs-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Admin Reply Badge ───────────────────────────────────── */
.cs-admin-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: var(--cs-primary);
  font-weight: 600;
  background: var(--cs-primary-light);
  border: 1px solid rgba(26,166,161,0.2);
  border-radius: 20px;
  padding: 5px 12px;
  align-self: center;
  animation: cs-msg-appear 0.3s ease;
}

/* ── Input Area ──────────────────────────────────────────── */
#cs-input-area {
  padding: 12px 14px;
  background: white;
  border-top: 1px solid var(--cs-gray-200);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

#cs-input {
  flex: 1;
  border: 1.5px solid var(--cs-gray-200);
  border-radius: 14px;
  padding: 10px 14px;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  color: var(--cs-gray-900);
  background: var(--cs-gray-50);
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 120px;
  transition: all 0.2s;
  direction: rtl;
  line-height: 1.5;
}

#cs-input::placeholder {
  color: var(--cs-gray-500);
}

#cs-input:focus {
  border-color: var(--cs-primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(26,166,161,0.1);
}

#cs-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--cs-primary), var(--cs-secondary));
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 12px rgba(26,166,161,0.35);
}

#cs-send-btn:hover {
  transform: scale(1.08) translateY(-1px);
  box-shadow: 0 6px 20px rgba(26,166,161,0.45);
}

#cs-send-btn:active {
  transform: scale(0.95);
}

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

/* ── Connection Status Bar ───────────────────────────────── */
#cs-status-bar {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px;
  font-size: 12px;
  font-weight: 500;
  background: #fee2e2;
  color: #b91c1c;
  border-bottom: 1px solid #fecaca;
  flex-shrink: 0;
}

#cs-status-bar.visible {
  display: flex;
}

#cs-status-bar.connecting {
  background: #fef9c3;
  color: #92400e;
  border-color: #fde68a;
}

/* ── FAQ Page Section ────────────────────────────────────── */
#cs-faq-section {
  padding: 80px 20px;
  background: linear-gradient(180deg, #f0fafa 0%, #ffffff 100%);
}

.cs-faq-container {
  max-width: 800px;
  margin: 0 auto;
}

.cs-faq-header {
  text-align: center;
  margin-bottom: 50px;
}

.cs-faq-badge {
  display: inline-block;
  background: var(--cs-primary-light);
  color: var(--cs-primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 16px;
  border-radius: 20px;
  margin-bottom: 16px;
  border: 1px solid rgba(26,166,161,0.2);
}

.cs-faq-title {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 800;
  color: var(--cs-gray-900);
  margin-bottom: 14px;
  line-height: 1.2;
}

.cs-faq-subtitle {
  font-size: 16px;
  color: var(--cs-gray-500);
  line-height: 1.6;
  max-width: 520px;
  margin: 0 auto;
}

/* FAQ Items */
.cs-faq-item {
  background: white;
  border: 1.5px solid var(--cs-gray-200);
  border-radius: 14px;
  margin-bottom: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.cs-faq-item:hover {
  border-color: var(--cs-primary);
  box-shadow: 0 4px 20px rgba(26,166,161,0.12);
  transform: translateY(-1px);
}

.cs-faq-item.cs-active {
  border-color: var(--cs-primary);
  box-shadow: 0 6px 24px rgba(26,166,161,0.15);
}

.cs-faq-question {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--cs-gray-900);
  text-align: right;
  gap: 12px;
  transition: color 0.2s;
}

.cs-faq-question:hover,
.cs-faq-item.cs-active .cs-faq-question {
  color: var(--cs-primary);
}

.cs-faq-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--cs-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cs-faq-item.cs-active .cs-faq-icon {
  background: var(--cs-primary);
  color: white;
  transform: rotate(45deg);
}

.cs-faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), padding 0.3s ease;
  padding: 0 22px;
}

.cs-faq-answer-inner {
  font-size: 14.5px;
  color: var(--cs-gray-700);
  line-height: 1.8;
  padding-bottom: 18px;
  white-space: pre-line;
  border-top: 1px solid var(--cs-gray-200);
  padding-top: 14px;
}

.cs-faq-item.cs-active .cs-faq-answer {
  max-height: 500px;
}

/* CTA at bottom of FAQ */
.cs-faq-cta {
  margin-top: 40px;
  text-align: center;
  padding: 32px;
  background: linear-gradient(135deg, var(--cs-primary-light), white);
  border-radius: 16px;
  border: 1.5px solid rgba(26,166,161,0.2);
}

.cs-faq-cta h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--cs-gray-900);
  margin-bottom: 10px;
}

.cs-faq-cta p {
  color: var(--cs-gray-500);
  font-size: 14px;
  margin-bottom: 18px;
}

.cs-faq-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--cs-primary), var(--cs-secondary));
  color: white;
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 28px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 16px rgba(26,166,161,0.35);
  text-decoration: none;
}

.cs-faq-cta-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 24px rgba(26,166,161,0.45);
  color: white;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  #cs-chat-widget {
    bottom: 16px;
    right: 16px;
  }

  /* Full screen chat on mobile */
  #cs-chat-widget.cs-open {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
  }

  #cs-chat-widget.cs-open #cs-chat-toggle {
    display: none; /* Hide toggle button when open on mobile */
  }

  #cs-chat-widget.cs-open #cs-chat-window {
    width: 100vw;
    height: 100%;
    height: 100dvh; /* Use dynamic viewport height for mobile browsers */
    bottom: 0;
    right: 0;
    border-radius: 0;
    border: none;
    transform: none !important;
  }
  
  .cs-msg-bubble {
    font-size: 14px;
    padding: 10px 14px;
  }
}
