/* =========================================================================
   SISTEMA AISLADO: HEADER MODALES (Prefijo: phm- / Premium Header Modales)
   ========================================================================= */

/* --- VARIABLES GLOBALES DE MODALES (Light & Dark) --- */
:root {
    /* MODO CLARO (Fondo de wizard totalmente sólido) */
    --phm-overlay-bg: rgba(15, 23, 42, 0.7);
    --phm-fs-overlay-bg: #f8fafc;
    --phm-modal-bg: #ffffff;
    --phm-modal-border: #cbd5e1;
    --phm-text-main: #0f172a;
    --phm-text-muted: #64748b;
    --phm-primary: #0ea5e9;
    --phm-primary-hover: #0284c7;
    --phm-success: #10b981;
    --phm-danger: #ef4444;
    --phm-input-bg: #ffffff;
    --phm-input-border: #cbd5e1;
    --phm-block-bg: #f1f5f9;
    --phm-track-bg: #e2e8f0;
    --phm-shadow-card: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

body.dark-mode {
    /* MODO OSCURO (Fondo de wizard totalmente sólido) */
    --phm-overlay-bg: rgba(2, 6, 23, 0.85);
    --phm-fs-overlay-bg: #0b0f19;
    --phm-modal-bg: #1e293b;
    --phm-modal-border: #334155;
    --phm-text-main: #f8fafc;
    --phm-text-muted: #94a3b8;
    --phm-primary: #38bdf8;
    --phm-primary-hover: #7dd3fc;
    --phm-success: #10b981;
    --phm-danger: #f87171;
    --phm-input-bg: #090e18;
    --phm-input-border: #334155;
    --phm-block-bg: #0f172a;
    --phm-track-bg: #334155;
    --phm-shadow-card: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

/* =========================================================================
   CONTENEDORES Y OVERLAYS
   ========================================================================= */

/* Overlay para modales centrados (QR, Junta, Confirmación) */
.phm-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--phm-overlay-bg);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 20px;
    animation: phmFadeIn 0.3s ease forwards;
}

/* Overlay Fullscreen (Wizard Verificador) - Estrictamente bloqueado sin scroll */
.phm-fs-overlay {
    position: fixed;
    inset: 0;
    width: 100vw; 
    height: 100dvh;
    background: var(--phm-fs-overlay-bg);
    z-index: 999999;
    overflow: hidden; /* Scroll eliminado del overlay */
    animation: phmFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Fallback para navegadores antiguos que no soporten 100dvh */
@supports not (height: 100dvh) {
    .phm-fs-overlay {
        height: 100%;
    }
}

/* Tarjeta estándar centrada */
.phm-card {
    background: var(--phm-modal-bg);
    border: 1px solid var(--phm-modal-border);
    padding: 30px;
    border-radius: 20px;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--phm-shadow-card);
    position: relative;
    transition: all 0.3s ease;
}

/* Animaciones Base */
@keyframes phmFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes phmSlideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes phmScaleUp {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Botón Cerrar (General) */
.phm-btn-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--phm-block-bg);
    border: none;
    font-size: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--phm-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.2s ease;
    z-index: 10;
}
.phm-btn-close:hover {
    background: var(--phm-danger);
    color: #ffffff;
    transform: scale(1.1);
}

/* =========================================================================
   ELEMENTOS DE FORMULARIO COMUNES
   ========================================================================= */
