/* ═══════════════════════════════════════════════════════════════════
   cerca · Asistente Conversacional Reactivo · v2 CSS
   Editorial Médico · Mobile: modal pequeño interactivo
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --ai-ink:   #1A1A1A;
  --ai-paper: #FAFAF8;
  --ai-line:  #E0DDD7;
  --ai-accent:#C62828;
  --ai-white: #FFFFFF;
  --ai-display: 'Playfair Display', Georgia, serif;
  --ai-body: 'Inter', sans-serif;
}

/* ─── FAB (botón flotante) ─────────────────────────────────────── */
.cerca-fab {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 52px; height: 52px;
  background: var(--ai-ink);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 90;
  box-shadow: 0 4px 20px rgba(26,26,26,0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.cerca-fab:hover { transform: scale(1.05); }
.cerca-fab svg { transition: opacity 0.2s; }
.cerca-fab .icon-close { position: absolute; opacity: 0; }
.cerca-fab.open .icon-chat { opacity: 0; }
.cerca-fab.open .icon-close { opacity: 1; }
.cerca-fab.open { border-radius: 16px; }

/* ─── Panel desktop (380px) ─────────────────────────────────────── */
.cerca-panel {
  position: fixed;
  bottom: 90px; right: 24px;
  width: 380px; max-width: calc(100vw - 48px);
  height: 520px; max-height: calc(100vh - 120px);
  background: var(--ai-white);
  border: 1px solid var(--ai-line);
  border-radius: 8px;
  display: none; flex-direction: column; overflow: hidden;
  box-shadow: 0 16px 48px rgba(26,26,26,0.12);
  z-index: 91; font-family: var(--ai-body);
}
.cerca-panel.open { display: flex; animation: cerca-slide 0.3s; }
@keyframes cerca-slide { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Header */
.cerca-header {
  background: var(--ai-ink); padding: 16px 20px;
  color: var(--ai-white); display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.cerca-avatar {
  width: 36px; height: 36px; background: var(--ai-accent); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--ai-display); font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.cerca-header h3 { font-family: var(--ai-display); font-size: 15px; font-weight: 700; }
.cerca-header p { font-size: 10px; color: rgba(255,255,255,0.5); display: flex; align-items: center; gap: 5px; }
.cerca-header p::before { content: ''; width: 5px; height: 5px; background: #2E7D32; border-radius: 50%; }

/* Messages */
.cerca-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  background: var(--ai-paper);
}
.cerca-messages::-webkit-scrollbar { width: 4px; }
.cerca-messages::-webkit-scrollbar-thumb { background: var(--ai-line); border-radius: 2px; }

.cerca-msg { margin-bottom: 14px; max-width: 85%; animation: cerca-fade 0.3s ease; }
@keyframes cerca-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.cerca-msg.bot .bubble {
  background: var(--ai-white); border: 1px solid var(--ai-line);
  padding: 10px 14px; border-radius: 2px 2px 12px 2px;
  font-size: 14px; line-height: 1.6; color: var(--ai-ink);
}
.cerca-msg.bot .author {
  font-size: 10px; color: var(--ai-accent); text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 3px; font-weight: 600;
}
.cerca-msg.user { margin-left: auto; }
.cerca-msg.user .bubble {
  background: var(--ai-ink); color: var(--ai-white);
  padding: 10px 14px; border-radius: 12px 2px 2px 12px;
  font-size: 14px; line-height: 1.5;
}

/* Action buttons */
.cerca-action-btn {
  display: inline-block; background: var(--ai-ink); color: var(--ai-white);
  padding: 7px 12px; border-radius: 2px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: none; margin-top: 6px; margin-right: 5px;
  text-decoration: none; transition: background 0.15s;
}
.cerca-action-btn:hover { background: var(--ai-accent); color: white; }

/* Chips */
.cerca-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.cerca-chip {
  background: var(--ai-paper); border: 1px solid var(--ai-line);
  padding: 5px 10px; border-radius: 100px;
  font-size: 12px; color: #3D3D3D; cursor: pointer; transition: all 0.15s;
}
.cerca-chip:hover { background: var(--ai-ink); color: white; border-color: var(--ai-ink); }

/* Typing */
.cerca-typing {
  display: flex; gap: 4px; padding: 10px 14px;
  background: var(--ai-white); border: 1px solid var(--ai-line);
  border-radius: 2px 2px 12px 2px; width: fit-content; margin-bottom: 14px;
}
.cerca-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--ai-line); animation: cerca-bounce 1.4s infinite; }
.cerca-typing span:nth-child(2) { animation-delay: 0.2s; }
.cerca-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cerca-bounce { 0%,60%,100% { transform: translateY(0); opacity: 0.3; } 30% { transform: translateY(-5px); opacity: 1; } }

/* Input */
.cerca-input-area {
  padding: 10px 14px; border-top: 1px solid var(--ai-line);
  background: var(--ai-white); flex-shrink: 0; display: flex; gap: 6px;
}
.cerca-input {
  flex: 1; border: 1px solid var(--ai-line); border-radius: 4px;
  padding: 10px 12px; font-size: 14px; font-family: var(--ai-body);
  color: var(--ai-ink); background: var(--ai-paper); outline: none;
}
.cerca-input:focus { border-color: var(--ai-ink); }
.cerca-input::placeholder { color: #B0B0B0; }
.cerca-send {
  width: 38px; height: 38px; background: var(--ai-ink);
  border: none; border-radius: 4px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background 0.15s;
}
.cerca-send:hover { background: var(--ai-accent); }
.cerca-send svg { color: white; }

/* Highlight de sección */
.cerca-highlight { animation: cerca-glow 1.5s ease; }
@keyframes cerca-glow {
  0% { box-shadow: 0 0 0 0 rgba(198,40,40,0); }
  30% { box-shadow: 0 0 0 4px rgba(198,40,40,0.2); }
  100% { box-shadow: 0 0 0 0 rgba(198,40,40,0); }
}

/* Botones del asistente (solo cuando se muestran explícitamente) */
.cerca-boton-wrap { margin-top: 8px; }
.cerca-boton {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ai-accent, #C62828); color: white; border: none;
  padding: 10px 16px; border-radius: 4px;
  font-family: var(--ai-body, 'Inter', sans-serif); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
  text-decoration: none;
}
.cerca-boton:hover { background: #B71C1C; transform: translateY(-1px); box-shadow: 0 2px 6px rgba(198,40,40,0.3); }

/* ═══ MOBILE: modal pequeño interactivo ═══ */
@media (max-width: 640px) {
  .cerca-panel {
    bottom: 80px; right: 12px; left: 12px;
    width: auto; max-width: none;
    height: 360px; max-height: 50vh;
    border-radius: 8px;
  }
  .cerca-fab { bottom: 16px; right: 16px; width: 48px; height: 48px; }
}
