/* ==========================================================================
   Asistente Virtual - Catalunya Plants
   Estilos aislados y alineados con la identidad visual de catalunyaplants.com
   ========================================================================== */

#cp-assistant-root {
  --cp-green: #2a4d33;
  --cp-green-dark: #1f3a26;
  --cp-green-soft: rgba(42, 77, 51, 0.08);
  --cp-orange: #E97300;
  --cp-orange-hover: #cf6500;
  --cp-cream: #F8F5EF;
  --cp-surface: #ffffff;
  --cp-ink: #4d4035;
  --cp-muted: #76685b;
  --cp-border: rgba(42, 77, 51, 0.14);
  --cp-shadow: 0 18px 48px rgba(24, 38, 28, 0.18), 0 4px 14px rgba(24, 38, 28, 0.08);
  --cp-font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --cp-font-head: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2147483000;
  font-family: var(--cp-font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--cp-ink);
  -webkit-font-smoothing: antialiased;
}

#cp-assistant-root *,
#cp-assistant-root *::before,
#cp-assistant-root *::after {
  box-sizing: border-box;
}

/* ---------- Botón lanzador discreto (estado cerrado) ---------- */
.cp-asst-launcher {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: var(--cp-green);
  color: #ffffff;
  padding: 11px 16px 11px 13px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(42, 77, 51, 0.28);
  font-family: var(--cp-font-head);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              background-color 0.2s ease,
              box-shadow 0.22s ease;
}

.cp-asst-launcher:hover {
  background: var(--cp-green-dark);
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(42, 77, 51, 0.34);
}

.cp-asst-launcher:focus-visible,
.cp-asst-icon-btn:focus-visible,
.cp-asst-lang-btn:focus-visible,
.cp-asst-chip:focus-visible,
.cp-asst-action:focus-visible,
.cp-asst-send:focus-visible,
.cp-asst-promo:focus-visible {
  outline: 2px solid var(--cp-orange);
  outline-offset: 2px;
}

.cp-asst-launcher-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  flex-shrink: 0;
}

.cp-asst-status-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--cp-green);
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.75);
}

.cp-asst-status-dot.is-closed {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.75);
}

.cp-asst-launcher-label {
  white-space: nowrap;
}

/* ---------- Panel del asistente (estado abierto) ---------- */
.cp-asst-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(392px, calc(100vw - 24px));
  height: min(600px, calc(100vh - 36px));
  max-height: calc(100dvh - 36px);
  display: flex;
  flex-direction: column;
  background: var(--cp-cream);
  border: 1px solid var(--cp-border);
  border-radius: 20px;
  box-shadow: var(--cp-shadow);
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  transform-origin: bottom right;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.24s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.24s;
}

#cp-assistant-root.is-open .cp-asst-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

#cp-assistant-root.is-open .cp-asst-launcher {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
}

/* ---------- Cabecera ---------- */
.cp-asst-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--cp-green) 0%, var(--cp-green-dark) 100%);
  color: #ffffff;
  flex-shrink: 0;
}

.cp-asst-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.cp-asst-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.14);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cp-asst-brand-text {
  min-width: 0;
}

.cp-asst-title {
  margin: 0;
  padding: 0;
  font-family: var(--cp-font-head);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cp-asst-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.86);
}

.cp-asst-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 7px rgba(74, 222, 128, 0.75);
  flex-shrink: 0;
}

.cp-asst-live-dot.is-closed {
  background: #ef4444;
  box-shadow: 0 0 7px rgba(239, 68, 68, 0.75);
}

.cp-asst-header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.cp-asst-lang-switch {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 2px;
}

.cp-asst-lang-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  font-family: var(--cp-font-head);
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.cp-asst-lang-btn.is-active {
  background: #ffffff;
  color: var(--cp-green);
}

.cp-asst-icon-btn {
  appearance: none;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.15s ease;
}

.cp-asst-icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ---------- Banner estacional opcional ---------- */
.cp-asst-promo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  background: rgba(233, 115, 0, 0.1);
  border-bottom: 1px solid rgba(233, 115, 0, 0.2);
  text-decoration: none;
  color: var(--cp-ink);
  font-size: 12.5px;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.cp-asst-promo:hover {
  background: rgba(233, 115, 0, 0.16);
}

