/* ==========================================================================
   DR. SUHAIL'S VIRTUAL DENTAL ASSISTANT CHATBOT - REDESIGN DENTAL CLINICS
   A premium, predefined interactive virtual assistant adhering to the
   clinic's luxury teal and gold-cyan aesthetic.
   ========================================================================== */

/* ─── CSS Variables & Design Tokens ──────────────────────────────────────── */
:root {
  --sh-teal-primary: #0e3032;
  --sh-teal-dark: #072426;
  --sh-teal-deep: #051a1c;
  --sh-teal-accent: #2ec4b6;
  --sh-teal-light: #e6f6f5;
  --sh-teal-border: rgba(14, 48, 50, 0.12);
  --sh-teal-glow: rgba(46, 196, 182, 0.28);
  --sh-gold-accent: #d4af37;
  
  --sh-bg-canvas: #f8fbfb;
  --sh-bg-card: #ffffff;
  --sh-bg-hover: #f0f7f7;
  --sh-text-main: #14282a;
  --sh-text-muted: #5e777a;
  --sh-text-white: #ffffff;
  
  --sh-radius-panel: 24px;
  --sh-radius-bubble: 18px;
  --sh-radius-chip: 999px;
  --sh-radius-btn: 12px;
  
  --sh-shadow-panel: 0 24px 60px -12px rgba(5, 26, 28, 0.35), 0 8px 24px -4px rgba(5, 26, 28, 0.15);
  --sh-shadow-card: 0 2px 8px rgba(14, 48, 50, 0.06);
  --sh-shadow-btn: 0 4px 14px rgba(14, 48, 50, 0.18);
  
  --sh-font-sans: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --sh-z-index: 9999;
}

/* ─── Chatbot Widget Overlay / Panel ──────────────────────────────────────── */
.sh-chat-widget {
  position: fixed;
  bottom: 120px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 630px;
  max-height: calc(100vh - 140px);
  background: var(--sh-bg-canvas);
  border-radius: var(--sh-radius-panel);
  box-shadow: var(--sh-shadow-panel);
  border: 1px solid var(--sh-teal-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--sh-z-index);
  font-family: var(--sh-font-sans);
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.sh-chat-widget.is-active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ─── Chatbot Header ──────────────────────────────────────────────────────── */
.sh-chat-header {
  background: linear-gradient(135deg, var(--sh-teal-dark) 0%, var(--sh-teal-primary) 100%);
  color: var(--sh-text-white);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(5, 26, 28, 0.15);
}

.sh-header-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.sh-avatar-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(46, 196, 182, 0.6);
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--sh-teal-glow);
}

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

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

.sh-header-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.2px;
  color: #ffffff;
  margin: 0;
}

.sh-header-subtitle {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.78);
  margin: 1px 0 0 0;
  font-weight: 400;
}

.sh-header-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  color: #a7f3d0;
  font-weight: 600;
  margin-top: 2px;
}

.sh-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: shPulseDot 2s infinite ease-in-out;
}

@keyframes shPulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

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

.sh-header-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.2s ease;
}

.sh-header-btn:hover {
  background: rgba(255, 255, 255, 0.24);
  transform: scale(1.06);
}

.sh-header-btn:active {
  transform: scale(0.95);
}

.sh-header-btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.sh-header-reset-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  width: auto;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sh-header-reset-btn svg {
  width: 12px;
  height: 12px;
}

/* ─── Chat Body / Conversation Scroll Area ────────────────────────────────── */
.sh-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  background: var(--sh-bg-canvas);
  -webkit-overflow-scrolling: touch;
}

.sh-chat-body::-webkit-scrollbar {
  width: 5px;
}

.sh-chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.sh-chat-body::-webkit-scrollbar-thumb {
  background: rgba(14, 48, 50, 0.15);
  border-radius: 10px;
}

/* ─── Chat Message Item ───────────────────────────────────────────────────── */
.sh-message-row {
  display: flex;
  gap: 10px;
  width: 100%;
  animation: shMessageFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.sh-message-row.is-assistant {
  align-items: flex-start;
  justify-content: flex-start;
}

.sh-message-row.is-user {
  align-items: flex-end;
  justify-content: flex-end;
}

.sh-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--sh-teal-light);
  border: 1.5px solid var(--sh-teal-accent);
  padding: 1px;
  flex-shrink: 0;
  margin-top: 2px;
}

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

