
:root{
  --tecno-blue:#1f2b57;
  --tecno-blue-2:#0057b8;
  --tecno-orange:#f5820b;
  --tecno-bg:#f4f6f8;
  --tecno-white:#ffffff;
  --tecno-text:#253047;
  --tecno-muted:#6b7280;
  --tecno-border:#dbe3ec;
  --tecno-success:#25d366;
  --tecno-shadow:0 18px 50px rgba(24,39,75,.18);
  --tecno-radius:18px;
  --tecno-bottom:92px; /* pensado para convivir con el botón flotante de WhatsApp actual */
  --tecno-right:20px;
}

#tecno-widget,
#tecno-widget *{
  box-sizing:border-box;
}

#tecno-widget{
  position:fixed;
  right:var(--tecno-right);
  bottom:var(--tecno-bottom);
  z-index:99999;
  font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
  color:var(--tecno-text);
}

.tecno-launcher{
  width:64px;
  height:64px;
  border:0;
  border-radius:50%;
  display:grid;
  place-items:center;
  cursor:pointer;
  background:linear-gradient(135deg,var(--tecno-blue-2),var(--tecno-blue));
  color:#fff;
  box-shadow:0 12px 30px rgba(0,87,184,.32);
  transition:transform .22s ease, box-shadow .22s ease;
  position:relative;
}

.tecno-launcher:hover{
  transform:translateY(-2px);
  box-shadow:0 16px 36px rgba(0,87,184,.38);
}

.tecno-launcher:focus-visible,
.tecno-close:focus-visible,
.tecno-option:focus-visible,
.tecno-send:focus-visible,
.tecno-input:focus-visible{
  outline:3px solid rgba(0,87,184,.25);
  outline-offset:3px;
}

.tecno-launcher-mark{
  width:34px;
  height:34px;
  border:4px solid #fff;
  border-radius:50%;
  position:relative;
}

.tecno-launcher-mark::after{
  content:"";
  position:absolute;
  width:16px;
  height:6px;
  border-radius:99px;
  background:var(--tecno-orange);
  right:-7px;
  top:-3px;
  transform:rotate(-45deg);
}

.tecno-launcher-badge{
  position:absolute;
  right:-1px;
  top:-2px;
  width:18px;
  height:18px;
  border-radius:50%;
  background:var(--tecno-orange);
  border:3px solid #fff;
}

.tecno-panel{
  position:fixed;
  right:20px;
  bottom:92px;
  width:min(390px, calc(100vw - 24px));
  max-height:min(680px, calc(100dvh - 112px));
  background:var(--tecno-white);
  border:1px solid rgba(31,43,87,.12);
  border-radius:22px;
  box-shadow:var(--tecno-shadow);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  opacity:0;
  visibility:hidden;
  transform:translateY(18px) scale(.97);
  transform-origin:bottom right;
  transition:opacity .22s ease, transform .22s ease, visibility .22s ease;
}

#tecno-widget.tecno-open .tecno-panel{
  opacity:1;
  visibility:visible;
  transform:translateY(0) scale(1);
}

.tecno-header{
  background:linear-gradient(135deg,var(--tecno-blue),#26366c);
  cursor:grab;
  user-select:none;
  touch-action:none;
  color:#fff;
  padding:16px 16px 14px;
  display:flex;
  align-items:center;
  gap:12px;
}

.tecno-avatar{
  width:46px;
  height:46px;
  border-radius:50%;
  background:#fff;
  display:grid;
  place-items:center;
  flex:0 0 46px;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.2);
}

.tecno-avatar-logo{
  display:block;
  width:30px;
  height:30px;
  object-fit:contain;
}

.tecno-title-wrap{
  min-width:0;
  flex:1;
}

.tecno-title{
  margin:0;
  font-size:1rem;
  font-weight:800;
  letter-spacing:.1px;
}

.tecno-subtitle{
  margin:2px 0 0;
  font-size:.78rem;
  color:rgba(255,255,255,.78);
  display:flex;
  align-items:center;
  gap:6px;
}

