/* Babeth — asistente web en tienda (discreto, sin header) */
.babeth-root {
  --babeth-teal: #0f766e;
  --babeth-teal-dark: #134e4a;
  --babeth-amber: #fef3c7;
  --babeth-stone: #1c1917;
  --babeth-muted: #78716c;
  --babeth-bg: #fafaf9;
  --babeth-panel: #ffffff;
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  z-index: 9990;
}

html.babeth-chat-open,
html.babeth-chat-open body {
  overflow: hidden;
}

.babeth-fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: calc(100vw - 2rem);
  padding: 0.65rem 1rem 0.65rem 0.75rem;
  border: 1px solid rgba(15, 118, 110, 0.25);
  border-radius: 999px;
  background: linear-gradient(135deg, #0f766e 0%, #134e4a 100%);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 28px rgba(15, 118, 110, 0.28);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.babeth-fab:hover,
.babeth-fab:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(15, 118, 110, 0.35);
  outline: none;
}

.babeth-fab-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: var(--babeth-amber);
  color: var(--babeth-teal-dark);
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  flex-shrink: 0;
  overflow: hidden;
}
.babeth-fab-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.babeth-fab-label {
  white-space: nowrap;
}

.babeth-fab-sub {
  display: none;
  font-weight: 500;
  font-size: 0.7rem;
  opacity: 0.9;
}

@media (min-width: 768px) {
  .babeth-fab {
    flex-direction: column;
    align-items: flex-start;
    border-radius: 1.1rem;
    padding: 0.7rem 1rem;
    gap: 0.15rem;
  }
  .babeth-fab-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  .babeth-fab-sub {
    display: block;
    padding-left: 2.5rem;
  }
}

.babeth-panel {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: min(380px, calc(100vw - 2rem));
  height: min(560px, calc(100vh - 2rem));
  display: none;
  flex-direction: column;
  border-radius: 1.25rem;
  overflow: hidden;
  background: var(--babeth-panel);
  border: 1px solid #e7e5e4;
  box-shadow: 0 24px 48px rgba(28, 25, 23, 0.18);
}

.babeth-panel.is-open {
  display: flex;
  animation: babeth-in 0.22s ease;
}

@keyframes babeth-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.babeth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  padding-top: calc(0.9rem + env(safe-area-inset-top, 0px));
  background: linear-gradient(135deg, #0f766e 0%, #134e4a 55%, #1c1917 100%);
  color: #fff;
  flex-shrink: 0;
}

.babeth-header-text {
  min-width: 0;
}

.babeth-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
}

.babeth-header p {
  margin: 0.15rem 0 0;
  font-size: 0.7rem;
  color: #ccfbf1;
  font-weight: 500;
}

.babeth-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 800;
  line-height: 1;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.babeth-close:hover,
.babeth-close:focus-visible {
  background: rgba(255, 255, 255, 0.32);
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.babeth-close-icon {
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1;
}

.babeth-close-label {
  display: none;
}

.babeth-back-store {
  display: none;
  width: 100%;
  border: 0;
  border-top: 1px solid #e7e5e4;
  background: #fff;
  color: #0f766e;
  font-size: 0.875rem;
  font-weight: 800;
  padding: 0.85rem 1rem;
  padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.babeth-back-store:hover,
.babeth-back-store:focus-visible {
  background: #f0fdfa;
  outline: none;
}

.babeth-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: var(--babeth-bg);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.babeth-bubble {
  max-width: 92%;
  padding: 0.7rem 0.85rem;
  border-radius: 1rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.babeth-bubble a {
  color: var(--babeth-teal);
  font-weight: 700;
  text-decoration: underline;
}

.babeth-bubble--bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e7e5e4;
  color: var(--babeth-stone);
  border-bottom-left-radius: 0.35rem;
}

.babeth-bubble--user {
  align-self: flex-end;
  background: var(--babeth-teal);
  color: #fff;
  border-bottom-right-radius: 0.35rem;
}

.babeth-bubble--meta {
  align-self: center;
  font-size: 0.7rem;
  color: var(--babeth-muted);
  background: transparent;
  border: 0;
  padding: 0.25rem;
}

.babeth-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1rem 0.65rem;
  background: var(--babeth-bg);
}

.babeth-chip {
  border: 1px solid rgba(15, 118, 110, 0.35);
  background: #fff;
  color: var(--babeth-teal-dark);
  font-size: 0.7rem;
  font-weight: 650;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.babeth-chip:hover,
.babeth-chip:focus-visible {
  background: #ccfbf1;
  outline: none;
}

.babeth-chip--wa {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.babeth-chip--tienda {
  border-color: rgba(15, 118, 110, 0.5);
  background: #ccfbf1;
  color: #134e4a;
  font-weight: 750;
}

.babeth-footer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid #e7e5e4;
  background: #fff;
}

.babeth-input {
  flex: 1;
  border: 1px solid #d6d3d1;
  border-radius: 0.85rem;
  padding: 0.65rem 0.8rem;
  font-size: 0.8125rem;
  resize: none;
  min-height: 2.5rem;
  max-height: 5rem;
  font-family: inherit;
}

.babeth-input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.35);
  border-color: var(--babeth-teal);
}

.babeth-send {
  border: 0;
  border-radius: 0.85rem;
  background: var(--babeth-teal);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0 0.9rem;
  cursor: pointer;
}

.babeth-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.babeth-typing {
  font-size: 0.75rem;
  color: var(--babeth-muted);
  padding: 0 1rem 0.5rem;
  background: var(--babeth-bg);
}

@media (max-width: 767px) {
  .babeth-fab {
    right: 0.75rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    padding: 0.55rem;
    max-width: none;
  }

  .babeth-fab-label,
  .babeth-fab-sub {
    display: none;
  }
}

@media (max-width: 640px) {
  .babeth-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    z-index: 10000;
  }

  .babeth-close {
    min-width: 5.5rem;
    min-height: 2.75rem;
    padding: 0.5rem 0.9rem;
    background: #fff;
    color: #134e4a;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  }

  .babeth-close:hover,
  .babeth-close:focus-visible {
    background: #fef3c7;
    outline: 2px solid #fbbf24;
    outline-offset: 2px;
  }

  .babeth-close-label {
    display: inline;
  }

  .babeth-close-icon {
    font-size: 1.25rem;
  }

  .babeth-back-store {
    display: block;
  }
}

@media (max-width: 420px) {
  .babeth-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
  }
}
