/* Épica — estilo propio sobre Bootstrap 5, en tono azul empresarial suave. */
:root {
    --marca: #1f5fa8;
    --marca-oscuro: #174a85;
    --marca-suave: #e8f0fb;
    --acento: #4aa3df;
    --fondo: #f3f6fb;
    --lateral: #13325c;
    --lateral-texto: #cdd9ec;
    --ancho-lateral: 236px;
    --bs-primary: #1f5fa8;
    --bs-primary-rgb: 31, 95, 168;
    --bs-link-color: #1f5fa8;
    --bs-link-color-rgb: 31, 95, 168;
}

body { background: var(--fondo); font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
.btn-primary { --bs-btn-bg: var(--marca); --bs-btn-border-color: var(--marca); --bs-btn-hover-bg: var(--marca-oscuro); --bs-btn-hover-border-color: var(--marca-oscuro); --bs-btn-active-bg: var(--marca-oscuro); }
.btn-outline-primary { --bs-btn-color: var(--marca); --bs-btn-border-color: var(--marca); --bs-btn-hover-bg: var(--marca); --bs-btn-hover-border-color: var(--marca); --bs-btn-active-bg: var(--marca-oscuro); }
.oculto { display: none !important; }

/* ---------- logo ---------- */
.logo-epica { width: 30px; height: 30px; border-radius: 9px; }
.logo-epica.grande { width: 56px; height: 56px; border-radius: 16px; }

/* ---------- panel: menú lateral + contenido ---------- */
.app { display: flex; min-height: 100vh; }
.lateral {
    width: var(--ancho-lateral); background: var(--lateral); color: var(--lateral-texto);
    flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1040;
    transition: transform .2s ease;
}
.lateral .marca { display: flex; align-items: center; gap: .55rem; padding: 1rem 1.1rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.lateral .empresa { padding: .6rem 1.1rem; font-size: .8rem; color: #93a9cc; }
.lateral .seccion { padding: .9rem 1.1rem .3rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #7590bb; }
.lateral a.item { display: flex; align-items: center; gap: .65rem; padding: .5rem 1.1rem; color: var(--lateral-texto); text-decoration: none; border-left: 3px solid transparent; font-size: .93rem; }
.lateral a.item:hover { background: rgba(255,255,255,.05); color: #fff; }
.lateral a.item.activo { background: rgba(74,163,223,.22); color: #fff; border-left-color: var(--acento); }
.lateral a.item i { font-size: 1.05rem; width: 1.2rem; text-align: center; }

.contenido { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.barra { background: #fff; border-bottom: 1px solid #e1e8f2; padding: .55rem 1rem; display: flex; align-items: center; gap: .75rem; position: sticky; top: 0; z-index: 1030; }
.barra .titulo-barra { font-weight: 600; color: #2b4266; }
.pie { margin-top: auto; padding: .75rem 1rem; font-size: .78rem; color: #7a869a; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.velo { display: none; }

@media (max-width: 991.98px) {
    .lateral { position: fixed; left: 0; top: 0; transform: translateX(-100%); }
    .lateral.abierto { transform: none; }
    .velo.visible { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1035; }
}

/* ---------- tarjetas, tablas, listados ---------- */
.card { border: 1px solid #e1e8f2; border-radius: .7rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; font-weight: 600; }
.tarjeta-numero { display: block; padding: 1rem; text-decoration: none; color: inherit; }
.tarjeta-numero .valor { font-size: 1.9rem; font-weight: 700; line-height: 1; color: var(--marca-oscuro); }
.tarjeta-numero .rotulo { font-size: .85rem; color: #5e6c84; }
.tarjeta-numero:hover { background: #f6f9ff; }
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: #5e6c84; background: #f7f9fd; white-space: nowrap; }
.table td { vertical-align: middle; }
.col-copiar { width: 34px; padding-left: .5rem !important; padding-right: 0 !important; }
.btn-copiar { border: 0; background: transparent; color: #97a0af; padding: 0 .2rem; }
.btn-copiar:hover { color: var(--marca); }
th.ordenable { cursor: pointer; user-select: none; }
th.ordenable:hover { color: var(--marca); }
th.ordenable::after { content: "\2195"; opacity: .25; margin-left: .3rem; font-size: .8em; }
th[aria-sort="ascending"]::after { content: "\2191"; opacity: .9; }
th[aria-sort="descending"]::after { content: "\2193"; opacity: .9; }
.paginador { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; padding: .6rem .9rem; border-bottom: 1px solid #eef1f6; font-size: .85rem; color: #5e6c84; }
.paginador select { width: auto; display: inline-block; }
.solapas .nav-link { color: #42526e; }
.solapas .nav-link.active { font-weight: 600; color: var(--marca); }
.solapas .badge { font-weight: 500; }
.totales { font-size: .88rem; color: #42526e; }
.totales strong { color: #172b4d; }
.form-check-input.toggle-activo { width: 1.25rem; height: 1.25rem; cursor: pointer; }
.cargando { opacity: .55; pointer-events: none; transition: opacity .15s; }
.avatar-mini { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #dfe7f3; }
.qr-grande { width: 100%; max-width: 360px; height: auto; image-rendering: pixelated; }
.qr-chico { width: 120px; height: 120px; image-rendering: pixelated; }

/* ---------- logins ---------- */
.login-fondo { min-height: 100vh; background: linear-gradient(135deg, #13325c 0%, #1f5fa8 60%, #4aa3df 100%); display: flex; align-items: center; justify-content: safe center; padding: 1.5rem; }
.login-caja { width: 100%; max-width: 430px; }
.login-caja .card { border: 0; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-marca { color: #fff; text-align: center; margin-bottom: 1.25rem; }
.acceso-rapido { max-width: 760px; width: 100%; }
.codigo-simulado { font-size: 1.8rem; letter-spacing: .35em; font-weight: 700; font-family: ui-monospace, Consolas, monospace; }
.input-codigo { font-size: 1.5rem; letter-spacing: .4em; text-align: center; font-family: ui-monospace, Consolas, monospace; }

/* ---------- sitio de participantes ---------- */
.barra-sitio { background: var(--lateral); color: #fff; padding: .6rem 1rem; display: flex; align-items: center; gap: .6rem; position: sticky; top: 0; z-index: 1030; }
.barra-sitio a { color: #fff; text-decoration: none; }
.barra-sitio .marca { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.sitio { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.foto-perfil { position: relative; border-radius: .7rem; overflow: hidden; background: #dfe7f3; aspect-ratio: 1 / 1; }
.foto-perfil img { width: 100%; height: 100%; object-fit: cover; }
.foto-perfil .acciones { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: .3rem; justify-content: center; padding: .4rem; background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.foto-perfil.avatar { outline: 3px solid var(--acento); outline-offset: -3px; }
.foto-vacia { border: 2px dashed #b8c7dc; border-radius: .7rem; aspect-ratio: 1 / 1; display: grid; place-items: center; color: #7a8ba8; cursor: pointer; background: #fff; }
.foto-vacia:hover { border-color: var(--marca); color: var(--marca); }
.sala-item { display: flex; align-items: center; gap: .8rem; padding: .75rem 1rem; border-bottom: 1px solid #eef1f6; text-decoration: none; color: inherit; }
.sala-item:hover { background: #f6f9ff; }
.sala-item .icono { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--marca-suave); color: var(--marca); font-size: 1.2rem; flex-shrink: 0; }
.sala-item.cerrada .icono { background: #eceff3; color: #8792a2; }

/* chat */
.chat { display: grid; grid-template-columns: 280px 1fr; gap: 1rem; height: calc(100vh - 140px); min-height: 420px; }
.chat .personas { overflow-y: auto; }
.persona { display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem; text-decoration: none; color: inherit; border-bottom: 1px solid #f0f3f8; }
.persona:hover { background: #f6f9ff; }
.persona.activa { background: var(--marca-suave); }
.persona .punto { width: 9px; height: 9px; border-radius: 50%; background: var(--acento); margin-left: auto; }
.conversacion { display: flex; flex-direction: column; min-height: 0; }
.mensajes { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .45rem; background: #f7f9fd; }
.burbuja { max-width: 75%; padding: .5rem .75rem; border-radius: 1rem; background: #fff; border: 1px solid #e3e9f3; align-self: flex-start; word-wrap: break-word; }
.burbuja.mio { align-self: flex-end; background: var(--marca); color: #fff; border-color: var(--marca); }
.burbuja .hora { font-size: .7rem; opacity: .65; margin-top: .15rem; text-align: right; }
.burbuja .fotos { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .3rem; }
.burbuja .fotos img { width: 110px; height: 110px; object-fit: cover; border-radius: .5rem; cursor: zoom-in; }
.foto-vencida { width: 110px; height: 110px; border-radius: .5rem; background: rgba(0,0,0,.08); display: grid; place-items: center; font-size: .72rem; text-align: center; padding: .3rem; }
.escribir { border-top: 1px solid #e3e9f3; padding: .6rem; background: #fff; }
.adjuntos { font-size: .8rem; color: #5e6c84; }
@media (max-width: 767.98px) {
    .chat { grid-template-columns: 1fr; min-height: 320px; }
    .chat.con-conversacion .personas { display: none; }
    .chat:not(.con-conversacion) .conversacion { display: none; }
}
.visor { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 2100; cursor: zoom-out; }
.visor img { max-width: 95vw; max-height: 92vh; border-radius: .4rem; }

/* ---------- impresión del QR ---------- */
@media print {
    .no-imprimir { display: none !important; }
    body { background: #fff; }
}

/* ---------- aviso flotante (toast) ---------- */
.toast-fijo {
    position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%) translateY(150%);
    background: #172b4d; color: #fff; padding: .65rem 1.1rem; border-radius: .5rem; z-index: 2000;
    box-shadow: 0 8px 24px rgba(0,0,0,.25); transition: transform .25s ease; max-width: 90vw; font-size: .93rem;
}
.toast-fijo.visible { transform: translateX(-50%) translateY(0); }
.toast-fijo.error { background: #c9372c; }
.toast-fijo.ok { background: #1f845a; }

/* Chat General, videos y Galería */
.persona.general { border-bottom: 1px solid #e3e9f3; }
.avatar-general { width: 34px; height: 34px; border-radius: 50%; background: var(--marca-suave); color: var(--marca); display: inline-grid; place-items: center; flex: none; }
.avatar-chico { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
.burbuja .autor { display: flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 600; color: var(--marca); margin-bottom: .2rem; }
.burbuja .fotos video { width: 220px; max-height: 260px; border-radius: .5rem; background: #000; }
.visor video { max-width: 95vw; max-height: 92vh; border-radius: .4rem; background: #000; cursor: auto; }
.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
.medio { position: relative; margin: 0; aspect-ratio: 1; border-radius: .6rem; overflow: hidden; background: #e9eef6; cursor: zoom-in; }
.medio img, .medio video { width: 100%; height: 100%; object-fit: cover; display: block; }
.medio .play { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.6rem; color: rgba(255,255,255,.92); pointer-events: none; }
.medio figcaption { position: absolute; left: 0; right: 0; bottom: 0; padding: .15rem .45rem; font-size: .72rem; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.6)); }

/* Login de participantes: terraza de noche con paralaje (fondo-login.js) */
.login-fondo.fiesta { position: relative; background: #0d1630; overflow-x: hidden; }
.login-fondo.fiesta > :not(.fiesta-fondo) { position: relative; z-index: 1; }
.fiesta-fondo { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0;
    background: linear-gradient(180deg, #0b1330 0%, #18264f 55%, #2b2350 100%); }
.fiesta-fondo .capa { position: absolute; inset: -40px; will-change: transform; }
.fiesta-fondo .luz { position: absolute; border-radius: 50%; filter: blur(6px); animation: luz-flota ease-in-out infinite alternate; }
@keyframes luz-flota { from { transform: translateY(0) scale(1); } to { transform: translateY(-22px) scale(1.12); } }
.fiesta-fondo .edificio { position: absolute; bottom: 40px; background: #0a1126; }
.fiesta-fondo .edificio i { position: absolute; width: 5px; height: 6px; background: #ffd98a; opacity: .55; }
.fiesta-fondo #capa-guirnalda svg { position: absolute; top: 40px; left: 0; width: 100%; height: 16vh; }
.fiesta-fondo .lamparita { fill: #ffe08a; animation: lamparita 3s ease-in-out infinite; }
@keyframes lamparita { 0%, 100% { opacity: .95; } 50% { opacity: .45; } }
.fiesta-fondo .bailarin { position: absolute; bottom: 30px; transform-origin: bottom center; animation: bailar ease-in-out infinite; }
.fiesta-fondo .bailarin svg { width: 100%; height: 100%; fill: #03060f; stroke: #03060f; }
.fiesta-fondo .bailarin .brazo, .fiesta-fondo .bailarin .pierna { fill: none; stroke-width: 7; stroke-linecap: round; }
.fiesta-fondo .bailarin .pierna { stroke-width: 9; }
@keyframes bailar { 0%, 100% { transform: translateY(0) rotate(-5deg); } 50% { transform: translateY(-3vh) rotate(5deg); } }
.fiesta-fondo::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 40%;
    background: linear-gradient(180deg, transparent, rgba(3,6,15,.55)); }
.fiesta-fondo.quieto .luz, .fiesta-fondo.quieto .lamparita, .fiesta-fondo.quieto .bailarin { animation: none; }
@media (prefers-reduced-motion: reduce) { .fiesta-fondo * { animation: none !important; } }

/* Pantallas de participantes: cabecera de noche y mini escenas (escenas.js) */
.cab-noche { position: relative; overflow: hidden; border-radius: 1rem; background: #0d1630; color: #fff;
    padding: 1.6rem 1.25rem 1.1rem; margin-bottom: 1rem; min-height: 112px; display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem; }
.cab-noche.baja { min-height: 0; padding: .9rem 1rem .7rem; }
.cab-noche > :not(.cab-fondo) { position: relative; z-index: 1; }
.cab-noche h1 { margin: 0; }
.cab-noche .text-muted, .cab-noche .small { color: rgba(255,255,255,.75) !important; }
.cab-noche .btn-light { background: rgba(255,255,255,.14); border-color: transparent; color: #fff; }
.cab-noche .btn-outline-primary { color: #fff; border-color: rgba(255,255,255,.55); }
.cab-noche .btn-outline-primary:hover { background: rgba(255,255,255,.16); }
.cab-fondo { position: absolute; inset: 0; pointer-events: none; }
.cab-fondo .capa, .escena .capa { position: absolute; inset: -14px; will-change: transform; transition: transform .25s ease-out; }
.cab-noche .luz, .escena .luz { position: absolute; border-radius: 50%; filter: blur(3px); animation: luz-flota ease-in-out infinite alternate; }
.cab-noche .lamparita, .escena .lamparita { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: #ffe08a; animation: lamparita 3s ease-in-out infinite; }
.escena .lamparita { width: 4px; height: 4px; }
.escena { position: relative; display: block; overflow: hidden; flex-shrink: 0; background: #18264f; }
.escena-sala { width: 70px; height: 44px; border-radius: 9px; }
.escena-mini { width: 34px; height: 34px; border-radius: 9px; }
.escena-vacia { position: absolute; inset: 0; border-radius: inherit; }
.escena.apagada { background: #2a2f3d; }
.escena .pista { inset: auto -6px -3px -6px; height: 100%; }
.escena .bailarin { position: absolute; bottom: 0; transform-origin: bottom center; animation: bailar-chico ease-in-out infinite; }
@keyframes bailar-chico { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-12%) rotate(6deg); } }
.escena .bailarin svg { width: 100%; height: 100%; fill: #03060f; stroke: #03060f; }
.escena .bailarin .trazo { fill: none; stroke-width: 7; stroke-linecap: round; }
.escena.apagada .bailarin { animation: none; }
.escena.apagada .bailarin svg { fill: #1a1e28; stroke: #1a1e28; }
a:hover > .escena .capa, .escena-host:hover .escena .capa { transform: translateY(-3px) scale(1.08); }
.vacio-escena { position: relative; min-height: 220px; height: 100%; border-radius: .6rem; overflow: hidden; }
.vacio-escena .texto { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; color: #fff; z-index: 1; text-align: center; padding: 2.2rem 1rem 1rem; }
.avatar-mini.escribio { animation: saluda 1.1s ease-in-out infinite; transform-origin: bottom center; box-shadow: 0 0 0 2px var(--acento); }
@keyframes saluda { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg) translateY(-2px); } }
.foto-perfil { transition: transform .25s ease; }
.foto-perfil:hover { transform: translateY(-3px) rotate(-1.5deg) scale(1.03); }
@media (prefers-reduced-motion: reduce) { .cab-noche *, .escena *, .avatar-mini.escribio { animation: none !important; transition: none !important; } }
.cab-noche + .chat { height: calc(100vh - 250px); height: calc(100dvh - 250px); }
.cab-noche.baja + .chat { height: calc(100vh - 200px); height: calc(100dvh - 200px); }
.conversacion .vacio-escena { margin: .5rem; height: calc(100% - 1rem); }
/* Panel /appadmin: misma cabecera de noche, más baja (herramienta de trabajo) */
.cab-noche.cab-panel { min-height: 84px; padding: 1.1rem 1.1rem .9rem; align-items: center; }
.cab-noche .btn-outline-success { color: #8ff0c2; border-color: #8ff0c2; }
.cab-noche .btn-outline-success:hover { background: rgba(143,240,194,.16); color: #fff; }
.cab-noche .btn-outline-secondary { color: #fff; border-color: rgba(255,255,255,.55); }
tr:hover .escena .capa, .list-group-item:hover .escena .capa { transform: translateY(-3px) scale(1.08); }
/* Panel en el celular: cada fila de las tablas es una tarjeta (tablas-celular.js pone data-label) */
@media (max-width: 767.98px) {
    .tabla-tarjetas thead { display: none; }
    .tabla-tarjetas, .tabla-tarjetas tbody, .tabla-tarjetas tr, .tabla-tarjetas td { display: block; width: 100%; }
    .tabla-tarjetas tr { position: relative; border: 1px solid #e3e9f3; border-radius: .75rem; margin: 0 0 .7rem; padding: .55rem .8rem; background: #fff; }
    .tabla-tarjetas tr:hover { background: #fff; }
    .tabla-tarjetas td { border: 0 !important; padding: .18rem 0 !important; text-align: left !important; white-space: normal !important; display: flex; gap: .6rem; align-items: center; }
    .tabla-tarjetas td[data-label]::before { content: attr(data-label); flex: 0 0 38%; color: #7a869a; font-size: .78rem; }
    .tabla-tarjetas td:empty { display: none; }
    .tabla-tarjetas td.col-copiar { position: absolute; top: .45rem; right: .5rem; width: auto; }
    .tabla-tarjetas td.col-copiar::before { content: none; }
    .tabla-tarjetas td.text-end { justify-content: flex-end; padding-top: .45rem !important; }
    .tabla-tarjetas td.text-end::before { content: none; }
    .tabla-tarjetas tr.sin-datos td { justify-content: center; }
    .table-responsive:has(.tabla-tarjetas) { overflow-x: visible; }
}
/* QR que cambia cada 30 s (qr-rotativo.js) */
.qr-dibujo { width: 260px; max-width: 100%; aspect-ratio: 1 / 1; }
.qr-dibujo svg { width: 100%; height: 100%; display: block; border-radius: .5rem; }
.qr-barra { height: 6px; border-radius: 3px; background: #e3e9f3; overflow: hidden; max-width: 260px; margin: 0 auto; }
.qr-barra span { display: block; height: 100%; width: 100%; background: var(--marca); transition: width .25s linear; }
.pantalla-qr { justify-content: center; }
.pantalla-qr-caja { position: relative; z-index: 1; padding: 1.5rem; }
.qr-pantalla { width: min(60vh, 86vw); background: #fff; padding: 1rem; border-radius: 1.2rem; box-shadow: 0 25px 60px rgba(0,0,0,.45); }
.qr-barra-grande { max-width: min(60vh, 86vw); height: 10px; background: rgba(255,255,255,.2); }
.qr-barra-grande span { background: #f7b731; }

/* ---- Permisos obligatorios del participante (cámara, micrófono, GPS, push): tapa todo hasta tenerlos ---- */
.permisos { position: fixed; inset: 0; z-index: 2000; background: rgba(13, 18, 40, .92); overflow-y: auto;
    display: flex; align-items: flex-start; justify-content: center; padding: 1rem; }
.permisos.d-none { display: none !important; }
.permisos-caja { background: #fff; border-radius: 1rem; padding: 1.25rem; width: 100%; max-width: 30rem; margin: auto 0;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, .4); }
.permisos-caja .list-group-item i.fs-4 { color: #5b3fd0; width: 2rem; text-align: center; }
body.sin-permisos { overflow: hidden; }
