/* ==========================================================================
   IBSA AI Chatbot Widget Styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   Floating Toggle Button
   -------------------------------------------------------------------------- */

.ibsa-chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #0073aa;
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.ibsa-chatbot-toggle:hover {
  background: #005a87;
  transform: scale(1.05);
}

.ibsa-chatbot-widget[data-mode="inline"] .ibsa-chatbot-toggle {
  display: none;
}

/* --------------------------------------------------------------------------
   Chat Panel
   -------------------------------------------------------------------------- */

.ibsa-chatbot-panel {
  width: 350px;
  height: 500px;
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9999;
}

.ibsa-chatbot-panel[hidden] {
  display: none;
}

.ibsa-chatbot-widget[data-mode="inline"] .ibsa-chatbot-panel {
  position: relative;
  width: 100%;
  max-width: 600px;
  bottom: auto;
  right: auto;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.ibsa-chatbot-header {
  background: #0073aa;
  color: white;
  padding: 12px 16px;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.ibsa-chatbot-header-name {
  font-weight: 600;
  font-size: 15px;
}

.ibsa-chatbot-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  line-height: 1;
}

/* --------------------------------------------------------------------------
   Messages Area
   -------------------------------------------------------------------------- */

.ibsa-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ibsa-chatbot-message {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

.ibsa-chatbot-message--user {
  align-self: flex-end;
  background: #0073aa;
  color: white;
  border-radius: 12px 12px 0 12px;
}

.ibsa-chatbot-message--bot {
  align-self: flex-start;
  background: #f1f1f1;
  color: #333;
  border-radius: 12px 12px 12px 0;
}

/* --------------------------------------------------------------------------
   Sources
   -------------------------------------------------------------------------- */

.ibsa-chatbot-sources {
  margin-top: 6px;
  font-size: 12px;
}

.ibsa-chatbot-sources a {
  color: #0073aa;
  text-decoration: none;
}

.ibsa-chatbot-sources a:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Typing Animation
   -------------------------------------------------------------------------- */

.ibsa-chatbot-typing {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: #f1f1f1;
  border-radius: 12px 12px 12px 0;
  align-self: flex-start;
}

.ibsa-chatbot-typing span {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: ibsa-bounce 1.4s infinite;
}

.ibsa-chatbot-typing span:nth-child(1) {
  animation-delay: 0s;
}

.ibsa-chatbot-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.ibsa-chatbot-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes ibsa-bounce {
  0%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-8px);
  }
}

/* --------------------------------------------------------------------------
   Input Row
   -------------------------------------------------------------------------- */

.ibsa-chatbot-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e5e5e5;
  flex-shrink: 0;
  align-items: center;
}

.ibsa-chatbot-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  resize: none;
}

.ibsa-chatbot-input:focus {
  border-color: #0073aa;
}

.ibsa-chatbot-send {
  background: #0073aa;
  color: white;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.ibsa-chatbot-send:hover {
  background: #005a87;
}

/* --------------------------------------------------------------------------
   Consent Row
   -------------------------------------------------------------------------- */

.ibsa-chatbot-consent-row {
  padding: 0 12px 10px;
  font-size: 12px;
  color: #666;
  flex-shrink: 0;
}

.ibsa-chatbot-consent-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   Responsive — Mobile
   -------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .ibsa-chatbot-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
}

/* --------------------------------------------------------------------------
   Markdown content inside bot messages
   -------------------------------------------------------------------------- */

.ibsa-chatbot-message-content p {
  margin: 0 0 8px 0;
}

.ibsa-chatbot-message-content p:last-child {
  margin-bottom: 0;
}

.ibsa-chatbot-message-content a {
  color: #0073aa;
  text-decoration: underline;
}

.ibsa-chatbot-message-content a:hover {
  color: #005a87;
}

.ibsa-chatbot-message-content strong {
  font-weight: 700;
}

.ibsa-chatbot-message-content em {
  font-style: italic;
}

.ibsa-chatbot-message-content code {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: monospace;
  font-size: 13px;
}

.ibsa-chatbot-message-content pre {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  margin: 0 0 8px 0;
}

.ibsa-chatbot-message-content pre code {
  background: none;
  padding: 0;
  font-size: 13px;
}

.ibsa-chatbot-message-content ul,
.ibsa-chatbot-message-content ol {
  margin: 0 0 8px 0;
  padding-left: 20px;
}

.ibsa-chatbot-message-content li {
  margin-bottom: 2px;
}

.ibsa-chatbot-message-content li:last-child {
  margin-bottom: 0;
}

.ibsa-chatbot-message-content h1,
.ibsa-chatbot-message-content h2,
.ibsa-chatbot-message-content h3,
.ibsa-chatbot-message-content h4 {
  margin: 8px 0 4px 0;
  font-weight: 600;
  line-height: 1.3;
}

.ibsa-chatbot-message-content h1 { font-size: 16px; }
.ibsa-chatbot-message-content h2 { font-size: 15px; }
.ibsa-chatbot-message-content h3 { font-size: 14px; font-weight: 700; }
.ibsa-chatbot-message-content h4 { font-size: 13px; }

.ibsa-chatbot-message-content blockquote {
  border-left: 3px solid #0073aa;
  margin: 0 0 8px 0;
  padding: 4px 12px;
  color: #555;
}
