:root {
  --epresa-primary: #e87a1f;
  --epresa-primary-strong: #c95f08;
  --epresa-accent: #f28f16;
  --epresa-bg: #ffffff;
  --epresa-panel: #f4f8fb;
  --epresa-border: #d8e3ec;
  --epresa-text: #163246;
  --epresa-muted: #5a7486;
  --epresa-shadow: 0 20px 60px rgba(4, 30, 48, 0.22), 0 4px 16px rgba(4, 30, 48, 0.10);
  --epresa-bubble-shadow: 0 8px 24px rgba(232, 122, 31, 0.45), 0 2px 8px rgba(232, 122, 31, 0.25);
  --epresa-msg-shadow: 0 2px 8px rgba(4, 30, 48, 0.08);
}

#epresa-chatbot-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 999999;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

/* ── Bubble ── */
.epresa-chatbot-bubble {
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--epresa-primary), #f29a2e);
  color: #fff;
  box-shadow: var(--epresa-bubble-shadow);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.epresa-chatbot-bubble:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 32px rgba(232, 122, 31, 0.55), 0 4px 12px rgba(232, 122, 31, 0.3);
}

.epresa-chatbot-bubble:active {
  transform: scale(0.96);
}

.epresa-chatbot-bubble:focus {
  outline: 3px solid rgba(232, 122, 31, 0.4);
  outline-offset: 3px;
}

.epresa-chatbot-bubble-icon {
  display: block;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.22));
}

/* ── Panel ── */
.epresa-chatbot-panel {
  width: min(380px, calc(100vw - 24px));
  height: min(620px, calc(100vh - 110px));
  background: var(--epresa-bg);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--epresa-shadow);
  display: none;
  flex-direction: column;
  border: 1px solid rgba(216, 227, 236, 0.6);
  margin-bottom: 14px;
  animation: epresaSlideUp 0.25s cubic-bezier(0.34, 1.4, 0.64, 1);
  transform-origin: bottom right;
}

@keyframes epresaSlideUp {
  from { opacity: 0; transform: scale(0.88) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.epresa-chatbot-panel.is-open {
  display: flex;
}

/* ── Header ── */
.epresa-chatbot-header {
  background: linear-gradient(135deg, var(--epresa-primary-strong) 0%, var(--epresa-primary) 60%, var(--epresa-accent) 100%);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(201, 95, 8, 0.3);
  position: relative;
  overflow: hidden;
}

.epresa-chatbot-header::before {
  content: '';
  position: absolute;
  top: -30px; right: -20px;
  width: 100px; height: 100px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
  pointer-events: none;
}

.epresa-chatbot-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.epresa-chatbot-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  border: 2px solid rgba(255,255,255,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.epresa-chatbot-header-info h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.epresa-chatbot-header-status {
  font-size: 11px;
  opacity: 0.88;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.epresa-chatbot-header-status::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5dffa0;
  box-shadow: 0 0 6px #5dffa0;
  animation: epresaPulse 2s infinite;
}

@keyframes epresaPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.epresa-chatbot-close {
  border: 0;
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.epresa-chatbot-close:hover {
  background: rgba(255,255,255,0.32);
}

/* ── Messages area ── */
.epresa-chatbot-messages {
  flex: 1;
  padding: 16px 14px;
  background: linear-gradient(180deg, #f0f6fa 0%, #edf3f8 100%);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

.epresa-chatbot-messages::-webkit-scrollbar {
  width: 4px;
}
.epresa-chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}
.epresa-chatbot-messages::-webkit-scrollbar-thumb {
  background: #c8d8e4;
  border-radius: 99px;
}

/* ── Message row (avatar + bubble) ── */
.epresa-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: epresaMsgIn 0.22s cubic-bezier(0.34, 1.3, 0.64, 1);
  margin-bottom: 6px;
}

@keyframes epresaMsgIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.epresa-msg-row.user {
  flex-direction: row-reverse;
}

.epresa-msg-row-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--epresa-primary-strong), var(--epresa-primary));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(232, 122, 31, 0.35);
}

/* ── Bubbles ── */
.epresa-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  position: relative;
}

.epresa-msg.user {
  background: linear-gradient(135deg, var(--epresa-primary), var(--epresa-accent));
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 4px 14px rgba(232, 122, 31, 0.35), 0 1px 4px rgba(232, 122, 31, 0.2);
  white-space: pre-wrap;
}

.epresa-msg.bot {
  background: #ffffff;
  color: var(--epresa-text);
  border: 1px solid rgba(216, 227, 236, 0.9);
  border-bottom-left-radius: 5px;
  box-shadow: var(--epresa-msg-shadow);
}

