/* =========================================================
   FEGI BOT CRM 2026
   Alejandro Morán - Asistente Virtual FEGI
   Archivo: /fegi-bot-crm/assets/alejandro-chat.css
   Versión: Mobile Fix v33
   ========================================================= */

:root {
  --fegi-primary: #009879;
  --fegi-primary-dark: #00785f;
  --fegi-secondary: #00a7c8;
  --fegi-accent: #22c55e;
  --fegi-bg: #f4fbf8;
  --fegi-white: #ffffff;
  --fegi-text: #0f172a;
  --fegi-muted: #64748b;
  --fegi-border: #dbeafe;
  --fegi-shadow: 0 22px 55px rgba(15, 23, 42, 0.22);
  --fegi-radius: 22px;
  --fegi-font: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ==============================
   BOTÓN FLOTANTE
   ============================== */

#fegiBotLauncher {
  position: fixed;
  right: 22px;
  bottom: 96px;
  z-index: 999998;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 58px;
  padding: 14px 22px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--fegi-primary), var(--fegi-secondary));
  color: #ffffff;
  font-family: var(--fegi-font);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  cursor: pointer;
  box-shadow: 0 18px 38px rgba(0, 152, 121, 0.35);
  transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.22s ease;
}

#fegiBotLauncher span {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
  font-size: 17px;
}

#fegiBotLauncher strong {
  color: #ffffff;
  font-weight: 800;
  white-space: nowrap;
}

#fegiBotLauncher:hover {
  transform: translateY(-3px);
  box-shadow: 0 24px 48px rgba(0, 152, 121, 0.45);
}

#fegiBotLauncher.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(0.96);
}

/* ==============================
   CAJA PRINCIPAL DEL CHAT
   ============================== */

#fegiBotBox {
  position: fixed;
  right: 22px;
  bottom: 96px;
  z-index: 1000000;
  width: 390px;
  max-width: calc(100vw - 24px);
  height: 610px;
  max-height: calc(100vh - 130px);
  display: flex;
  flex-direction: column;
  background: var(--fegi-white);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: var(--fegi-radius);
  box-shadow: var(--fegi-shadow);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(26px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease;
  font-family: var(--fegi-font);
}

#fegiBotBox.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* ==============================
   HEADER
   ============================== */

.fegi-bot-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 17px 58px 17px 18px;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,0.25), transparent 30%),
    linear-gradient(135deg, #00785f 0%, #009879 48%, #00a7c8 100%);
  color: #ffffff;
  flex: 0 0 auto;
  min-height: 76px;
}

.fegi-bot-avatar {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.28);
  color: #ffffff;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -0.04em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22);
}

.fegi-bot-title {
  font-size: 17px;
  font-weight: 900;
  line-height: 1.15;
  color: #ffffff;
  letter-spacing: -0.03em;
}

.fegi-bot-subtitle {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
}

/* BOTÓN CERRAR VISIBLE */
.fegi-bot-close {
  position: absolute;
  top: 17px;
  right: 16px;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 999px;
  background: rgba(255,255,255,0.24);
  color: #ffffff;
  font-size: 28px;
  line-height: 34px;
  font-weight: 400;
  cursor: pointer;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.fegi-bot-close:hover {
  background: rgba(255,255,255,0.34);
  transform: rotate(90deg);
}

/* ==============================
   CUERPO DEL CHAT
   ============================== */

.fegi-bot-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px;
  background: linear-gradient(180deg, #f7fffb 0%, #eef8f5 100%);
  overflow-y: auto;
  scroll-behavior: smooth;
}

.fegi-bot-body::-webkit-scrollbar {
  width: 8px;
}

.fegi-bot-body::-webkit-scrollbar-track {
  background: transparent;
}

.fegi-bot-body::-webkit-scrollbar-thumb {
  background: rgba(0, 152, 121, 0.28);
  border-radius: 999px;
}

/* ==============================
   MENSAJES
   ============================== */

.fegi-bot-message-row {
  display: flex;
  width: 100%;
  margin: 9px 0;
}

.fegi-bot-message-row.bot {
  justify-content: flex-start;
}

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

.fegi-bot-message {
  max-width: 86%;
  padding: 12px 14px;
  border-radius: 17px;
  font-size: 14px;
  line-height: 1.48;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.fegi-bot-message-row.bot .fegi-bot-message {
  color: var(--fegi-text);
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-bottom-left-radius: 6px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.fegi-bot-message-row.user .fegi-bot-message {
  color: #ffffff;
  background: linear-gradient(135deg, var(--fegi-primary), var(--fegi-secondary));
  border-bottom-right-radius: 6px;
  box-shadow: 0 10px 20px rgba(0, 152, 121, 0.2);
}

.fegi-bot-message a {
  color: #00785f;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.fegi-bot-message-row.user .fegi-bot-message a {
  color: #ffffff;
}

/* ==============================
   RESPUESTAS RÁPIDAS
   ============================== */

.fegi-bot-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  flex: 0 0 auto;
  max-height: 158px;
  overflow-y: auto;
}

.fegi-bot-chip {
  border: 1px solid rgba(0, 152, 121, 0.18);
  background: #ecfdf5;
  color: #065f46;
  border-radius: 999px;
  padding: 8px 12px;
  font-family: var(--fegi-font);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.fegi-bot-chip:hover {
  background: #d1fae5;
  border-color: rgba(0, 152, 121, 0.36);
  transform: translateY(-1px);
}

/* ==============================
   FOOTER INPUT
   ============================== */

.fegi-bot-footer {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px;
  background: #ffffff;
  border-top: 1px solid rgba(148, 163, 184, 0.22);
  flex: 0 0 auto;
}

#fegiBotInput {
  flex: 1 1 auto;
  width: 100%;
  height: 45px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 14px;
  padding: 0 14px;
  background: #f8fafc;
  color: var(--fegi-text);
  font-family: var(--fegi-font);
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

#fegiBotInput::placeholder {
  color: #94a3b8;
}

#fegiBotInput:focus {
  background: #ffffff;
  border-color: rgba(0, 152, 121, 0.55);
  box-shadow: 0 0 0 4px rgba(0, 152, 121, 0.11);
}

#fegiBotInput:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

#fegiBotSend {
  flex: 0 0 auto;
  height: 45px;
  min-width: 82px;
  border: none;
  border-radius: 14px;
  padding: 0 16px;
  background: linear-gradient(135deg, var(--fegi-primary), var(--fegi-secondary));
  color: #ffffff;
  font-family: var(--fegi-font);
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(0, 152, 121, 0.24);
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

#fegiBotSend:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(0, 152, 121, 0.3);
}