.sh-msg-content-wrap {
  max-width: 86%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sh-msg-bubble {
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}

.sh-message-row.is-assistant .sh-msg-bubble {
  background: var(--sh-bg-card);
  color: var(--sh-text-main);
  border-radius: 4px var(--sh-radius-bubble) var(--sh-radius-bubble) var(--sh-radius-bubble);
  border: 1px solid var(--sh-teal-border);
  box-shadow: var(--sh-shadow-card);
}

.sh-message-row.is-user .sh-msg-bubble {
  background: linear-gradient(135deg, var(--sh-teal-primary) 0%, var(--sh-teal-dark) 100%);
  color: #ffffff;
  border-radius: var(--sh-radius-bubble) 4px var(--sh-radius-bubble) var(--sh-radius-bubble);
  box-shadow: 0 4px 14px rgba(14, 48, 50, 0.2);
}

.sh-msg-bubble p {
  margin: 0 0 8px 0;
}

.sh-msg-bubble p:last-child {
  margin-bottom: 0;
}

.sh-msg-time {
  font-size: 10px;
  color: var(--sh-text-muted);
  align-self: flex-start;
  margin-top: 2px;
}

.sh-message-row.is-user .sh-msg-time {
  align-self: flex-end;
}

/* ─── Typing Indicator ────────────────────────────────────────────────────── */
.sh-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--sh-bg-card);
  border: 1px solid var(--sh-teal-border);
  border-radius: 4px var(--sh-radius-bubble) var(--sh-radius-bubble) var(--sh-radius-bubble);
  box-shadow: var(--sh-shadow-card);
}

.sh-typing-dot {
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  background: var(--sh-teal-accent);
  animation: shDotBounce 1.4s infinite ease-in-out both;
}

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

@keyframes shDotBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1.15);
    opacity: 1;
    background: var(--sh-teal-primary);
  }
}

.sh-typing-text {
  font-size: 11px;
  color: var(--sh-text-muted);
  font-style: italic;
  margin-left: 4px;
}

/* ─── CTA Action Buttons Inside Chat ──────────────────────────────────────── */
.sh-cta-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.sh-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--sh-font-sans);
  border-radius: var(--sh-radius-btn);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  border: none;
  box-shadow: var(--sh-shadow-btn);
}

.sh-cta-btn.is-primary {
  background: linear-gradient(135deg, var(--sh-teal-primary) 0%, #1a4f52 100%);
  color: #ffffff !important;
}

.sh-cta-btn.is-primary:hover {
  background: linear-gradient(135deg, #133f42 0%, #206165 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(14, 48, 50, 0.28);
}

.sh-cta-btn.is-secondary {
  background: var(--sh-teal-light);
  color: var(--sh-teal-primary) !important;
  border: 1px solid rgba(46, 196, 182, 0.4);
  box-shadow: none;
}

.sh-cta-btn.is-secondary:hover {
  background: #d8f1ef;
  color: var(--sh-teal-dark) !important;
  transform: translateY(-2px);
  border-color: var(--sh-teal-accent);
}

.sh-cta-btn.is-whatsapp {
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  color: #ffffff !important;
}

.sh-cta-btn.is-whatsapp:hover {
  background: linear-gradient(135deg, #22bf5b 0%, #0f776b 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.35);
}

.sh-cta-btn.is-call {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff !important;
}

.sh-cta-btn.is-call:hover {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.35);
}

.sh-cta-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  flex-shrink: 0;
}

/* ─── Dedicated Quick Questions Panel ────────────────────────────────────── */
.sh-quick-questions-area {
  background: #ffffff;
  border-top: 1px solid rgba(14, 48, 50, 0.1);
  padding: 12px 16px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sh-qq-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--sh-text-muted);
}

.sh-qq-list,
.sh-qq-expanded-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sh-qq-expanded-panel {
  max-height: 160px;
  overflow-y: auto;
  padding-right: 4px;
  margin-top: 2px;
}

.sh-qq-expanded-panel::-webkit-scrollbar {
  width: 4px;
}

.sh-qq-expanded-panel::-webkit-scrollbar-thumb {
  background: rgba(14, 48, 50, 0.15);
  border-radius: 4px;
}

.sh-qq-btn {
  background: var(--sh-teal-light);
  color: var(--sh-teal-primary);
  border: 1px solid rgba(46, 196, 182, 0.3);
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--sh-font-sans);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  line-height: 1.35;
}

.sh-qq-btn:hover {
  background: var(--sh-teal-primary);
  color: #ffffff;
  border-color: var(--sh-teal-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(14, 48, 50, 0.14);
}

.sh-qq-btn:active {
  transform: translateY(0);
}

.sh-see-more-btn {
  background: transparent;
  border: 1px dashed rgba(14, 48, 50, 0.25);
  color: var(--sh-teal-primary);
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--sh-font-sans);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  margin-top: 2px;
}

.sh-see-more-btn:hover {
  background: var(--sh-teal-light);
  border-color: var(--sh-teal-accent);
}

.sh-see-more-icon {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease;
}

.sh-see-more-icon svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.sh-see-more-btn.is-expanded .sh-see-more-icon {
  transform: rotate(180deg);
}

