/* ============================================
   ONA Club - Chat interno (#/chat)
   ============================================ */

/* ── Lista de conversaciones ── */
.chat-page { max-width: 760px; margin: 0 auto; padding-top: calc(env(safe-area-inset-top, 0px) + 72px); }
.chat-list-head { padding: 0 var(--space-md) var(--space-md); }
.chat-list-head__eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--text-muted); }
.chat-list-head__title { margin: 2px 0 0; font-family: 'Fraunces', Georgia, serif; font-weight: 500; font-size: 2rem; color: var(--text-heading); }

.chat-section { background: var(--bg-card); border-radius: var(--border-radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; margin: 0 var(--space-sm) var(--space-md); }
.chat-section__title { margin: var(--space-lg) var(--space-md) var(--space-sm); font-size: 13px; font-weight: 700; color: var(--text-secondary); }
.chat-hint { margin: 0 var(--space-md) var(--space-lg); font-size: 12px; color: var(--text-muted); text-align: center; }

.chat-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: inherit; text-decoration: none; border-bottom: 1px solid var(--border-color); }
.chat-row:last-child { border-bottom: 0; }
.chat-row:active { background: var(--bg-cream-soft); }
.chat-row__main { flex: 1; min-width: 0; }
.chat-row__top, .chat-row__bottom { display: flex; align-items: center; gap: 8px; }
.chat-row__name { flex: 1; min-width: 0; font-weight: 700; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row__time { flex-shrink: 0; font-size: 12px; color: var(--text-muted); }
.chat-row__preview { flex: 1; min-width: 0; margin-top: 2px; font-size: 14px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row__preview strong { font-weight: 600; color: var(--text-primary); }
.chat-row__muted { display: inline-flex; color: var(--text-muted); }
.chat-row__badge { flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--color-primary-dark); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.chat-row--unread .chat-row__time { color: var(--color-primary-dark); font-weight: 700; }
.chat-row--unread .chat-row__preview { color: var(--text-primary); }
.chat-row--dir { cursor: default; }
.chat-dir__state { flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-secondary); padding: 6px 10px; border-radius: 999px; background: var(--bg-cream-soft); }

.chat-avatar {
    flex-shrink: 0; width: 48px; height: 48px; border-radius: 50%;
    background: var(--bg-cream) center / cover no-repeat; color: var(--text-heading);
    display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700;
}
.chat-avatar { position: relative; }
.chat-avatar--ona { background: var(--color-primary); }
.chat-avatar--ona img { width: 72%; height: auto; }
.chat-avatar--avisos { background: rgba(63, 157, 98, .14); color: #3f9d62; }
.chat-avatar--icon { background: var(--bg-cream); color: var(--color-primary-dark); }
.chat-avatar__dot { position: absolute; right: -1px; bottom: -1px; width: 30%; height: 30%; min-width: 10px; min-height: 10px; border-radius: 50%; background: var(--c); border: 2px solid var(--bg-card); }

/* ── Conversación (capa a pantalla completa sobre la navegación) ── */
body.chat-room-open { overflow: hidden; }
body.chat-room-open #fab-qr-global { display: none !important; }

.chat-room {
    position: fixed; inset: 0; z-index: 260;
    display: flex; flex-direction: column;
    background: var(--bg-cream-soft);
}
.chat-room__head {
    flex-shrink: 0; display: flex; align-items: center; gap: 10px;
    padding: calc(env(safe-area-inset-top, 0px) + 8px) 10px 8px;
    background: var(--bg-card); border-bottom: 1px solid var(--border-color);
}
.chat-room__back, .chat-room__menu {
    flex-shrink: 0; width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent;
    color: var(--text-heading); font-size: 22px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.chat-room__back:active, .chat-room__menu:active { background: var(--bg-cream-soft); }
.chat-room__title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 2px 0; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.chat-room__title .chat-avatar { width: 38px; height: 38px; font-size: 18px; }
.chat-room__title-text { min-width: 0; display: flex; flex-direction: column; }
.chat-room__name { font-weight: 700; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-room__sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-room__msgs { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 10px 16px; overscroll-behavior: contain; }
.chat-room__jump {
    position: absolute; right: 14px; bottom: calc(78px + env(safe-area-inset-bottom, 0px)); z-index: 2;
    min-width: 42px; height: 42px; border: 0; border-radius: 999px; padding: 0 12px; gap: 4px;
    align-items: center; justify-content: center; background: var(--bg-card); color: var(--color-primary-dark);
    font-size: 12px; font-weight: 700; box-shadow: var(--shadow-md); cursor: pointer;
}
.chat-room__jump span:empty { display: none; }

.chat-room__reply {
    flex-shrink: 0; align-items: center; gap: 8px; padding: 8px 12px;
    background: var(--bg-card); border-top: 1px solid var(--border-color);
}
.chat-room__reply-text { flex: 1; min-width: 0; padding-left: 10px; border-left: 3px solid var(--color-primary); font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-room__reply-text strong { display: block; color: var(--color-primary-dark); font-size: 12px; }
.chat-room__reply button { border: 0; background: transparent; color: var(--text-muted); cursor: pointer; padding: 4px; }

.chat-room__composer {
    flex-shrink: 0; display: flex; align-items: flex-end; gap: 6px;
    padding: 8px 8px calc(env(safe-area-inset-bottom, 0px) + 8px);
    background: var(--bg-card); border-top: 1px solid var(--border-color);
}
.chat-room__input {
    flex: 1; min-width: 0; resize: none; max-height: 140px; padding: 10px 14px;
    border: 1px solid var(--border-color); border-radius: 22px; background: var(--bg-cream-soft);
    font: inherit; font-size: 16px; line-height: 1.35; color: var(--text-primary); outline: none;
}
.chat-room__input:focus { border-color: var(--color-primary); }
.chat-room__icon-btn {
    flex-shrink: 0; width: 42px; height: 42px; border: 0; border-radius: 50%; background: transparent;
    color: var(--text-secondary); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.chat-room__send {
    flex-shrink: 0; width: 44px; height: 44px; border: 0; border-radius: 50%;
    background: var(--color-primary-dark); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.chat-room__send:disabled { opacity: .35; cursor: default; }
.chat-room__readonly { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 10px; font-size: 13px; color: var(--text-muted); }

/* ── Mensajes ── */
.chat-day { text-align: center; margin: 14px 0 8px; }
.chat-day span, .chat-sys span {
    display: inline-block; padding: 4px 12px; border-radius: 999px;
    background: rgba(94, 79, 63, .07); font-size: 12px; color: var(--text-secondary);
}
.chat-sys { text-align: center; margin: 6px 0; }
.chat-sys span { font-style: italic; }
.chat-empty, .chat-older { text-align: center; padding: 18px; font-size: 13px; color: var(--text-muted); }

.chat-msg { display: flex; flex-direction: column; align-items: flex-start; margin-top: 8px; }
.chat-msg--cont { margin-top: 2px; }
.chat-msg--mine { align-items: flex-end; }
.chat-msg__bubble {
    position: relative; max-width: min(82%, 520px); padding: 7px 10px 5px;
    border-radius: 18px 18px 18px 6px; background: var(--bg-card); box-shadow: var(--shadow-sm);
    cursor: pointer; overflow-wrap: anywhere;
}
.chat-msg--mine .chat-msg__bubble { border-radius: 18px 18px 6px 18px; background: #efe5d7; }
.chat-msg--cont .chat-msg__bubble { border-radius: 18px; }
.chat-msg__bubble--staff { border-left: 3px solid var(--color-primary); }
.chat-msg__name { font-size: 12px; font-weight: 700; color: var(--color-primary-dark); margin-bottom: 2px; }
.chat-msg__text { font-size: 15px; line-height: 1.4; color: var(--text-primary); }
.chat-msg__text a { color: var(--color-primary-dark); text-decoration: underline; }
.chat-msg__deleted { font-size: 14px; font-style: italic; color: var(--text-muted); }
.chat-msg__meta { margin-top: 2px; display: flex; align-items: center; justify-content: flex-end; gap: 3px; font-size: 10px; color: var(--text-muted); }
.chat-msg__status { display: inline-flex; color: var(--color-primary-dark); }
.chat-msg--pending .chat-msg__bubble { opacity: .75; }
.chat-msg__retry { margin-top: 4px; display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; color: var(--color-error); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; padding: 0; }
.chat-msg__img { display: block; max-width: 100%; max-height: 320px; border-radius: 12px; margin: 2px 0 4px; object-fit: cover; }
.chat-msg__quote {
    margin-bottom: 4px; padding: 5px 8px; border-left: 3px solid var(--color-primary); border-radius: 6px;
    background: rgba(94, 79, 63, .06); font-size: 13px; color: var(--text-secondary);
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.chat-msg__quote strong { display: block; font-size: 12px; color: var(--color-primary-dark); }

.chat-msg__reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: -4px; padding: 0 8px; position: relative; z-index: 1; }
.chat-react {
    display: inline-flex; align-items: center; gap: 3px;
    border: 1px solid var(--border-color); border-radius: 999px; padding: 2px 7px;
    background: var(--bg-card); font-size: 12px; font-weight: 600; line-height: 1.4; cursor: pointer; box-shadow: var(--shadow-sm);
}


/* Tarjeta de clase (sustituye a las encuestas de WhatsApp) */
.chat-class { min-width: 220px; padding: 4px 2px; }
.chat-class__eyebrow { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--color-primary-dark); }
.chat-class__note { margin-top: 6px; font-size: 14px; color: var(--text-primary); }
.chat-class__title { margin: 2px 0; font-family: 'Fraunces', Georgia, serif; font-size: 18px; color: var(--text-heading); }
.chat-class__meta { font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; }
.chat-class__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.chat-class__ok { font-size: 13px; font-weight: 700; color: var(--color-success); display: inline-flex; align-items: center; gap: 4px; }
.chat-class__off { font-size: 12px; color: var(--text-muted); }

/* Hoja de acciones de un mensaje */
/* 6 reacciones (iconos SVG) en una fila; hueco arriba para la X flotante del modal */
.chat-sheet__reactions { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 34px 0 12px; border-bottom: 1px solid var(--border-color); }
.chat-sheet__emoji { border: 0; background: var(--bg-cream-soft); padding: 10px 0; border-radius: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.chat-sheet__emoji.is-mine { background: #f3eadf; box-shadow: inset 0 0 0 2px currentColor; }
.chat-sheet__list { display: flex; flex-direction: column; padding-top: 6px; }
.chat-sheet__item {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 6px; border: 0; background: transparent;
    font: inherit; font-size: 15px; color: var(--text-primary); text-align: left; cursor: pointer; border-radius: 10px;
}
.chat-sheet__item:active { background: var(--bg-cream-soft); }
.chat-sheet__item--danger { color: var(--color-error); }

/* Globo de no leídos del icono de chat en la navbar */
#chat-badge {
    display: none; position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 8px; background: var(--danger, #b4665c); color: #fff; font-size: 10px; font-weight: 700;
    align-items: center; justify-content: center; line-height: 1;
}

@media (min-width: 900px) {
    /* En escritorio la conversación ocupa una columna centrada, no toda la pantalla */
    .chat-room { left: 50%; transform: translateX(-50%); width: 760px; box-shadow: var(--shadow-md); }
}

/* ── Iconos SVG, puntos de color y piezas nuevas ── */
.ci { flex-shrink: 0; vertical-align: -3px; }
.ci--inline { margin-right: 3px; vertical-align: -2px; }
.ci--right { transform: rotate(-90deg); }
.chat-dot { display: inline-block; flex-shrink: 0; border-radius: 50%; background: var(--c); margin-right: 6px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .06); }

/* Reacciones: cada icono con su color; la propia, rellena y con borde */
.chat-react--heart { color: #c4534a; }
.chat-react--like { color: #3a7cc1; }
.chat-react--haha, .chat-react--wow, .chat-react--star { color: #c99a1e; }
.chat-react--fire { color: #e0862b; }
.chat-react--mine { border-color: currentColor; background: #fbf4ea; }
.chat-react--mine.chat-react--heart svg, .chat-react--mine.chat-react--star svg,
.chat-sheet__emoji.is-mine.chat-react--heart svg, .chat-sheet__emoji.is-mine.chat-react--star svg { fill: currentColor; }
.chat-react span { color: var(--text-secondary); }

/* Separador "mensajes nuevos" al entrar */
.chat-unread-sep { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; color: var(--color-primary-dark); font-size: 12px; font-weight: 700; }
.chat-unread-sep::before, .chat-unread-sep::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: .35; }

.chat-hint--left { text-align: left; margin-top: -4px; }
.chat-photo-preview { display: block; width: 100%; max-height: 55vh; object-fit: contain; border-radius: 12px; background: var(--bg-cream-soft); }

/* Lista de miembros (menú del grupo) */
.chat-members__title { display: flex; align-items: center; gap: 6px; margin: var(--space-md) 0 6px; font-size: 13px; color: var(--text-secondary); }
.chat-members { max-height: 40vh; overflow-y: auto; }
.chat-members__row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border-color); font-size: 14px; }
.chat-members__row:last-child { border-bottom: 0; }
.chat-members__tag { margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: .08em; color: var(--color-primary-dark); background: var(--bg-cream-soft); padding: 2px 8px; border-radius: 999px; }

/* Paleta de colores de grupo (admin) */
.chat-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-swatch { width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--c); cursor: pointer; box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); }
.chat-swatch.is-on { box-shadow: 0 0 0 3px var(--bg-card), 0 0 0 5px var(--c); }

/* ── Chat en la pantalla de inicio ── */
.home-chat { background: var(--bg-card); border-radius: var(--border-radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.home-chat__head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px; color: var(--text-heading); text-decoration: none; }
.home-chat__icon { display: inline-flex; width: 30px; height: 30px; border-radius: 50%; align-items: center; justify-content: center; background: var(--bg-cream); color: var(--color-primary-dark); }
.home-chat__title { flex: 1; font-weight: 700; }
.home-chat__badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--color-primary-dark); color: #fff; font-size: 11px; font-weight: 700; align-items: center; justify-content: center; }
.home-chat__open { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; color: var(--color-primary-dark); }
.home-chat__row { display: flex; align-items: center; gap: 10px; padding: 9px 16px; color: inherit; text-decoration: none; border-top: 1px solid var(--border-color); }
.home-chat__row:active { background: var(--bg-cream-soft); }
.home-chat__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.home-chat__name { font-weight: 600; font-size: 14px; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-chat__preview { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-chat__row.is-unread .home-chat__preview { color: var(--text-primary); font-weight: 600; }
.home-chat__time { flex-shrink: 0; font-size: 11px; color: var(--text-muted); }
.home-chat__cta { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 4px 16px 14px; padding: 11px; border-radius: 999px; background: var(--color-primary-dark); color: #fff; font-weight: 700; font-size: 14px; text-decoration: none; }
.home-chat__note { display: flex; align-items: center; gap: 6px; padding: 10px 16px 14px; font-size: 13px; color: var(--text-secondary); border-top: 1px solid var(--border-color); }
