/* ── Reset & base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

/* ── PÁGINA: REGISTRO ──────────────────────────────────── */
body.page-registro {
    background: #f0f4ff;
    color: #1e293b;
    min-height: 100%;
}

.registro-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 40px 24px 56px;
}

.registro-header {
    text-align: center;
    margin-bottom: 32px;
}

.registro-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 12px;
}

.registro-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 8px;
}

.registro-header p {
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.5;
}

.registro-form {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
}

.required { color: #dc2626; }

.field-group input,
.field-group textarea {
    padding: 12px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    color: #1e293b;
    background: #f8fafc;
    transition: border-color .2s, box-shadow .2s;
    outline: none;
    resize: none;
}

.field-group input:focus,
.field-group textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
    background: #fff;
}

.field-group input.error,
.field-group textarea.error {
    border-color: #ef4444;
}

.field-error {
    font-size: 0.78rem;
    color: #ef4444;
    min-height: 16px;
}

.btn-registrar {
    margin-top: 4px;
    padding: 16px;
    background: #1e40af;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s, transform .1s;
    letter-spacing: .3px;
}

.btn-registrar:active { transform: scale(.98); }
.btn-registrar:disabled { background: #93c5fd; cursor: not-allowed; transform: none; }

.registro-nota {
    font-size: 0.78rem;
    color: #94a3b8;
    text-align: center;
    line-height: 1.5;
}

.alerta-error {
    margin-top: 16px;
    padding: 14px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    color: #dc2626;
    font-size: 0.9rem;
}

/* ── PÁGINA: APP (botón de pánico) ─────────────────────── */
body.page-app {
    background: #0a0a0a;
    color: #fff;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pantalla-carga {
    position: fixed;
    inset: 0;
    background: #0a0a0a;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,.1);
    border-top-color: #dc2626;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.app-main {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 12px;
    background: #111;
    border-bottom: 1px solid #1f1f1f;
}

.usuario-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex-shrink: 0;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #1e40af;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    flex-shrink: 0;
}

.usuario-nombre {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: #f1f5f9;
}

.usuario-estado {
    display: block;
    font-size: 0.75rem;
    color: #22c55e;
    margin-top: 2px;
}