.cp-asst-promo-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.cp-asst-promo-badge {
  background: var(--cp-orange);
  color: #ffffff;
  font-family: var(--cp-font-head);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.cp-asst-promo-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.cp-asst-promo-cta {
  color: var(--cp-orange);
  font-family: var(--cp-font-head);
  font-weight: 700;
  font-size: 11.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---------- Zona de conversación ---------- */
.cp-asst-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.cp-asst-messages::-webkit-scrollbar {
  width: 6px;
}

.cp-asst-messages::-webkit-scrollbar-thumb {
  background: rgba(42, 77, 51, 0.18);
  border-radius: 999px;
}

.cp-asst-msg {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  animation: cpAsstFadeUp 0.2s ease both;
}

.cp-asst-msg.is-bot {
  align-self: flex-start;
}

.cp-asst-msg.is-user {
  align-self: flex-end;
}

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

.cp-asst-bubble {
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-line;
  word-break: break-word;
}

.cp-asst-msg.is-bot .cp-asst-bubble {
  background: var(--cp-surface);
  color: var(--cp-ink);
  border: 1px solid var(--cp-border);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(42, 77, 51, 0.04);
}

.cp-asst-msg.is-user .cp-asst-bubble {
  background: var(--cp-green);
  color: #ffffff;
  border-bottom-right-radius: 6px;
}

.cp-asst-greeting-title {
  display: block;
  font-family: var(--cp-font-head);
  font-size: 15px;
  font-weight: 700;
  color: var(--cp-green);
  margin-bottom: 4px;
}

/* ---------- Botones de acción dentro de la respuesta ---------- */
.cp-asst-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.cp-asst-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--cp-green-soft);
  color: var(--cp-green);
  font-family: var(--cp-font-head);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(42, 77, 51, 0.16);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cp-asst-action:hover {
  background: var(--cp-green);
  border-color: var(--cp-green);
  color: #ffffff;
}

.cp-asst-action.is-primary {
  background: var(--cp-orange);
  border-color: var(--cp-orange);
  color: #ffffff;
}

.cp-asst-action.is-primary:hover {
  background: var(--cp-orange-hover);
  border-color: var(--cp-orange-hover);
}

/* ---------- Chips de preguntas rápidas ---------- */
.cp-asst-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.cp-asst-chip {
  appearance: none;
  border: 1px solid rgba(42, 77, 51, 0.22);
  background: var(--cp-surface);
  color: var(--cp-green);
  font-family: var(--cp-font-body);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.3;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.cp-asst-chip:hover {
  background: var(--cp-green);
  border-color: var(--cp-green);
  color: #ffffff;
  transform: translateY(-1px);
}

.cp-asst-chip.is-secondary {
  border-style: dashed;
  color: var(--cp-muted);
  background: transparent;
}

.cp-asst-chip.is-secondary:hover {
  background: var(--cp-green-soft);
  border-color: var(--cp-green);
  color: var(--cp-green);
}

/* ---------- Barra inferior de entrada ---------- */
.cp-asst-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px;
  background: var(--cp-surface);
  border-top: 1px solid var(--cp-border);
  flex-shrink: 0;
}

.cp-asst-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid rgba(42, 77, 51, 0.18);
  background: var(--cp-cream);
  color: var(--cp-ink);
  font-family: var(--cp-font-body);
  font-size: 13.5px;
  padding: 9px 13px;
  border-radius: 999px;
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.cp-asst-input::placeholder {
  color: var(--cp-muted);
}

.cp-asst-input:focus {
  border-color: var(--cp-green);
  background: #ffffff;
}

.cp-asst-send {
  appearance: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  background: var(--cp-orange);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.cp-asst-send:hover {
  background: var(--cp-orange-hover);
  transform: scale(1.04);
}

/* ---------- Responsive móvil ---------- */
@media (max-width: 480px) {
  #cp-assistant-root {
    right: 12px;
    bottom: 12px;
  }

  .cp-asst-launcher {
    padding: 10px 14px 10px 11px;
  }

  .cp-asst-panel {
    width: calc(100vw - 24px);
    height: min(78dvh, 560px);
    max-height: calc(100dvh - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cp-asst-launcher,
  .cp-asst-panel,
  .cp-asst-msg,
  .cp-asst-chip,
  .cp-asst-send {
    transition: none;
    animation: none;
  }
}
