/* =============================================
   CHAT WIDGET - Clínica Dental Medisch
   Colores: #283B6A (azul), #13C5DD (cyan)
   ============================================= */

/* --- Floating Button --- */
#chat-toggle-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #283B6A 0%, #1a5f7a 100%);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 22px 14px 18px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(40, 59, 106, 0.45);
  font-family: 'Rubik', sans-serif;
  font-size: 14px;
  font-weight: 500;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  white-space: nowrap;
}

#chat-toggle-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(40, 59, 106, 0.55);
}

#chat-toggle-btn .chat-btn-icon {
  width: 36px;
  height: 36px;
  background: #13C5DD;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  transition: background 0.2s;
}

#chat-toggle-btn .chat-btn-label {
  line-height: 1.2;
}

#chat-toggle-btn .chat-btn-label small {
  display: block;
  font-size: 11px;
  opacity: 0.8;
  font-weight: 400;
}

/* Notification dot */
#chat-toggle-btn .chat-notif-dot {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 10px;
  height: 10px;
  background: #ff4757;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: pulse-dot 2s infinite;
}

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

/* --- Chat Window --- */
#chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9998;
  width: 370px;
  max-height: 580px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 12px 48px rgba(40, 59, 106, 0.22), 0 2px 8px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.22s ease;
}

#chat-window.chat-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* --- Chat Header --- */
.chat-header {
  background: linear-gradient(135deg, #283B6A 0%, #1e4d6b 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 42px;
  height: 42px;
  background: #13C5DD;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.25);
}

.chat-header-text h6 {
  color: #fff;
  margin: 0;
  font-family: 'Rubik', sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.chat-header-text span {
  color: #13C5DD;
  font-size: 12px;
  font-family: 'Roboto', sans-serif;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-online-dot {
  width: 7px;
  height: 7px;
  background: #2ed573;
  border-radius: 50%;
  display: inline-block;
  animation: pulse-online 2s infinite;
}

@keyframes pulse-online {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.chat-close-btn {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.chat-close-btn:hover {
  background: rgba(255,255,255,0.22);
}

/* --- Messages Area --- */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f7f9fc;
  min-height: 0;
}

#chat-messages::-webkit-scrollbar {
  width: 5px;
}
#chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
#chat-messages::-webkit-scrollbar-thumb {
  background: #c8d3e8;
  border-radius: 10px;
}

/* --- Message Bubbles --- */
.chat-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 90%;
  animation: fadeInMsg 0.25s ease;
}

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

.chat-msg.user-msg {
  margin-left: auto;
  flex-direction: row-reverse;
}

.chat-msg .msg-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #13C5DD;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
  align-self: flex-end;
}

.chat-msg.user-msg .msg-icon {
  background: #283B6A;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-family: 'Roboto', sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  max-width: 100%;
  word-break: break-word;
}

.chat-msg.bot-msg .msg-bubble {
  background: #fff;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.chat-msg.user-msg .msg-bubble {
  background: linear-gradient(135deg, #283B6A, #1a5f7a);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Forzar colores para que no los sobreescriba styles.css */
.chat-msg.bot-msg .msg-bubble,
.chat-msg.bot-msg .msg-bubble p,
.chat-msg.bot-msg .msg-bubble li,
.chat-msg.bot-msg .msg-bubble strong,
.chat-msg.bot-msg .msg-bubble em { color: #333 !important; }

.chat-msg.user-msg .msg-bubble,
.chat-msg.user-msg .msg-bubble p,
.chat-msg.user-msg .msg-bubble li,
.chat-msg.user-msg .msg-bubble strong,
.chat-msg.user-msg .msg-bubble em { color: #fff !important; }

/* Markdown rendering */
.msg-bubble strong { font-weight: 700; }
.msg-bubble em { font-style: italic; }
.msg-bubble ul, .msg-bubble ol {
  margin: 6px 0 0 0;
  padding-left: 18px;
}
.msg-bubble li { margin-bottom: 3px; }
.msg-bubble p { margin: 0 0 6px; }
.msg-bubble p:last-child { margin-bottom: 0; }

/* --- Typing Indicator --- */
.typing-indicator {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 10px 14px;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  background: #13C5DD;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* --- Quick Actions --- */
#chat-quick-actions {
  padding: 8px 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  background: #f7f9fc;
  border-top: 1px solid #e8edf5;
  flex-shrink: 0;
}

#chat-quick-actions button {
  background: #fff;
  border: 1.5px solid #d0daea;
  color: #283B6A;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-family: 'Roboto', sans-serif;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

#chat-quick-actions button:hover {
  background: #283B6A;
  color: #fff;
  border-color: #283B6A;
  transform: translateY(-1px);
}

/* --- Input Area --- */
.chat-input-area {
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid #e8edf5;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  border: 1.5px solid #d8e2f0;
  border-radius: 12px;
  padding: 10px 14px;
  font-family: 'Roboto', sans-serif;
  font-size: 13.5px;
  color: #333;
  resize: none;
  outline: none;
  background: #f7f9fc;
  max-height: 90px;
  overflow-y: auto;
  transition: border-color 0.2s;
  line-height: 1.4;
}

#chat-input:focus {
  border-color: #13C5DD;
  background: #fff;
}

#chat-input::placeholder {
  color: #a0aec0;
}

#chat-send-btn {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #283B6A, #13C5DD);
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.2s;
}

#chat-send-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: scale(1.05);
}

#chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Mobile Responsive --- */
@media (max-width: 480px) {
  #chat-window {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 90px;
    max-height: calc(100vh - 110px);
    border-radius: 16px;
  }

  #chat-toggle-btn {
    right: 16px;
    bottom: 20px;
    padding: 12px 18px 12px 14px;
  }

  #chat-toggle-btn .chat-btn-label {
    display: none;
  }

  #chat-toggle-btn {
    border-radius: 50%;
    padding: 0;
    width: 56px;
    height: 56px;
    justify-content: center;
  }

  #chat-toggle-btn .chat-btn-icon {
    width: 30px;
    height: 30px;
    font-size: 15px;
    background: transparent;
  }
}
