/* ==========================================================
   BlackBull — Portafolio · estilos del CHAT
   Usa las mismas variables que css/style.css
   ========================================================== */

.chat-root { bottom: 24px; position: fixed; right: 24px; z-index: 280; }

/* ===== Botón flotante ===== */
.chat-launcher {
  align-items: center;
  background: linear-gradient(140deg, var(--ec-blue), var(--ec-blue-dim));
  border: 0;
  border-radius: 50%;
  box-shadow: 0 10px 34px rgba(59,130,246,0.45), 0 2px 8px rgba(0,0,0,0.4);
  color: #fff;
  cursor: pointer;
  display: flex;
  height: 60px; width: 60px;
  justify-content: center;
  position: relative;
  transition: transform 0.28s cubic-bezier(.2,.7,.3,1), box-shadow 0.25s ease, opacity 0.2s ease;
}
.chat-launcher:hover { box-shadow: 0 14px 42px rgba(59,130,246,0.6); transform: translateY(-3px) scale(1.04); }
.chat-launcher svg {
  fill: currentColor;
  height: 26px; width: 26px;
  position: absolute;
  transition: opacity 0.2s ease, transform 0.3s ease;
}
.chat-launcher .ic-chat circle { fill: currentColor; }
.chat-launcher .ic-x { opacity: 0; transform: rotate(-90deg) scale(.6); }
.chat-root.is-open .ic-chat { opacity: 0; transform: rotate(90deg) scale(.6); }
.chat-root.is-open .ic-x { opacity: 1; transform: none; }

.chat-launcher::before {
  animation: ring 2.8s ease-out infinite;
  border: 2px solid rgba(59,130,246,0.55);
  border-radius: 50%;
  content: "";
  inset: -6px;
  position: absolute;
}
.chat-root.is-open .chat-launcher::before { display: none; }

.chat-badge {
  background: var(--ec-cyan);
  border: 2px solid var(--ec-bg-deep);
  border-radius: 20px;
  color: #06121f;
  font-size: 11px; font-weight: 800;
  line-height: 1;
  min-width: 21px;
  padding: 4px 5px;
  position: absolute;
  right: -3px; top: -3px;
}

/* ===== Burbuja de invitación ===== */
.chat-peek {
  background: var(--ec-bg-panel);
  border: 1px solid var(--ec-border-bright);
  border-radius: 14px 14px 4px 14px;
  bottom: 78px;
  box-shadow: 0 16px 44px rgba(0,0,0,0.5);
  cursor: pointer;
  max-width: 260px;
  opacity: 0;
  padding: 14px 34px 14px 16px;
  position: absolute;
  right: 0;
  transform: translateY(10px) scale(.94);
  transform-origin: bottom right;
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(.2,.7,.3,1);
}
.chat-peek.is-on { opacity: 1; transform: none; }
.chat-peek p { color: var(--ec-text-primary); font-size: 13.5px; line-height: 1.5; }
.chat-peek-x {
  background: none; border: 0;
  color: var(--ec-text-muted);
  cursor: pointer;
  font-size: 19px; line-height: 1;
  padding: 2px 6px;
  position: absolute; right: 6px; top: 6px;
}
.chat-peek-x:hover { color: var(--ec-text-primary); }

/* ===== Panel ===== */
.chat-panel {
  background: var(--ec-bg-panel);
  border: 1px solid var(--ec-border);
  border-radius: var(--ec-radius-xl);
  bottom: 78px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.65), 0 0 0 1px rgba(59,130,246,0.08);
  display: flex;
  flex-direction: column;
  height: min(620px, calc(100vh - 140px));
  opacity: 0;
  overflow: hidden;
  position: absolute;
  right: 0;
  transform: translateY(16px) scale(.96);
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.32s cubic-bezier(.2,.7,.3,1);
  width: 380px;
}
.chat-root.is-open .chat-panel { opacity: 1; transform: none; }

