/* =============================================
   LisaKey - Chatbot web de cotizaciones
   Funciona 100% en el navegador y reutiliza
   Google Apps Script / Google Sheets existente.
   ============================================= */

.webchat {
  position: fixed;
  right: 22px;
  bottom: 88px;
  z-index: 1200;
  font-family: 'Poppins', sans-serif;
}

.webchat__launcher {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  padding: 0;
  border: 1px solid rgba(54, 163, 255, 0.58);
  border-radius: 50%;
  background: rgba(10, 107, 255, 0.16);
  color: #FFFFFF;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.34), 0 0 0 1px rgba(255,255,255,0.12) inset;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  position: relative;
  isolation: isolate;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.webchat__launcher:hover {
  transform: translateY(-2px);
  background: rgba(10, 107, 255, 0.28);
  border-color: rgba(54, 163, 255, 0.8);
  box-shadow: none;
}

.webchat__launcher-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(10, 107, 255, 0.18);
  font-size: 27px;
  line-height: 1;
}

.webchat__launcher-icon svg { width: 23px; height: 23px; }

.webchat__greeting{
  position:absolute;
  right:calc(100% + 10px);
  top:50%;
  padding:7px 11px;
  transform:translateY(-50%);
  border:1px solid rgba(54,163,255,.45);
  border-radius:12px 12px 3px 12px;
  background:#111827;
  color:#fff;
  font-size:12px;
  font-weight:700;
  line-height:1;
  white-space:nowrap;
  pointer-events:none;
  animation:webchatGreeting 5s ease-in-out infinite;
}
@keyframes webchatGreeting{
  0%,12%,88%,100%{opacity:0;transform:translate(5px,-50%)}
  20%,78%{opacity:1;transform:translate(0,-50%)}
}

.webchat__robot{
  position:relative;
  width:30px;
  height:24px;
  border:2px solid #fff;
  border-radius:8px;
  background:rgba(3,6,13,.46);
  transform-origin:center bottom;
  animation:webchatRobotLookAround 6s ease-in-out infinite;
}
.webchat__robot::before,
.webchat__robot::after{
  content:'';
  position:absolute;
  top:8px;
  width:3px;
  height:8px;
  border-radius:2px;
  background:#fff;
}
.webchat__robot::before{left:-5px}
.webchat__robot::after{right:-5px}
.webchat__robot-antenna{
  position:absolute;
  left:50%;
  top:-8px;
  width:2px;
  height:6px;
  transform:translateX(-50%);
  border-radius:2px;
  background:#fff;
}
.webchat__robot-antenna::before{
  content:'';
  position:absolute;
  left:50%;
  top:-3px;
  width:5px;
  height:5px;
  transform:translateX(-50%);
  border-radius:50%;
  background:#fff;
}
.webchat__robot-eye{
  position:absolute;
  top:6px;
  width:5px;
  height:6px;
  border-radius:50%;
  background:#66b2ff;
  transform-origin:center;
  animation:webchatRobotBlink 4.2s infinite;
}
.webchat__robot-eye--left{left:6px}
.webchat__robot-eye--right{right:6px}
.webchat__robot-mouth{
  position:absolute;
  left:50%;
  bottom:4px;
  width:10px;
  height:2px;
  transform:translateX(-50%);
  border-radius:2px;
  background:#fff;
}
@keyframes webchatRobotBlink{
  0%,44%,48%,100%{transform:scaleY(1)}
  46%{transform:scaleY(.08)}
}
@keyframes webchatRobotLookAround{
  0%,12%,40%,62%,90%,100%{transform:translateX(0) rotate(0)}
  22%,30%{transform:translateX(-3px) rotate(-12deg)}
  72%,80%{transform:translateX(3px) rotate(12deg)}
}
@media (prefers-reduced-motion:reduce){
  .webchat__robot,
  .webchat__robot-eye,
  .webchat__greeting{animation:none}
  .webchat__greeting{opacity:1;transform:translate(0,-50%)}
}

.webchat.is-open .webchat__launcher { display: none; }

.webchat__panel {
  width: min(400px, calc(100vw - 32px));
  height: min(650px, calc(100vh - 40px));
  background: #0B111C;
  border: 1px solid rgba(10, 107, 255, 0.24);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.58), 0 0 0 1px rgba(255,255,255,0.035) inset;
  flex-direction: column;
}

.webchat.is-open .webchat__panel { display: flex; }

.webchat__header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 14px 13px;
  background: linear-gradient(135deg, #151F2E 0%, #0F1724 100%);
  border-bottom: 1px solid rgba(10, 107, 255, 0.14);
}

