/*==================================================
        CALCULADORA DE MODALIDAD 40 - PENSIONHUB
==================================================*/

/* Contenedor Principal */
.phcrm-calculadora {
    background: #ffffff;
    border-radius: 20px;
    padding: 35px;
    box-shadow: 0 15px 35px rgba(4, 3, 74, 0.08);
    border: 1px solid #eef2f7;
    max-width: 800px;
    margin: 0 auto;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Títulos del Paso */
.ph-step h2,
.phcrm-card h2 {
    color: #04034a;
    font-size: 22px;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eef2f7;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Tarjetas Internas */
.phcrm-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
}

/* Grid para Formulario (2 o 3 columnas) */
.phcrm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 20px;
}

/* Campos de Formulario */
.phcrm-campo {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Etiquetas (Labels) */
.ph-step label,
.phcrm-campo label {
    font-size: 14px;
    font-weight: 600;
    color: #04034a;
}

/* Controles de Formulario (Inputs, Selects, Dates) */
.ph-step input[type="text"],
.ph-step input[type="number"],
.ph-step input[type="date"],
.ph-step select,
.phcrm-campo input,
.phcrm-campo select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid #cbd5e1;
    border-radius: 12px;
    font-size: 15px;
    color: #1e293b;
    background-color: #ffffff;
    transition: all 0.25s ease;
    outline: none;
    box-sizing: border-box;
}

/* Efecto al seleccionar un input/select */
.ph-step input:focus,
.ph-step select:focus,
.phcrm-campo input:focus,
.phcrm-campo select:focus {
    border-color: #5b9f3b;
    box-shadow: 0 0 0 4px rgba(91, 159, 59, 0.15);
}

/*==================================================
                BOTONES DE NAVEGACIÓN
==================================================*/

/* Botones de "Continuar" y "Calcular" (Principales) */
button[id^="btnPaso"],
#btnCalcular {
    background: linear-gradient(135deg, #5b9f3b 0%, #48842e 100%);
    color: #ffffff;
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 14px rgba(91, 159, 59, 0.3);
    margin-top: 10px;
    margin-right: 8px;
}

button[id^="btnPaso"]:hover,
#btnCalcular:hover {
    background: linear-gradient(135deg, #4b8730 0%, #3c6e26 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(91, 159, 59, 0.45);
}

button[id^="btnPaso"]:active,
#btnCalcular:active {
    transform: translateY(0);
}

/* Botón Especial de Cálculo Final */
#btnCalcular {
    width: 100%;
    font-size: 16px;
    padding: 16px;
    margin-top: 15px;
}

/* Botones "Anterior" (Secundarios) */
button[id^="btnAtras"] {
    background: #f0f4f9;
    color: #04034a;
    border: 1.5px solid #d5e0eb;
    padding: 14px 22px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-top: 10px;
    margin-right: 8px;
}

button[id^="btnAtras"]:hover {
    background: #e2ebf5;
    border-color: #b8cde0;
    transform: translateY(-2px);
}

/*==================================================
            PANEL DE PROCESO Y BARRA
==================================================*/

#panelProceso {
    text-align: center;
    padding: 40px 20px;
    background: #f8fafc;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
}

#panelProceso h2 {
    color: #04034a;
    font-size: 20px;
    margin-bottom: 20px;
}

.barra {
    width: 100%;
    height: 14px;
    background-color: #e2e8f0;
    border-radius: 50px;
    overflow: hidden;
    margin: 20px 0;
}

#barraProgreso,
#barraDiagnostico {
    height: 100%;
    background: linear-gradient(90deg, #5b9f3b, #74bf4f);
    border-radius: 50px;
    transition: width 0.4s ease;
}

#mensajeProceso {
    color: #64748b;
    font-weight: 600;
    font-size: 15px;
}

/*==================================================
                TABLA DE RESULTADOS
==================================================*/

#resultadoCalculo table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    margin-top: 15px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

#resultadoCalculo table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
    color: #334155;
}

#resultadoCalculo table tr:nth-child(even) {
    background-color: #f8fafc;
}

#resultadoCalculo table tr:last-child td {
    border-bottom: none;
}

#resultadoCalculo h3 {
    color: #04034a;
    font-size: 17px;
    margin-top: 15px;
    margin-bottom: 10px;
}

