/* ── Variables institucionales Gobernación del Tolima ─── */
:root {
    --tl-magenta: #A4025A;
    --tl-dorado: #F8B135;
    --tl-rojo: #BF2116;
    --tl-verde: #0F7641;
    --tl-tinta: #1F2937;
    --tl-gris: #6B7280;
    --tl-fondo: #F9FAFB;
    --tl-borde: #E5E7EB;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--tl-fondo);
    color: var(--tl-tinta);
}

/* ── Encabezado institucional ────────────────────────── */
.header-institucional {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-bottom: 4px solid var(--tl-magenta);
    padding: 1rem 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.header-institucional img {
    max-height: 70px;
    width: auto;
}

.titulo-formulario {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--tl-magenta);
    line-height: 1.35;
    text-align: center;
    margin-top: 0.75rem;
}

@media (min-width: 768px) {
    .titulo-formulario { font-size: 1.2rem; }
    .header-institucional img { max-height: 85px; }
}

/* ── Triatomino marca de agua ────────────────────────── */
.watermark-triatomino {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 80px;
    height: 80px;
    opacity: 0.04;
    pointer-events: none;
    z-index: 0;
}

/* ── Formulario ──────────────────────────────────────── */
.form-registro {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    padding: 1.5rem;
    margin-top: 1rem;
    position: relative;
    z-index: 1;
}

.form-registro .form-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--tl-tinta);
    margin-bottom: 0.35rem;
}

.form-registro .form-label .badge {
    font-size: 0.7rem;
    font-weight: 500;
}

.pregunta-grupo {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--tl-borde);
}

.pregunta-grupo:last-of-type {
    border-bottom: none;
}

.pregunta-numero {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--tl-magenta);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 0.4rem;
    flex-shrink: 0;
}

/* Select2 ajustes */
.select2-container--bootstrap-5 .select2-selection {
    border-color: var(--tl-borde) !important;
    min-height: 38px;
}
.select2-container--bootstrap-5 .select2-selection--single:focus,
.select2-container--bootstrap-5.select2-container--focus .select2-selection {
    border-color: var(--tl-magenta) !important;
    box-shadow: 0 0 0 0.2rem rgba(164, 2, 90, 0.15) !important;
}

/* ── Botón principal ─────────────────────────────────── */
.btn-registrar {
    background: var(--tl-magenta);
    border-color: var(--tl-magenta);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-registrar:hover,
.btn-registrar:focus {
    background: #8a0150;
    border-color: #8a0150;
    color: #fff;
    box-shadow: 0 4px 12px rgba(164, 2, 90, 0.3);
}

.btn-registrar:disabled {
    background: #ccc;
    border-color: #ccc;
}

/* ── Alerta de precarga ──────────────────────────────── */
.alert-precarga {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    display: none;
}

.alert-precarga.show { display: block; }

/* ── Tratamiento de datos ────────────────────────────── */
.tratamiento-box {
    background: #f8f9fa;
    border: 2px solid var(--tl-borde);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    max-height: 220px;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.tratamiento-check {
    background: #fffbeb;
    border: 2px solid var(--tl-dorado);
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

/* ── Franja inferior institucional ───────────────────── */
.footer-institucional {
    background: var(--tl-tinta);
    color: #9CA3AF;
    font-size: 0.78rem;
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
}

.footer-institucional a {
    color: var(--tl-dorado);
    text-decoration: none;
}

/* ── Éxito ───────────────────────────────────────────── */
.exito-container {
    text-align: center;
    padding: 3rem 1rem;
}

.exito-container .check-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--tl-verde);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.exito-container .check-icon i { font-size: 2.5rem; color: #fff; }

/* ── Éxito: evento registrado y aviso de salida ───────── */
.exito-evento {
    max-width: 460px;
    margin: 0.5rem auto 1rem;
    padding: 1rem 1.15rem;
    background: #fdf2f8;
    border: 1px solid rgba(164, 2, 90, .25);
    border-radius: 0.9rem;
}

.exito-evento .ev-etiqueta {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #8a5568;
}

.exito-evento .ev-nombre {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--tl-magenta);
    margin-top: 0.15rem;
    line-height: 1.25;
}

.exito-evento .ev-cuando {
    margin-top: 0.35rem;
    font-size: 0.95rem;
    color: #444;
}

.exito-mensaje {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.exito-salir {
    max-width: 480px;
    margin: 1.25rem auto 0;
    padding: 0.85rem 1rem;
    background: #fff7e6;
    border: 1px solid #ffe0a3;
    border-radius: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #7a5200;
    line-height: 1.35;
}

/* ── Login ───────────────────────────────────────────── */
.login-card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    max-width: 400px;
    margin: 0 auto;
}

.login-bg {
    min-height: 100vh;
    background: linear-gradient(160deg, var(--tl-tinta) 0%, #374151 45%, #4B5563 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-triatomino {
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem;
    display: block;
    filter: brightness(0) invert(1);
    opacity: 0.7;
}

/* ── Admin / Panel ───────────────────────────────────── */
.admin-sidebar {
    background: var(--tl-tinta);
    min-height: 100vh;
}

.stat-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-2px); }

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--tl-tinta);
}