.tecno-status-dot{
  width:7px;
  height:7px;
  border-radius:50%;
  background:#6ee7a0;
}

.tecno-close{
  border:0;
  background:rgba(255,255,255,.1);
  color:#fff;
  width:34px;
  height:34px;
  border-radius:10px;
  cursor:pointer;
  font-size:22px;
  line-height:1;
}

.tecno-body{
  background:linear-gradient(180deg,#f8fafc 0%,#f3f6f9 100%);
  padding:16px;
  overflow-y:auto;
  overscroll-behavior:contain;
  flex:1;
  min-height:290px;
}

.tecno-message-row{
  display:flex;
  gap:9px;
  margin-bottom:12px;
  align-items:flex-end;
}

.tecno-message-row.user{
  justify-content:flex-end;
}

.tecno-mini-avatar{
  width:28px;
  height:28px;
  border-radius:50%;
  background:var(--tecno-blue);
  color:#fff;
  display:grid;
  place-items:center;
  font-size:11px;
  font-weight:800;
  flex:0 0 28px;
}

.tecno-bubble{
  max-width:82%;
  padding:11px 13px;
  border-radius:15px 15px 15px 4px;
  background:#fff;
  border:1px solid #e3e8ef;
  box-shadow:0 3px 10px rgba(31,43,87,.05);
  font-size:.91rem;
  line-height:1.45;
}

.tecno-message-row.user .tecno-bubble{
  background:var(--tecno-blue-2);
  color:#fff;
  border-color:var(--tecno-blue-2);
  border-radius:15px 15px 4px 15px;
}

.tecno-note{
  display:block;
  margin-top:7px;
  color:var(--tecno-muted);
  font-size:.75rem;
}

.tecno-options{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:9px;
  margin:14px 0 6px 37px;
}

.tecno-option{
  border:1px solid #dbe4ee;
  background:#fff;
  color:var(--tecno-blue);
  border-radius:12px;
  padding:11px 10px;
  text-align:left;
  font-size:.82rem;
  font-weight:700;
  cursor:pointer;
  transition:border-color .18s ease, transform .18s ease, background .18s ease;
}

.tecno-option:hover{
  border-color:#9bbce1;
  background:#f7fbff;
  transform:translateY(-1px);
}

.tecno-option[data-action="presupuesto"]{
  border-color:rgba(245,130,11,.35);
  background:#fffaf3;
}

.tecno-option[data-action="consulta"]{
  grid-column:1 / -1;
  text-align:center;
}

.tecno-footer{
  padding:12px;
  border-top:1px solid var(--tecno-border);
  background:#fff;
}

.tecno-form{
  display:flex;
  align-items:flex-end;
  gap:8px;
}

.tecno-input{
  flex:1;
  min-width:0;
  max-height:100px;
  resize:none;
  border:1px solid #d7dee7;
  background:#f8fafc;
  border-radius:14px;
  padding:11px 12px;
  font:inherit;
  font-size:.9rem;
  line-height:1.35;
  color:var(--tecno-text);
  transition:border-color .18s ease, box-shadow .18s ease;
}

.tecno-input:focus{
  border-color:#8ab5e2;
  box-shadow:0 0 0 3px rgba(0,87,184,.08);
  background:#fff;
}

.tecno-send{
  width:44px;
  height:44px;
  flex:0 0 44px;
  border:0;
  border-radius:12px;
  cursor:pointer;
  background:var(--tecno-blue-2);
  color:#fff;
  display:grid;
  place-items:center;
  transition:transform .18s ease, opacity .18s ease;
}

.tecno-send:hover{
  transform:translateY(-1px);
}

.tecno-send svg{
  width:19px;
  height:19px;
}

.tecno-footer-note{
  margin:7px 2px 0;
  text-align:center;
  font-size:.68rem;
  color:#8a94a5;
}

.tecno-hidden{
  display:none !important;
}

@media (max-width:600px){
  :root{
    --tecno-right:10px;
    --tecno-bottom:82px;
  }

  .tecno-launcher{
    width:58px;
    height:58px;
  }

  .tecno-panel{
    position:fixed;
    left:8px;
    right:8px;
    bottom:78px;
    width:auto;
    max-height:calc(100dvh - 96px);
    border-radius:18px;
  }

  .tecno-options{
    grid-template-columns:1fr;
    margin-left:37px;
  }

  .tecno-option[data-action="consulta"]{
    grid-column:auto;
  }

  .tecno-body{
    min-height:260px;
  }
}

@media (prefers-reduced-motion:reduce){
  .tecno-panel,
  .tecno-launcher,
  .tecno-option,
  .tecno-send{
    transition:none !important;
  }
}


/* FASE 1 DEFINITIVA: ocultar botón flotante mientras el chat está abierto */
#tecno-widget.tecno-open .tecno-launcher{
  opacity:0;
  visibility:hidden;
  pointer-events:none;
  transform:scale(.92);
}