#fegiBotSend:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
}

/* ==============================
   MOBILE FIX REAL
   ============================== */

@media (max-width: 640px) {
  #fegiBotLauncher {
    right: 14px;
    bottom: 88px;
    min-height: 52px;
    padding: 12px 16px;
    font-size: 13px;
  }

  #fegiBotLauncher strong {
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #fegiBotBox {
    left: 10px;
    right: 10px;
    top: 82px;
    bottom: 76px;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    border-radius: 20px;
    transform: translateY(18px) scale(0.98);
  }

  #fegiBotBox.is-open {
    transform: translateY(0) scale(1);
  }

  .fegi-bot-header {
    min-height: 72px;
    padding: 13px 56px 13px 14px;
  }

  .fegi-bot-avatar {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    font-size: 14px;
  }

  .fegi-bot-title {
    font-size: 15px;
  }

  .fegi-bot-subtitle {
    font-size: 11px;
    line-height: 1.25;
  }

  .fegi-bot-close {
    top: 14px;
    right: 13px;
    width: 40px;
    height: 40px;
    font-size: 30px;
    line-height: 36px;
    background: rgba(255,255,255,0.30);
  }

  .fegi-bot-body {
    padding: 13px;
  }

  .fegi-bot-message {
    max-width: 92%;
    font-size: 13.5px;
    line-height: 1.45;
    padding: 11px 13px;
  }

  .fegi-bot-quick {
    padding: 10px 12px;
    gap: 7px;
    max-height: 142px;
  }

  .fegi-bot-chip {
    font-size: 11.5px;
    padding: 7px 10px;
  }

  .fegi-bot-footer {
    padding: 10px;
    gap: 8px;
  }

  #fegiBotInput {
    height: 44px;
    font-size: 13.5px;
    border-radius: 13px;
  }

  #fegiBotSend {
    height: 44px;
    min-width: 74px;
    padding: 0 12px;
    border-radius: 13px;
  }
}

/* Celulares bajos o con navegador muy grande */
@media (max-width: 640px) and (max-height: 720px) {
  #fegiBotBox {
    top: 72px;
    bottom: 64px;
  }

  .fegi-bot-header {
    min-height: 64px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .fegi-bot-avatar {
    width: 38px;
    height: 38px;
  }

  .fegi-bot-subtitle {
    display: none;
  }

  .fegi-bot-quick {
    max-height: 118px;
  }

  .fegi-bot-message {
    font-size: 13px;
  }
}

/* Pantallas muy pequeñas */
@media (max-width: 380px) {
  #fegiBotBox {
    left: 6px;
    right: 6px;
    top: 76px;
    bottom: 68px;
    border-radius: 18px;
  }

  .fegi-bot-chip {
    font-size: 11px;
    padding: 7px 9px;
  }

  #fegiBotSend {
    min-width: 68px;
  }
}

/* ==============================
   EVITA QUE OTROS CSS DEL SITIO ROMPAN EL CHAT
   ============================== */

#fegiBotBox *,
#fegiBotLauncher,
#fegiBotLauncher * {
  box-sizing: border-box;
}

#fegiBotBox button,
#fegiBotLauncher {
  appearance: none;
  -webkit-appearance: none;
}

#fegiBotBox input,
#fegiBotBox button {
  font-family: var(--fegi-font);
}
/* =========================================================
   FEGI BOT CRM 2026
   FIX RESPONSIVE REAL CELULAR + TABLET v35
   Pegar al final de alejandro-chat.css
   ========================================================= */

