/*
 * Estilos del widget webchat.
 * Archivo vigente. Comentarios por bloque para soporte y mantenimiento.
 */

.integra-chat-widget{position:fixed;right:22px;bottom:86px;z-index:90;font-family:inherit}
.integra-chat-launcher{border:0;border-radius:999px;background:linear-gradient(135deg,#061E5B,#0077FF);color:#fff;font-weight:900;padding:14px 18px;box-shadow:0 14px 38px rgba(6,30,91,.28);cursor:pointer;display:flex;align-items:center;gap:10px}
.integra-chat-launcher:hover{transform:translateY(-1px)}
.integra-chat-launcher-dot{width:10px;height:10px;border-radius:50%;background:#33E1FF;box-shadow:0 0 0 6px rgba(51,225,255,.16)}
.integra-chat-panel[hidden]{display:none!important}
.integra-chat-panel{position:absolute;right:0;bottom:58px;width:min(390px,calc(100vw - 32px));height:min(640px,calc(100vh - 130px));background:#fff;border:1px solid rgba(0,174,239,.18);border-radius:24px;box-shadow:0 24px 70px rgba(3,13,38,.24);overflow:hidden;display:flex;flex-direction:column;color:#10233f}
.integra-chat-header{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:18px 18px;background:linear-gradient(135deg,#030D26,#061E5B 58%,#0077FF);color:#fff}
.integra-chat-header strong{display:block;font-size:16px}
.integra-chat-header span{display:block;color:#CFF8FF;font-size:13px;margin-top:3px}
.integra-chat-close{border:0;background:rgba(255,255,255,.14);color:#fff;width:34px;height:34px;border-radius:50%;font-size:24px;cursor:pointer;line-height:1}
.integra-chat-notice{padding:12px 16px;background:#eef8ff;color:#52627a;font-size:12px;line-height:1.35;border-bottom:1px solid rgba(0,174,239,.14)}
.integra-chat-messages{flex:1;overflow:auto;padding:16px;background:linear-gradient(180deg,#f8fcff,#fff);display:flex;flex-direction:column;gap:10px}
.integra-chat-message{max-width:86%;padding:11px 13px;border-radius:16px;white-space:pre-wrap;line-height:1.42;font-size:14px}
.integra-chat-message.is-assistant{align-self:flex-start;background:#edf6ff;color:#10233f;border-bottom-left-radius:6px}
.integra-chat-message.is-user{align-self:flex-end;background:#061E5B;color:#fff;border-bottom-right-radius:6px}
.integra-chat-message.is-loading{opacity:.72;font-style:italic}
.integra-chat-form{display:grid;grid-template-columns:1fr auto;gap:10px;padding:12px;border-top:1px solid rgba(0,174,239,.14);background:#fff}
.integra-chat-form textarea{resize:none;border:1px solid rgba(0,174,239,.24);border-radius:14px;padding:11px 12px;font:inherit;min-height:46px;max-height:110px;outline:none}
.integra-chat-form textarea:focus{border-color:#0077FF;box-shadow:0 0 0 3px rgba(0,119,255,.10)}
.integra-chat-form button{border:0;border-radius:14px;background:#0077FF;color:#fff;font-weight:900;padding:0 16px;cursor:pointer}
.integra-chat-form button:disabled{opacity:.55;cursor:not-allowed}
.integra-chat-actions{display:flex;gap:10px;padding:0 12px 12px;background:#fff}
.integra-chat-actions a{flex:1;text-align:center;text-decoration:none;border-radius:12px;padding:10px;background:#f1f7ff;color:#061E5B;font-weight:800;font-size:13px}
.integra-chat-actions a:last-child{background:#25D366;color:#fff}
@media (max-width:640px){.integra-chat-widget{right:16px;bottom:78px}.integra-chat-panel[hidden]{display:none!important}
.integra-chat-panel{position:fixed;right:12px;left:12px;bottom:142px;width:auto;height:min(620px,calc(100vh - 170px))}.integra-chat-launcher{padding:13px 16px}}


/* ===== Ajustes v21: flotantes móviles más compactos ===== */
.integra-chat-widget {
  max-width: calc(100vw - 24px);
}
.integra-chat-launcher {
  max-width: calc(100vw - 24px);
}
@media (max-width: 640px) {
  .integra-chat-widget {
    right: 12px;
    bottom: 84px;
  }
  .integra-chat-launcher {
    padding: 12px 14px;
    font-size: 15px;
  }
  .integra-chat-panel {
    right: 10px;
    left: 10px;
    bottom: 136px;
    height: min(620px, calc(100vh - 160px));
  }
}


/* ===== v36.2 - UX webchat ajustado ===== */
.integra-chat-widget{
  right:22px;
  bottom:84px;
  z-index:95;
}
.integra-chat-launcher{
  min-height:54px;
  padding:12px 18px;
  border-radius:999px;
  gap:10px;
}
.integra-chat-launcher-icon{
  width:28px;
  height:28px;
  border-radius:50%;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:rgba(255,255,255,.16);
  box-shadow:0 0 0 5px rgba(51,225,255,.12);
  font-size:17px;
  line-height:1;
}
.integra-chat-launcher-dot{display:none!important}
.integra-chat-panel{
  top:84px;
  bottom:auto;
  height:min(620px,calc(100vh - 112px));
}
.integra-chat-header{
  padding:14px 18px;
}
.integra-chat-header strong{
  font-size:15px;
}
.integra-chat-header span{
  font-size:12px;
}
.integra-chat-notice{
  padding:10px 16px;
  font-size:12px;
}
.integra-chat-form{
  display:grid;
  grid-template-columns:1fr auto;
  gap:10px;
  align-items:stretch;
  padding:12px;
}
.integra-chat-form textarea{
  min-height:54px;
  max-height:100px;
}
.integra-chat-form button{
  min-width:72px;
  width:auto;
  padding:0 14px;
}
.integra-chat-actions{
  display:none!important;
}

@media (max-width: 760px){
  .integra-chat-widget{
    right:12px;
    bottom:82px;
  }
  .integra-chat-launcher{
    min-height:52px;
    padding:11px 15px;
  }
  .integra-chat-panel{
    top:78px;
    right:10px;
    left:10px;
    bottom:auto;
    width:auto;
    height:min(620px,calc(100vh - 104px));
  }
  .integra-chat-form{
    grid-template-columns:1fr 68px;
    gap:8px;
  }
  .integra-chat-form button{
    min-width:68px;
    padding:0 10px;
    font-size:13px;
  }
}


/* ===== v36.3 - Corrección apertura panel: fijo bajo menú, no en footer ===== */
/* El botón flotante permanece abajo; el panel se independiza del footer y del launcher. */
.integra-chat-panel{
  position:fixed!important;
  right:22px!important;
  top:92px!important;
  bottom:auto!important;
  width:min(390px,calc(100vw - 44px))!important;
  height:min(620px,calc(100vh - 118px))!important;
  max-height:calc(100vh - 118px)!important;
  z-index:9999!important;
}
.integra-chat-widget{
  z-index:9998!important;
}
.integra-chat-launcher{
  z-index:9998!important;
}

@media (max-width: 760px){
  .integra-chat-panel{
    position:fixed!important;
    top:78px!important;
    left:10px!important;
    right:10px!important;
    bottom:auto!important;
    width:auto!important;
    height:min(620px,calc(100vh - 104px))!important;
    max-height:calc(100vh - 104px)!important;
  }
}


/* ===== v36.5 - Ajuste visual input/botón y launcher ===== */
.integra-chat-launcher{
  padding:11px 16px!important;
  min-height:50px!important;
}
.integra-chat-launcher-icon{
  width:26px!important;
  height:26px!important;
  font-size:16px!important;
}
.integra-chat-form{
  grid-template-columns:minmax(0,1fr) 74px!important;
  gap:8px!important;
  padding:10px 12px!important;
}
.integra-chat-form textarea{
  min-height:48px!important;
  max-height:82px!important;
  padding:10px 11px!important;
  font-size:14px!important;
  border-radius:14px!important;
}
.integra-chat-form button{
  min-width:0!important;
  width:74px!important;
  padding:0 8px!important;
  font-size:13px!important;
  border-radius:14px!important;
}
.integra-chat-notice{
  font-size:12px!important;
  line-height:1.35!important;
}

@media (max-width: 760px){
  .integra-chat-form{
    grid-template-columns:minmax(0,1fr) 70px!important;
    gap:8px!important;
    padding:10px!important;
  }
  .integra-chat-form button{
    width:70px!important;
    font-size:12.5px!important;
  }
}

/* Enlaces renderizados dentro del chat, por ejemplo descargas de prepresupuesto. */
.integra-chat-message a{color:inherit;text-decoration:underline;font-weight:700;word-break:break-word;}
.integra-chat-message.is-assistant a{color:#0B5CAB;}
.integra-chat-message.is-user a{color:#fff;}

/* Acciones para evitar mezclar solicitudes en una misma sesión. */
.integra-chat-actions{display:flex;gap:8px;padding:8px 12px;border-bottom:1px solid rgba(11,92,171,.12);background:#f8fafc}
.integra-chat-actions button{border:1px solid #d8e3f2;background:#fff;color:#0b2b5c;border-radius:999px;padding:6px 10px;font-size:12px;font-weight:700;cursor:pointer}
.integra-chat-actions button:hover{background:#eaf7fb;border-color:#20b7c9}


/* ===== v39.4 - Launcher IA solo icono ===== */
.integra-chat-widget{
    right:22px!important;
    bottom:94px!important;
}
.integra-chat-launcher{
    width:58px!important;
    height:58px!important;
    min-height:58px!important;
    padding:0!important;
    border-radius:50%!important;
    display:grid!important;
    place-items:center!important;
    background:linear-gradient(135deg,#061E5B,#0077FF)!important;
    box-shadow:0 16px 42px rgba(3,13,38,.24)!important;
}
.integra-chat-launcher-icon{
    width:34px!important;
    height:34px!important;
    background:transparent!important;
    box-shadow:none!important;
    color:#fff!important;
}
.integra-chat-launcher-icon svg{
    width:34px!important;
    height:34px!important;
    display:block!important;
}
.integra-chat-launcher > span:not(.integra-chat-launcher-icon){
    display:none!important;
}
@media (max-width:760px){
    .integra-chat-widget{
        right:14px!important;
        bottom:84px!important;
    }
    .integra-chat-launcher{
        width:54px!important;
        height:54px!important;
        min-height:54px!important;
    }
}