.phm-form-group {
    margin-bottom: 16px;
    width: 100%;
}
.phm-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--phm-primary);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.phm-input, .phm-select {
    width: 100%;
    height: 50px;
    padding: 8px 18px;
    font-size: 15px;
    color: var(--phm-text-main);
    background-color: var(--phm-input-bg);
    border: 2px solid var(--phm-input-border);
    border-radius: 16px;
    box-sizing: border-box;
    transition: all 0.3s ease;
    outline: none;
}
.phm-input:focus, .phm-select:focus {
    border-color: var(--phm-primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}
.phm-input[readonly] {
    background-color: var(--phm-block-bg);
    color: var(--phm-text-muted);
    cursor: not-allowed;
    border-color: var(--phm-modal-border);
}
.phm-input-file {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    color: var(--phm-text-muted);
    background: var(--phm-input-bg);
    border: 2px dashed var(--phm-input-border);
    border-radius: 16px;
    cursor: pointer;
}

/* =========================================================================
   ESTILOS ESPECÍFICOS: MODAL QR
   ========================================================================= */
.phm-qr-text-center { text-align: center; }
.phm-qr-title { margin: 0 0 5px 0; color: var(--phm-text-main); font-size: 18px; }
.phm-qr-subtitle { font-size: 12px; color: var(--phm-text-muted); margin-bottom: 15px; }

.phm-qr-box {
    background: var(--phm-input-bg);
    padding: 15px;
    border-radius: 12px;
    border: 2px dashed var(--phm-input-border);
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}
.phm-qr-loading { color: var(--phm-primary); font-weight: 600; font-size: 14px; }
.phm-qr-img { width: 200px; height: 200px; border-radius: 8px; }

.phm-qr-progress-wrapper {
    width: 100%; background: var(--phm-track-bg); height: 6px; border-radius: 10px; overflow: hidden; margin-bottom: 5px;
}
.phm-qr-progress-bar {
    height: 100%; width: 100%; background: var(--phm-primary); transition: width 1s linear;
}
.phm-qr-timer { font-size: 11px; font-weight: 700; color: var(--phm-primary); }

.phm-qr-success-icon { font-size: 60px; margin-bottom: 15px; animation: phmScaleUp 0.5s ease; }
.phm-qr-success-title { color: var(--phm-success); margin: 0 0 10px 0; font-size: 22px; }
.phm-qr-success-desc { font-size: 14px; font-weight: 700; color: var(--phm-text-main); margin-bottom: 20px; }
.phm-qr-success-footer { background: var(--phm-block-bg); padding: 10px; border-radius: 8px; font-size: 12px; color: var(--phm-text-muted); }
.phm-qr-success-footer span { font-weight: 900; color: var(--phm-danger); font-size: 14px; }

/* Escáner & Confirmación */
.phm-scanner-viewport { width: 100%; background: #000; border-radius: 12px; overflow: hidden; margin-bottom: 15px; min-height: 250px; }
.phm-btn-block {
    width: 100%; height: 45px; border-radius: 12px; font-weight: 700; cursor: pointer; border: none; transition: 0.3s;
}
.phm-btn-primary { background: var(--phm-primary); color: #fff; }
.phm-btn-primary:hover { background: var(--phm-primary-hover); }
.phm-btn-cancel { background: var(--phm-block-bg); color: var(--phm-text-main); margin-top: 10px; }

/* =========================================================================
   ESTILOS ESPECÍFICOS: JUNTA DIRECTIVA
   ========================================================================= */
.phm-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.phm-modal-header h3 { margin: 0; color: var(--phm-text-main); font-size: 20px; }
.phm-alert-info {
    background: rgba(14, 165, 233, 0.1); border-left: 4px solid var(--phm-primary);
    padding: 12px; font-size: 13px; color: var(--phm-text-main); margin-bottom: 15px; border-radius: 4px;
}

/* =========================================================================
   WIZARD FULL SCREEN (VERIFICADOR)
   ========================================================================= */

/* Contenedor principal del Wizard - Layout de Columna Estricto */
.phm-fs-container {
    max-width: 500px;
    width: 100%;
    height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: transparent;
    position: relative;
    box-sizing: border-box; 
}

.phm-fs-header {
    padding: max(20px, env(safe-area-inset-top)) 20px 20px;
    background: var(--phm-modal-bg);
    border-bottom: 1px solid var(--phm-modal-border);
    border-radius: 0 0 30px 30px;
    box-shadow: var(--phm-shadow-card);
    margin-bottom: 10px;
    flex-shrink: 0; /* Evita que el header colapse o se encoja */
    position: relative;
    z-index: 10;
}

/* Nodos de Progreso */
.phm-progress-wrapper { position: relative; width: 100%; max-width: 400px; margin: 0 auto; padding-top: 15px; }
.phm-progress-track { position: absolute; top: 30px; left: 10%; right: 10%; height: 4px; background: var(--phm-track-bg); border-radius: 2px; z-index: 1; }
.phm-progress-fill { height: 100%; width: 0%; background: var(--phm-primary); border-radius: 2px; transition: width 0.5s ease; }
.phm-nodes { display: flex; justify-content: space-between; position: relative; z-index: 2; }
.phm-node { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 50px; }

.phm-node-icon {
    width: 32px; height: 32px; border-radius: 50%; background: var(--phm-modal-bg);
    border: 2px solid var(--phm-track-bg); display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; color: var(--phm-text-muted); transition: all 0.4s ease;
}
.phm-node-label { font-size: 10px; font-weight: 600; color: var(--phm-text-muted); text-align: center; }

.phm-node.active .phm-node-icon {
    border-color: var(--phm-primary); background: var(--phm-primary); color: #fff; transform: scale(1.15);
}
.phm-node.active .phm-node-label { color: var(--phm-primary); }
.phm-node.completed .phm-node-icon { border-color: var(--phm-success); background: var(--phm-success); color: #fff; }
.phm-node.completed .phm-node-label { color: var(--phm-text-main); }

/* Pasos del Wizard - Scroll Habilitado Solo Aquí */
.phm-fs-body { 
    padding: 10px 20px 20px 20px; 
    flex: 1; 
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch; 
}
.phm-step { display: none; animation: phmSlideInRight 0.4s ease; }
.phm-step.active { display: block; }

.phm-step-title {
    font-size: 24px; font-weight: 800; color: var(--phm-text-main);
    margin: 0 0 8px 0; line-height: 1.2; text-align: center;
}
.phm-step-desc { font-size: 14px; color: var(--phm-text-muted); margin: 0 0 24px 0; text-align: center; }

/* Bloques Grises */
.phm-card-block {
    background: var(--phm-block-bg); border: 1px solid var(--phm-modal-border);
    border-radius: 20px; padding: 20px; margin-bottom: 20px;
}

/* Tarjetas de Rol (Radio Buttons) */
.phm-role-wrapper { display: block; margin-bottom: 16px; cursor: pointer; }
.phm-role-wrapper input { display: none; }
.phm-role-card {
    display: flex; align-items: center; gap: 16px; padding: 18px 20px;
    background: var(--phm-modal-bg); border: 2px solid var(--phm-modal-border);
    border-radius: 20px; transition: all 0.3s ease;
}
.phm-role-icon {
    width: 48px; height: 48px; border-radius: 14px; background: var(--phm-block-bg);
    color: var(--phm-primary); font-size: 24px; display: flex; align-items: center; justify-content: center;
}
.phm-role-info h4 { margin: 0 0 4px 0; font-size: 18px; font-weight: 700; color: var(--phm-text-main); }
.phm-role-info p { margin: 0; font-size: 13px; color: var(--phm-text-muted); }

.phm-role-wrapper input:checked + .phm-role-card {
    border-color: var(--phm-primary); background: rgba(14, 165, 233, 0.05); transform: translateY(-3px);
}
.phm-role-wrapper input:checked + .phm-role-card .phm-role-icon {
    background: var(--phm-primary); color: #fff;
}

/* Custom Checkbox */
.phm-checkbox-wrapper { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; margin-bottom: 15px; }
.phm-checkbox-wrapper input { display: none; }
.phm-checkbox-box {
    width: 22px; height: 22px; border: 2px solid var(--phm-input-border); border-radius: 6px;
    flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: 0.2s;
}
.phm-checkbox-wrapper span { font-size: 14px; color: var(--phm-text-main); line-height: 1.4; }
.phm-checkbox-wrapper input:checked + .phm-checkbox-box { background: var(--phm-success); border-color: var(--phm-success); }
.phm-checkbox-wrapper input:checked + .phm-checkbox-box::after { content: "✓"; color: white; font-size: 14px; font-weight: bold; }

/* Footer del Wizard - Integrado al flujo Flexbox */
.phm-fs-footer {
    flex-shrink: 0;
    background: var(--phm-modal-bg);
    border-top: 1px solid var(--phm-modal-border);
    padding: 15px 20px max(15px, env(safe-area-inset-bottom));
    display: flex; justify-content: center; gap: 15px; z-index: 100;
}
@media (min-width: 500px) {
    .phm-fs-footer {
        border-radius: 24px 24px 0 0; border: 1px solid var(--phm-modal-border); border-bottom: none;
    }
}

.phm-btn-nav {
    flex: 1; height: 50px; border-radius: 30px; font-size: 15px; font-weight: 700;
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: 0.3s;
}
.phm-btn-nav-sec { background: transparent; border: 2px solid var(--phm-modal-border); color: var(--phm-text-main); }
.phm-btn-nav-sec:hover { background: var(--phm-block-bg); }
.phm-btn-nav-pri { background: var(--phm-primary); border: none; color: white; }
.phm-btn-nav-pri:disabled { background: var(--phm-track-bg); color: var(--phm-text-muted); cursor: not-allowed; }


/* =========================================================================
   INPUTS BLOQUEADOS CON CANDADO Y TOOLTIP (Activado al hacer clic en el campo)
   ========================================================================= */

/* Contenedor relativo para posicionar el candado y el tooltip */
.phm-input-wrapper {
    position: relative;
    width: 100%;
}

/* Espacio a la derecha para que el texto no choque con el candado */
.phm-input-wrapper .phm-input {
    padding-right: 45px; 
}

/* El botón del candado (estético y funcional) */
.phm-input-lock {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--phm-text-muted);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: color 0.3s ease;
}

.phm-input-lock:hover {
    color: var(--phm-primary);
}

/* El globo de texto (Tooltip) */
.phm-tooltip {
    position: absolute;
    bottom: calc(100% + 8px); /* Justo arriba del input */
    right: 0; 
    background: var(--phm-modal-bg);
    border: 1px solid var(--phm-modal-border);
    box-shadow: var(--phm-shadow-card);
    color: var(--phm-text-main);
    font-size: 11px;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: 10px;
    width: 240px;
    text-align: right;
    line-height: 1.4;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    z-index: 10;
}

/* Triangulito del tooltip */
.phm-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 18px;
    border-width: 6px;
    border-style: solid;
    border-color: var(--phm-modal-border) transparent transparent transparent;
}

/* MAGIA: Muestra el tooltip cuando el input recibe foco (clic) o interactúan con el wrapper */
.phm-input-wrapper:focus-within .phm-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Cambia de color el icono del candado cuando el campo está seleccionado/enfocado */
.phm-input-wrapper:focus-within .phm-input-lock {
    color: var(--phm-primary);
}