/* ===================================
   CASA CONSUELO CHATBOT - MODERN v3.1
   Diseño minimalista tipo Apple
   =================================== */

/* VARIABLES DE COLOR - CASA CONSUELO */
:root {
  --cc-primary: #15527B;        /* Azul principal del logo */
  --cc-secondary: #1a68a0;      /* Azul más claro */
  --cc-accent: #6BB3D9;         /* Celeste del logo */
  --cc-beige: #B8B5A6;          /* Beige del logo */
  --cc-bg: #ffffff;             /* Fondo blanco limpio */
  --cc-bg-alt: #f9fafb;         /* Fondo alternativo sutil */
  --cc-text: #1d1d1f;           /* Texto oscuro (Apple) */
  --cc-text-light: #86868b;     /* Texto secundario */
  --cc-border: #e5e5ea;         /* Bordes sutiles */
  --cc-shadow: 0 10px 16px rgba(0, 0, 0, 0.08);
  --cc-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* RESET Y BASE */
#cc-chatbot-widget * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* WIDGET PRINCIPAL */
#cc-chatbot-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
  z-index: 99999;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* BOTÓN FLOTANTE - ESTILO APPLE */
#cc-chat-button {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--cc-primary);
  color: white;
  border: none;
  border-radius: 28px;
  padding: 16px 12px;
  cursor: pointer;
  box-shadow: var(--cc-shadow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.01em;
}

#cc-chat-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--cc-shadow-lg);
  background: var(--cc-secondary);
}

#cc-chat-button:active {
  transform: translateY(0);
}

#cc-chat-button svg {
  flex-shrink: 0;
}

/* BADGE DE NOTIFICACIÓN */
#cc-notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ff3b30;
  color: white;
  border-radius: 10px;
  min-width: 20px;
  height: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(255, 59, 48, 0.4);
}

/* VENTANA DEL CHAT - MINIMALISTA */
#cc-chat-window {
  position: absolute;
  bottom: 84px;
  right: 0;
  width: 380px;
  height: 600px;
  background: var(--cc-bg);
  border-radius: 20px;
  box-shadow: var(--cc-shadow-lg);
  border: 1px solid var(--cc-border);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.98);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

#cc-chat-window.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* HEADER - LIMPIO Y MODERNO */
#cc-chat-header {
  background: var(--cc-bg);
  border-bottom: 1px solid var(--cc-border);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

/* AVATAR DEL HEADER - CON LOGO */
.cc-header-avatar {
  width: 44px;
  height: 44px;
  background: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.cc-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.cc-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cc-header-text .cc-name {
  font-weight: 600;
  font-size: 17px;
  color: var(--cc-text);
  letter-spacing: -0.02em;
}

.cc-header-text .cc-status {
  font-size: 13px;
  color: var(--cc-text-light);
  font-weight: 400;
}

#cc-chat-close {
  background: var(--cc-bg-alt);
  border: none;
  color: var(--cc-text-light);
  font-size: 24px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

#cc-chat-close:hover {
  background: var(--cc-border);
  color: var(--cc-text);
}

/* ÁREA DE MENSAJES - ESPACIOSO */
#cc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  background: var(--cc-bg-alt);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* SCROLLBAR MINIMALISTA */
#cc-chat-messages::-webkit-scrollbar {
  width: 6px;
}

#cc-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

#cc-chat-messages::-webkit-scrollbar-thumb {
  background: var(--cc-border);
  border-radius: 3px;
}

#cc-chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--cc-text-light);
}

/* MENSAJES - ESTILO APPLE MESSAGES */
.cc-message {
  display: flex;
  gap: 10px;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  align-items: flex-end;
}

.cc-message.user {
  flex-direction: row-reverse;
}

/* AVATARES EN MENSAJES */
.cc-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
}

/* Avatar del BOT - con LOGO */
.cc-message.bot .cc-message-avatar {
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.cc-message.bot .cc-message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 2px;
}

/* Avatar del USUARIO */
.cc-message.user .cc-message-avatar {
  background: var(--cc-border);
  color: var(--cc-text);
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
  min-width: 32px;
  max-width: 32px;
  width: 32px;
  height: 32px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
}

