/* =============================================================
   Dito Collective — Widget de chat
   Estilos del chat flotante embebido en la tienda Shopify.
   Los colores de marca están en variables (:root) para
   cambiarlos en un solo sitio.
   ============================================================= */

:root {
  /* --- Colores de marca (CAMBIAR AQUÍ) --- */
  --dito-accent: #1b4233;          /* verde oscuro Dito Collective */
  --dito-accent-hover: #24563f;    /* variante más clara al pasar el ratón */
  --dito-accent-text: #ffffff;     /* texto sobre el color de marca */

  /* --- Colores de interfaz --- */
  --dito-bg: #ffffff;              /* fondo del panel de chat */
  --dito-text: #1a1a1a;            /* texto principal */
  --dito-bot-bubble: #f2f2f2;      /* burbuja del asistente */
  --dito-user-bubble: var(--dito-accent);
  --dito-user-text: var(--dito-accent-text);
  --dito-border: #e6e6e6;
  --dito-muted: #8a8a8a;

  /* --- Medidas --- */
  --dito-radius: 16px;
  --dito-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Contenedor raíz — no hereda estilos de la tienda */
#dito-chat-root,
#dito-chat-root * {
  box-sizing: border-box;
  font-family: var(--dito-font);
}

/* --- Botón flotante (burbuja) --- */
#dito-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--dito-accent);
  color: var(--dito-accent-text);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  transition: transform 0.15s ease, background 0.2s ease;
}
#dito-chat-toggle:hover {
  background: var(--dito-accent-hover);
  transform: scale(1.05);
}
#dito-chat-toggle svg {
  width: 28px;
  height: 28px;
}

/* --- Panel de chat --- */
#dito-chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--dito-bg);
  border-radius: var(--dito-radius);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#dito-chat-root.dito-open #dito-chat-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* --- Cabecera --- */
#dito-chat-header {
  background: var(--dito-accent);
  color: var(--dito-accent-text);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#dito-chat-header .dito-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
#dito-chat-header .dito-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ffffff;
  color: var(--dito-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#dito-chat-header .dito-avatar svg {
  width: 20px;
  height: 20px;
}
#dito-chat-header .dito-title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.2px;
}
#dito-chat-header .dito-subtitle {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 2px;
}
.dito-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
#dito-chat-language {
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 6px;
  background: transparent;
  color: var(--dito-accent-text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
#dito-chat-language:hover { background: rgba(255, 255, 255, 0.15); }
#dito-chat-close {
  background: none;
  border: none;
  color: var(--dito-accent-text);
  cursor: pointer;
  opacity: 0.85;
  padding: 4px;
  line-height: 0;
}
#dito-chat-close:hover { opacity: 1; }
#dito-chat-close svg { width: 20px; height: 20px; }

/* --- Zona de mensajes --- */
#dito-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--dito-bg);
}
.dito-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.dito-msg.bot {
  align-self: flex-start;
  background: var(--dito-bot-bubble);
  color: var(--dito-text);
  border-bottom-left-radius: 4px;
}
.dito-msg.user {
  align-self: flex-end;
  background: var(--dito-user-bubble);
  color: var(--dito-user-text);
  border-bottom-right-radius: 4px;
}
.dito-chat-link {
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--dito-accent);
  color: var(--dito-accent-text);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
  text-decoration: none;
}
.dito-chat-link:hover {
  background: var(--dito-accent-hover);
}

/* --- Indicador "escribiendo..." --- */
.dito-typing {
  align-self: flex-start;
  background: var(--dito-bot-bubble);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 4px;
}
.dito-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dito-muted);
  animation: dito-bounce 1.2s infinite ease-in-out;
}
.dito-typing span:nth-child(2) { animation-delay: 0.2s; }
.dito-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dito-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* --- Zona de entrada --- */
#dito-chat-input-area {
  border-top: 1px solid var(--dito-border);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: var(--dito-bg);
}
#dito-chat-input {
  flex: 1;
  border: 1px solid var(--dito-border);
  border-radius: 20px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 20px;
  min-height: 42px;
  height: 42px;
  resize: none;
  overflow-y: auto;
  max-height: 96px;
  outline: none;
  font-family: var(--dito-font);
  color: var(--dito-text);
  -webkit-appearance: none;
  appearance: none;
}
/* Oculta el control de redimensionar nativo del textarea (las flechitas) */
#dito-chat-input::-webkit-resizer {
  display: none;
}
#dito-chat-input:focus { border-color: var(--dito-accent); }
#dito-chat-send {
  background: var(--dito-accent);
  color: var(--dito-accent-text);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
#dito-chat-send:hover:not(:disabled) { background: var(--dito-accent-hover); }
#dito-chat-send:disabled { opacity: 0.45; cursor: default; }
#dito-chat-send svg { width: 18px; height: 18px; }

/* --- Pie discreto --- */
#dito-chat-footer {
  text-align: center;
  font-size: 10px;
  color: var(--dito-muted);
  padding: 4px 0 8px;
  flex-shrink: 0;
  background: var(--dito-bg);
}
#dito-chat-footer a {
  color: var(--dito-muted);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}
#dito-chat-footer a:hover {
  color: var(--dito-accent);
  text-decoration: underline;
}

/* --- Botones de sugerencia (quick replies) --- */
#dito-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: stretch;
  margin-top: 4px;
}
.dito-suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--dito-bg);
  color: var(--dito-text);
  border: 1px solid var(--dito-border);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13.5px;
  font-family: var(--dito-font);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dito-suggestion::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dito-accent);
  flex-shrink: 0;
}
.dito-suggestion:hover {
  border-color: var(--dito-accent);
  background: #f7f9f8;
}

/* --- Botones de producto (alternativas del "dependiente") --- */
.dito-product-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: flex-start;
  max-width: 82%;
  margin: 2px 0 4px;
}
.dito-product-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  background: var(--dito-bg);
  color: var(--dito-text);
  border: 1px solid var(--dito-border);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dito-product-btn::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dito-accent);
  flex-shrink: 0;
}
.dito-product-btn:hover {
  border-color: var(--dito-accent);
  background: #f7f9f8;
}

/* --- Responsive: pantalla pequeña, chat casi completo --- */
@media (max-width: 480px) {
  #dito-chat-panel {
    right: 8px;
    left: 8px;
    bottom: 84px;
    width: auto;
    height: calc(100vh - 92px);
    max-height: calc(100vh - 92px);
  }
  #dito-chat-toggle { bottom: 16px; right: 16px; }
  #dito-chat-header { padding: 12px 18px; }
  #dito-chat-messages { padding: 8px; gap: 4px; }
  #dito-suggestions { gap: 4px; }
  #dito-chat-input-area { padding: 8px 12px; }
  #dito-chat-footer { padding: 2px 0 4px; }
}
