/**
 * Calculadora Nómina PRO - Convenio Limpieza La Laguna
 * Hoja de estilos completa - OPTIMIZADO MÓVILES
 * Version: 3.1.1
 */

/* ============================================
   VARIABLES CSS
   ============================================ */
:root {
    --nlp-primary: #0052a3;
    --nlp-secondary: #1a5490;
    --nlp-accent: #d4af37;
    --nlp-success: #27ae60;
    --nlp-danger: #e74c3c;
    --nlp-warning: #f39c12;
    --nlp-info: #3498db;
    --nlp-text: #2c3e50;
    --nlp-text-light: #718096;
    --nlp-border: #cbd5e0;
    --nlp-light: #f7fafc;
    --nlp-light-blue: #e3f2fd;
    --nlp-light-green: #e8f5e9;
    --nlp-light-red: #ffebee;
    --nlp-light-yellow: #fffbea;
    --nlp-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --nlp-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --nlp-shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
    --nlp-radius: 8px;
    --nlp-radius-lg: 12px;
    --nlp-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   RESET Y BASE - OPTIMIZADO MÓVIL
   ============================================ */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    touch-action: manipulation;
}

body {
    margin: 0;
    padding: 0;
}

/* ============================================
   CONTENEDOR PRINCIPAL
   ============================================ */
.nlp-wrapper {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 15px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--nlp-text);
    width: 100%;
}

.nlp-card {
    background: white;
    border-radius: var(--nlp-radius-lg);
    box-shadow: var(--nlp-shadow-lg);
    overflow: hidden;
    width: 100%;
}

/* ============================================
   HEADER
   ============================================ */
.nlp-header {
    background: linear-gradient(135deg, var(--nlp-primary) 0%, var(--nlp-secondary) 100%);
    color: white;
    padding: 45px 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.nlp-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 400px;
    height: 400px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    pointer-events: none;
}

.nlp-header::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 350px;
    height: 350px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 50%;
    pointer-events: none;
}

.nlp-logo {
    font-size: 52px;
    margin-bottom: 15px;
    animation: fadeInDown 0.6s ease-out;
    position: relative;
    z-index: 1;
}

