/* ===========================================================================
   Chat de consultas sobre pedido — estilo WhatsApp, marca Floradomicilio
   =========================================================================== */
:root {
  --oc-brand: #b11c22;
  --oc-brand-dark: #8b0000;
  --oc-bg: #efe7e0;
  --oc-in: #ffffff;
  --oc-out: #fbe3d0;
}

/* ── Launcher (burbuja flotante redonda) — mismo lado que el carrito, justo encima ── */
.oc-launcher {
  position: fixed;
  right: 20px;
  bottom: 92px;              /* encima del botón del carrito (60px + separación) */
  z-index: 1199;
  width: 60px;
  height: 60px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--oc-brand);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(177, 28, 34, .4);
  transition: transform .15s ease, box-shadow .15s ease, background .15s;
}
.oc-launcher:hover { background: var(--oc-brand-dark); transform: translateY(-2px); box-shadow: 0 12px 30px rgba(177,28,34,.45); }
.oc-launcher i { font-size: 24px; }
.oc-launcher .oc-launcher-label { display: none; }   /* solo icono, botón redondo */

.oc-launcher .oc-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 20px; height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #16a34a;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px #fff;
}
.oc-launcher .oc-badge.show { display: inline-flex; }

/* ── Panel del chat ── */
.oc-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1210;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 600px;
  max-height: calc(100vh - 44px);
  background: var(--oc-bg);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
  transform: translateY(16px) scale(.98);
  opacity: 0;
  pointer-events: none;
  transition: transform .18s ease, opacity .18s ease;
}
.oc-panel.open { transform: translateY(0) scale(1); opacity: 1; pointer-events: auto; }

/* ── Cabecera ── */
.oc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--oc-brand) 0%, var(--oc-brand-dark) 100%);
  color: #fff;
  flex-shrink: 0;
  position: relative;
  z-index: 30;   /* por encima de las capas (overlays) para poder cerrar/volver */
}
.oc-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: #fff;
  border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
  overflow: hidden;
}
.oc-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.oc-header-info { flex: 1; min-width: 0; }
.oc-header-title { font-size: 15px; font-weight: 800; line-height: 1.2; }
.oc-header-status { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 5px; margin-top: 1px; }
.oc-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 0 rgba(74,222,128,.7); animation: oc-pulse 2s infinite; }
@keyframes oc-pulse { 0%{box-shadow:0 0 0 0 rgba(74,222,128,.6)} 70%{box-shadow:0 0 0 6px rgba(74,222,128,0)} 100%{box-shadow:0 0 0 0 rgba(74,222,128,0)} }
.oc-close {
  background: rgba(255,255,255,.15); border: none; color: #fff;
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  font-size: 18px; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: background .15s; flex-shrink: 0;
}
.oc-close:hover { background: rgba(255,255,255,.28); }

/* ── Botón volver ── */
.oc-back {
  background: rgba(255,255,255,.15); border: none; color: #fff;
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  font-size: 16px; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: background .15s; flex-shrink: 0;
}
.oc-back:hover { background: rgba(255,255,255,.28); }
.oc-back[hidden] { display: none; }