/* Ajustes adicionales para tablet y pantallas intermedias */
@media (min-width:601px) and (max-width:1024px){
  .tecno-panel{
    width:min(410px, calc(100vw - 32px));
    max-height:min(720px, calc(100vh - 120px));
  }
}

@media (max-height:650px) and (min-width:601px){
  .tecno-panel{
    max-height:calc(100vh - 100px);
  }
}


/* FASE 2: estados de conexión con IA */
.tecno-typing .tecno-bubble{
  color:#6b7280;
  font-style:italic;
}

.tecno-input:disabled{
  opacity:.7;
  cursor:wait;
}

.tecno-send:disabled{
  opacity:.55;
  cursor:wait;
  transform:none;
}


/* FASE 4: acciones de presupuesto */
.tecno-footer-actions{
  display:flex;
  justify-content:center;
  margin-top:7px;
}

.tecno-reset{
  border:0;
  background:transparent;
  color:var(--tecno-blue-2);
  font:inherit;
  font-size:.72rem;
  font-weight:700;
  cursor:pointer;
  padding:4px 8px;
  border-radius:8px;
}

.tecno-reset:hover{
  background:#eef4fb;
}

.tecno-reset:focus-visible{
  outline:3px solid rgba(0,87,184,.18);
  outline-offset:2px;
}


/* FASE 4: conservar saltos de línea en resúmenes estructurados */
.tecno-bubble{
  white-space: pre-line;
}


/* FASE 5: confirmación de envío de presupuesto */
.tecno-confirmation .tecno-bubble{
  background:#eefbf3;
  border-color:#bfe8cd;
  color:#176b38;
  font-weight:700;
}

.tecno-warning .tecno-bubble{
  background:#fff7ed;
  border-color:#fed7aa;
  color:#9a4b0b;
}


/* Posición segura + ventana arrastrable */
.tecno-panel.tecno-dragging{
  transition:none !important;
}

.tecno-panel.tecno-dragging .tecno-header{
  cursor:grabbing;
}

@media (max-width:600px){
  .tecno-panel{
    top:auto !important;
    left:8px !important;
    right:8px !important;
    bottom:78px !important;
    width:auto !important;
    max-height:calc(100dvh - 96px) !important;
  }

  .tecno-header{
    cursor:default;
    touch-action:auto;
  }
}


/* Etiqueta del botón flotante de Tecno */
.tecno-launcher-wrap{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
}

.tecno-launcher-label{
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:1px;
  padding:9px 12px;
  border-radius:14px;
  background:#fff;
  color:var(--tecno-blue);
  border:1px solid rgba(31,43,87,.12);
  box-shadow:0 10px 26px rgba(24,39,75,.14);
  line-height:1.15;
  white-space:nowrap;
  pointer-events:none;
  transition:opacity .2s ease, transform .2s ease;
}

.tecno-launcher-label strong{
  font-size:.8rem;
  font-weight:800;
}

.tecno-launcher-label span{
  font-size:.72rem;
  color:#667085;
  font-weight:600;
}

#tecno-widget.tecno-open .tecno-launcher-wrap{
  opacity:0;
  visibility:hidden;
  pointer-events:none;
}

