/* ══════════════════════════════════════════
   Dr Jawad Physio – Chatbot Widget Styles
   v1.2  —  Chatbot on BOTTOM RIGHT
            Book Now pill is on BOTTOM LEFT (in style.css)
            No overlap possible.
══════════════════════════════════════════ */

/* ── Widget root ── */
#djp-chat-widget {
  position: fixed;
  bottom: 28px;
  right: 28px;           /* chatbot stays right */
  z-index: 999;
  font-family: 'DM Sans', system-ui, sans-serif;
}

/* ── Toggle button ── */
#djp-chat-toggle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(140deg, #1D9E75 0%, #0F6E56 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(29,158,117,.5), 0 1px 4px rgba(0,0,0,.12);
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .22s ease;
  position: relative;
  outline: none;
}
#djp-chat-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 28px rgba(29,158,117,.55), 0 2px 6px rgba(0,0,0,.14);
}
#djp-chat-toggle:active { transform: scale(.95); }
#djp-chat-toggle:focus-visible {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px #1D9E75;
}

/* pulse ring behind toggle */
#djp-chat-toggle::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(29,158,117,.35);
  animation: chat-ring 3s ease infinite;
}
@keyframes chat-ring {
  0%,100% { transform:scale(1);   opacity:.5; }
  50%      { transform:scale(1.18); opacity:0; }
}

/* ── Notification badge ── */
.chat-badge {
  position: absolute;
  top: -3px; right: -3px;
  width: 20px; height: 20px;
  background: #EF9F27;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: badge-pulse 2.2s ease infinite;
  pointer-events: none;
}
.chat-badge.hidden { display: none; }
@keyframes badge-pulse {
  0%,100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(239,159,39,.5); }
  50%      { transform: scale(1.12); box-shadow: 0 0 0 5px rgba(239,159,39,0); }
}

/* ── Chat window ── */
#djp-chat-window {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 370px;
  max-height: 600px;
  background: #fff;
  border-radius: 18px;
  box-shadow:
    0 24px 64px rgba(4,52,44,.22),
    0 6px 20px rgba(0,0,0,.10),
    0 0 0 1px rgba(4,52,44,.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: chat-open .28s cubic-bezier(.34,1.56,.64,1);
}
#djp-chat-window[hidden] { display: none !important; }