.ph-tiempo-inversion {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.ph-label-secundario {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: #666;
    font-weight: 600;
}

.ph-tiempo-inversion input {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #d8d8d8;
    font-size: 16px;
    transition: .2s;
}

.ph-tiempo-inversion input:focus {
    outline: none;
    border-color: #5b9f3b;
    box-shadow: 0 0 8px rgba(91, 159, 59, .20);
}

/*====================================================
  CONFIGURACIÓN PARA EXPORTACIÓN A PDF (FUERA DE PRINT)
====================================================*/

/* Ancho compacto óptimo para Hoja Carta */
.ph-report.pdf-mode {
    padding: 0 !important;
    max-width: 820px !important;
    margin: 0 auto !important;
    background: #ffffff !important;
}

/* Reducir espacio de tarjetas en PDF para evitar desbordes */
.ph-report.pdf-mode .ph-section,
.ph-report.pdf-mode .ph-header {
    padding: 16px 20px !important;
    margin-bottom: 14px !important;
    border-radius: 12px !important;
    box-shadow: none !important;
    border: 1px solid #cbd5e1 !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.ph-report.pdf-mode .ph-header {
    margin-top: 5mm !important;
}

.ph-report.pdf-mode .ph-card {
    padding: 12px 14px !important;
}

.ph-report.pdf-mode .ph-m40-grid {
    gap: 8px !important;
    margin-bottom: 12px !important;
}

.ph-report.pdf-mode .ph-box {
    padding: 10px 6px !important;
}

.ph-report.pdf-mode .ph-vchart-bars {
    height: 120px !important;
}

.ph-report.pdf-mode .ph-cuotas-table th,
.ph-report.pdf-mode .ph-cuotas-table td {
    padding: 8px 10px !important;
}

.ph-report.pdf-mode .ph-cuotas-table tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

/* ====================================================
   PAGINACIÓN Y CENTRADO VERTICAL EXACTO POR HOJA
==================================================== */

/* 📄 HOJA 1: Header + Ficha (Centrado vertical suave en Hoja 1) */
.ph-report.pdf-mode section:nth-of-type(1) {
    page-break-before: avoid !important;
    break-before: auto !important;
    margin-top: 20mm !important;
}

.ph-report.pdf-mode section:nth-of-type(2) {
    page-break-before: avoid !important;
    break-before: auto !important;
}

/* 📄 HOJA 2: Modalidad 40 (CENTRADO VERTICAL TOTAL) */
.ph-report.pdf-mode section:nth-of-type(3) {
    page-break-before: always !important;
    break-before: page !important;
    min-height: 235mm !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    box-sizing: border-box !important;
}

/* 📄 HOJA 3: Comparativa / Gráficas (CENTRADO VERTICAL TOTAL) */
.ph-report.pdf-mode section:nth-of-type(4) {
    page-break-before: always !important;
    break-before: page !important;
    min-height: 235mm !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    box-sizing: border-box !important;
}

/* 📄 HOJA 4: Tabla de Cuotas + ROI (Centrado suave en Hoja 4) */
.ph-report.pdf-mode section:nth-of-type(5) {
    page-break-before: always !important;
    break-before: page !important;
    margin-top: 10mm !important;
}

.ph-report.pdf-mode section:nth-of-type(6) {
    page-break-before: avoid !important;
    break-before: auto !important;
}

/*====================================================
  ELIMINAR BORDES EXTERIORES EN MODO PDF
====================================================*/

.ph-report.pdf-mode {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    background: #ffffff !important;
}

.ph-report.pdf-mode .ph-section,
.ph-report.pdf-mode .ph-header {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

/*====================================================
  SUBIDA INTERACTIVA Y CAMBIO DE LOGO DEL ASESOR
====================================================*/

.ph-header-logo {
    width: 150px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.ph-logo-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ph-logo-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.ph-logo-actions {
    position: absolute;
    top: -6px;
    right: -6px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.ph-logo-wrapper:hover .ph-logo-actions {
    opacity: 1;
}

.ph-btn-logo-action {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
}

.ph-btn-logo-action:hover {
    background: #f1f5f9;
    color: #04034a;
}

.ph-btn-logo-action.delete:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

@media print {
    .ph-logo-actions, .ph-btn-upload-logo {
        display: none !important;
    }
}

/*====================================================
  CAPA DE PERSONALIZACIÓN SOBRE LOGO PENSIÓN HUB
====================================================*/

.ph-logo-upload-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    border-radius: 8px;
    z-index: 5;
}

.ph-logo-wrapper:hover .ph-logo-upload-overlay {
    opacity: 1;
}

.ph-btn-upload-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    background: #f8fafc;
    border: 2px dashed #5b9f3b;
    border-radius: 8px;
    color: #5b9f3b;
    font-size: 10px;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.ph-btn-upload-logo:hover {
    background: #5b9f3b;
    color: #ffffff;
}

@media print {
    .ph-logo-upload-overlay {
        display: none !important;
    }
}

/*====================================================
  BORDE PUNTEADO EDITABLE Y REGLAS PARA PDF
====================================================*/

.ph-logo-wrapper.is-default-logo {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 4px;
    transition: border-color 0.25s ease;
}

.ph-logo-wrapper.is-default-logo:hover {
    border-color: #5b9f3b;
}

.ph-btn-upload-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    background: #ffffff;
    border: 1px solid #5b9f3b;
    border-radius: 8px;
    color: #5b9f3b;
    font-size: 10px;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ph-btn-upload-logo:hover {
    background: #5b9f3b;
    color: #ffffff;
}

.ph-report.pdf-mode .ph-logo-wrapper.is-default-logo {
    border: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

.ph-report.pdf-mode .ph-logo-upload-overlay {
    display: none !important;
}

/*====================================================
  MARCA DE AGUA / PIE DE PÁGINA DISCRETO PARA PDF
====================================================*/

/* Modo PDF (Generación con html2pdf.js) */
.ph-report.pdf-mode section:nth-of-type(2)::after,
.ph-report.pdf-mode section:nth-of-type(3)::after,
.ph-report.pdf-mode section:nth-of-type(4)::after,
.ph-report.pdf-mode section:nth-of-type(6)::after {
    content: "pensionhub.com.mx";
    display: block;
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    color: #94a3b8 !important;
    letter-spacing: 2px;
    margin-top: auto !important; /* Empuja el texto al fondo exacto de la hoja */
    padding-top: 15px;
    border-top: 1px dashed #cbd5e1;
    text-transform: lowercase;
    width: 100%;
}

/* Impresión física nativa */
@media print {
    .ph-report section:nth-of-type(2)::after,
    .ph-report section:nth-of-type(3)::after,
    .ph-report section:nth-of-type(4)::after,
    .ph-report section:nth-of-type(6)::after {
        content: "pensionhub.com.mx";
        display: block;
        text-align: center;
        font-size: 10px;
        font-weight: 700;
        color: #94a3b8 !important;
        letter-spacing: 2px;
        margin-top: auto !important;
        padding-top: 15px;
        border-top: 1px dashed #cbd5e1;
        text-transform: lowercase;
        width: 100%;
    }
}

/*====================================================
  BARRA DE CONTROL DE ESCENARIOS Y BANNER DE HUBI
====================================================*/

.ph-escenarios-container {
    background: #ffffff;
    border-radius: 16px;
    padding: 20px 24px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 12px rgba(4, 3, 74, 0.05);
    margin-bottom: 24px;
}

/* BANNER DE HUBI AI */
.ph-hubi-banner {
    background: linear-gradient(135deg, #f4fbf1 0%, #ffffff 100%);
    border: 1.5px solid #5b9f3b;
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    box-shadow: 0 4px 14px rgba(91, 159, 59, 0.1);
}

.ph-hubi-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #5b9f3b;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(91, 159, 59, 0.3);
}

.ph-hubi-content {
    flex: 1;
}

.ph-hubi-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #5b9f3b;
    font-weight: 800;
    margin-bottom: 3px;
}

.ph-hubi-text {
    font-size: 13px;
    color: #1e293b;
    line-height: 1.5;
    margin: 0;
}

/* HEADER DE PESTAÑAS Y ACCIONES */
.ph-tabs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}

.ph-tabs-label {
    font-size: 13px;
    font-weight: 800;
    color: #04034a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ph-tabs-actions {
    display: flex;
    gap: 10px;
}

.ph-btn-hubi-magic {
    background: linear-gradient(135deg, #04034a 0%, #171285 100%);
    color: #ffffff;
    border: none;
    padding: 9px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(4, 3, 74, 0.2);
    transition: all 0.2s ease;
}

.ph-btn-hubi-magic:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(4, 3, 74, 0.3);
}

.ph-btn-nuevo-escenario {
    background: #f8fafc;
    color: #04034a;
    border: 1.5px dashed #cbd5e1;
    padding: 9px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ph-btn-nuevo-escenario:hover {
    background: #eef8ea;
    border-color: #5b9f3b;
    color: #5b9f3b;
}

/* GRID DE PESTAÑAS */
.ph-tabs-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.ph-tab-item {
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.ph-tab-item:hover {
    border-color: #cbd5e1;
    background: #ffffff;
    transform: translateY(-2px);
}

.ph-tab-item.active {
    background: #ffffff;
    border-color: #5b9f3b;
    box-shadow: 0 4px 14px rgba(91, 159, 59, 0.2);
}

.ph-tab-badge {
    font-size: 10px;
    font-weight: 800;
    color: #5b9f3b;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.ph-tab-title {
    font-size: 12px;
    font-weight: 700;
    color: #04034a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.ph-tab-price {
    font-size: 15px;
    font-weight: 800;
    color: #5b9f3b;
}

/* Ocultar barra de escenarios al exportar PDF */
@media print {
    .ph-escenarios-container {
        display: none !important;
    }
}

/*====================================================
  BÚHO HUBI AI, CHECKMARKS Y CONTROL DE ESCENARIOS
====================================================*/

.ph-hubi-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #04034a;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(4, 3, 74, 0.3);
}

.ph-hubi-owl-svg {
    width: 28px;
    height: 28px;
    fill: #5b9f3b;
}

/* Indicador de Escenario Guardado */
.ph-saved-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #dcfce7;
    color: #16a34a;
    margin-left: 6px;
}

/* Botón de Borrar Escenario en la pestaña */
.ph-tab-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 12px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.ph-tab-delete-btn:hover {
    background: #fee2e2;
    color: #dc2626;
}

.ph-btn-guardar-escenario {
    background: linear-gradient(135deg, #5b9f3b 0%, #46822a 100%);
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(91, 159, 59, 0.3);
    transition: all 0.2s ease;
}

.ph-btn-guardar-escenario:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 14px rgba(91, 159, 59, 0.4);
}