/* ============================================================================
 * IG Tech Advisory · Floating Chat Launcher
 * Botón flotante + panel de chat reutilizable en cualquier página pública.
 * Variables propias para no chocar con styles.css.
 * ========================================================================== */

:root {
  --igc-navy:        #0F2A44;
  --igc-navy-dark:   #0B2138;
  --igc-green:       #22C55E;
  --igc-green-dark:  #16A34A;
  --igc-ink:         #1E3954;
  --igc-ink-soft:    #5C6B7A;
  --igc-bg:          #FFFFFF;
  --igc-bg-soft:     #F4F6F9;
  --igc-border:      #E4E4E7;
  --igc-shadow-lg:   0 18px 48px rgba(15, 42, 68, 0.18), 0 4px 12px rgba(15, 42, 68, 0.08);
  --igc-shadow-md:   0 6px 18px rgba(15, 42, 68, 0.12);
  --igc-radius:      16px;
  --igc-radius-sm:   10px;
  --igc-font:        "Inter", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
}

/* ---------- Launcher button (botón flotante) ---------- */
.igc-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 54px;
  padding: 0 22px 0 18px;
  background: var(--igc-navy);
  color: #fff;
  border: 0;
  border-radius: 999px;
  font-family: var(--igc-font);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--igc-shadow-lg);
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.igc-launcher:hover { background: var(--igc-navy-dark); transform: translateY(-2px); }
.igc-launcher:active { transform: translateY(0); }
.igc-launcher__dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--igc-green);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
  animation: igcPulse 2.4s ease-in-out infinite;
}
@keyframes igcPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18); }
  50%      { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0.06); }
}
.igc-launcher__svg { width: 18px; height: 18px; }
.igc-launcher.is-open { display: none; }

/* ---------- Panel ---------- */
.igc-panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10000;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 560px;
  max-height: calc(100vh - 48px);
  background: var(--igc-bg);
  border-radius: var(--igc-radius);
  box-shadow: var(--igc-shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--igc-font);
  color: var(--igc-ink);
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}
.igc-panel.is-open {
  display: flex;
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* ---------- Header ---------- */
.igc-panel__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--igc-navy), #163a5e);
  color: #fff;
}
.igc-panel__avatar {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--igc-green);
  color: #fff;
  border-radius: 50%;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
  overflow: hidden;
  flex-shrink: 0;
}
/* Variante con imagen (agent_logo en config) */
.igc-panel__avatar--img {
  background: #fff;
  padding: 2px;
}
.igc-panel__avatar--img img {
  width: 100%; height: 100%;
  object-fit: contain;
  border-radius: 50%;
}
.igc-panel__meta { flex: 1; min-width: 0; }
.igc-panel__title {
  font-size: 14.5px;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
  /* Nombre largo del agente: 2 líneas máx, con ellipsis */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}
.igc-panel__sub {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px;
  color: rgba(255,255,255,0.78);
  margin-top: 2px;
}
.igc-panel__sub::before {
  content: ''; display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--igc-green);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.25);
}
.igc-panel__close {
  background: rgba(255,255,255,0.10);
  border: 0; color: #fff;
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 120ms ease;
}
.igc-panel__close:hover { background: rgba(255,255,255,0.18); }

/* ---------- Body ---------- */
.igc-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 4px;
  background: var(--igc-bg-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.igc-bubble {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.igc-bubble--bot {
  align-self: flex-start;
  background: #fff;
  color: var(--igc-ink);
  border: 1px solid var(--igc-border);
  border-bottom-left-radius: 6px;
}
.igc-bubble--bot a { color: var(--igc-navy); font-weight: 600; }
.igc-bubble--user {
  align-self: flex-end;
  background: var(--igc-navy);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.igc-bubble.igc-typing {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 12px 14px;
}
.igc-bubble.igc-typing span {
  width: 6px; height: 6px;
  background: var(--igc-ink-soft);
  border-radius: 50%;
  opacity: 0.45;
  animation: igcDot 1s ease-in-out infinite;
}
.igc-bubble.igc-typing span:nth-child(2) { animation-delay: 0.15s; }
.igc-bubble.igc-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes igcDot {
  0%, 100% { transform: translateY(0); opacity: 0.45; }
  50%      { transform: translateY(-3px); opacity: 1; }
}

/* ---------- Menú inicial (¿en qué te ayudo?) ---------- */
.igc-menu {
  margin: 4px 0 6px;
  align-self: stretch;
  background: #fff;
  border: 1px solid var(--igc-border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(15, 42, 68, 0.04);
}
.igc-menu__label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--igc-ink-soft);
  margin-bottom: 10px;
}
.igc-menu__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.igc-menu__item {
  appearance: none;
  background: var(--igc-bg-soft);
  border: 1px solid var(--igc-border);
  border-radius: 10px;
  padding: 10px 12px;
  font: 600 13px/1.3 var(--igc-font);
  color: var(--igc-ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}
.igc-menu__item:hover {
  border-color: var(--igc-navy);
  background: #fff;
  transform: translateY(-1px);
}
.igc-menu__item:active { transform: translateY(0); }
@media (max-width: 380px) {
  .igc-menu__grid { grid-template-columns: 1fr; }
}

/* ---------- Quick replies ---------- */
.igc-panel__quick {
  display: flex;
  gap: 6px;
  padding: 8px 12px 0;
  background: var(--igc-bg-soft);
  overflow-x: auto;
  scrollbar-width: none;
}
.igc-panel__quick::-webkit-scrollbar { display: none; }
.igc-panel__quick button {
  flex: 0 0 auto;
  background: #fff;
  border: 1px solid var(--igc-border);
  color: var(--igc-ink);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 120ms ease, background 120ms ease;
}
.igc-panel__quick button:hover {
  border-color: var(--igc-navy);
  background: #fafbfc;
}

/* ---------- Input ---------- */
.igc-panel__input {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  background: var(--igc-bg-soft);
  border-top: 1px solid var(--igc-border);
}
.igc-panel__input input {
  flex: 1;
  border: 1px solid var(--igc-border);
  background: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--igc-ink);
  outline: 0;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.igc-panel__input input:focus {
  border-color: var(--igc-navy);
  box-shadow: 0 0 0 3px rgba(15, 42, 68, 0.08);
}
.igc-panel__send {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--igc-navy);
  border: 0;
  color: #fff;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 120ms ease, transform 120ms ease;
}
.igc-panel__send:hover { background: var(--igc-navy-dark); }
.igc-panel__send:active { transform: scale(0.95); }
.igc-panel__send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Footer (legal mini-print) ---------- */
.igc-panel__foot {
  font-size: 10.5px;
  color: var(--igc-ink-soft);
  text-align: center;
  padding: 4px 12px 8px;
  background: var(--igc-bg-soft);
  line-height: 1.4;
}
.igc-panel__foot a { color: inherit; text-decoration: underline; }

/* ---------- Responsive (móvil ocupa pantalla completa) ---------- */
@media (max-width: 520px) {
  .igc-panel {
    right: 0; bottom: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .igc-launcher {
    right: 12px; bottom: 12px;
    padding: 0 18px;
    font-size: 14px;
  }
}

/* ---------- Hidden until JS loads ---------- */
.igc-hidden { display: none !important; }