.usuario-estado.offline { color: #ef4444; }

.header-acciones {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-instalar {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #1e40af;
    border: none;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    padding: 7px 12px;
    border-radius: 20px;
    transition: background .2s;
    white-space: nowrap;
}
.btn-instalar:hover { background: #1d4ed8; }

.btn-desregistrar {
    background: none;
    border: none;
    color: #475569;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: color .2s, background .2s;
}

.btn-desregistrar:hover { color: #94a3b8; background: #1f1f1f; }

/* Banner de instalación para iOS */
.banner-ios {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #1e3a8a;
    color: #e0e7ff;
    font-size: 0.82rem;
    padding: 10px 16px;
    border-bottom: 1px solid #1e40af;
}
.banner-ios strong { color: #fff; }
.banner-ios-cerrar {
    background: none;
    border: none;
    color: #93c5fd;
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    padding: 2px 4px;
}

/* Body / estados */
.app-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.estado-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
    width: 100%;
}

/* Instrucciones */
.instruccion {
    font-size: 1rem;
    color: #94a3b8;
    max-width: 280px;
    line-height: 1.5;
}

.instruccion-sub {
    font-size: 0.8rem;
    color: #475569;
}

/* ── Botón de pánico ────────────────────────── */
.boton-wrapper {
    position: relative;
    width: 260px;
    height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    my: 8px;
}

.boton-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid #dc2626;
    opacity: 0;
    animation: expandir 3s ease-out infinite;
}

.ring-1 { width: 220px; height: 220px; animation-delay: 0s; }
.ring-2 { width: 240px; height: 240px; animation-delay: 1s; }
.ring-3 { width: 260px; height: 260px; animation-delay: 2s; }

@keyframes expandir {
    0%   { transform: scale(.7); opacity: .6; }
    100% { transform: scale(1.1); opacity: 0; }
}

.btn-panico {
    position: relative;
    z-index: 1;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ef4444, #b91c1c);
    border: 4px solid #dc2626;
    box-shadow: 0 0 40px rgba(220,38,38,.4), inset 0 -6px 12px rgba(0,0,0,.3);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    user-select: none;
    transition: transform .1s, box-shadow .1s;
    -webkit-user-select: none;
    touch-action: none;
}

.btn-panico:active,
.btn-panico.presionando {
    transform: scale(.95);
    box-shadow: 0 0 20px rgba(220,38,38,.3), inset 0 -2px 6px rgba(0,0,0,.4);
}

.btn-panico.presionando {
    animation: progreso-color 2s linear forwards;
}

@keyframes progreso-color {
    0%   { background: radial-gradient(circle at 35% 35%, #ef4444, #b91c1c); }
    100% { background: radial-gradient(circle at 35% 35%, #fca5a5, #7f1d1d); }
}

.panico-texto { font-size: 2.8rem; font-weight: 900; letter-spacing: 6px; color: #fff; pointer-events: none; }

/* Barra de progreso bajo el botón */
.progreso-barra {
    width: 200px;
    height: 6px;
    background: #1f1f1f;
    border-radius: 3px;
    overflow: hidden;
    opacity: 0;
    transition: opacity .2s;
}

.progreso-barra.visible { opacity: 1; }

.progreso-fill {
    height: 100%;
    width: 0%;
    background: #ef4444;
    border-radius: 3px;
    transition: width .1s linear;
}

/* Estados: enviando / enviado / error */
.estado-icono {
    font-size: 4rem;
    line-height: 1;
}

.enviando-icono { animation: bounce .6s infinite alternate; }

@keyframes bounce {
    from { transform: translateY(0); }
    to   { transform: translateY(-8px); }
}

.estado-titulo {
    font-size: 1.4rem;
    font-weight: 700;
    color: #f1f5f9;
}

.estado-desc {
    font-size: 0.9rem;
    color: #64748b;
    max-width: 280px;
    line-height: 1.5;
}

.btn-nuevo, .btn-reintentar {
    margin-top: 8px;
    padding: 14px 32px;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity .2s;
}

.btn-nuevo { background: #22c55e; color: #fff; }
.btn-reintentar { background: #f59e0b; color: #fff; }

/* ── PIN de comunidad ──────────────────────────────────── */
.paso-pin-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 28px 36px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 4px 32px rgba(0,0,0,.09);
}

.pin-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 36px;
    text-align: center;
}

.pin-logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
    margin-bottom: 14px;
}

.pin-marca {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: #1e40af;
    margin-bottom: 10px;
}

.pin-titulo {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 6px;
}

.pin-desc {
    font-size: .84rem;
    color: #64748b;
    line-height: 1.5;
    text-align: center;
    max-width: 240px;
}

.pin-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
    width: 100%;
}

.pin-boxes {
    display: flex;
    gap: 8px;
    justify-content: center;
    width: 100%;
}

.pin-box {
    flex: 1;
    min-width: 0;
    max-width: 48px;
    height: 58px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    color: #1e293b;
    background: #f8fafc;
    outline: none;
    transition: border-color .2s, box-shadow .2s, background .2s;
    caret-color: transparent;
}

.pin-box:focus {
    border-color: #1e40af;
    box-shadow: 0 0 0 3px rgba(30,64,175,.15);
    background: #fff;
}

.pin-box.filled {
    border-color: #1e40af;
    background: #eff6ff;
}

.pin-box.error-box {
    border-color: #ef4444;
    background: #fef2f2;
    animation: sacudir .35s ease;
}

@keyframes sacudir {
    0%,100% { transform: translateX(0); }
    25%      { transform: translateX(-6px); }
    75%      { transform: translateX(6px); }
}

.pin-error {
    font-size: .85rem;
    color: #ef4444;
    font-weight: 600;
    min-height: 20px;
    text-align: center;
}

.btn-pin-ingresar {
    width: 100%;
    padding: 16px;
    background: #1e40af;
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: .3px;
    transition: background .2s, opacity .2s, transform .1s;
}
.btn-pin-ingresar:disabled {
    background: #bfdbfe;
    cursor: not-allowed;
}
.btn-pin-ingresar:not(:disabled):hover  { background: #1d4ed8; }
.btn-pin-ingresar:not(:disabled):active { transform: scale(.98); }

.pin-comunidad-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    font-size: .82rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 50px;
    margin-bottom: 4px;
}

/* ── Formulario por pasos ──────────────────────────────── */
.paso-form-card {
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 4px 32px rgba(0,0,0,.09);
    overflow: hidden;
}

.form-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #f1f5f9;
}

.form-card-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
}

.form-card-marca {
    font-size: .65rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #1e40af;
}

.form-card-comunidad {
    font-size: .78rem;
    font-weight: 600;
    color: #64748b;
    margin-top: 1px;
}

/* Indicador de pasos */
.pasos-indicador {
    display: flex;
    align-items: center;
    padding: 16px 24px 12px;
    gap: 0;
}

.paso-item {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.paso-circulo {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #94a3b8;
    font-size: .78rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .3s, color .3s;
}

.paso-item span {
    font-size: .78rem;
    font-weight: 600;
    color: #94a3b8;
    transition: color .3s;
}

.paso-item.activo .paso-circulo {
    background: #1e40af;
    color: #fff;
}

.paso-item.activo span { color: #1e293b; }

.paso-item.completado .paso-circulo {
    background: #16a34a;
    color: #fff;
}

.paso-linea {
    flex: 1;
    height: 2px;
    background: #e2e8f0;
    margin: 0 10px;
    transition: background .3s;
}

.paso-linea.completada { background: #16a34a; }

/* Contenido de cada paso */
.form-paso {
    padding: 8px 24px 24px;
    animation: entrar .25s ease;
}

@keyframes entrar {
    from { opacity: 0; transform: translateX(16px); }
    to   { opacity: 1; transform: translateX(0); }
}

.paso-titulo {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 18px;
}

.btn-paso-siguiente {
    width: 100%;
    margin-top: 8px;
    padding: 15px;
    background: #1e40af;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s, transform .1s;
}
.btn-paso-siguiente:hover  { background: #1d4ed8; }
.btn-paso-siguiente:active { transform: scale(.98); }

.paso-botones {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.btn-paso-atras {
    padding: 15px 18px;
    background: transparent;
    border: 1.5px solid #e2e8f0;
    color: #64748b;
    border-radius: 12px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .2s, color .2s;
    white-space: nowrap;
}
.btn-paso-atras:hover { border-color: #94a3b8; color: #1e293b; }

.btn-paso-enviar {
    flex: 1;
    padding: 15px;
    background: #1e40af;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s, transform .1s;
}
.btn-paso-enviar:disabled { background: #93c5fd; cursor: not-allowed; }
.btn-paso-enviar:not(:disabled):hover  { background: #1d4ed8; }
.btn-paso-enviar:not(:disabled):active { transform: scale(.98); }

/* ── Consentimiento (Ley 21.719) ───────────────────────── */
.consentimiento-box {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.politica-toggle {
    background: none;
    border: none;
    color: #1e40af;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    padding: 0;
}
.politica-toggle:hover { text-decoration: underline; }

.politica-texto {
    font-size: 0.8rem;
    color: #475569;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid #e2e8f0;
    padding-top: 12px;
}
.politica-texto strong { color: #1e293b; }

.consentimiento-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 0.84rem;
    color: #374151;
    line-height: 1.5;
}
.consentimiento-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
    accent-color: #1e40af;
    cursor: pointer;
}

/* ── Barra fija de instalación (iOS + Android) ─────────── */
.barra-instalar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 150;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #1e3a8a;
    color: #fff;
    padding: 14px 20px;
    box-shadow: 0 -2px 16px rgba(0,0,0,.2);
}

.barra-instalar-icono {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 10px;
    flex-shrink: 0;
}

.barra-instalar-texto {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.barra-instalar-texto strong {
    font-size: 0.9rem;
    font-weight: 700;
}

.barra-instalar-texto span {
    font-size: 0.75rem;
    color: #93c5fd;
}

.barra-instalar-btn {
    background: #fff;
    color: #1e3a8a;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Modal de instalación PWA ──────────────────────────── */
.modal-instalar {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.55);
}

.modal-sheet {
    position: relative;
    background: #fff;
    border-radius: 24px 24px 0 0;
    padding: 12px 28px 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    animation: modal-subir .35s cubic-bezier(.22,.61,.36,1);
}

@keyframes modal-subir {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.modal-barra {
    width: 40px;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    margin-bottom: 6px;
}

.modal-icono {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
}

.modal-titulo {
    font-size: 1.15rem;
    font-weight: 800;
    color: #1e293b;
    margin-top: 4px;
}

.modal-desc {
    font-size: 0.88rem;
    color: #64748b;
    line-height: 1.55;
    max-width: 280px;
}

.modal-btn-instalar {
    width: 100%;
    padding: 16px;
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 6px;
    transition: background .2s;
}
.modal-btn-instalar:hover { background: #b91c1c; }

.modal-ios-pasos {
    background: #f1f5f9;
    border-radius: 14px;
    padding: 16px;
    width: 100%;
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ios-guia-titulo {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #94a3b8;
    text-align: center;
    margin-bottom: 2px;
}

.ios-paso {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ios-paso-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #1e40af;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ios-paso-body {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.86rem;
    color: #475569;
    line-height: 1.4;
    text-align: left;
}
.ios-paso-body strong { color: #1e293b; }

.ios-share-svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: #1e40af;
}

.modal-btn-cancelar {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 0.88rem;
    cursor: pointer;
    padding: 6px 12px;
    margin-top: 2px;
}

/* Footer */
.app-footer {
    padding: 10px 20px 20px;
    text-align: center;
    font-size: 0.75rem;
    color: #374151;
    min-height: 40px;
}