@keyframes chat-open {
  from { opacity: 0; transform: scale(.82) translateY(20px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* ── Header ── */
.chat-header {
  background: linear-gradient(135deg, #04342C 0%, #0F6E56 100%);
  padding: 15px 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.chat-header-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.22);
  font-size: 18px;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-info strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: rgba(255,255,255,.65);
  margin-top: 2px;
}
.status-dot {
  width: 7px; height: 7px;
  background: #5DCAA5;
  border-radius: 50%;
  animation: status-blink 2.5s ease infinite;
}
@keyframes status-blink {
  0%,100% { opacity:1; } 50% { opacity:.3; }
}
.chat-close-btn {
  width: 30px; height: 30px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
  flex-shrink: 0;
}
.chat-close-btn:hover { background: rgba(255,255,255,.25); }
.chat-close-btn svg   { display: block; }

/* ── Disclaimer banner ── */
.chat-disclaimer {
  background: #E1F5EE;
  border-bottom: 1px solid #C0EAD8;
  padding: 8px 14px;
  font-size: 11px;
  color: #0A5C42;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  line-height: 1.55;
  flex-shrink: 0;
}
.chat-disclaimer-icon {
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Messages ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb {
  background: #D3D1C7;
  border-radius: 4px;
}
.chat-messages::-webkit-scrollbar-track { background: transparent; }

.chat-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: msg-in .2s ease both;
}
@keyframes msg-in {
  from { opacity:0; transform:translateY(8px); }
  to   { opacity:1; transform:translateY(0); }
}
.chat-msg.user { flex-direction: row-reverse; }
.chat-msg.bot  { flex-direction: row; }

.msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 600;
}
.chat-msg.bot  .msg-avatar { background: #E1F5EE; font-size: 15px; }
.chat-msg.user .msg-avatar { background: #1D9E75; color: #fff; font-size: 11px; }

.msg-content { display: flex; flex-direction: column; max-width: 80%; }
.chat-msg.user .msg-content { align-items: flex-end; }
.chat-msg.bot  .msg-content { align-items: flex-start; }

.msg-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.58;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.bot  .msg-bubble {
  background: #F1EFE8;
  color: #2C2C2A;
  border-bottom-left-radius: 4px;
}
.chat-msg.user .msg-bubble {
  background: linear-gradient(135deg, #1D9E75 0%, #0F6E56 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(29,158,117,.3);
}
.msg-time {
  font-size: 10px;
  color: #888780;
  margin-top: 3px;
  padding: 0 2px;
}

/* Typing indicator */
#djp-typing { margin-top: 2px; }
.typing-wrap { display: flex; align-items: center; gap: 8px; }
.typing-dots {
  background: #F1EFE8;
  padding: 10px 14px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 5px;
  align-items: center;
}
.typing-dots span {
  width: 7px; height: 7px;
  background: #9E9B94;
  border-radius: 50%;
  animation: typing-bounce 1.3s ease infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .18s; }
.typing-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes typing-bounce {
  0%,80%,100% { transform:translateY(0); opacity:.45; }
  40%          { transform:translateY(-5px); opacity:1; }
}

/* ── Quick replies ── */
.chat-quick-replies {
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  border-top: 1px solid #F1EFE8;
  flex-shrink: 0;
  background: #FAFAF8;
}
.quick-reply {
  background: #fff;
  color: #0F6E56;
  border: 1.5px solid #C0EAD8;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all .18s ease;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(4,52,44,.06);
}
.quick-reply:hover {
  background: #1D9E75;
  color: #fff;
  border-color: #1D9E75;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(29,158,117,.3);
}

/* ── Input row ── */
.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #EDEDEA;
  align-items: flex-end;
  flex-shrink: 0;
  background: #fff;
}
#chat-input {
  flex: 1;
  border: 1.5px solid #D3D1C7;
  border-radius: 10px;
  padding: 9px 12px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 13.5px;
  resize: none;
  outline: none;
  color: #2C2C2A;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color .2s, box-shadow .2s;
  line-height: 1.5;
  background: #fff;
}
#chat-input:focus {
  border-color: #1D9E75;
  box-shadow: 0 0 0 3px rgba(29,158,117,.1);
}
#chat-input::placeholder { color: #A0A09A; }

#chat-send-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1D9E75 0%, #0F6E56 100%);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity .18s, transform .15s;
  box-shadow: 0 2px 8px rgba(29,158,117,.35);
}
#chat-send-btn:hover   { opacity: .88; }
#chat-send-btn:active  { transform: scale(.92); }
#chat-send-btn:disabled {
  background: #D3D1C7;
  box-shadow: none;
  cursor: not-allowed;
}

/* ── In-chat booking form ── */
.chat-booking-form {
  background: #F5F4F0;
  border-top: 1px solid #E0DDD6;
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex-shrink: 0;
  animation: msg-in .22s ease both;
}
.chat-booking-form[hidden] { display: none; }
.cbf-header {
  font-size: 13px;
  font-weight: 600;
  color: #04342C;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-booking-form input,
.chat-booking-form select {
  background: #fff;
  border: 1.5px solid #D3D1C7;
  border-radius: 8px;
  padding: 8px 11px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 13px;
  color: #2C2C2A;
  outline: none;
  width: 100%;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
}
.chat-booking-form input:focus,
.chat-booking-form select:focus {
  border-color: #1D9E75;
  box-shadow: 0 0 0 3px rgba(29,158,117,.1);
}
.chat-booking-form .btn-primary {
  width: 100%;
  justify-content: center;
  padding: 10px;
  font-size: 13.5px;
}
#cbf-notice {
  font-size: 12.5px;
  min-height: 16px;
  font-family: 'DM Sans', system-ui, sans-serif;
}
#cbf-notice.ok  { color: #0F6E56; }
#cbf-notice.err { color: #A32D2D; }

/* ── Footer note ── */
.chat-footer-note {
  text-align: center;
  font-size: 11px;
  color: #A0A09A;
  padding: 6px 0 8px;
  border-top: 1px solid #F1EFE8;
  flex-shrink: 0;
  line-height: 1.5;
}
.chat-footer-note a { color: #1D9E75; }

/* ═══════════════════════════════════════════
   RESPONSIVE — chatbot
═══════════════════════════════════════════ */
@media (max-width: 500px) {
  #djp-chat-widget { right: 14px; bottom: 16px; }
  #djp-chat-window {
    width: calc(100vw - 28px);
    right: 0;
    bottom: 74px;
    max-height: 78vh;
    border-radius: 16px;
  }
}