.stat-card .stat-label {
    font-size: 0.78rem;
    color: var(--tl-gris);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filtros-panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.tabla-respuestas {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
}

.tabla-respuestas table thead {
    background: var(--tl-tinta);
    color: #fff;
}

.tabla-respuestas table thead th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 0.75rem 0.5rem;
    border: none;
}

.tabla-respuestas table tbody td {
    font-size: 0.85rem;
    vertical-align: middle;
    padding: 0.6rem 0.5rem;
}

.tabla-respuestas table tbody tr:hover {
    background: #f0fdf4;
}

.btn-export-excel {
    background: var(--tl-verde);
    border-color: var(--tl-verde);
    color: #fff;
}
.btn-export-excel:hover { background: #0a5c33; color: #fff; }

.btn-export-pdf {
    background: var(--tl-rojo);
    border-color: var(--tl-rojo);
    color: #fff;
}
.btn-export-pdf:hover { background: #9e1b12; color: #fff; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 576px) {
    .form-registro { padding: 1rem; border-radius: 0; }
    .pregunta-grupo { padding: 0.5rem 0; }
    .titulo-formulario { font-size: 0.92rem; }
    .btn-registrar { width: 100%; padding: 1rem; font-size: 1.15rem; }
    .watermark-triatomino { width: 50px; height: 50px; bottom: 10px; right: 10px; }
}

/* ── Turnstile ───────────────────────────────────────── */
.cf-turnstile {
    margin: 1rem auto;
    display: flex;
    justify-content: center;
}

/* ── Enfoque diferencial checkboxes ──────────────────── */
.enfoque-checks .form-check {
    display: inline-flex;
    align-items: center;
    margin-right: 1rem;
    margin-bottom: 0.5rem;
}

.enfoque-checks .form-check-input:checked {
    background-color: var(--tl-magenta);
    border-color: var(--tl-magenta);
}

/* ── Animación de carga ──────────────────────────────── */
.spinner-precarga {
    display: none;
}

.spinner-precarga.active {
    display: inline-block;
}

/* ══════════════════════════════════════════════════════
   Barra de estado (conexión / registros pendientes)
   ══════════════════════════════════════════════════════ */
.barra-estado {
    background-color: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
}

.barra-estado .badge {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.45rem 0.7rem;
}

/* ══════════════════════════════════════════════════════
   Verificación de seguridad (Turnstile por dispositivo)
   ══════════════════════════════════════════════════════ */
.seguridad-header {
    color: var(--tl-magenta);
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

#turnstileWrap {
    background: linear-gradient(135deg, #fdf4f8 0%, #ffffff 100%);
    border: 1px dashed rgba(164, 2, 90, .35);
    border-radius: 1rem;
}

/* ══════════════════════════════════════════════════════
   Modo rápido — la persona ya está registrada
   ══════════════════════════════════════════════════════ */
.mr-saludo {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, var(--tl-magenta) 0%, #7d0245 100%);
    border-radius: 1rem;
    color: #fff;
}

.mr-icono {
    flex: 0 0 auto;
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, .2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}

.mr-hola {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    opacity: .85;
}

.mr-nombre {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.2;
}

.mr-doc {
    font-size: 0.85rem;
    opacity: .9;
    margin-top: 0.15rem;
}

.mr-mensaje {
    margin: 1rem 0 0;
    padding: 0.75rem 1rem;
    background: #fdf2f8;
    border: 1px solid rgba(164, 2, 90, .25);
    border-radius: 0.75rem;
    color: #6b0238;
    font-size: 0.95rem;
    text-align: center;
}

.mr-editar {
    margin: 1.25rem 0 0.75rem;
    text-align: center;
    font-size: 0.95rem;
    color: #555;
}

.mr-link-editar {
    color: var(--tl-magenta);
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.mr-link-editar:hover {
    text-decoration: underline;
}

.btn-soy-otra {
    display: block;
    width: 100%;
    padding: 0.85rem 1rem;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: .02em;
    color: var(--tl-magenta);
    background: #fff;
    border: 2px solid var(--tl-magenta);
    border-radius: 0.75rem;
}

.btn-soy-otra:hover {
    color: #fff;
    background: var(--tl-magenta);
}

.mr-legal {
    margin: 1rem 0 0.75rem;
    text-align: center;
    font-size: 0.8rem;
    color: #6c757d;
}

/* ══════════════════════════════════════════════════════
   Cards de evento (reemplazan el <select> del evento)
   ══════════════════════════════════════════════════════ */
.evento-cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.evento-card {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 0.6rem;
    align-items: start;
    padding: 0.7rem 0.9rem;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.evento-card:hover {
    border-color: rgba(164, 2, 90, .5);
}

.evento-card .evento-radio {
    grid-column: 1;
    grid-row: 1 / span 3;
    margin-top: 0.3rem;
}

.evento-card .evc-nombre,
.evento-card .evc-fecha,
.evento-card .evc-check,
.evento-card .evc-nofut {
    grid-column: 2;
}

.evento-card .evc-nombre {
    font-weight: 700;
    color: var(--tl-magenta);
    line-height: 1.25;
}

.evento-card .evc-fecha {
    font-size: 0.85rem;
    color: #555;
    margin-top: 0.2rem;
}

.evento-card .evc-check {
    display: none;
    font-size: 0.85rem;
    font-weight: 600;
    color: #1e7e34;
    margin-top: 0.3rem;
}

.evento-card .evc-nofut {
    display: none;
    font-size: 0.85rem;
    font-weight: 600;
    color: #868e96;
    margin-top: 0.3rem;
}

/* Evento futuro (aún no disponible): gris y no seleccionable */
.evento-card.no-disponible {
    background: #f1f3f5;
    border-color: #dee2e6;
    cursor: default;
}

.evento-card.no-disponible .evc-nombre {
    color: #868e96;
}

.evento-card.no-disponible .evc-nofut {
    display: inline-flex;
    align-items: center;
}

/* Evento ya registrado: verde y no seleccionable */
.evento-card.ya-registrado {
    background: #e6f4ea;
    border-color: #b7dfc4;
    cursor: default;
}

.evento-card.ya-registrado .evc-nombre {
    color: #1e7e34;
}

.evento-card.ya-registrado .evc-check {
    display: inline-flex;
    align-items: center;
}

/* Evento seleccionado */
.evento-card.seleccionado {
    border-color: var(--tl-magenta);
    box-shadow: 0 0 0 0.18rem rgba(164, 2, 90, .15);
}

/* ══════════════════════════════════════════════════════
   Ajustes móviles generales
   ══════════════════════════════════════════════════════ */
@media (max-width: 576px) {
    .mr-nombre { font-size: 1.15rem; }
    .mr-icono { width: 2.75rem; height: 2.75rem; font-size: 1.35rem; }
    .header-institucional { padding: 0.75rem 0; }
}

/* Evita el zoom automático en iOS al enfocar campos */
@supports (-webkit-touch-callout: none) {
    .form-control, .form-select, input, select, textarea {
        font-size: 16px !important;
    }
}

/* ══════════════════════════════════════════════════════
   Triatomino que camina mientras se diligencia el formulario
   ══════════════════════════════════════════════════════ */
.bicho-andante {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 104px;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
    opacity: 0.5;
}

body.form-visible .bicho-andante {
    display: block;
}

.bicho-pista {
    position: absolute;
    bottom: 8px;
    left: 0;
    width: 56px;
    animation: bicho-cruza 26s linear infinite;
    will-change: transform;
}

.bicho-pista svg {
    display: block;
    width: 56px;
    height: 73px;
    transform-origin: bottom center;
    animation: bicho-bob 0.5s ease-in-out infinite;
}

.bicho-pista .pata {
    transform-box: fill-box;
}
.bicho-pista .p1 { animation: pata-mueve 0.5s ease-in-out infinite; }
.bicho-pista .p2 { animation: pata-mueve 0.5s ease-in-out infinite; animation-delay: -0.17s; }
.bicho-pista .p3 { animation: pata-mueve 0.5s ease-in-out infinite; animation-delay: -0.34s; }

@keyframes bicho-cruza {
    0%   { transform: translateX(-70px) scaleX(1); }
    46%  { transform: translateX(calc(100vw + 10px)) scaleX(1); }
    50%  { transform: translateX(calc(100vw + 10px)) scaleX(-1); }
    96%  { transform: translateX(-70px) scaleX(-1); }
    100% { transform: translateX(-70px) scaleX(1); }
}

@keyframes bicho-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-2px); }
}

@keyframes pata-mueve {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(3px); }
}

/* Las animaciones se respetan si el usuario las prefiere reducidas */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
    /* El triatomino camina aunque el sistema pida menos movimiento */
    .bicho-pista { animation-duration: 26s !important; }
    .bicho-pista svg { animation-duration: 0.5s !important; }
    .bicho-pista .p1,
    .bicho-pista .p2,
    .bicho-pista .p3 { animation-duration: 0.5s !important; }
}