/* Markdown content inside bot messages */
.epresa-msg.bot p {
  margin: 0 0 6px;
}
.epresa-msg.bot p:last-child { margin-bottom: 0; }
.epresa-msg.bot strong {
  font-weight: 700;
  color: var(--epresa-primary-strong);
}
.epresa-msg.bot em {
  font-style: italic;
  color: var(--epresa-muted);
}
.epresa-msg.bot ul,
.epresa-msg.bot ol {
  margin: 6px 0 6px 18px;
  padding: 0;
}
.epresa-msg.bot li { margin-bottom: 3px; }
.epresa-msg.bot code {
  background: #eef3f7;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  font-family: monospace;
  color: var(--epresa-primary-strong);
}
.epresa-msg.bot hr {
  border: none;
  border-top: 1px solid var(--epresa-border);
  margin: 8px 0;
}

/* Choice options */
.epresa-msg.choice-option {
  max-width: 88%;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  animation: epresaMsgIn 0.22s cubic-bezier(0.34, 1.3, 0.64, 1);
  margin-bottom: 4px;
}

.epresa-chatbot-action-btn {
  border: 1.5px solid var(--epresa-primary);
  background: #fff;
  color: var(--epresa-primary);
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.12s;
  box-shadow: 0 2px 8px rgba(232, 122, 31, 0.15);
}

.epresa-chatbot-action-btn:hover {
  border-color: var(--epresa-primary);
  color: var(--epresa-primary);
  background: #fff8f2;
  box-shadow: 0 4px 12px rgba(232, 122, 31, 0.18);
  transform: translateY(-1px);
}

.epresa-chatbot-action-btn:active {
  transform: translateY(0);
}

/* ── File row ── */
.epresa-chatbot-file-row {
  padding: 8px 14px 10px;
  background: #edf4f9;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--epresa-border);
}

.epresa-chatbot-file-row.is-visible {
  display: flex;
}

.epresa-chatbot-file-label {
  font-size: 12px;
  color: var(--epresa-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.epresa-chatbot-file-btn {
  border: 1.5px dashed var(--epresa-primary);
  color: var(--epresa-primary);
  background: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s;
}

.epresa-chatbot-file-btn:hover {
  background: #fff5ec;
}

/* ── Footer ── */
.epresa-chatbot-footer {
  border-top: 1px solid rgba(216, 227, 236, 0.7);
  background: var(--epresa-bg);
  padding: 10px 12px 8px;
}

.epresa-chatbot-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.epresa-chatbot-input {
  width: 100%;
  border: 1.5px solid var(--epresa-border);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  padding: 10px 12px;
  color: var(--epresa-text);
  background: #f8fbfd;
  min-height: 44px;
  max-height: 130px;
  resize: none;
  overflow-y: auto;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.epresa-chatbot-input::placeholder {
  color: #9ab3c3;
}

.epresa-chatbot-input:focus {
  outline: none;
  border-color: var(--epresa-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(232, 122, 31, 0.12);
}

.epresa-chatbot-send {
  border: 0;
  background: linear-gradient(135deg, #19a974, #12c97f);
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(25, 169, 116, 0.45);
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}

.epresa-chatbot-send:hover:not([disabled]) {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(25, 169, 116, 0.55);
}

.epresa-chatbot-send:active:not([disabled]) {
  transform: scale(0.95);
}

.epresa-chatbot-send[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.epresa-chatbot-status {
  font-size: 11px;
  color: var(--epresa-muted);
  margin-top: 5px;
  min-height: 15px;
  padding-left: 2px;
}

/* ── Typing indicator ── */
.epresa-typing-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
}

.epresa-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a8becf;
  animation: epresaTyping 1.3s infinite ease-in-out;
}

.epresa-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.epresa-typing-dot:nth-child(3) { animation-delay: 0.36s; }

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

/* ── Responsive ── */
@media (max-width: 600px) {
  #epresa-chatbot-root {
    right: 10px;
    bottom: 10px;
  }

  .epresa-chatbot-panel {
    width: calc(100vw - 20px);
    height: calc(100vh - 90px);
    border-radius: 16px;
  }
}

/* ── Icono personalizado (imagen) ── */
.epresa-chatbot-bubble-img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.7);
  display: block;
}

.epresa-chatbot-avatar-img {
  background: transparent;
  border: none;
  padding: 0;
  overflow: hidden;
}

.epresa-chatbot-avatar-img img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.6);
  display: block;
}
