/* ============================================================
   AbhaCare Ultra Premium Chatbot CSS
   LOCATION: abhacare/assets/css/chatbot.css
   ============================================================ */

.abha-cart-bot {
  --green: #046a38;
  --green-dark: #0a7d44;
  --orange: #ff7a18;
  --orange-dark: #e06812;
  --white: #ffffff;
  --bg: #f4f6f5;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 32px 64px rgba(0, 0, 0, 0.18), 0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
  --radius: 20px;
  --radius-sm: 12px;
  --font: "DM Sans", sans-serif;
  --font-display: "Playfair Display", serif;
}

.abha-cart-bot {
  font-family: var(--font);
}

/* ====== FLOATING TOGGLE ====== */
#chatbot-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 67px;
  height: 67px;
  background-color: #046a38;
  background-image: url("../img/abha-assistant-60x60.webp");
  background-size: cover;
  background-position: center;
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow:
    0 6px 28px rgba(15, 157, 88, 0.45),
    0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s,
    opacity 0.3s;
}
#chatbot-toggle:hover {
  box-shadow: 0 10px 36px rgba(15, 157, 88, 0.55);
}
#chatbot-toggle.hide {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.7);
}
#chatbot-toggle svg {
  width: 26px;
  height: 26px;
}

/* Notification dot */
#chatbot-toggle::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 12px;
  height: 12px;
  background: #ff671f;
  border-radius: 50%;
  border: 2px solid white;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.7;
  }
}
#chatbot-toggle.hide::after {
  display: none;
}

/* ====== CHAT WINDOW — DESKTOP ====== */
#chatbot-box {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 370px;
  max-height: 560px;
  display: none;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 9997;
  background: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow-lg);
  transform: translateY(24px) scale(0.95);
  opacity: 0;
  transition:
    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.3s ease;
}
#chatbot-box.active {
  transform: translateY(0) scale(1);
  opacity: 1;
}
#chatbot-box.fullscreen {
  width: min(94vw, 500px);
  height: 88vh;
  max-height: none;
  bottom: 6vh;
  right: 3vw;
  border-radius: var(--radius);
}

/* ====== HEADER ====== */
.chat-header {
  background-color: #0a7d44;
  padding: 16px 18px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  flex-shrink: 0;
}
.chat-header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
}
.chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-avatar {
  width: 45px;
  height: 45px;
  background-color: #046a38;
  background-image: url("../img/abha-assistant-40x40.webp");
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}
.chat-header-text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 15px;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.chat-header-text span {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}
.online-dot {
  width: 7px;
  height: 7px;
  background: #ff671f;
  border-radius: 50%;
  display: inline-block;
  animation: pulse-dot 1.8s infinite;
}
.chat-actions {
  display: flex;
  gap: 6px;
}
.chat-actions button {
  background: #e06812;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s,
    transform 0.15s;
  flex-shrink: 0;
}
.chat-actions button:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.08);
}
.chat-actions button svg {
  width: 15px;
  height: 15px;
}

/* ====== PROGRESS STEPS ====== */
.chat-progress {
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  padding: 10px 18px 8px;
  display: flex;
  flex-shrink: 0;
}
.step-item {
  flex: 1;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  position: relative;
  padding-top: 20px;
}
.step-item::before {
  content: attr(data-num);
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 18px;
  background: #e5e7eb;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  transition:
    background 0.3s,
    color 0.3s;
  line-height: 18px;
}
.step-item::after {
  content: "";
  position: absolute;
  top: 9px;
  left: calc(50% + 9px);
  right: calc(-50% + 9px);
  height: 1px;
  background: #e5e7eb;
}
.step-item:last-child::after {
  display: none;
}
.step-item.active::before {
  background: var(--green);
  color: white;
}
.step-item.done::before {
  background: var(--green);
  color: white;
  content: "✓";
}

/* ====== STATS BAR ====== */
.stats-bar {
  background: linear-gradient(
    90deg,
    rgba(15, 157, 88, 0.05),
    rgba(255, 122, 24, 0.05)
  );
  border-top: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  justify-content: space-around;
  flex-shrink: 0;
}
.stat-item {
  text-align: center;
}
.stat-item strong {
  display: block;
  font-size: 13px;
  color: var(--green);
  font-weight: 600;
}
.stat-item span {
  font-size: 9.5px;
  color: var(--text-muted);
}

/* ====== CHAT BODY ====== */
.chat-body {
  flex: 1;
  min-height: 0; /* IMPORTANT: flex child ko proper shrink karne deta hai */
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(
      ellipse 60% 40% at 20% 80%,
      rgba(15, 157, 88, 0.04) 0%,
      transparent 70%
    ),
    radial-gradient(
      ellipse 60% 40% at 80% 20%,
      rgba(255, 122, 24, 0.04) 0%,
      transparent 70%
    ),
    #fafafa;
}
.chat-body::-webkit-scrollbar {
  width: 4px;
}
.chat-body::-webkit-scrollbar-track {
  background: transparent;
}
.chat-body::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 4px;
}