@media (max-width:760px){
  .tecno-launcher-label{
    padding:7px 10px;
  }

  .tecno-launcher-label strong{
    display:none;
  }

  .tecno-launcher-label span{
    font-size:.72rem;
    color:var(--tecno-blue);
    font-weight:800;
  }
}

@media (max-width:420px){
  .tecno-launcher-wrap{
    gap:7px;
  }

  .tecno-launcher-label{
    display:flex;
    padding:7px 9px;
    border-radius:12px;
  }

  .tecno-launcher-label strong{
    display:none;
  }

  .tecno-launcher-label span{
    font-size:.68rem;
    font-weight:800;
  }
}


/* =========================================================
   V8 — "Configurar cookies" igual que el resto del footer
   El elemento real es un BUTTON, no un enlace.
   ========================================================= */
.footer-cookie-settings{
  appearance:none !important;
  -webkit-appearance:none !important;
  background:none !important;
  border:0 !important;
  padding:0 !important;
  margin:0 !important;
  color:inherit !important;
  font:inherit !important;
  line-height:inherit !important;
  text-decoration:none !important;
  cursor:pointer !important;
  box-shadow:none !important;
}

.footer-cookie-settings:hover,
.footer-cookie-settings:focus-visible{
  color:inherit !important;
  text-decoration:underline !important;
}

/* Móvil: el panel sigue el área visible al abrir el teclado.
   El campo conserva 16px y la página permite ampliar con los dedos. */
@media (max-width:600px), (max-width:1024px) and (pointer:coarse){
  #tecno-widget .tecno-panel{
    top:calc(var(--tecno-viewport-top, 0px) + 8px) !important;
    left:calc(var(--tecno-viewport-left, 0px) + 8px) !important;
    right:auto !important;
    bottom:auto !important;
    width:calc(var(--tecno-viewport-width, 100vw) - 16px) !important;
    max-width:calc(var(--tecno-viewport-width, 100vw) - 16px) !important;
    height:min(680px, calc(var(--tecno-viewport-height, 100dvh) - 16px));
    max-height:calc(var(--tecno-viewport-height, 100dvh) - 16px) !important;
    min-height:0;
    border-radius:18px;
    transition:opacity .18s ease, visibility .18s ease;
  }
  #tecno-widget.tecno-open .tecno-panel{transform:none}
  #tecno-widget .tecno-header{flex:0 0 auto;min-width:0;cursor:default;touch-action:auto;padding:12px}
  #tecno-widget .tecno-subtitle{overflow-wrap:anywhere}
  #tecno-widget .tecno-close{flex:0 0 40px;width:40px;height:40px}
  #tecno-widget .tecno-body{flex:1 1 0;min-height:0;min-width:0;overflow:auto;-webkit-overflow-scrolling:touch;padding:12px}
  #tecno-widget .tecno-bubble{min-width:0;overflow-wrap:anywhere}
  #tecno-widget .tecno-options{grid-template-columns:1fr;min-width:0;margin-left:0}
  #tecno-widget .tecno-option{min-width:0;overflow-wrap:anywhere}
  #tecno-widget .tecno-option[data-action="consulta"]{grid-column:auto}
  #tecno-widget .tecno-footer{flex:0 0 auto;min-width:0;padding:10px 10px max(10px, env(safe-area-inset-bottom, 0px))}
  #tecno-widget .tecno-form{min-width:0;width:100%;gap:8px}
  #tecno-widget .tecno-input{flex:1 1 0;width:0;min-width:0;max-width:100%;font-size:16px !important;max-height:84px;min-height:44px}
  #tecno-widget .tecno-send{flex:0 0 44px;width:44px;min-width:44px;height:44px}
  #tecno-widget .tecno-footer-note{overflow-wrap:anywhere}
  #tecno-widget.tecno-keyboard-open .tecno-footer-note{display:none}
  #tecno-widget.tecno-keyboard-open .tecno-header{padding:8px 10px;gap:8px}
  #tecno-widget.tecno-keyboard-open .tecno-avatar{width:34px;height:34px;flex-basis:34px}
  #tecno-widget.tecno-keyboard-open .tecno-footer{padding-bottom:10px}
}
