/*
 * CREAURA Chatbot Widget CSS
 * Corrige estilos completos del widget, links clicables y estado cerrado por defecto.
 */

.cr-chatbot-root,
.cr-chatbot-root * {
  box-sizing: border-box;
}

.cr-chatbot-root {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 99999;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #0f172a;
}

/* Botón flotante */
.cr-chatbot-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 16px;
  border: 0;
  border-radius: 999px;
  background: #0f3a63;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 14px 35px rgba(15, 58, 99, 0.26);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.cr-chatbot-toggle:hover {
  transform: translateY(-1px);
  background: #0b2f52;
  box-shadow: 0 18px 40px rgba(15, 58, 99, 0.32);
}

.cr-chatbot-toggle:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 3px;
}

.cr-chatbot-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 17px;
  line-height: 1;
}

.cr-chatbot-toggle-text {
  white-space: nowrap;
}

.cr-chatbot-root.cr-chatbot-open .cr-chatbot-toggle {
  display: none;
}

/* Panel */
.cr-chatbot-panel {
  display: none;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: min(650px, calc(100vh - 56px));
  max-height: 650px;
  background: #ffffff;
  border: 1px solid rgba(15, 58, 99, 0.14);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}

.cr-chatbot-root.cr-chatbot-open .cr-chatbot-panel {
  display: flex;
  flex-direction: column;
}

/* Header */
.cr-chatbot-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border-bottom: 1px solid rgba(15, 58, 99, 0.1);
}

.cr-chatbot-title {
  display: block;
  color: #0f172a;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

.cr-chatbot-subtitle {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.35;
}

.cr-chatbot-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  transition: background 160ms ease, color 160ms ease;
}

.cr-chatbot-close:hover {
  background: #eef4fb;
  color: #0f3a63;
}

.cr-chatbot-close:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25);
}

/* Mensajes */
.cr-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  background: #f7faff;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 58, 99, 0.35) transparent;
}

.cr-chatbot-message-row {
  display: flex;
  margin: 0 0 12px;
}

.cr-chatbot-message-row-user {
  justify-content: flex-end;
}

.cr-chatbot-message-row-assistant {
  justify-content: flex-start;
}

.cr-chatbot-message {
  max-width: 86%;
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.48;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.cr-chatbot-message-user {
  background: #1d4ed8;
  color: #ffffff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 8px 18px rgba(29, 78, 216, 0.18);
}

.cr-chatbot-message-assistant {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid rgba(15, 58, 99, 0.11);
  border-bottom-left-radius: 6px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.cr-chatbot-loading {
  color: #64748b;
}

/* Enlaces dentro del chat */
.cr-chatbot-link {
  color: #0f4ea8;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.cr-chatbot-link:hover {
  color: #083878;
}

.cr-chatbot-link:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.45);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Quick replies */
.cr-chatbot-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px 10px;
  background: #ffffff;
  border-top: 1px solid rgba(15, 58, 99, 0.08);
}

.cr-chatbot-quick-reply {
  border: 1px solid rgba(15, 58, 99, 0.18);
  border-radius: 999px;
  background: #f8fbff;
  color: #0f3a63;
  cursor: pointer;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.cr-chatbot-quick-reply:hover {
  background: #eaf3ff;
  border-color: rgba(15, 58, 99, 0.32);
  transform: translateY(-1px);
}

.cr-chatbot-quick-reply:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25);
}

/* Form */
.cr-chatbot-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px;
  background: #ffffff;
  border-top: 1px solid rgba(15, 58, 99, 0.1);
}

.cr-chatbot-input-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.cr-chatbot-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border: 1px solid rgba(15, 58, 99, 0.18);
  border-radius: 16px;
  background: #ffffff;
  color: #0f172a;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.02);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.cr-chatbot-input::placeholder {
  color: #94a3b8;
}

.cr-chatbot-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.cr-chatbot-send {
  min-width: 48px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: #1d4ed8;
  color: #ffffff;
  cursor: pointer;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 800;
  transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.cr-chatbot-send:hover {
  background: #153fae;
  transform: translateY(-1px);
}

.cr-chatbot-send:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

.cr-chatbot-send:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 3px;
}

/* Compatibilidad con versiones anteriores */
.creaura-chatbot,
.creaura-chatbot * {
  box-sizing: border-box;
}

/* Mobile */
@media (max-width: 640px) {
  .cr-chatbot-root {
    right: 12px;
    bottom: 12px;
  }

  .cr-chatbot-toggle {
    min-height: 46px;
    padding: 11px 14px;
  }

  .cr-chatbot-panel {
    width: calc(100vw - 24px);
    height: min(620px, calc(100vh - 34px));
    border-radius: 22px;
  }

  .cr-chatbot-header {
    padding: 16px 16px 12px;
  }

  .cr-chatbot-messages {
    padding: 14px;
  }

  .cr-chatbot-message {
    max-width: 92%;
    font-size: 14px;
  }

  .cr-chatbot-quick-replies {
    padding: 10px 12px;
  }

  .cr-chatbot-form {
    padding: 12px;
  }

  .cr-chatbot-send {
    min-width: 46px;
    padding: 0 14px;
  }
}