/* Asegura que el chat nunca quede detrás del menú ni cortado */
#fegiBotBox {
  z-index: 2147483000 !important;
}

#fegiBotLauncher {
  z-index: 2147482999 !important;
}

/* Botón cerrar siempre visible */
.fegi-bot-close {
  position: absolute !important;
  top: 14px !important;
  right: 14px !important;
  width: 42px !important;
  height: 42px !important;
  min-width: 42px !important;
  min-height: 42px !important;
  border-radius: 999px !important;
  background: rgba(255,255,255,0.28) !important;
  color: #ffffff !important;
  font-size: 30px !important;
  line-height: 1 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  opacity: 1 !important;
  visibility: visible !important;
  z-index: 20 !important;
}

/* Header protegido para que no se corte */
.fegi-bot-header {
  flex: 0 0 auto !important;
  min-height: 78px !important;
  padding: 15px 62px 15px 16px !important;
  overflow: visible !important;
}

.fegi-bot-title,
.fegi-bot-subtitle {
  display: block !important;
  overflow: visible !important;
}

/* ==============================
   TABLET HORIZONTAL / VERTICAL
   ============================== */

@media (max-width: 1180px) {
  #fegiBotBox {
    position: fixed !important;
    top: auto !important;
    left: auto !important;
    right: 14px !important;
    bottom: 92px !important;
    width: 390px !important;
    max-width: calc(100vw - 28px) !important;
    height: auto !important;
    max-height: min(620px, calc(100dvh - 130px)) !important;
    border-radius: 22px !important;
    overflow: hidden !important;
    transform: translateY(22px) scale(0.98) !important;
  }

  #fegiBotBox.is-open {
    transform: translateY(0) scale(1) !important;
  }

  .fegi-bot-body {
    flex: 1 1 auto !important;
    min-height: 180px !important;
    max-height: calc(100dvh - 350px) !important;
    overflow-y: auto !important;
  }

  .fegi-bot-quick {
    flex: 0 0 auto !important;
    max-height: 130px !important;
    overflow-y: auto !important;
  }

  .fegi-bot-footer {
    flex: 0 0 auto !important;
  }
}

/* ==============================
   CELULAR
   ============================== */

@media (max-width: 640px) {
  #fegiBotBox {
    position: fixed !important;
    top: auto !important;
    left: 10px !important;
    right: 10px !important;
    bottom: 82px !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    max-height: min(590px, calc(100dvh - 115px)) !important;
    border-radius: 22px !important;
    overflow: hidden !important;
    box-shadow: 0 18px 50px rgba(15,23,42,0.35) !important;
  }

  #fegiBotLauncher {
    right: 14px !important;
    bottom: 86px !important;
  }

  .fegi-bot-header {
    min-height: 76px !important;
    padding: 14px 62px 14px 14px !important;
  }

  .fegi-bot-avatar {
    width: 42px !important;
    height: 42px !important;
    border-radius: 14px !important;
    font-size: 14px !important;
  }

  .fegi-bot-title {
    font-size: 15px !important;
    line-height: 1.15 !important;
  }

  .fegi-bot-subtitle {
    font-size: 11px !important;
    line-height: 1.25 !important;
  }

  .fegi-bot-body {
    padding: 13px !important;
    min-height: 170px !important;
    max-height: calc(100dvh - 360px) !important;
    overflow-y: auto !important;
  }

  .fegi-bot-message {
    max-width: 92% !important;
    font-size: 13.5px !important;
    line-height: 1.45 !important;
  }

  .fegi-bot-quick {
    padding: 10px 12px !important;
    gap: 7px !important;
    max-height: 132px !important;
    overflow-y: auto !important;
  }

  .fegi-bot-chip {
    font-size: 11.5px !important;
    padding: 7px 10px !important;
  }

  .fegi-bot-footer {
    padding: 10px !important;
    gap: 8px !important;
  }

  #fegiBotInput {
    height: 44px !important;
    font-size: 13.5px !important;
  }

  #fegiBotSend {
    height: 44px !important;
    min-width: 74px !important;
    padding: 0 12px !important;
  }
}

/* Celulares bajos: reduce altura para que no tape todo */
@media (max-width: 640px) and (max-height: 760px) {
  #fegiBotBox {
    bottom: 74px !important;
    max-height: calc(100dvh - 98px) !important;
  }

  .fegi-bot-header {
    min-height: 68px !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
  }

  .fegi-bot-avatar {
    width: 38px !important;
    height: 38px !important;
  }

  .fegi-bot-body {
    max-height: calc(100dvh - 330px) !important;
  }

  .fegi-bot-quick {
    max-height: 112px !important;
  }
}

/* Celulares angostos */
@media (max-width: 380px) {
  #fegiBotBox {
    left: 6px !important;
    right: 6px !important;
    bottom: 72px !important;
    border-radius: 18px !important;
  }

  .fegi-bot-chip {
    font-size: 11px !important;
    padding: 7px 9px !important;
  }

  #fegiBotSend {
    min-width: 68px !important;
  }
}