/* BURBUJAS - LIMPIAS Y ESPACIOSAS */
.cc-message-content {
  max-width: 260px;
  padding: 12px 32px;
  border-radius: 8px;  /* Menos redondeado para evitar apariencia circular */
  line-height: 1.5;
  font-size: 15px;
  letter-spacing: -0.01em;
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-width: 60px;  /* Ancho mínimo para evitar burbujas muy pequeñas */
}

.cc-message.bot .cc-message-content {
  background: white;
  color: var(--cc-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  border-bottom-left-radius: 4px;  /* Esquina puntiaguda estilo iMessage */
}

.cc-message.user .cc-message-content {
  background: transparent;           /* Sin burbuja de color */
  color: #1d1d1f !important;        /* Texto negro */
  box-shadow: none;                  /* Sin sombra */
  border: none;                      /* Sin borde */
  padding: 8px 12px;                 /* Menos padding */
  text-align: right;                 /* Alineado a la derecha */
}

.cc-message-time {
  font-size: 12px;
  opacity: 0.5;
  margin-top: 6px;
  font-weight: 400;
}

/* FORMULARIO DE INPUT - MODERNO */
#cc-chat-form {
  padding: 16px 20px 20px;
  background: var(--cc-bg);
  border-top: 1px solid var(--cc-border);
}

#cc-chat-input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--cc-bg-alt);
  border-radius: 20px;
  border: 1px solid var(--cc-border);
  padding: 10px 24px;
  transition: all 0.2s ease;
}

#cc-chat-input-container:focus-within {
  border-color: var(--cc-primary);
  background: white;
}

#cc-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  padding: 10px 26px;
  font-family: inherit;
  color: var(--cc-text) !important;  /* Forzar color oscuro */
  letter-spacing: -0.01em;
  -webkit-text-fill-color: var(--cc-text) !important;  /* Fix para iOS */
}

#cc-chat-input::placeholder {
  color: var(--cc-text-light);
  -webkit-text-fill-color: var(--cc-text-light);
}

/* BOTÓN ENVIAR - MINIMALISTA */
#cc-chat-send {
  background: var(--cc-primary);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

#cc-chat-send:hover:not(:disabled) {
  background: var(--cc-secondary);
  transform: scale(1.05);
}

#cc-chat-send:active:not(:disabled) {
  transform: scale(0.95);
}

#cc-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* INDICADOR DE ESCRITURA */
#cc-typing-indicator {
  padding: 0 24px;
  background: var(--cc-bg-alt);
}

.cc-typing-dots {
  display: flex;
  gap: 5px;
  padding: 12px 18px;
  background: white;
  border-radius: 18px;
  width: fit-content;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.cc-typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--cc-text-light);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

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

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

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

/* ERROR MESSAGES */
.cc-message.error .cc-message-content {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
}

/* ANIMACIONES */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-8px);
  }
}

/* RESPONSIVE - MÓVILES */
@media (max-width: 480px) {
  #cc-chatbot-widget {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }
  
  #cc-chat-window {
    width: 100%;
    height: 85vh;
    max-height: 600px;
    bottom: 70px;
    right: 0;
    left: 0;
  }
  
  #cc-chat-button {
    width: 100%;
    justify-content: center;
  }
  
  /* Fix para input en móvil - asegurar que el texto sea visible */
  #cc-chat-input {
    color: #1d1d1f !important;
    -webkit-text-fill-color: #1d1d1f !important;
    background: transparent !important;
  }
  
  #cc-chat-input::placeholder {
    color: #86868b !important;
    -webkit-text-fill-color: #86868b !important;
  }
  
  /* Asegurar que las burbujas no sean circulares en móvil */
  .cc-message-content {
    min-width: 80px;
    border-radius: 14px;
  }
}

/* MODO OSCURO (OPCIONAL) */
@media (prefers-color-scheme: dark) {
  :root {
    --cc-bg: #1c1c1e;
    --cc-bg-alt: #2c2c2e;
    --cc-text: #f5f5f7;
    --cc-text-light: #98989d;
    --cc-border: #38383a;
  }
  
  .cc-message.bot .cc-message-content {
    background: var(--cc-bg-alt);
    color: var(--cc-text);
  }
  
  #cc-chat-close {
    color: var(--cc-text-light);
  }
  
  #cc-chat-close:hover {
    background: #38383a;
    color: var(--cc-text);
  }
  
  .cc-header-avatar,
  .cc-message.bot .cc-message-avatar {
    background: var(--cc-bg-alt);
  }
}