/* ====== DATE DIVIDER ====== */
.date-divider {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin: 8px 0;
  position: relative;
}
.date-divider::before,
.date-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 35%;
  height: 1px;
  background: var(--border);
}
.date-divider::before {
  left: 0;
}
.date-divider::after {
  right: 0;
}

/* ====== MESSAGES ====== */
.message {
  max-width: 82%;
  font-size: 13.5px;
  line-height: 1.55;
  animation: msg-in 0.35s cubic-bezier(0.34, 1.4, 0.64, 1) both;
  word-break: break-word;
}
@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.bot-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  align-self: flex-start;
  max-width: 82%;
}
.bot-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background-color: #046a38;
  background-image: url("../img/abha-assistant-40x40.webp");
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(15, 157, 88, 0.3);
  margin-bottom: 2px;
}
.message.bot {
  background: var(--white);
  color: var(--text);
  border-radius: 18px 18px 18px 4px;
  padding: 10px 14px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
  border: 1px solid rgba(0, 0, 0, 0.05);
  white-space: pre-line;
}
.message.user {
  background: linear-gradient(135deg, var(--green), #1db863);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  padding: 10px 14px;
  align-self: flex-end;
  box-shadow: 0 4px 16px rgba(15, 157, 88, 0.35);
  white-space: pre-line;
}
.message.urgent {
  background: linear-gradient(135deg, #fff5f5, #fff);
  border-left: 3px solid #ff4d4d;
  color: var(--text);
  border-radius: 0 16px 16px 0;
  padding: 10px 14px;
  white-space: pre-line;
}

/* ====== TYPING INDICATOR ====== */
.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 16px;
  background: var(--white);
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
  width: fit-content;
}
.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
  opacity: 0.6;
}
.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ====== OPTION PILLS ====== */
.chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 6px;
  padding-left: 36px;
}
.chat-option-btn {
  background: var(--white);
  border: 1.5px solid var(--green);
  color: var(--green);
  padding: 7px 14px;
  border-radius: 50px;
  cursor: pointer;
  font-size: 12.5px;
  font-family: var(--font);
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 8px rgba(15, 157, 88, 0.1);
}
.chat-option-btn:hover {
  background: var(--green);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15, 157, 88, 0.35);
}
.chat-option-btn:active {
  transform: scale(0.96);
}
.chat-option-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ====== INFO CARD ====== */
.info-card {
  background: linear-gradient(135deg, #f0fdf4, #fff);
  border: 1px solid rgba(15, 157, 88, 0.2);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 6px 0;
  box-shadow: 0 2px 12px rgba(15, 157, 88, 0.08);
}
.info-card h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--green-dark);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.info-card p {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.info-card .info-cta {
  display: inline-block;
  margin-top: 8px;
  background: var(--green);
  color: white;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: var(--font);
  transition: background 0.2s;
}
.info-card .info-cta:hover {
  background: var(--green-dark);
}

/* ====== DOCTOR CARD ====== */
.doctor-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
.doctor-avatar {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--green), #1db863);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.doctor-info {
  flex: 1;
}
.doctor-info strong {
  font-size: 13px;
  color: var(--text);
  display: block;
}
.doctor-info span {
  font-size: 11.5px;
  color: var(--text-muted);
}
.doctor-badge {
  background: #f0fdf4;
  color: var(--green);
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 20px;
  font-weight: 600;
  border: 1px solid rgba(15, 157, 88, 0.2);
}
.rating {
  display: flex;
  gap: 2px;
  margin-top: 3px;
}
.star {
  color: #fbbf24;
  font-size: 11px;
}

/* ====== INPUT AREA ====== */
.chat-input-area {
  flex-shrink: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  /* iOS safe area (home bar ke liye) */
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
.chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f4f6f5;
  border-radius: 50px;
  padding: 6px 6px 6px 14px;
  border: 1.5px solid transparent;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.chat-input:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 157, 88, 0.12);
  background: var(--white);
}
.chat-input input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13.5px;
  font-family: var(--font);
  color: var(--text);
}
.chat-input input::placeholder {
  color: #aaa;
}

.send-btn {
  width: 36px;
  height: 36px;
  background: #ff671f;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  box-shadow: 0 3px 10px rgba(15, 157, 88, 0.3);
}
.send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 5px 14px rgba(15, 157, 88, 0.45);
}
.send-btn svg {
  width: 16px;
  height: 16px;
  fill: white;
}

.voice-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: 50%;
  transition:
    background 0.2s,
    color 0.2s;
  flex-shrink: 0;
}
.voice-btn:hover {
  background: rgba(15, 157, 88, 0.1);
  color: var(--green);
}
.voice-btn.listening {
  color: #ff4d4d;
  background: rgba(255, 77, 77, 0.1);
  animation: listening-pulse 1s infinite;
}
@keyframes listening-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}
.voice-btn svg {
  width: 16px;
  height: 16px;
}

