/* Franquicia Chatbot IA v3 – Mobile First */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

#fcb {
  --accent:    #1565C0;
  --accent-lt: #1E88E5;
  --green:     #2E7D32;
  --green-lt:  #69F0AE;
  --bg:        #EEF2F7;
  --bot-bg:    #FFFFFF;
  --user-bg:   #1E88E5;
  --user-txt:  #FFFFFF;
  --bot-txt:   #1A1A2E;
  --muted:     #6B7A99;
  --border:    #D8E0EC;
  --font:      'Segoe UI', Arial, sans-serif;

  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  background: var(--bg);
  color: var(--bot-txt);
  z-index: 99999;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────────────────── */
#fcb-head {
  background: var(--accent);
  color: #fff;
  padding: 14px 16px 12px;
  padding-top: max(14px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#fcb-logo {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 900; flex-shrink: 0;
}

#fcb-head-info { flex: 1; min-width: 0; }
#fcb-head-info h2 { font-size: 15px; font-weight: 700; line-height: 1.2; }
#fcb-head-info p  { font-size: 11px; opacity: .75; margin-top: 2px; }

#fcb-online {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; opacity: .85; flex-shrink: 0;
}

#fcb-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green-lt);
  animation: blink 2s infinite;
}

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── Progreso ────────────────────────────────────────────────────────── */
#fcb-prog-wrap {
  background: rgba(0,0,0,.15);
  height: 28px;
  display: flex;
  align-items: center;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--accent);
  border-top: 1px solid rgba(255,255,255,.1);
}

#fcb-prog {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--green-lt);
  width: 0%;
  transition: width .5s ease;
  opacity: .35;
}

#fcb-prog-txt {
  position: relative;
  z-index: 1;
  font-size: 11px;
  color: #fff;
  padding: 0 12px;
  font-weight: 600;
  letter-spacing: .3px;
}

/* ── Mensajes ────────────────────────────────────────────────────────── */
#fcb-msgs {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

#fcb-msgs::-webkit-scrollbar       { width: 3px; }
#fcb-msgs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Filas ───────────────────────────────────────────────────────────── */
.fcb-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  animation: fadeUp .25s ease;
}

@keyframes fadeUp {
  from { opacity:0; transform:translateY(8px) }
  to   { opacity:1; transform:translateY(0) }
}

.fcb-row.bot  { justify-content: flex-start; }
.fcb-row.user { justify-content: flex-end; }

/* ── Avatares ────────────────────────────────────────────────────────── */
.fcb-av {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}

.bot-av { background: var(--accent-lt); }

/* ── Burbujas ────────────────────────────────────────────────────────── */
.fcb-bub {
  max-width: calc(100% - 44px);
  padding: 10px 13px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.bot-bub {
  background: var(--bot-bg);
  color: var(--bot-txt);
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.user-bub {
  background: var(--user-bg);
  color: var(--user-txt);
  border-radius: 16px 4px 16px 16px;
  max-width: 75%;
  font-weight: 500;
}

/* ── Typing ──────────────────────────────────────────────────────────── */
.fcb-typing-bub {
  background: var(--bot-bg);
  border-radius: 4px 16px 16px 16px;
  padding: 12px 16px;
  display: flex; gap: 5px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.fcb-dot-a {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #B0BEC5;
  animation: tdot 1.1s infinite;
}
.fcb-dot-a:nth-child(2) { animation-delay:.18s }
.fcb-dot-a:nth-child(3) { animation-delay:.36s }

@keyframes tdot {
  0%,60%,100% { transform:translateY(0) }
  30%          { transform:translateY(-6px) }
}

/* ── Botones de opciones ─────────────────────────────────────────────── */
.fcb-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-left: 36px;
  animation: fadeUp .25s ease;
}

.fcb-opt {
  background: #fff;
  color: var(--accent);
  border: 1.5px solid var(--accent-lt);
  border-radius: 22px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-family: var(--font);
  cursor: pointer;
  transition: all .18s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  white-space: nowrap;
}

.fcb-opt:active,
.fcb-opt:hover {
  background: var(--accent-lt);
  color: #fff;
  border-color: var(--accent-lt);
  transform: scale(.97);
}

/* ── Tarjeta confirmación ────────────────────────────────────────────── */
.fcb-confirm {
  background: #E8F5E9;
  border: 1.5px solid #A5D6A7;
  border-radius: 14px;
  padding: 14px 16px;
  margin-top: 4px;
  animation: fadeUp .3s ease;
}

.fcb-confirm h4 {
  color: var(--green);
  font-size: 13px;
  margin-bottom: 10px;
}

.fcb-cr {
  display: flex;
  gap: 8px;
  font-size: 12.5px;
  color: #455A64;
  margin-bottom: 4px;
  line-height: 1.4;
}

.fcb-cr b {
  color: #263238;
  min-width: 90px;
  flex-shrink: 0;
}

/* ── Input area ──────────────────────────────────────────────────────── */
#fcb-input-wrap {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-height: 60px;
}

#fcb-inp {
  flex: 1;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 9px 16px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--bot-txt);
  outline: none;
  transition: border-color .2s;
}

#fcb-inp:focus    { border-color: var(--accent-lt); }
#fcb-inp::placeholder { color: var(--muted); }

#fcb-btn {
  width: 42px; height: 42px; min-width: 42px;
  background: var(--accent-lt);
  border: none; border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, transform .1s;
  flex-shrink: 0;
}
#fcb-btn:active   { transform: scale(.92); }
#fcb-btn:disabled { background: #B0BEC5; cursor: default; }
#fcb-btn svg      { display: block; }

/* ── Shake error ─────────────────────────────────────────────────────── */
@keyframes fcb-shake {
  0%,100%{transform:translateX(0)}
  20%    {transform:translateX(-6px)}
  40%    {transform:translateX(6px)}
  60%    {transform:translateX(-4px)}
  80%    {transform:translateX(4px)}
}

/* ── Desktop: tarjeta centrada ───────────────────────────────────────── */
@media (min-width: 600px) {
  #fcb {
    position: relative;
    inset: auto;
    max-width: 500px;
    height: 700px;
    margin: 40px auto;
    border-radius: 22px;
    box-shadow: 0 16px 56px rgba(0,0,0,.18);
    overflow: hidden;
  }
}