.webchat__avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: contain;
  background: #03060D;
  border: 1px solid rgba(10, 107, 255, 0.35);
}

.webchat__header-copy { min-width: 0; flex: 1; }
.webchat__header-copy strong { display: block; color: #FFFFFF; font-size: 14px; letter-spacing: .1px; }
.webchat__status { display: flex; align-items: center; gap: 6px; color: #AAB4C3; font-size: 11px; }
.webchat__status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #22C55E; }

.webchat__restart,
.webchat__close {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #D7DEE8;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.webchat__restart:hover,
.webchat__close:hover { background: rgba(255,255,255,0.08); }
.webchat__restart:focus-visible,
.webchat__close:focus-visible { outline: 2px solid #66B2FF; outline-offset: 2px; }

.webchat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 13px 18px;
  background:
    radial-gradient(circle at 20% 10%, rgba(10, 107, 255, 0.055), transparent 30%),
    #080D15;
  scroll-behavior: smooth;
}

.webchat__row { display: flex; margin: 0 0 11px; }
.webchat__row--user { justify-content: flex-end; }
.webchat__row--bot { justify-content: flex-start; }

.webchat__bubble {
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-line;
  word-wrap: break-word;
}

.webchat__row--bot .webchat__bubble {
  color: #EEF2F7;
  background: #151D2A;
  border-bottom-left-radius: 5px;
}

.webchat__row--user .webchat__bubble {
  color: #FFFFFF;
  background: #0A6BFF;
  border-bottom-right-radius: 5px;
  font-weight: 600;
}

.webchat__choices {
  display: grid;
  gap: 8px;
  margin: 2px 0 14px;
}

.webchat__choice,
.webchat__action {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(10, 107, 255, 0.38);
  background: rgba(10, 107, 255, 0.08);
  color: #66B2FF;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.webchat__choice:hover,
.webchat__action:hover { background: rgba(10, 107, 255, 0.15); border-color: rgba(10, 107, 255, 0.65); }
.webchat__choice--specialist {
  color: #86EFAC;
  background: rgba(37, 211, 102, 0.12);
  border-color: rgba(37, 211, 102, 0.48);
}
.webchat__choice--specialist:hover {
  color: #FFFFFF;
  background: rgba(37, 211, 102, 0.22);
  border-color: rgba(37, 211, 102, 0.72);
}
.webchat__choice:disabled { opacity: 0.45; cursor: default; }

.webchat__select-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 2px 0 14px;
}

.webchat__select {
  width: 100%;
  min-width: 0;
  min-height: 43px;
  padding: 0 10px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 11px;
  background: #111827;
  color: #F3F4F6;
  font: inherit;
  font-size: 12px;
  outline: none;
}
.webchat__select:focus { border-color: #0A6BFF; }

.webchat__select-btn {
  min-width: 72px;
  border: 0;
  border-radius: 11px;
  background: #0A6BFF;
  color: #FFFFFF;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.webchat__select-btn:disabled { opacity: 0.45; cursor: default; }

.webchat__summary {
  display: grid;
  gap: 4px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  padding: 11px 12px;
  margin: 2px 0 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.09);
  color: #DCE3EC;
  font-size: 12px;
}
.webchat__summary strong { color: #FFFFFF; }

.webchat__composer {
  display: none;
  gap: 8px;
  padding: 11px;
  background: #0E1622;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.webchat__composer.is-visible { display: flex; }

.webchat__input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 13px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  background: #161F2D;
  color: #FFFFFF;
  font: inherit;
  font-size: 13px;
  outline: none;
}
.webchat__input::placeholder { color: #8190A4; }
.webchat__input:focus { border-color: #0A6BFF; }
.webchat__input.is-error { border-color: #EF4444; }

.webchat__send {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 0;
  border-radius: 50%;
  background: #0A6BFF;
  color: #FFFFFF;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.webchat__send svg { width: 20px; height: 20px; }

.webchat__privacy {
  padding: 0 12px 9px;
  background: #0E1622;
  color: #718096;
  font-size: 9px;
  text-align: center;
}
.webchat__privacy a{color:#66b2ff;text-decoration:underline;text-underline-offset:2px}

.webchat__whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  margin-top: 3px;
  border: 1px solid rgba(37, 211, 102, 0.62);
  border-radius: 12px;
  background: rgba(37, 211, 102, 0.14);
  color: #86EFAC;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}
.webchat__whatsapp:hover {
  background: rgba(37, 211, 102, 0.24);
  border-color: rgba(37, 211, 102, 0.82);
  color: #FFFFFF;
}

.webchat__typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  min-width: 52px;
}
.webchat__typing span { width: 6px; height: 6px; border-radius: 50%; background: #8290A3; animation: webchatTyping 1s infinite ease-in-out; }
.webchat__typing span:nth-child(2) { animation-delay: 120ms; }
.webchat__typing span:nth-child(3) { animation-delay: 240ms; }
@keyframes webchatTyping { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-3px); opacity: 1; } }

@media (min-width: 768px) {
  .webchat { right: 30px; bottom: 30px; }
}

@media (max-width: 520px) {
  .webchat { right: 14px; bottom: 88px; }
  .webchat__panel {
    width: calc(100vw - 28px);
    height: min(650px, calc(100vh - 28px));
    border-radius: 18px;
  }
  .webchat.is-open {
    right: 14px;
    bottom: 14px;
  }
  .webchat__launcher { width: 56px; height: 56px; border-radius: 50%; }
}

@media (max-width: 390px) {
  .webchat__launcher { width: 56px; height: 56px; padding: 0; justify-content: center; border-radius: 50%; }
}

@media print {
  .webchat { display: none !important; }
}



.webchat__summary-key {
  width: 64px;
  height: 64px;
  max-width: 100%;
  justify-self: start;
  align-self: start;
  box-sizing: border-box;
  overflow: hidden;
  margin-top: 5px;
  padding: 4px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(19, 108, 244, .30);
  border-radius: 10px;
  background: #FFFFFF;
  cursor: zoom-in;
}
.webchat__summary-key img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  min-width: 0;
  object-fit: contain;
}
.webchat__summary-key:focus-visible { outline: 2px solid #136CF4; outline-offset: 2px; }

/* =====================================================
   Vista de llave dentro del chatbot
   Reutiliza las imágenes del mismo catálogo del cotizador.
   ===================================================== */
.webchat__key-options {
  display: grid;
  gap: 10px;
  margin: 2px 0 8px;
}

.webchat__key-card {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  padding: 9px;
  border: 1px solid rgba(19, 108, 244, .28);
  border-radius: 15px;
  background: rgba(19, 108, 244, .055);
}

.webchat__key-photo-btn {
  width: 82px;
  height: 82px;
  padding: 5px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(19, 108, 244, .34);
  border-radius: 12px;
  background: #FFFFFF;
  cursor: zoom-in;
  overflow: hidden;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.webchat__key-photo-btn:hover {
  transform: scale(1.025);
  border-color: #136CF4;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .22);
}

.webchat__key-photo-btn:focus-visible,
.webchat__key-select:focus-visible,
.webchat__key-help:focus-visible {
  outline: 2px solid #136CF4;
  outline-offset: 2px;
}

.webchat__key-photo-btn:disabled {
  cursor: default;
  opacity: .7;
}

.webchat__key-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.webchat__key-photo-placeholder {
  font-size: 30px;
}

.webchat__key-info {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.webchat__key-year {
  color: #FFFFFF;
  font-size: 14px;
  line-height: 1.2;
}

.webchat__key-select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #136CF4;
  border-radius: 10px;
  background: #136CF4;
  color: #FFFFFF;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}

.webchat__key-select:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.webchat__key-select:disabled,
.webchat__key-photo-btn:disabled {
  opacity: .48;
}

.webchat__key-help {
  width: 100%;
  padding: 7px 8px;
  margin: 0 0 14px;
  border: 0;
  background: transparent;
  color: #AAB4C3;
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.webchat__key-preview {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(2, 9, 20, .78);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.webchat__key-preview-box {
  position: relative;
  width: min(82vw, 320px);
  min-height: 230px;
  padding: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(19, 108, 244, .48);
  border-radius: 18px;
  background: #FFFFFF;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .55);
}

.webchat__key-preview-box img {
  display: block;
  width: 100%;
  max-width: 260px;
  max-height: 360px;
  object-fit: contain;
}

.webchat__key-preview-close {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0 0 2px;
  border: 1px solid rgba(19, 108, 244, .24);
  border-radius: 50%;
  background: #F4F7FB;
  color: #136CF4;
  font: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.webchat__key-preview-close:hover { background: #EAF1FF; }
.webchat__key-preview-close:focus-visible { outline: 2px solid #136CF4; outline-offset: 2px; }

@media (max-width: 390px) {
  .webchat__key-card {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 9px;
  }
  .webchat__key-photo-btn {
    width: 72px;
    height: 72px;
  }
}
