/* Estilos para el modal de Abonos - MEJORADO */
.modal-abonos {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    overflow: hidden;
}

.modal-abonos-content {
    max-width: 95%;
    width: 1000px;
    max-height: 90vh;
    margin: 2% auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* HEADER MEJORADO - UNA SOLA LÍNEA */
.abonos-header.sticky-header {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 20px 25px 15px 25px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    border-radius: 12px 12px 0 0;
}

.abonos-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.abonos-title h2 {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Badge de solo lectura en el título */
#abonosSoloLecturaBadge {
    background: #dc3545;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: none;
}

/* Header info en UNA SOLA LÍNEA */
.abonos-header-info {
    display: flex;
    flex-direction: row;
    gap: 25px;
    width: 100%;
    flex-wrap: wrap;
}

.abonos-header-line {
    display: flex;
    align-items: center;
    gap: 25px;
    width: 100%;
    flex-wrap: nowrap;
    overflow: hidden;
}

.abonos-header-line .header-item {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    flex-shrink: 0;
}

.abonos-header-line .header-item strong {
    font-size: 11px;
    opacity: 0.8;
    font-weight: 600;
}

.abonos-header-line .header-item span {
    font-weight: 500;
}

/* X DE CERRAR */
.close-modal-abonos {
    position: absolute;
    top: 15px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #333;
    font-size: 28px;
    cursor: pointer;
    padding: 5px 15px;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 10001;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.close-modal-abonos:hover {
    background: #dc3545;
    color: white;
    transform: scale(1.1);
}

/* BODY */
.abonos-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.abonos-section {
    padding: 20px 25px;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}

.abonos-section:last-of-type {
    border-bottom: none;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.section-header h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 18px;
}

/* ESTADÍSTICAS DEL PEDIDO */
.estadisticas-pedido {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.estadistica-item {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #3498db;
    text-align: center;
}

.estadistica-label {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
}

.estadistica-valor {
    font-size: 18px;
    font-weight: 700;
    color: #2c3e50;
}

.estadistica-total { border-left-color: #28a745; }
.estadistica-abonos { border-left-color: #17a2b8; }
.estadistica-saldo { border-left-color: #dc3545; }

/* FORM CONTROLS */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
    font-size: 13px;
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* BOTÓN AGREGAR ABONO */
.btn-agregar-abono {
    background: linear-gradient(135deg, #6f42c1, #5a2d9c);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.btn-agregar-abono:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(111, 66, 193, 0.3);
}

/* TABLAS DE ABONOS - ACTIVOS Y ELIMINADOS */
.abonos-tablas-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.tabla-abonos-container {
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
    border: 1px solid #e0e0e0;
}

.tabla-abonos {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    border-radius: 6px;
    overflow: hidden;
    table-layout: fixed;
    height: auto;
    font-size: 12px; /* Tamaño consistente para toda la tabla */
}

/* CABECERA DE TABLA STICKY */
.tabla-abonos thead {
    position: sticky;
    top: 0;
    z-index: 30;
    background: #34495e;
    display: table-header-group;
}

.tabla-abonos th {
    background: #34495e !important;
    color: white !important;
    padding: 8px 10px !important; /* Padding reducido y consistente */
    text-align: left;
    font-weight: 600;
    font-size: 11px !important; /* Tamaño reducido para cabeceras */
    position: sticky;
    top: 0;
    z-index: 35;
    border-bottom: 2px solid #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 36px; /* Altura fija para consistencia */
    vertical-align: middle;
}

/* ESTADÍSTICAS STICKY */
.abonos-section:first-of-type {
    position: sticky;
    top: 0;
    z-index: 20;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
}

.estadisticas-pedido {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 10px; /* Reducir margen inferior */
}

/* ANCHOS OPTIMIZADOS Y CONSISTENTES PARA TABLA DE ABONOS ACTIVOS */
.tabla-abonos.activos th:nth-child(1), 
.tabla-abonos.activos td:nth-child(1) { 
    width: 15%; 
    min-width: 100px; 
    max-width: 120px;
} /* ABONO */

.tabla-abonos.activos th:nth-child(2), 
.tabla-abonos.activos td:nth-child(2) { 
    width: 12%; 
    min-width: 90px; 
    max-width: 100px;
} /* FECHA ABONO */

.tabla-abonos.activos th:nth-child(3), 
.tabla-abonos.activos td:nth-child(3) { 
    width: 15%; 
    min-width: 100px; 
    max-width: 120px;
} /* TIPO */

.tabla-abonos.activos th:nth-child(4), 
.tabla-abonos.activos td:nth-child(4) { 
    width: 20%; 
    min-width: 120px; 
    max-width: 150px;
} /* REFERENCIA */

.tabla-abonos.activos th:nth-child(5), 
.tabla-abonos.activos td:nth-child(5) { 
    width: 15%; 
    min-width: 100px; 
    max-width: 120px;
} /* USUARIO */

.tabla-abonos.activos th:nth-child(6), 
.tabla-abonos.activos td:nth-child(6) { 
    width: 18%; 
    min-width: 120px; 
    max-width: 140px;
} /* FECHA || HORA */

.tabla-abonos.activos th:nth-child(7), 
.tabla-abonos.activos td:nth-child(7) { 
    width: 10%; 
    min-width: 80px; 
    max-width: 90px;
} /* ACCIONES */

/* ANCHOS OPTIMIZADOS Y CONSISTENTES PARA TABLA DE ABONOS ELIMINADOS */
.tabla-abonos.eliminados th:nth-child(1), 
.tabla-abonos.eliminados td:nth-child(1) { 
    width: 12%; 
    min-width: 90px; 
    max-width: 100px;
} /* ABONO */

.tabla-abonos.eliminados th:nth-child(2), 
.tabla-abonos.eliminados td:nth-child(2) { 
    width: 10%; 
    min-width: 80px; 
    max-width: 90px;
} /* FECHA ABONO */

.tabla-abonos.eliminados th:nth-child(3), 
.tabla-abonos.eliminados td:nth-child(3) { 
    width: 12%; 
    min-width: 90px; 
    max-width: 100px;
} /* TIPO */

.tabla-abonos.eliminados th:nth-child(4), 
.tabla-abonos.eliminados td:nth-child(4) { 
    width: 16%; 
    min-width: 110px; 
    max-width: 130px;
} /* REFERENCIA */

.tabla-abonos.eliminados th:nth-child(5), 
.tabla-abonos.eliminados td:nth-child(5) { 
    width: 12%; 
    min-width: 90px; 
    max-width: 100px;
} /* USUARIO */

.tabla-abonos.eliminados th:nth-child(6), 
.tabla-abonos.eliminados td:nth-child(6) { 
    width: 15%; 
    min-width: 100px; 
    max-width: 120px;
} /* FECHA || HORA */

.tabla-abonos.eliminados th:nth-child(7), 
.tabla-abonos.eliminados td:nth-child(7) { 
    width: 12%; 
    min-width: 90px; 
    max-width: 100px;
} /* USUARIO ELIMINÓ */

.tabla-abonos.eliminados th:nth-child(8), 
.tabla-abonos.eliminados td:nth-child(8) { 
    width: 11%; 
    min-width: 90px; 
    max-width: 100px;
} /* FECHA ELIMINACIÓN */

.tabla-abonos td {
    padding: 8px 10px !important; /* Mismo padding que las cabeceras */
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px; /* Tamaño consistente con el resto */
    height: 36px; /* Misma altura que cabeceras */
}

.tabla-abonos tbody tr:hover {
    background: #f8f9fa;
}

/* BOTONES DE ACCIÓN EN TABLA */
.acciones-abono {
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.btn-accion {
    background: none;
    border: none;
    padding: 4px 6px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.btn-eliminar {
    color: #dc3545;
}

.btn-eliminar:hover {
    background: #dc3545;
    color: white;
}

.btn-accion:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-accion:disabled:hover {
    background: none;
    color: inherit;
}

/* ESTILOS PARA FILAS EN EDICIÓN */
.fila-edicion-abono {
    background: #fff9e6 !important;
    border-left: 3px solid #f39c12;
}

/* ESTILOS PARA INPUTS EN TABLAS - TAMAÑO CONSISTENTE */
.fila-edicion-abono input,
.fila-edicion-abono select {
    background: white;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 4px 6px;
    font-size: 11px;
    width: 100%;
    box-sizing: border-box;
    height: 24px;
    line-height: 1;
}

.fila-edicion-abono input:focus,
.fila-edicion-abono select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* FOOTER */
.abonos-footer {
    padding: 20px 25px;
    background: #f8f9fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
    border-radius: 0 0 12px 12px;
}

.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    min-width: 160px;
    justify-content: center;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-success {
    background: linear-gradient(135deg, #27ae60, #219a52);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    min-width: 160px;
    justify-content: center;
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
}

.btn-success:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    min-width: 160px;
    justify-content: center;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-secondary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ESTILOS PARA MODO SOLO LECTURA */
.modo-solo-lectura .abonos-section {
    opacity: 0.8;
    background: #f8f9fa;
}

.modo-solo-lectura .form-group select,
.modo-solo-lectura .form-group input {
    background: #e9ecef;
    cursor: not-allowed;
    border-color: #ced4da;
}

.modo-solo-lectura .btn-primary,
.modo-solo-lectura .btn-secondary,
.modo-solo-lectura .btn-success,
.modo-solo-lectura .btn-agregar-abono {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.modo-solo-lectura .btn-primary:hover,
.modo-solo-lectura .btn-secondary:hover,
.modo-solo-lectura .btn-success:hover,
.modo-solo-lectura .btn-agregar-abono:hover {
    transform: none;
    box-shadow: none;
}

.modo-solo-lectura .btn-accion {
    opacity: 0.3;
    cursor: not-allowed;
}

.modo-solo-lectura .btn-accion:hover {
    background: none;
    color: inherit;
}

/* LOADING STATES */
.loading-abonos {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 2s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* SCROLLBAR PERSONALIZADO */
.tabla-abonos-container::-webkit-scrollbar {
    width: 6px;
}

.tabla-abonos-container::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

.tabla-abonos-container::-webkit-scrollbar-thumb {
    background: #3498db;
    border-radius: 4px;
    border: 2px solid #f8f9fa;
}

.tabla-abonos-container::-webkit-scrollbar-thumb:hover {
    background: #2980b9;
}

.tabla-abonos-container {
    scrollbar-width: thin;
    scrollbar-color: #3498db #f8f9fa;
}

.abonos-body::-webkit-scrollbar {
    width: 8px;
}

.abonos-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.abonos-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.abonos-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive */
@media (max-width: 1200px) {
    .abonos-header-info {
        gap: 20px;
    }
    
    .abonos-header-line .header-item {
        font-size: 12px;
    }
    
    .abonos-header-line .header-item strong {
        font-size: 10px;
    }
}

@media (max-width: 768px) {
    .modal-abonos-content {
        margin: 5% auto;
        width: 98%;
        max-height: 95vh;
    }
    
    .abonos-header-info {
        flex-direction: column;
        gap: 8px;
    }
    
    .abonos-header-line {
        flex-direction: column;
        gap: 8px;
    }
    
    .abonos-header-line .header-item {
        min-width: 100%;
    }
    
    .estadisticas-pedido {
        grid-template-columns: 1fr;
    }
    
    .abonos-footer {
        flex-direction: column;
    }
    
    .btn-primary, .btn-secondary, .btn-success {
        width: 100%;
        min-width: auto;
    }
    
    .tabla-abonos {
        table-layout: auto;
        min-width: 800px;
    }
    
    .tabla-abonos th,
    .tabla-abonos td {
        line-height: 1.2;
        box-sizing: border-box;
    }
}

/*--------------nuevos stilos----------------------*/
/*--------------nuevos stilos----------------------*/
/*--------------nuevos stilos----------------------*/
/*--------------nuevos stilos----------------------*/


/* Estilos para el sistema de lote */
.fila-edicion-abono {
    background: #fff9e6 !important;
    border-left: 3px solid #ffc107;
}

.fila-edicion-abono td {
    color: #856404 !important;
    font-style: italic;
}

#badgeCambiosPendientes {
    background: #ffc107 !important;
    color: #000 !important;
    margin-left: 8px;
    font-size: 11px;
    padding: 3px 8px;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary:disabled:hover {
    transform: none;
    box-shadow: none;
}


/*--------------nuevos stilos----------------------*/
/*--------------nuevos stilos----------------------*/
/*--------------nuevos stilos----------------------*/
/*--------------nuevos stilos----------------------*/



/* ESTILOS MEJORADOS PARA TOASTS - VISIBLES SOBRE MODALES */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10050; /* 🔥 MAYOR que todos los modales */
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none; /* Permite clicks a través del contenedor */
}

.toast-container > * {
    pointer-events: auto; /* Los toasts individuales sí reciben clicks */
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    border: 1px solid;
    max-width: 450px;
    min-width: 300px;
    animation: slideInRight 0.3s ease-out;
    z-index: 10051;
    position: relative;
    font-weight: 500;
    font-size: 14px;
    backdrop-filter: blur(10px); /* Efecto glass moderno */
}

.toast-success {
    background: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.toast-error {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.toast-warning {
    background: #fff3cd;
    color: #856404;
    border-color: #ffeaa7;
}

.toast-info {
    background: #d1ecf1;
    color: #0c5460;
    border-color: #b8ebf4;
}

.toast-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.7;
    padding: 4px;
    border-radius: 4px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.toast-close:hover {
    opacity: 1;
    background: rgba(0,0,0,0.1);
}

/* Animaciones mejoradas */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Asegurar que los toasts estén siempre visibles */
.modal-abonos ~ .toast-container,
.modal-identificacion-overlay ~ .toast-container,
.confirmacion-overlay ~ .toast-container {
    z-index: 10050 !important;
}