/* ── Vista selector de pedidos ── */
.oc-picker {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.oc-picker[hidden] { display: none; }
.oc-picker-title { font-size: 14px; font-weight: 700; color: #374151; margin: 2px 2px 4px; }

.oc-order-list { display: flex; flex-direction: column; gap: 8px; }
.oc-order-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid #eee0e0;
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.oc-order-item:hover { border-color: var(--oc-brand); box-shadow: 0 4px 14px rgba(177,28,34,.12); }
.oc-order-item:active { transform: scale(.99); }
.oc-order-icon {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 10px; background: #fdeceb; color: var(--oc-brand);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.oc-order-info { flex: 1; min-width: 0; }
.oc-order-num { font-size: 14px; font-weight: 800; color: #111827; }
.oc-order-sub { font-size: 12px; color: #6b7280; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oc-order-chev { color: #cbb6b6; font-size: 16px; flex-shrink: 0; }
.oc-order-badge {
  min-width: 22px; height: 22px; padding: 0 6px; flex-shrink: 0;
  border-radius: 999px; background: #16a34a; color: #fff;
  font-size: 12px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ── Vista de chat ── */
.oc-chat-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.oc-chat-view[hidden] { display: none; }
.oc-order-tag {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: #fff;
  border-bottom: 1px solid #f0e5e5;
  font-size: 12.5px;
  font-weight: 600;
  color: #6b7280;
  flex-shrink: 0;
}
.oc-order-tag i { color: var(--oc-brand); }

/* ── Zona de mensajes ── */
.oc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background-color: var(--oc-bg);
  background-image:
    radial-gradient(rgba(177,28,34,.05) 1px, transparent 1px);
  background-size: 22px 22px;
  scroll-behavior: smooth;
}
.oc-messages::-webkit-scrollbar { width: 6px; }
.oc-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 3px; }

/* Burbujas */
.oc-msg {
  max-width: 80%;
  padding: 8px 11px 6px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  color: #1f2937;
  position: relative;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 1px rgba(0,0,0,.06);
  animation: oc-pop .18s ease;
}
@keyframes oc-pop { from { transform: translateY(6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.oc-msg .oc-time { font-size: 10px; color: #9ca3af; display: block; text-align: right; margin-top: 2px; }

.oc-msg-in  { align-self: flex-start; background: var(--oc-in); border-top-left-radius: 4px; }
.oc-msg-out { align-self: flex-end; background: var(--oc-out); border-top-right-radius: 4px; }
.oc-msg-system {
  align-self: center;
  max-width: 92%;
  text-align: center;
  background: rgba(255,255,255,.75);
  color: #6b7280;
  font-size: 13px;
  border-radius: 10px;
  box-shadow: none;
}
.oc-msg-system .oc-time { text-align: center; }

.oc-day {
  align-self: center;
  background: rgba(0,0,0,.06);
  color: #6b7280;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 8px;
  margin: 6px 0;
}

/* Indicador escribiendo */
.oc-typing { align-self: flex-start; display: none; padding: 10px 12px; background: var(--oc-in); border-radius: 12px; border-top-left-radius: 4px; }
.oc-typing.show { display: inline-flex; gap: 3px; }
.oc-typing span { width: 6px; height: 6px; border-radius: 50%; background: #b0b0b0; animation: oc-blink 1.2s infinite; }
.oc-typing span:nth-child(2) { animation-delay: .2s; }
.oc-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes oc-blink { 0%,60%,100%{opacity:.3} 30%{opacity:1} }

/* ── Respuestas rápidas ── */
.oc-quick {
  display: flex;
  gap: 7px;
  padding: 8px 12px;
  overflow-x: auto;
  background: var(--oc-bg);
  flex-shrink: 0;
  scrollbar-width: none;
}
.oc-quick::-webkit-scrollbar { display: none; }
.oc-quick-chip {
  white-space: nowrap;
  border: 1px solid var(--oc-brand);
  background: #fff;
  color: var(--oc-brand);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.oc-quick-chip:hover { background: var(--oc-brand); color: #fff; }

/* ── Barra de entrada ── */
.oc-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #f0e5e5;
  flex-shrink: 0;
}
.oc-input {
  flex: 1;
  border: 1px solid #e5d3d3;
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  resize: none;
  height: 40px;                /* arranca en una sola línea */
  max-height: 110px;
  overflow-y: hidden;         /* sin flechas de scroll hasta el máximo */
  outline: none;
  box-sizing: border-box;
  transition: border-color .15s;
}
.oc-input:focus { border-color: var(--oc-brand); }
.oc-send {
  width: 42px; height: 42px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--oc-brand);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
}
.oc-send:hover { background: var(--oc-brand-dark); }
.oc-send:active { transform: scale(.92); }
.oc-send:disabled { opacity: .5; cursor: not-allowed; }

.oc-empty { text-align: center; color: #9ca3af; font-size: 13px; margin: auto 0; padding: 20px; }

/* ── ≤768px: igualar EXACTAMENTE al #floating-cart-btn ──
   El carrito tiene su tamaño de escritorio en un style="" inline (60px,
   right:20/bottom:20) y, dentro de <style> en base.html, una regla con
   !important para max-width:768px que lo cambia a 56px, right:15/bottom:15.
   Ese !important es lo único que de verdad manda (gana incluso al inline).
   Replicamos aquí los mismos valores para que el botón del chat quede
   siempre idéntico en tamaño y alineado en el mismo eje que el carrito. */
@media (max-width: 768px) {
  .oc-launcher {
    right: 15px;
    bottom: 83px;   /* 15 (bottom carrito) + 56 (alto carrito) + 12 (separación) */
    width: 56px;
    height: 56px;
  }
  .oc-launcher i { font-size: 22px; }
}

/* ── Móvil: el panel del chat pasa a pantalla completa ── */
@media (max-width: 480px) {
  .oc-panel {
    right: 0; bottom: 0; top: 0; left: 0;
    width: 100vw; max-width: 100vw;
    /* 100vh no descuenta las barras del navegador (atrás/menú/opciones) y
       tapaba el input. 100dvh sí se ajusta a la zona visible real. */
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
  /* Respeta el área segura inferior (barra de gestos / botones del sistema)
     para que "escribir" y "enviar" nunca queden ocultos. */
  .oc-input-bar {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
}

/* ── Subtítulo del selector (p. ej. "Tus pedidos") ── */
.oc-picker-subtitle {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #9ca3af;
  margin: 8px 2px 0;
}
.oc-picker-subtitle[hidden] { display: none; }

/* ── Capas (overlays) por encima del chat: identidad / login ── */
.oc-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(20, 12, 12, .45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  animation: ocFade .18s ease-out;
}
.oc-overlay[hidden] { display: none; }
@keyframes ocFade { from { opacity: 0; } to { opacity: 1; } }

.oc-overlay-card {
  width: 100%;
  max-width: 320px;
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
  animation: ocSlide .22s ease-out;
}
@keyframes ocSlide { from { transform: translateY(12px); opacity: .6; } to { transform: none; opacity: 1; } }

.oc-overlay-back {
  border: none; background: none; color: var(--oc-brand);
  font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 0; margin-bottom: 10px;
  display: inline-flex; align-items: center; gap: 4px;
}
.oc-overlay-title { font-size: 16px; font-weight: 800; color: #374151; margin-bottom: 4px; }
.oc-overlay-sub { font-size: 13px; color: #6b7280; margin-bottom: 12px; }

.oc-form { display: flex; flex-direction: column; gap: 10px; }
.oc-field {
  width: 100%;
  border: 1px solid #e5d7d7;
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.oc-field:focus { border-color: var(--oc-brand); }

/* Honeypots invisibles para bots */
.oc-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.oc-form-error { color: #b11c22; font-size: 12.5px; margin: -2px 0 0; }
.oc-form-error[hidden] { display: none; }

.oc-overlay-btn {
  width: 100%;
  border: none;
  border-radius: 10px;
  background: var(--oc-brand);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 12px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.oc-overlay-btn:hover { background: var(--oc-brand-dark); }
.oc-overlay-btn:active { transform: scale(.98); }
.oc-overlay-btn:disabled { opacity: .6; cursor: not-allowed; }

.oc-overlay-alt { margin-top: 14px; font-size: 13px; color: #6b7280; text-align: center; }
.oc-link {
  border: none; background: none; color: var(--oc-brand);
  font-weight: 700; cursor: pointer; padding: 0; font-size: inherit;
  text-decoration: underline;
}
#oc-login-resend { align-self: center; margin-top: 2px; }
