﻿/* ==========================================================================
   MYCLOUD.UNO — MICLO CONVERSATIONAL ASSISTANT & SCHEDULER (CHAT.CSS)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CONTENEDOR PRINCIPAL DEL CHAT MODAL
   -------------------------------------------------------------------------- */
#miclo-chat-modal {
  position: fixed;
  bottom: 110px;
  right: 32px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 130px);
  background: var(--bg, #ffffff);
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(17, 24, 39, 0.16), 0 4px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.28s;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

#miclo-chat-modal.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* --------------------------------------------------------------------------
   2. CABECERA DEL CHAT
   -------------------------------------------------------------------------- */
.chat-header {
  background: #111827;
  color: #ffffff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

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

.chat-avatar-wrap {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-soft, #eef2ff);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.chat-avatar-img {
  width: 85%;
  height: 85%;
  object-fit: contain;
}

.chat-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  border: 1.5px solid #111827;
}

.chat-title-group {
  display: flex;
  flex-direction: column;
}

.chat-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  line-height: 1.2;
}

.chat-subtitle {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.65);
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-control-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, color 0.2s;
}

.chat-control-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   3. CUERPO DE MENSAJES
   -------------------------------------------------------------------------- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

/* Burbujas de Mensaje */
.message-row {
  display: flex;
  gap: 8px;
  max-width: 86%;
  animation: messageFadeIn 0.25s ease-out;
}

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

.message-bot {
  align-self: flex-start;
}

.message-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar-mini {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e0e7ff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.message-avatar-mini img {
  width: 80%;
  height: 80%;
  object-fit: contain;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

.message-bot .message-bubble {
  background: #ffffff;
  color: var(--ink, #111827);
  border: 1px solid var(--line, #e5e7eb);
  border-top-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.message-user .message-bubble {
  background: var(--accent, #4f46e5);
  color: #ffffff;
  border-top-right-radius: 4px;
}

.message-bubble strong {
  color: inherit;
  font-weight: 700;
}

.message-bubble a {
  color: var(--accent, #4f46e5);
  font-weight: 600;
  text-decoration: underline;
}

.message-user .message-bubble a {
  color: #ffffff;
}

/* Indicador de Escritura (Typing...) */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 12px;
  border-top-left-radius: 4px;
  align-self: flex-start;
  margin-left: 34px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted, #6b7280);
  animation: typingBounce 1.3s infinite ease-in-out;
}

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

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

/* --------------------------------------------------------------------------
   4. PILLS DE ACCIÓN RÁPIDA / SUGERENCIAS
   -------------------------------------------------------------------------- */
.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  padding-left: 34px;
}

.suggestion-pill {
  background: #ffffff;
  border: 1px solid var(--line, #e5e7eb);
  color: var(--ink, #111827);
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.suggestion-pill:hover {
  background: var(--accent-soft, #eef2ff);
  border-color: var(--accent, #4f46e5);
  color: var(--accent, #4f46e5);
  transform: translateX(2px);
}

/* --------------------------------------------------------------------------
   5. FORMULARIO DE AGENDAMIENTO EN CHAT
   -------------------------------------------------------------------------- */
.chat-booking-card {
  background: #ffffff;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 12px;
  padding: 14px;
  margin-top: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.booking-form-group {
  margin-bottom: 10px;
}

.booking-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-secondary, #374151);
  margin-bottom: 4px;
}

.booking-input,
.booking-select {
  width: 100%;
  padding: 8px 10px;
  font-size: 12.5px;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink, #111827);
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
}

.booking-input:focus,
.booking-select:focus {
  border-color: var(--accent, #4f46e5);
  background: #ffffff;
}

.booking-submit-btn {
  width: 100%;
  padding: 9px;
  background: var(--accent, #4f46e5);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.2s, transform 0.15s;
}

.booking-submit-btn:hover {
  background: var(--accent-hover, #4338ca);
  transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   6. BARRA DE ENTRADA DE TEXTO
   -------------------------------------------------------------------------- */
.chat-input-bar {
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid var(--line, #e5e7eb);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 10px;
  font-size: 13px;
  background: #f8fafc;
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
  color: var(--ink, #111827);
}

.chat-input:focus {
  border-color: var(--accent, #4f46e5);
  background: #ffffff;
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent, #4f46e5);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.2s, transform 0.15s;
}

.chat-send-btn:hover {
  background: var(--accent-hover, #4338ca);
  transform: scale(1.05);
}

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* --------------------------------------------------------------------------
   7. RESPONSIVE DESIGN (MÓVILES)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  #miclo-chat-modal {
    right: 12px;
    bottom: 84px;
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
    max-height: 520px;
    border-radius: 16px;
  }

  .message-row {
    max-width: 92%;
  }

  .chat-suggestions {
    padding-left: 0;
  }
}
