/* =====================================================
   CHATBOTS.CSS – Estilos para chat estilo WhatsApp
   Inmobiliaria Salomón · Synaptx
   ===================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background: #e5ddd5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 0;
}

/* ===================== WRAPPER ===================== */
.chat-container {
  width: 100%;
  max-width: 430px;
  height: 100vh;
  max-height: 780px;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* ===================== HEADER ===================== */
.chat-header {
  background: #075e54;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  flex-shrink: 0;
}

.header-back {
  cursor: pointer;
  opacity: 0.85;
  flex-shrink: 0;
}

.header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.header-info { flex: 1; }
.header-info .name { font-weight: 600; font-size: 16px; letter-spacing: 0.2px; }
.header-info .status {
  font-size: 12px;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #25d366;
  display: inline-block;
}

.header-actions { display: flex; gap: 18px; opacity: 0.85; cursor: pointer; }

/* ===================== MESSAGES AREA ===================== */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #e5ddd5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  scroll-behavior: smooth;
}

.chat-body::-webkit-scrollbar { width: 5px; }
.chat-body::-webkit-scrollbar-thumb { background: #bbb; border-radius: 4px; }

/* Date separator */
.date-separator {
  text-align: center;
  margin: 8px 0;
}
.date-separator span {
  background: rgba(225,245,254,0.85);
  color: #555;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 500;
}

/* ===================== MESSAGE BUBBLES ===================== */
.message-row {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}
.message-row.user { align-self: flex-end; align-items: flex-end; }
.message-row.bot  { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 7px 10px 6px;
  border-radius: 8px;
  font-size: 14.5px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

/* User bubble */
.message-row.user .bubble {
  background: #dcf8c6;
  border-top-right-radius: 2px;
}
.message-row.user .bubble::after {
  content: '';
  position: absolute;
  right: -8px; top: 0;
  border: 8px solid transparent;
  border-top-color: #dcf8c6;
  border-right: none;
}

/* Bot bubble */
.message-row.bot .bubble {
  background: #fff;
  border-top-left-radius: 2px;
}
.message-row.bot .bubble::after {
  content: '';
  position: absolute;
  left: -8px; top: 0;
  border: 8px solid transparent;
  border-top-color: #fff;
  border-left: none;
}

/* Timestamp */
.bubble-meta {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.message-row.user .bubble-meta { justify-content: flex-end; }

/* Read ticks */
.ticks { color: #4fc3f7; font-size: 13px; }

/* ===================== MARKDOWN INSIDE BUBBLE ===================== */
.bubble p { margin: 0 0 6px; }
.bubble p:last-child { margin-bottom: 0; }

.bubble ul,
.bubble ol {
  margin: 4px 0 6px 0;
  padding-left: 20px;
}
.bubble ul { list-style: disc; }
.bubble ol { list-style: decimal; }
.bubble li { margin-bottom: 3px; }

.bubble strong { font-weight: 600; }
.bubble em { font-style: italic; }

.bubble a {
  color: #128c7e;
  text-decoration: underline;
  word-break: break-all;
}
.bubble a:hover { color: #075e54; }

.bubble code {
  background: #f0f0f0;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}

.bubble blockquote {
  border-left: 3px solid #128c7e;
  margin: 6px 0;
  padding: 2px 8px;
  color: #555;
  font-style: italic;
}

.bubble hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 8px 0;
}

/* ===================== TYPING INDICATOR ===================== */
.typing-row {
  display: flex;
  align-self: flex-start;
}
.typing-bubble {
  background: #fff;
  border-radius: 8px;
  border-top-left-radius: 2px;
  padding: 10px 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  display: flex;
  gap: 4px;
  align-items: center;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #aaa;
  animation: bounce 1.2s infinite;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* ===================== INPUT BAR ===================== */
.chat-footer {
  background: #f0f0f0;
  padding: 8px 10px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.emoji-btn,
.attach-btn,
.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.emoji-btn:hover,
.attach-btn:hover { background: rgba(0,0,0,0.06); }

.input-wrap {
  flex: 1;
  background: #fff;
  border-radius: 22px;
  display: flex;
  align-items: flex-end;
  padding: 6px 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

#input {
  flex: 1;
  border: none;
  outline: none;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  background: transparent;
  color: #111;
}

.send-btn {
  background: #25d366;
  width: 46px;
  height: 46px;
}
.send-btn:hover  { background: #1ebe5d; }
.send-btn:active { background: #18a852; }

/* ===================== SCROLLBAR GLOBAL ===================== */
* { scrollbar-width: thin; scrollbar-color: #ccc transparent; }