/* ─── Chatbot Footer / Search Bar ─────────────────────────────────────────── */
.sh-chat-footer {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid var(--sh-teal-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  position: relative;
}

.sh-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.sh-search-icon {
  position: absolute;
  left: 12px;
  width: 15px;
  height: 15px;
  fill: var(--sh-text-muted);
  pointer-events: none;
}

.sh-search-input {
  width: 100%;
  padding: 9px 34px 9px 36px;
  font-size: 13px;
  font-family: var(--sh-font-sans);
  border: 1px solid rgba(14, 48, 50, 0.18);
  border-radius: var(--sh-radius-chip);
  background: var(--sh-bg-canvas);
  color: var(--sh-text-main);
  outline: none;
  transition: all 0.2s ease;
}

.sh-search-input:focus {
  background: #ffffff;
  border-color: var(--sh-teal-accent);
  box-shadow: 0 0 0 3px rgba(46, 196, 182, 0.18);
}

.sh-search-input::placeholder {
  color: #8da4a6;
}

.sh-search-clear {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--sh-text-muted);
  cursor: pointer;
  padding: 4px;
  display: none;
  align-items: center;
  justify-content: center;
}

.sh-search-clear.is-visible {
  display: flex;
}

.sh-search-clear svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

/* ─── Live Search Filter Dropdown / Results ────────────────────────────────── */
.sh-search-results {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 14px;
  right: 14px;
  background: #ffffff;
  border: 1px solid var(--sh-teal-border);
  border-radius: 16px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 12px 32px rgba(5, 26, 28, 0.18);
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.sh-search-results.is-active {
  display: flex;
}

.sh-search-item {
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--sh-text-main);
  background: transparent;
  border: none;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
  line-height: 1.35;
}

.sh-search-item:hover,
.sh-search-item:focus {
  background: var(--sh-teal-light);
  color: var(--sh-teal-dark);
}

.sh-search-empty {
  padding: 12px;
  font-size: 12px;
  color: var(--sh-text-muted);
  text-align: center;
}

/* ─── Footer Clinic Notice ────────────────────────────────────────────────── */
.sh-footer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: var(--sh-text-muted);
  padding: 0 4px;
}

.sh-start-over-link {
  color: var(--sh-teal-primary);
  background: none;
  border: none;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.sh-start-over-link:hover {
  color: var(--sh-teal-accent);
}

/* ─── Doctor Floating Button Desktop Tooltip ──────────────────────────────── */
.sh-doc-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  background: rgba(7, 36, 38, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--sh-font-sans);
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(5, 26, 28, 0.35);
  border: 1px solid rgba(46, 196, 182, 0.3);
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1000;
}

.sh-doc-tooltip::after {
  content: '';
  position: absolute;
  bottom: -5px;
  right: 26px;
  width: 10px;
  height: 10px;
  background: rgba(7, 36, 38, 0.94);
  transform: rotate(45deg);
  border-right: 1px solid rgba(46, 196, 182, 0.3);
  border-bottom: 1px solid rgba(46, 196, 182, 0.3);
}

.rc-float-doc:hover .sh-doc-tooltip {
  opacity: 1;
  transform: translateY(0);
}

/* Hide tooltip immediately when button is active, focused, clicked, or chatbot is open */
.rc-float-doc:active .sh-doc-tooltip,
.rc-float-doc:focus .sh-doc-tooltip,
.rc-float-doc.is-active .sh-doc-tooltip,
.sh-chat-widget.is-active ~ .rc-floating-actions .sh-doc-tooltip,
body.sh-chat-open .sh-doc-tooltip {
  opacity: 0 !important;
  visibility: hidden !important;
  display: none !important;
  pointer-events: none !important;
}

/* ─── Backdrop / Click-Outside Catcher ────────────────────────────────────── */
.sh-chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 26, 28, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: calc(var(--sh-z-index) - 1);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  pointer-events: none;
}

.sh-chat-backdrop.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ─── Mobile Responsiveness (< 768px) ─────────────────────────────────────── */
@media (max-width: 768px) {
  .sh-chat-widget {
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    height: auto;
    max-height: 80vh;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    border-radius: 24px;
    box-shadow: 0 16px 48px rgba(5, 26, 28, 0.4);
    transform: translateY(30px) scale(0.98);
  }

  .sh-chat-widget.is-active {
    transform: translateY(0) scale(1);
  }

  .sh-chat-header {
    padding: 12px 14px;
  }

  .sh-avatar-wrapper {
    width: 38px;
    height: 38px;
  }

  .sh-header-title {
    font-size: 14px;
  }

  .sh-header-subtitle {
    font-size: 11px;
  }

  .sh-chat-body {
    padding: 14px 12px;
    gap: 12px;
  }

  .sh-msg-bubble {
    font-size: 13px;
    padding: 10px 14px;
  }

  .sh-qq-btn {
    font-size: 12px;
    padding: 8px 11px;
  }

  .sh-doc-tooltip {
    display: none !important;
  }
}

/* ─── Reduced Motion Support ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .sh-chat-widget,
  .sh-message-row,
  .sh-status-dot,
  .sh-typing-dot,
  .sh-qq-btn,
  .sh-cta-btn {
    animation: none !important;
    transition: none !important;
  }
}