.chat-footer-hint {
  text-align: center;
  font-size: 10.5px;
  color: #ccc;
  padding: 4px 0 2px;
}

/* ====== SATISFACTION ====== */
.satisfaction-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  padding-left: 36px;
}
.sat-btn {
  flex: 1;
  padding: 7px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--white);
  cursor: pointer;
  font-size: 18px;
  text-align: center;
  transition: all 0.2s;
  font-family: var(--font);
}
.sat-btn:hover {
  transform: scale(1.15);
  border-color: var(--green);
}
.sat-btn.selected {
  background: #f0fdf4;
  border-color: var(--green);
  transform: scale(1.1);
}
.sat-btn:disabled {
  cursor: not-allowed;
}

/* ====== UTILITY ====== */
.msg-time {
  font-size: 10px;
  color: #ccc;
  margin-top: 3px;
  text-align: right;
}
.msg-time.left {
  text-align: left;
  padding-left: 36px;
}

/* ==============================================================
   MOBILE FIX — COMPLETE SOLUTION
   Problem: Keyboard aane par chatbot ka header cut jaata tha
   Solution: 
     1. Chatbot open hone par body scroll lock
     2. Chatbot fullscreen fixed overlay ban jaata hai
     3. dvh unit use — keyboard ke saath viewport adjust hota hai
     4. Input font-size: 16px — iOS auto-zoom rokta hai
   ============================================================== */

/* Body scroll lock — jab chatbot open ho */
body.chatbot-open {
  overflow: hidden !important;
  /* Scroll position preserve karna — JS se --scroll-y set hoga */
  position: fixed !important;
  width: 100% !important;
  left: 0 !important;
  right: 0 !important;
}

@media (max-width: 600px) {
  /* Toggle button — Call/WhatsApp bar ke upar */
  #chatbot-toggle {
    bottom: 80px;
    right: 16px;
    width: 60px;
    height: 60px;
  }

  /* ---- MAIN FIX: Chat window fullscreen on mobile ---- */
  #chatbot-box {
    /* Sab sides se 0 — poora screen cover */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    border-radius: 0 !important;

    /* dvh = dynamic viewport height — keyboard aane par adjust hota hai */
    height: 100dvh !important;
    max-height: 100dvh !important;

    /* Purane browsers ke liye fallback */
    height: 100vh !important;
    max-height: 100vh !important;
    height: -webkit-fill-available !important;

    /* Keyboard ke saath scroll behavior */
    overflow: hidden;
  }

  /* Fullscreen toggle hide — already fullscreen hai mobile pe */
  #chatbot-expand {
    display: none !important;
  }

  /* Header bilkul fixed rahe — keyboard se affect na ho */
  .chat-header {
    flex-shrink: 0 !important;
    position: relative;
    z-index: 10;
  }

  /* Progress + Stats — compact */
  .chat-progress {
    flex-shrink: 0 !important;
    padding: 8px 14px 6px;
  }
  .stats-bar {
    flex-shrink: 0 !important;
    padding: 6px 12px;
  }
  .step-item {
    font-size: 9px;
    padding-top: 18px;
  }
  .stat-item strong {
    font-size: 12px;
  }
  .stat-item span {
    font-size: 9px;
  }

  /* Chat body — baaki poora space le, scroll kare */
  .chat-body {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Input area — bilkul bottom pe, keyboard ke upar */
  .chat-input-area {
    flex-shrink: 0 !important;
    position: relative;
    z-index: 10;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  /* iOS zoom fix — 16px se iOS auto-zoom nahi karta */
  .chat-input input {
    font-size: 16px !important;
    -webkit-text-size-adjust: 100%;
  }

  /* Option pills — thodi compact */
  .chat-option-btn {
    font-size: 12px;
    padding: 6px 12px;
  }
  .chat-options {
    padding-left: 0;
  }

  /* Bot icon thoda chhota */
  .bot-icon {
    width: 32px;
    height: 32px;
  }

  /* Messages thodi chhoti */
  .message {
    font-size: 13px;
  }
}

/* Landscape mobile — header/stats hide for more space */
@media (max-width: 600px) and (orientation: landscape) {
  .chat-progress,
  .stats-bar {
    display: none !important;
  }
  .chat-body {
    padding: 6px 10px;
  }
}

/* Very small phones */
@media (max-width: 360px) {
  .chat-header-text strong {
    font-size: 13px;
  }
  .chat-header-text span {
    font-size: 10px;
  }
  .chat-header {
    padding: 12px 14px 10px;
  }
}

/* ====== DESKTOP — Normal behavior ====== */
@media (min-width: 601px) {
  /* Desktop pe body lock nahi — sirf mobile ke liye */
  body.chatbot-open {
    overflow: auto !important;
    position: static !important;
  }

  #chatbot-box.fullscreen {
    width: min(94vw, 500px) !important;
    height: 88vh !important;
    max-height: none !important;
    bottom: 6vh !important;
    right: 3vw !important;
    top: auto !important;
    left: auto !important;
    border-radius: var(--radius) !important;
  }
}