.nlp-header h2 {
    margin: 10px 0;
    font-size: 34px;
    font-weight: 700;
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.nlp-subtitle,
.nlp-org,
.nlp-ref {
    margin: 5px 0;
    font-size: 14px;
    opacity: 0.95;
    position: relative;
    z-index: 1;
}

.nlp-org {
    font-weight: 600;
    font-size: 15px;
}

.nlp-ref {
    font-size: 12px;
    opacity: 0.85;
    font-style: italic;
    margin-top: 8px;
}

/* ============================================
   FORMULARIO
   ============================================ */
.nlp-form {
    padding: 35px 30px;
    background: #fafbfc;
}

.nlp-section {
    background: white;
    border-left: 4px solid var(--nlp-primary);
    padding: 25px;
    margin-bottom: 25px;
    border-radius: var(--nlp-radius);
    box-shadow: var(--nlp-shadow-sm);
}

.nlp-section h3 {
    color: var(--nlp-primary);
    font-size: 19px;
    margin: 0 0 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nlp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.nlp-full {
    grid-column: 1 / -1;
}

/* ============================================
   CAMPOS DE FORMULARIO - CORREGIDO MÓVIL
   ============================================ */
.nlp-field {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.nlp-field label {
    display: block;
    font-weight: 600;
    color: var(--nlp-text);
    margin-bottom: 8px;
    font-size: 16px; /* >= 16px para evitar zoom en iOS */
}

.nlp-check {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    padding: 8px 0;
    -webkit-tap-highlight-color: rgba(0, 82, 163, 0.1);
}

.nlp-check input[type="checkbox"] {
    width: 24px; /* Más grande para móvil */
    height: 24px;
    cursor: pointer;
    accent-color: var(--nlp-primary);
    flex-shrink: 0;
    -webkit-appearance: checkbox;
    appearance: checkbox;
}

.nlp-check span {
    font-weight: 600;
    font-size: 16px; /* >= 16px para evitar zoom */
}

.nlp-check-sindical {
    background: linear-gradient(135deg, #fff9e6 0%, #fffbf0 100%);
    padding: 12px 14px;
    border-radius: var(--nlp-radius);
    border: 2px solid var(--nlp-warning);
    transition: var(--nlp-transition);
}

.nlp-check-sindical:active {
    background: linear-gradient(135deg, #fff4d6 0%, #fff9e6 100%);
    border-color: #f39c12;
}

.nlp-check-sindical span {
    color: #d68910;
    font-weight: 700;
}

.nlp-field input,
.nlp-field select {
    width: 100%;
    padding: 14px 16px; /* Padding más grande para móvil */
    border: 2px solid var(--nlp-border);
    border-radius: var(--nlp-radius);
    font-size: 16px; /* IMPORTANTE: >= 16px evita zoom automático en iOS */
    transition: var(--nlp-transition);
    background: white;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    max-width: 100%;
}

/* Select personalizado para móvil */
.nlp-field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232c3e50' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 40px;
}

.nlp-field input:focus,
.nlp-field select:focus {
    outline: none;
    border-color: var(--nlp-primary);
    box-shadow: 0 0 0 3px rgba(0, 82, 163, 0.1);
}

/* CRÍTICO: Ocultar spinners en inputs numéricos móvil */
.nlp-field input[type="number"] {
    -moz-appearance: textfield;
}

.nlp-field input[type="number"]::-webkit-inner-spin-button,
.nlp-field input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
    display: none; /* Forzar ocultar */
}

/* Input numérico en Firefox */
.nlp-field input[type="number"] {
    appearance: textfield;
}

.nlp-field small {
    display: block;
    margin-top: 6px;
    font-size: 13px; /* Ligeramente más grande */
    color: var(--nlp-text-light);
    font-style: italic;
    line-height: 1.4;
}

/* ============================================
   BOTONES - OPTIMIZADO MÓVIL
   ============================================ */
.nlp-actions {
    text-align: center;
    padding: 30px;
    background: var(--nlp-light);
}

.nlp-btn-calc {
    background: linear-gradient(135deg, var(--nlp-primary) 0%, var(--nlp-secondary) 100%);
    color: white;
    border: none;
    padding: 18px 60px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--nlp-transition);
    box-shadow: 0 8px 25px rgba(0, 82, 163, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.nlp-btn-calc:active {
    transform: scale(0.98);
    box-shadow: 0 4px 15px rgba(0, 82, 163, 0.35);
}

.nlp-btn-icon {
    font-size: 22px;
    line-height: 1;
}

.nlp-btn-text {
    line-height: 1;
}

.nlp-btn-sec {
    padding: 14px 32px;
    border: 2px solid var(--nlp-primary);
    background: white;
    color: var(--nlp-primary);
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--nlp-radius);
    cursor: pointer;
    transition: var(--nlp-transition);
    margin: 0 8px;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.nlp-btn-sec:active {
    background: var(--nlp-primary);
    color: white;
    transform: scale(0.98);
}

/* ============================================
   RESULTADOS - ESTRUCTURA
   ============================================ */
.nlp-resultado {
    padding: 0;
    width: 100%;
}

/* ============================================
   NÓMINA - HEADER
   ============================================ */
.nlp-nomina {
    border: 3px solid var(--nlp-primary);
    border-radius: 0;
    width: 100%;
    overflow-x: auto; /* Scroll horizontal si es necesario */
}

.nlp-nomina-header {
    background: var(--nlp-primary);
    color: white;
    padding: 28px 30px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 5px solid var(--nlp-accent);
}

.nlp-nomina-header h3 {
    margin: 0 0 5px;
    font-size: 28px;
    letter-spacing: 2px;
    font-weight: 800;
    text-transform: uppercase;
}

.nlp-nomina-header p {
    margin: 0;
    font-size: 13px;
    opacity: 0.95;
}

.nlp-header-right {
    text-align: right;
    font-size: 13px;
    line-height: 1.9;
}

.nlp-header-right div {
    margin: 2px 0;
}

.nlp-header-right strong {
    font-weight: 700;
}

/* ============================================
   NÓMINA - BODY
   ============================================ */
.nlp-nomina-body {
    padding: 35px;
    background: #fafbfc;
    overflow-x: auto; /* Scroll horizontal si tablas son anchas */
}

/* ============================================
   BOXES (SECCIONES)
   ============================================ */
.nlp-box {
    background: white;
    border: 2px solid var(--nlp-border);
    margin-bottom: 22px;
    overflow: hidden;
    border-radius: 6px;
    box-shadow: var(--nlp-shadow-sm);
    width: 100%;
}

.nlp-box-title {
    background: linear-gradient(to right, var(--nlp-primary), var(--nlp-secondary));
    color: white;
    padding: 16px 25px;
    margin: 0;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 800;
}

.nlp-subsection {
    margin: 0;
}

.nlp-subsection h5 {
    background: #edf2f7;
    padding: 12px 25px;
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--nlp-text);
    border-bottom: 2px solid var(--nlp-border);
}

/* Variantes de boxes */
.nlp-box-bases {
    background: linear-gradient(135deg, #fffbea 0%, #fff9e6 100%);
    border-color: var(--nlp-accent);
}

.nlp-box-bases .nlp-box-title {
    background: linear-gradient(to right, var(--nlp-accent), #c9a02c);
    color: var(--nlp-text);
}

.nlp-box-liquido {
    background: linear-gradient(135deg, var(--nlp-success) 0%, #229954 100%);
    border: none;
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.3);
}

.nlp-box-liquido .liquido-row {
    background: transparent !important;
    border: none !important;
}

.nlp-box-liquido th {
    color: white;
    font-size: 22px;
    padding: 25px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.nlp-box-empresa {
    background: linear-gradient(135deg, #fff9e6 0%, #fffbf0 100%);
    border-color: var(--nlp-accent);
}

.nlp-box-empresa .nlp-box-title {
    background: linear-gradient(to right, var(--nlp-accent), #c9a02c);
    color: var(--nlp-text);
}

.nlp-box-anual {
    background: linear-gradient(135deg, #e3f2fd 0%, #f0f8ff 100%);
    border-color: var(--nlp-info);
}

.nlp-box-anual .nlp-box-title {
    background: linear-gradient(to right, var(--nlp-info), #2980b9);
}

/* ============================================
   TABLAS - OPTIMIZADO MÓVIL
   ============================================ */
.nlp-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 100%; /* Evitar que se comprima */
}

.nlp-table thead th {
    background: #e2e8f0;
    padding: 12px 15px;
    text-align: left;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--nlp-border);
    color: var(--nlp-text);
    white-space: nowrap; /* Evitar wrap en headers */
}

.nlp-table tbody tr {
    border-bottom: 1px solid #e2e8f0;
}

.nlp-table tbody tr:last-child {
    border-bottom: none;
}

.nlp-table td,
.nlp-table th {
    padding: 14px 15px;
    font-size: 14px;
    vertical-align: middle;
}

.nlp-table small {
    font-size: 12px;
    color: var(--nlp-text-light);
    font-weight: normal;
    display: block;
    margin-top: 3px;
}

.nlp-table .num {
    text-align: right;
    font-family: 'Courier New', Consolas, 'Lucida Console', monospace;
    font-weight: 700;
    color: var(--nlp-text);
    white-space: nowrap;
}

/* Tabla pequeña */
.nlp-table-small td,
.nlp-table-small th {
    padding: 10px 15px;
    font-size: 13px;
}

/* ============================================
   FILAS ESPECIALES DE TABLAS
   ============================================ */
.nlp-table tfoot .subtotal {
    background: #f7fafc;
    border-top: 2px solid var(--nlp-border);
    border-bottom: 2px solid var(--nlp-border);
    font-weight: 700;
}

.nlp-table tfoot .total-dev,
.nlp-table tfoot .total-ded,
.nlp-table tfoot .total-base,
.nlp-table tfoot .total-emp,
.nlp-table tfoot .total-anual {
    background: var(--nlp-light-blue);
    border-top: 3px solid var(--nlp-primary);
    border-bottom: 3px solid var(--nlp-primary);
    font-weight: 800;
    font-size: 15px;
}

.nlp-table tfoot .total-dev {
    background: var(--nlp-light-green);
    border-color: var(--nlp-success);
}

.nlp-table tfoot .total-ded {
    background: var(--nlp-light-red);
    border-color: var(--nlp-danger);
}

.nlp-table tfoot .total-base {
    background: var(--nlp-light-yellow);
    border-color: var(--nlp-accent);
}

.nlp-table tfoot .total-anual {
    background: var(--nlp-light-blue);
    border-color: var(--nlp-info);
}

/* Fila de cuota sindical */
#row_cuota_sindical {
    background: #fffbea;
    font-weight: 600;
}

#row_cuota_sindical td {
    color: #d68910;
}

/* ============================================
   FOOTER DE NÓMINA
   ============================================ */
.nlp-nomina-footer {
    background: var(--nlp-light);
    padding: 22px 30px;
    border-top: 3px solid var(--nlp-primary);
    text-align: center;
}

.nlp-nomina-footer p {
    margin: 5px 0;
    color: var(--nlp-text-light);
    font-size: 12px;
    line-height: 1.6;
}

/* ============================================
   ANIMACIONES
   ============================================ */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   RESPONSIVE - TABLETS
   ============================================ */
@media (max-width: 992px) {
    .nlp-wrapper {
        padding: 0 15px;
        margin: 20px auto;
    }

    .nlp-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }

    .nlp-nomina-header {
        flex-direction: column;
        gap: 15px;
    }

    .nlp-header-right {
        text-align: left;
        width: 100%;
    }

    .nlp-form {
        padding: 25px 20px;
    }

    .nlp-nomina-body {
        padding: 25px 20px;
    }
}

/* ============================================
   RESPONSIVE - MÓVILES (CRÍTICO)
   ============================================ */
@media (max-width: 768px) {
    .nlp-wrapper {
        margin: 10px auto;
        padding: 0 10px;
    }

    .nlp-card {
        border-radius: 8px;
    }

    .nlp-header {
        padding: 30px 20px;
    }

    .nlp-header h2 {
        font-size: 24px;
        letter-spacing: 0.3px;
    }

    .nlp-logo {
        font-size: 40px;
    }

    .nlp-subtitle,
    .nlp-org {
        font-size: 13px;
    }

    .nlp-ref {
        font-size: 11px;
    }

    .nlp-form {
        padding: 20px 15px;
    }

    .nlp-section {
        padding: 18px 15px;
        margin-bottom: 20px;
    }

    .nlp-section h3 {
        font-size: 17px;
        margin-bottom: 16px;
    }

    .nlp-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .nlp-field label {
        font-size: 16px; /* Mantener >= 16px */
        margin-bottom: 6px;
    }

    .nlp-field input,
    .nlp-field select {
        padding: 14px 16px; /* Mantener padding grande */
        font-size: 16px; /* CRÍTICO: >= 16px */
    }

    .nlp-field small {
        font-size: 13px;
    }

    .nlp-check {
        padding: 10px 0;
    }

    .nlp-check input[type="checkbox"] {
        width: 26px;
        height: 26px;
    }

    .nlp-btn-calc {
        padding: 16px 40px;
        font-size: 17px;
        width: 100%;
        justify-content: center;
        border-radius: 12px;
    }

    .nlp-btn-icon {
        font-size: 20px;
    }

    .nlp-actions {
        padding: 20px 15px;
    }

    /* Nómina móvil */
    .nlp-nomina-header {
        padding: 20px 15px;
        flex-direction: column;
    }

    .nlp-nomina-header h3 {
        font-size: 20px;
        letter-spacing: 1px;
    }

    .nlp-nomina-header p {
        font-size: 12px;
    }

    .nlp-header-right {
        font-size: 12px;
        line-height: 1.7;
    }

    .nlp-nomina-body {
        padding: 20px 12px;
    }

    .nlp-box {
        margin-bottom: 18px;
    }

    .nlp-box-title {
        padding: 12px 15px;
        font-size: 14px;
        letter-spacing: 0.8px;
    }

    .nlp-subsection h5 {
        padding: 10px 15px;
        font-size: 13px;
    }

    /* Tablas móvil - CRÍTICO */
    .nlp-table {
        font-size: 13px;
    }

    .nlp-table thead th {
        padding: 10px 8px;
        font-size: 11px;
    }

    .nlp-table td,
    .nlp-table th {
        padding: 10px 8px;
        font-size: 13px;
    }

    .nlp-table small {
        font-size: 11px;
    }

    .nlp-table-small td,
    .nlp-table-small th {
        padding: 8px 8px;
        font-size: 12px;
    }

    .nlp-box-liquido th {
        font-size: 18px;
        padding: 18px 15px;
    }

    .nlp-btn-sec {
        display: block;
        width: 100%;
        margin: 8px 0;
        padding: 14px 20px;
        font-size: 16px;
    }

    .nlp-nomina-footer {
        padding: 18px 15px;
    }

    .nlp-nomina-footer p {
        font-size: 11px;
    }
}

/* ============================================
   RESPONSIVE - MÓVILES PEQUEÑOS (<480px)
   ============================================ */
@media (max-width: 480px) {
    .nlp-wrapper {
        padding: 0 8px;
    }

    .nlp-header {
        padding: 25px 15px;
    }

    .nlp-header h2 {
        font-size: 20px;
    }

    .nlp-logo {
        font-size: 36px;
    }

    .nlp-form {
        padding: 15px 12px;
    }

    .nlp-section {
        padding: 15px 12px;
    }

    .nlp-section h3 {
        font-size: 16px;
    }

    .nlp-nomina-header h3 {
        font-size: 18px;
    }

    .nlp-box-title {
        font-size: 13px;
        padding: 10px 12px;
    }

    .nlp-table td,
    .nlp-table th {
        padding: 8px 6px;
        font-size: 12px;
    }

    .nlp-table thead th {
        font-size: 10px;
        padding: 8px 6px;
    }

    .nlp-table-small td,
    .nlp-table-small th {
        padding: 6px 6px;
        font-size: 11px;
    }

    .nlp-box-liquido th {
        font-size: 16px;
        padding: 15px 12px;
    }
}

/* ============================================
   MODO IMPRESIÓN
   ============================================ */
@media print {
    .nlp-wrapper {
        margin: 0;
        padding: 0;
    }

    .nlp-form,
    .nlp-actions {
        display: none !important;
    }

    .nlp-card {
        box-shadow: none;
        border-radius: 0;
    }

    .nlp-nomina {
        page-break-inside: avoid;
        border: 2px solid #000;
    }

    .nlp-box {
        page-break-inside: avoid;
    }

    .nlp-nomina-header {
        background: #333 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .nlp-box-title {
        background: #666 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .nlp-box-liquido {
        background: #28a745 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .nlp-table {
        border-collapse: collapse;
    }

    .nlp-table td,
    .nlp-table th {
        border: 1px solid #ddd;
    }
}

/* ============================================
   ACCESIBILIDAD
   ============================================ */
.nlp-btn-calc:focus-visible,
.nlp-btn-sec:focus-visible,
.nlp-field input:focus-visible,
.nlp-field select:focus-visible {
    outline: 3px solid var(--nlp-info);
    outline-offset: 2px;
}

/* Reducir movimiento */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}