/* ─── Lazzo Bienestar · Cliente — Pantalla Mensajes (C10) ──────────────────
 * Hilo único directo cliente↔profesional. Layout flex column con composer
 * sticky abajo (encima de bcl-bottom-nav). Patrón consistente con sesiones.css
 * y nav-cliente.css del cliente bienestar.
 *
 * 4 estados visuales:
 *   - empty (sin reserva confirmada)
 *   - pro_off (mensajería desactivada por la profesional)
 *   - cerrada (la pro finalizó la conversación)
 *   - activa (composer + scroll mensajes)
 * ──────────────────────────────────────────────────────────────────────────── */

#bcl-mensajes-root {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bcl-bg, #fdf6f0);
  color: var(--bcl-text, #2c2520);
}

/* ─── Header del hilo ─────────────────────────────────────────────────────── */
/* padding-top respeta safe-area-inset-top (Capacitor APK / iOS notch) para que
   foto+nombre no queden tapados por la status bar (cobertura, wifi, batería). */
.bcl-msg-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: linear-gradient(135deg, #9b7fd4 0%, #b394e0 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.bcl-msg-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.35);
  overflow: hidden;
  flex: 0 0 auto;
}

.bcl-msg-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bcl-msg-header-meta {
  flex: 1 1 auto;
  min-width: 0;
}

.bcl-msg-header-nombre {
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  line-height: 1.1;
  margin: 0;
}

.bcl-msg-header-sub {
  font-size: 12px;
  opacity: 0.9;
  margin-top: 2px;
}

.bcl-msg-header-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.2);
}

/* ─── Banner avisos (cerrada / pro_off / sin_reserva) ────────────────────── */
.bcl-msg-banner {
  margin: 12px 16px 0;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.bcl-msg-banner i {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.bcl-msg-banner.aviso {
  background: #fff3e0;
  color: #6b4a16;
  border: 1px solid #ffd699;
}

.bcl-msg-banner.cerrada {
  background: #efe5fa;
  color: #5a3f88;
  border: 1px solid #d4bff0;
}

.bcl-msg-banner.error {
  background: #fde8e8;
  color: #842323;
  border: 1px solid #f5b8b8;
}

/* ─── Lista de mensajes (scrollable) ──────────────────────────────────────── */
.bcl-msg-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.bcl-msg-bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.bcl-msg-bubble .ts {
  display: block;
  font-size: 10px;
  margin-top: 4px;
  opacity: 0.65;
}

.bcl-msg-bubble.mine {
  align-self: flex-end;
  background: #9b7fd4;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bcl-msg-bubble.theirs {
  align-self: flex-start;
  background: #fff;
  color: #2c2520;
  border-bottom-left-radius: 4px;
  border: 1px solid #ece4d8;
}

.bcl-msg-bubble.system {
  align-self: center;
  background: rgba(0, 0, 0, 0.05);
  color: #6a5d4f;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 10px;
}

/* Date/group separator */
.bcl-msg-date-sep {
  align-self: center;
  font-size: 11px;
  color: #8a7d6e;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid #ece4d8;
  padding: 3px 10px;
  border-radius: 999px;
  margin: 8px 0 4px;
}

/* ─── Empty state (sin reserva confirmada) ────────────────────────────────── */
.bcl-msg-empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 30px 24px;
  text-align: center;
}

.bcl-msg-empty-ico {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #efe5fa;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9b7fd4;
}

.bcl-msg-empty-ico i {
  width: 30px;
  height: 30px;
}

.bcl-msg-empty h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  margin: 0;
  color: #2c2520;
}

.bcl-msg-empty p {
  font-size: 14px;
  line-height: 1.5;
  color: #6a5d4f;
  margin: 0;
  max-width: 320px;
}

.bcl-msg-empty-cta {
  margin-top: 6px;
  padding: 12px 22px;
  background: linear-gradient(135deg, #9b7fd4, #b394e0);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(155, 127, 212, 0.4);
}

.bcl-msg-empty-cta:hover { transform: translateY(-1px); }

.bcl-msg-empty-email-line {
  margin: -4px 0 8px;
  font-size: 14px;
  line-height: 1.5;
  color: #6a5d4f;
  word-break: break-word;
  text-align: center;
}

.bcl-msg-empty-email {
  color: #9b7fd4;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, #9b7fd4 35%, transparent);
  padding-bottom: 1px;
  user-select: text;
  -webkit-user-select: text;
}

.bcl-msg-empty-email:hover,
.bcl-msg-empty-email:focus {
  color: #7a5fb8;
  border-bottom-color: #9b7fd4;
}

.bcl-msg-empty-secondary {
  margin-top: 4px;
  background: transparent;
  color: #9b7fd4;
  border: 1px solid #d4bff0;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

/* ─── Composer (input + send) ─────────────────────────────────────────────── */
.bcl-msg-composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-top: 1px solid #ece4d8;
  position: sticky;
  bottom: 0;
}

.bcl-msg-composer textarea {
  flex: 1 1 auto;
  resize: none;
  padding: 10px 14px;
  border: 1px solid #ece4d8;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  font-family: inherit;
  background: #fdf6f0;
  color: #2c2520;
  min-height: 38px;
  max-height: 140px;
  outline: none;
  transition: border-color .15s;
}

.bcl-msg-composer textarea:focus {
  border-color: #9b7fd4;
  background: #fff;
}

.bcl-msg-composer .bcl-msg-send {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #9b7fd4, #b394e0);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(155, 127, 212, 0.35);
  transition: transform .12s;
}

.bcl-msg-composer .bcl-msg-send:hover { transform: scale(1.06); }
.bcl-msg-composer .bcl-msg-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.bcl-msg-composer .bcl-msg-send i {
  width: 18px;
  height: 18px;
}

/* Composer disabled (estado cerrada / pro_off): mensaje informativo en su lugar */
.bcl-msg-composer-disabled {
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  background: #faf5ed;
  border-top: 1px solid #ece4d8;
  text-align: center;
  font-size: 13px;
  color: #6a5d4f;
  position: sticky;
  bottom: 0;
}

/* ─── Skeleton mientras carga ─────────────────────────────────────────────── */
.bcl-msg-skel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 14px;
}

.bcl-msg-skel-bubble {
  height: 40px;
  border-radius: 16px;
  background: linear-gradient(90deg, #f0e8db 25%, #fff5e1 50%, #f0e8db 75%);
  background-size: 200% 100%;
  animation: bcl-msg-skel-shine 1.4s ease-in-out infinite;
}

.bcl-msg-skel-bubble.mine { align-self: flex-end; width: 60%; }
.bcl-msg-skel-bubble.theirs { align-self: flex-start; width: 70%; }

@keyframes bcl-msg-skel-shine {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Badge no leídos en bottom nav (Mensajes) ────────────────────────────── */
.bcl-nav-unread {
  position: absolute;
  top: 4px;
  right: 18px;
  background: #e45050;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid #fff;
  z-index: 1;
}

.bcl-nav-tab { position: relative; }

/* Cuando el badge no leído está oculto via attr, no ocupa espacio */
.bcl-nav-unread[hidden] { display: none !important; }