/* ===== Cabecera ===== */
.chat-head {
  align-items: center;
  background: linear-gradient(180deg, var(--ec-bg-surface), var(--ec-bg-panel));
  border-bottom: 1px solid var(--ec-border);
  display: flex;
  gap: 11px;
  padding: 13px 14px;
}
.chat-avatar {
  background: linear-gradient(140deg, var(--ec-blue), var(--ec-cyan));
  border-radius: 50%;
  color: #fff;
  flex: none;
  font-size: 14px; font-weight: 800;
  height: 40px; width: 40px;
  overflow: hidden;
  position: relative;
}
.chat-avatar img { height: 100%; inset: 0; object-fit: cover; position: absolute; width: 100%; z-index: 1; }
.chat-avatar span { align-items: center; display: flex; height: 100%; justify-content: center; }
.chat-on {
  background: #22c55e;
  border: 2px solid var(--ec-bg-panel);
  border-radius: 50%;
  bottom: -1px; right: -1px;
  height: 12px; width: 12px;
  position: absolute;
  z-index: 2;
}
.chat-id { flex: 1; min-width: 0; }
.chat-id b { color: var(--ec-text-primary); display: block; font-size: 14px; font-weight: 700; }
.chat-id span {
  color: var(--ec-text-muted);
  display: block;
  font-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-ico {
  background: none; border: 0;
  border-radius: var(--ec-radius-sm);
  color: var(--ec-text-muted);
  cursor: pointer;
  display: flex;
  flex: none;
  padding: 6px;
  transition: color var(--ec-transition), background var(--ec-transition);
}
.chat-ico svg { height: 17px; width: 17px; }
.chat-ico:hover { background: var(--ec-bg-input); color: var(--ec-text-primary); }
.chat-ico.is-off { opacity: .5; }

/* ===== Cuerpo ===== */
.chat-body {
  background: radial-gradient(ellipse 80% 40% at 50% 0%, rgba(59,130,246,0.07), transparent 70%);
  display: flex; flex-direction: column;
  flex: 1;
  gap: 12px;
  overflow-y: auto;
  padding: 18px 16px;
  scroll-behavior: smooth;
}
.chat-body::-webkit-scrollbar { width: 5px; }

.msg { display: flex; flex-direction: column; gap: 3px; max-width: 82%; }
.msg-bot { align-items: flex-start; align-self: flex-start; }
.msg-yo  { align-items: flex-end;   align-self: flex-end; }
.burbuja {
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  padding: 10px 14px;
  overflow-wrap: anywhere;
}
.msg-bot .burbuja {
  background: var(--ec-bg-surface);
  border: 1px solid var(--ec-border);
  border-bottom-left-radius: 4px;
  color: var(--ec-text-primary);
}
.msg-yo .burbuja {
  background: linear-gradient(135deg, var(--ec-blue), var(--ec-blue-dim));
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(59,130,246,0.3);
  color: #fff;
}
.msg time { color: var(--ec-text-muted); font-size: 10px; padding: 0 4px; }

/* ===== Adjuntos: fotos y archivos ===== */
.burbuja.solo-adjuntos { padding: 5px; }
.adjuntos { display: flex; flex-direction: column; gap: 6px; }
.burbuja > .adjuntos:not(:first-child) { margin-top: 9px; }

.adj-img {
  border-radius: 10px;
  display: block;
  line-height: 0;
  overflow: hidden;
  position: relative;
}
.adj-img img {
  display: block;
  height: auto;
  max-height: 300px;
  max-width: 100%;
  object-fit: cover;
  transition: transform 0.3s cubic-bezier(.2,.7,.3,1);
  width: auto;
}
.adj-img:hover img { transform: scale(1.03); }
.adj-img.rota::after {
  background: var(--ec-bg-input);
  border: 1px dashed var(--ec-border-bright);
  border-radius: 10px;
  color: var(--ec-text-muted);
  content: "No se pudo cargar la imagen";
  display: block;
  font-size: 12px;
  line-height: 1.5;
  padding: 22px 14px;
  text-align: center;
}

.adj-file {
  align-items: center;
  background: var(--ec-bg-input);
  border: 1px solid var(--ec-border);
  border-radius: 8px;
  color: var(--ec-text-primary);
  display: flex;
  font-size: 12.5px;
  gap: 9px;
  overflow-wrap: anywhere;
  padding: 9px 12px;
  transition: all var(--ec-transition);
}
.adj-file:hover { border-color: var(--ec-blue); color: var(--ec-blue-bright); }
.adj-file svg { flex: none; height: 17px; width: 17px; }

/* Indicador "escribiendo..." */
.burbuja.escribiendo { display: flex; gap: 4px; padding: 14px; }
.burbuja.escribiendo i {
  animation: puntico 1.2s infinite;
  background: var(--ec-text-muted);
  border-radius: 50%;
  height: 6px; width: 6px;
}
.burbuja.escribiendo i:nth-child(2) { animation-delay: .18s; }
.burbuja.escribiendo i:nth-child(3) { animation-delay: .36s; }
@keyframes puntico {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30%           { opacity: 1;  transform: translateY(-4px); }
}

/* ===== Aviso del sistema (ticket abierto, cerrado, error de red) ===== */
.chat-sistema {
  color: var(--ec-text-muted);
  font-size: 11.5px;
  letter-spacing: 0.4px;
  padding: 2px 0;
  text-align: center;
}
.chat-sistema::before,
.chat-sistema::after { content: "·"; margin: 0 8px; }

/* ===== Resumen final ===== */
.chat-resumen {
  background: var(--ec-bg-surface);
  border: 1px solid rgba(59,130,246,0.35);
  border-radius: var(--ec-radius-lg);
  padding: 16px;
}
.chat-resumen h4 {
  color: var(--ec-blue-bright);
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.8px;
  margin-bottom: 12px;
  text-transform: uppercase;
}
.chat-resumen ul { list-style: none; }
.chat-resumen li {
  border-bottom: 1px solid var(--ec-border);
  display: flex; gap: 12px;
  justify-content: space-between;
  padding: 7px 0;
}
.chat-resumen li:last-child { border-bottom: 0; }
.chat-resumen li span { color: var(--ec-text-muted); flex: none; font-size: 12px; }
.chat-resumen li b {
  color: var(--ec-text-primary);
  font-size: 12.5px; font-weight: 600;
  overflow-wrap: anywhere;
  text-align: right;
}
.chat-resumen-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chat-resumen-btns .btn { flex: 1 1 auto; }

/* ===== Respuestas rápidas ===== */
.chat-ops { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 16px; }
.chat-ops.is-on { padding-bottom: 12px; }
.qr {
  background: rgba(59,130,246,0.10);
  border: 1px solid rgba(59,130,246,0.45);
  border-radius: 20px;
  color: var(--ec-blue-bright);
  cursor: pointer;
  font-size: 12.5px; font-weight: 600;
  padding: 7px 14px;
  transition: all var(--ec-transition);
}
.qr:hover { background: var(--ec-blue); border-color: var(--ec-blue); color: #fff; transform: translateY(-1px); }

/* ===== Entrada ===== */
.chat-form {
  align-items: center;
  border-top: 1px solid var(--ec-border);
  display: flex;
  gap: 8px;
  padding: 12px 14px;
}
.chat-form input {
  background: var(--ec-bg-input);
  border: 1px solid var(--ec-border);
  border-radius: 22px;
  color: var(--ec-text-primary);
  flex: 1;
  font-family: inherit;
  font-size: 13.5px;
  min-width: 0;
  outline: none;
  padding: 11px 16px;
  transition: border-color var(--ec-transition);
}
.chat-form input::placeholder { color: var(--ec-text-muted); }
.chat-form input:focus { border-color: var(--ec-blue); }
.chat-form input:disabled { opacity: .5; }
.chat-form button {
  align-items: center;
  background: var(--ec-blue);
  border: 0;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex: none;
  height: 40px; width: 40px;
  justify-content: center;
  transition: all var(--ec-transition);
}
.chat-form button svg { height: 18px; margin-left: -2px; width: 18px; }
.chat-form button:hover:not(:disabled) { background: var(--ec-blue-bright); transform: scale(1.06); }
.chat-form button:disabled { background: var(--ec-bg-elevated); cursor: default; }

.chat-pie {
  color: var(--ec-text-muted);
  font-size: 10.5px;
  padding: 0 14px 12px;
  text-align: center;
}
.chat-pie b { color: var(--ec-text-secondary); font-weight: 600; }

/* ===== Chat en móvil: pantalla completa ===== */
@media (max-width: 560px) {
  .chat-root { bottom: 16px; right: 16px; }
  .chat-panel {
    border-radius: 0;
    bottom: 0; left: 0; right: 0; top: 0;
    height: 100dvh;
    position: fixed;
    width: 100vw;
  }
  .chat-root.is-open .chat-launcher { opacity: 0; pointer-events: none; }
  .chat-peek { max-width: min(260px, calc(100vw - 48px)); }
}
