/* ── OTS Chatbot Widget ─────────────────────────────────── */
#ots-chatbot-root * { box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }

/* Toggle Button */
#ots-chat-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 99999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d1a3a, #1a3a8a);
  border: none;
  cursor: pointer;
  font-size: 1.6rem;
  color: #fff;
  box-shadow: 0 6px 24px rgba(13,26,58,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#ots-chat-toggle:hover { transform: scale(1.1); box-shadow: 0 8px 30px rgba(13,26,58,0.55); }

/* Badge */
.ots-chat-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #d63031;
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* Pulse animation */
@keyframes ots-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(13,26,58,0.55); }
  70%  { box-shadow: 0 0 0 14px rgba(13,26,58,0); }
  100% { box-shadow: 0 0 0 0 rgba(13,26,58,0); }
}
#ots-chat-toggle.ots-pulse { animation: ots-pulse 1.4s ease-out 3; }

/* Chat Box */
#ots-chatbot-box {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 99998;
  width: 360px;
  max-height: 560px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#ots-chatbot-box.ots-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header */
#ots-chat-header {
  background: linear-gradient(135deg, #0d1a3a, #1a3a8a);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ots-chat-header-info { display: flex; align-items: center; gap: 10px; }
.ots-chat-avatar {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
}
.ots-chat-name { color: #fff; font-weight: 700; font-size: 0.95rem; }
.ots-chat-status { color: rgba(255,255,255,0.85); font-size: 0.75rem; display: flex; align-items: center; gap: 5px; }
.ots-dot {
  width: 8px; height: 8px;
  background: #00b894;
  border-radius: 50%;
  display: inline-block;
  animation: ots-blink 1.5s infinite;
}
@keyframes ots-blink { 0%,100%{opacity:1} 50%{opacity:0.4} }

#ots-chat-close-btn {
  background: rgba(255,255,255,0.15);
  border: none; border-radius: 50%;
  width: 30px; height: 30px;
  color: #fff; font-size: 0.9rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
#ots-chat-close-btn:hover { background: rgba(255,255,255,0.3); }

/* Messages */
#ots-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8f9fc;
}
#ots-chat-messages::-webkit-scrollbar { width: 4px; }
#ots-chat-messages::-webkit-scrollbar-thumb { background: #c8c8d4; border-radius: 4px; }

.ots-msg-wrap { display: flex; }
.ots-msg-bot  { justify-content: flex-start; }
.ots-msg-user { justify-content: flex-end; }

.ots-bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 0.83rem;
  line-height: 1.55;
}
.ots-bubble-bot {
  background: #fff;
  color: #2d3436;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.ots-bubble-user {
  background: linear-gradient(135deg, #0d1a3a, #1a3a8a);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ots-bubble ul { padding-left: 18px; margin: 6px 0 0; }
.ots-bubble ol { padding-left: 18px; margin: 6px 0 0; }
.ots-bubble li { margin-bottom: 4px; }
.ots-bubble strong { font-weight: 700; }

/* Typing indicator */
.ots-typing { display: flex; align-items: center; gap: 5px; padding: 12px 16px; }
.ots-typing span {
  width: 8px; height: 8px;
  background: #1a3a8a;
  border-radius: 50%;
  animation: ots-bounce 1.2s infinite;
}
.ots-typing span:nth-child(2) { animation-delay: 0.2s; }
.ots-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ots-bounce {
  0%,80%,100% { transform: translateY(0); }
  40%          { transform: translateY(-7px); }
}

/* Quick Buttons */
#ots-quick-btns {
  padding: 8px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: #fff;
  border-top: 1px solid #f0f0f5;
  flex-shrink: 0;
  max-height: 110px;
  overflow-y: auto;
}
#ots-quick-btns::-webkit-scrollbar { width: 3px; }
#ots-quick-btns::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
.ots-quick-btn {
  background: #eaeff7;
  border: 1px solid #b8c4d8;
  border-radius: 20px;
  color: #0d1a3a;
  font-size: 0.73rem;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s, color 0.18s;
}
.ots-quick-btn:hover { background: #0d1a3a; color: #fff; }

/* Input Row */
#ots-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #f0f0f5;
  background: #fff;
  flex-shrink: 0;
}
#ots-chat-input {
  flex: 1;
  border: 1.5px solid #c8d0e0;
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 0.83rem;
  outline: none;
  color: #2d3436;
  transition: border-color 0.2s;
}
#ots-chat-input:focus { border-color: #0d1a3a; }
#ots-chat-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d1a3a, #1a3a8a);
  border: none;
  cursor: pointer;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s;
}
#ots-chat-send:hover { transform: scale(1.1); }

/* ── Mobile Responsive ───────────────────────── */
@media (max-width: 600px) {
  /* Chat box: full screen on mobile */
  #ots-chatbot-box {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    right: 0;
    bottom: 0;
    border-radius: 0;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
  }

  /* Toggle button: smaller, closer to edge */
  #ots-chat-toggle {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
    font-size: 1.4rem;
  }

  /* Messages area: more padding room */
  #ots-chat-messages {
    padding: 12px 10px;
    flex: 1;
    min-height: 0;
  }

  /* Bubbles: wider on small screen */
  .ots-bubble {
    max-width: 90%;
    font-size: 0.85rem;
  }

  /* Quick buttons: scrollable row, no wrap */
  #ots-quick-btns {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    padding: 8px 10px;
    gap: 7px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #ots-quick-btns::-webkit-scrollbar { display: none; }
  .ots-quick-btn {
    flex-shrink: 0;
    font-size: 0.75rem;
    padding: 6px 12px;
    /* Larger tap target */
    min-height: 34px;
  }

  /* Input row: bigger touch targets */
  #ots-chat-input-row {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  #ots-chat-input {
    font-size: 16px; /* prevents iOS zoom on focus */
    padding: 10px 14px;
  }
  #ots-chat-send {
    width: 42px;
    height: 42px;
  }

  /* Popup: full width minus margins */
  #ots-chat-popup {
    right: 10px;
    left: 10px;
    max-width: none;
    bottom: 82px;
  }
}

/* ── Popup bubble ─────────────────────────────── */
#ots-chat-popup {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 99997;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(13,26,58,0.22);
  padding: 14px 16px 14px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 290px;
  opacity: 0;
  transform: translateY(12px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  border-left: 4px solid #0d1a3a;
}
#ots-chat-popup.ots-popup-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}
.ots-popup-avatar {
  font-size: 1.8rem;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #0d1a3a, #1a3a8a);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ots-popup-text {
  font-size: 0.8rem;
  color: #2d3436;
  line-height: 1.5;
}
.ots-popup-text strong {
  display: block;
  font-size: 0.88rem;
  color: #0d1a3a;
  margin-bottom: 3px;
}
#ots-popup-chat-btn {
  display: inline-block;
  margin-top: 8px;
  background: linear-gradient(135deg, #0d1a3a, #1a3a8a);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}
#ots-popup-chat-btn:hover { opacity: 0.88; }
#ots-popup-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  font-size: 0.8rem;
  color: #b2bec3;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
}
#ots-popup-close:hover { color: #636e72; }

@media (max-width: 480px) {
  #ots-chat-popup { right: 10px; max-width: calc(100vw - 90px); }
}
