/* Estilos para el módulo de Facturas */

.sgt-facturas-system {
    padding: 20px;
}

/* Modal grande para facturas */
.sgt-modal-large {
    max-width: 900px;
    width: 90%;
}

#sgt-factura-modal .sgt-modal-body {
    position: relative;
    padding-bottom: 100px;
}

/* Contenedor de líneas de factura */
.sgt-factura-lineas-container {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-top: 10px;
}

.sgt-factura-lineas-header {
    display: grid;
    grid-template-columns: 120px 2fr 100px 120px 120px 50px;
    gap: 10px;
    padding: 10px 0;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 10px;
}

.sgt-factura-linea {
    display: grid;
    grid-template-columns: 120px 2fr 100px 120px 120px 50px;
    gap: 10px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.sgt-factura-linea:last-child {
    border-bottom: none;
}

.sgt-linea-codigo,
.sgt-linea-concepto {
    width: 100%;
}

.sgt-linea-cantidad,
.sgt-linea-precio {
    width: 100%;
    text-align: right;
}

.sgt-linea-cantidad,
.sgt-linea-precio,
#sgt-factura-descuento {
    font-variant-numeric: tabular-nums;
}

.sgt-linea-total-display {
    font-weight: 600;
    color: #2c3e50;
    text-align: right;
    padding-right: 10px;
}

#sgt-add-linea-factura {
    margin-top: 10px;
    width: 100%;
}

/* Totales de factura */
.sgt-factura-totales {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-top: 15px;
}

.sgt-totales-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
    margin-left: auto;
}

.sgt-total-row {
    display: grid;
    grid-template-columns: 1fr 150px;
    align-items: center;
    gap: 15px;
    padding: 8px 0;
}

.sgt-total-label {
    font-size: 0.95rem;
    font-weight: 500;
    color: #495057;
    text-align: right;
}

.sgt-total-value {
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
    text-align: right;
}

.sgt-total-input {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.95rem;
    text-align: right;
    font-weight: 600;
    color: #2c3e50;
    transition: all 0.2s;
}

.sgt-total-input:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* Total en el footer del modal */
#sgt-factura-modal .sgt-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.sgt-footer-total {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.sgt-footer-total-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sgt-footer-total-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
}

.sgt-footer-buttons {
    display: flex;
    gap: 10px;
}

/* Vista de factura en modal - Diseño Sobrio y Elegante */
.sgt-factura-view {
    text-align: left;
}

.sgt-factura-info {
    background: #1a1a2e;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    color: #f0f0f0;
    border: 1px solid #2d2d44;
}

.sgt-factura-info p {
    margin: 10px 0;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sgt-factura-info strong {
    font-weight: 500;
    color: #a0a0b0;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

/* Contenedor con scroll horizontal para la tabla */
.sgt-factura-table-wrapper {
    overflow-x: auto;
    margin: 24px 0;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.sgt-factura-lineas-table {
    width: 100%;
    min-width: 600px;
    margin: 0;
    border-collapse: collapse;
    table-layout: fixed;
    background: white;
}

.sgt-factura-lineas-table th,
.sgt-factura-lineas-table td {
    padding: 16px 14px;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.sgt-factura-lineas-table tbody tr {
    transition: background-color 0.15s ease;
}

.sgt-factura-lineas-table tbody tr:hover {
    background-color: #fafafa;
}

.sgt-factura-lineas-table tbody tr:last-child td {
    border-bottom: none;
}

/* Anchos de columna específicos */
.sgt-factura-lineas-table th:nth-child(1),
.sgt-factura-lineas-table td:nth-child(1) {
    width: 160px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 0.95rem;
    color: #1a1a1a;
    font-weight: 500;
}

.sgt-factura-lineas-table th:nth-child(2),
.sgt-factura-lineas-table td:nth-child(2) {
    width: auto;
    min-width: 200px;
    font-weight: 400;
    color: #1a1a1a;
}

.sgt-factura-lineas-table th:nth-child(3),
.sgt-factura-lineas-table td:nth-child(3) {
    width: 70px;
    text-align: center;
    font-weight: 500;
    color: #4a4a5a;
}

.sgt-factura-lineas-table th:nth-child(4),
.sgt-factura-lineas-table td:nth-child(4) {
    width: 110px;
    text-align: right;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    color: #5a5a6a;
}

.sgt-factura-lineas-table th:nth-child(5),
.sgt-factura-lineas-table td:nth-child(5) {
    width: 110px;
    text-align: right;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    color: #1a1a1a;
}

.sgt-factura-lineas-table th {
    background: #f8f8f8;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6a6a7a;
    white-space: nowrap;
    border-bottom: 2px solid #e5e5e5;
}

.sgt-factura-totales-view {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    margin-top: 24px;
    border: 1px solid #e5e7eb;
}

.sgt-factura-totales-view p {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    font-size: 0.9rem;
    color: #5a5a6a;
}

.sgt-factura-totales-view p strong {
    color: #1a1a1a;
    font-weight: 500;
}

.sgt-factura-totales-view .total-final {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1a1a1a;
    padding-top: 20px;
    margin-top: 15px;
    border-top: 1px solid #e5e5e5;
}

.sgt-factura-notas {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: 4px;
    padding: 15px;
    margin-top: 20px;
}

.sgt-factura-notas p {
    margin: 0;
    font-size: 0.9rem;
}

/* Badges de estado */
.sgt-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

.sgt-badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

.sgt-badge-success {
    background: #d4edda;
    color: #155724;
}

.sgt-badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.sgt-badge-warning {
    background: #fff3cd;
    color: #856404;
}

.sgt-badge-secondary {
    background: #e2e3e5;
    color: #383d41;
}

/* Modal moderno de confirmación */
.sgt-modern-popup {
    border-radius: 16px !important;
    border: 1px solid #e5e7eb !important;
}

.sgt-confirm-btn {
    background: #1a1a2e !important;
    border-radius: 8px !important;
    padding: 12px 24px !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
}

.sgt-confirm-btn:hover {
    background: #2d2d44 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 26, 46, 0.3);
}

.sgt-cancel-btn {
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    color: #5a5a6a !important;
    border-radius: 8px !important;
    padding: 12px 24px !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
}

.sgt-cancel-btn:hover {
    background: #f8f8f8 !important;
    border-color: #d1d5db !important;
}

/* Botones de estado */
.sgt-estado-buttons {
    display: flex;
    gap: 10px;
}

.sgt-estado-btn {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #dee2e6;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.sgt-estado-btn:hover {
    border-color: #4CAF50;
    background: #f1f8f4;
}

.sgt-estado-btn.active {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.sgt-estado-btn i {
    font-size: 16px;
}

/* Input con icono */
.sgt-input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sgt-input-with-icon .sgt-input {
    flex: 1;
}

.sgt-icon-btn {
    background: #2196F3;
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sgt-icon-btn:hover {
    background: #1976D2;
    transform: scale(1.05);
}

.sgt-icon-btn i {
    font-size: 16px;
}

/* Botón de eliminar línea */
.sgt-remove-btn {
    background: #dc3545;
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.sgt-remove-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

.sgt-remove-btn i {
    font-size: 14px;
}

/* Sugerencias de clientes */
.sgt-form-group {
    position: relative;
}

.sgt-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-top: 2px;
}

.sgt-cliente-suggestion {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.sgt-cliente-suggestion:hover {
    background: #f8f9fa;
}

.sgt-cliente-suggestion:last-child {
    border-bottom: none;
}

/* SweetAlert z-index para modales sobre facturas */
.swal-cliente-high-z,
.swal-datos-cliente-high-z {
    z-index: 10000 !important;
}

.swal2-container.swal-cliente-high-z,
.swal2-container.swal-datos-cliente-high-z {
    z-index: 10000 !important;
}

.swal2-container.swal-cliente-high-z .swal2-popup,
.swal2-container.swal-datos-cliente-high-z .swal2-popup {
    z-index: 10001 !important;
}

/* SweetAlert toast notifications - z-index más alto */
.swal2-container.swal2-top-end {
    z-index: 99999 !important;
}

.swal2-container .swal2-toast {
    z-index: 99999 !important;
}

/* Filtro de fechas */
.sgt-filter-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.sgt-date-filter-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.sgt-date-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    transition: all 0.2s;
}

.sgt-date-filter-group:hover {
    border-color: #2196F3;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.1);
}

.sgt-date-filter-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2196F3;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
}

.sgt-date-filter-group label i {
    font-size: 14px;
}

.sgt-date-input {
    border: none;
    padding: 0;
    font-size: 0.9rem;
    color: #495057;
    background: transparent;
    width: 140px;
}

.sgt-date-input:focus {
    outline: none;
}

.sgt-icon-clear-btn {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    background: white;
    color: #dc3545;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sgt-icon-clear-btn:hover {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.sgt-icon-clear-btn i {
    font-size: 14px;
}

/* Filas de tabla clickeables */
#facturas-tbody tr {
    cursor: pointer;
    transition: background-color 0.2s;
}

#facturas-tbody tr:hover {
    background-color: #ffebee !important;
}

/* Sobrescribir hover de celdas individuales para facturas */
#facturas-tbody tr:hover td {
    background-color: transparent !important;
}

#facturas-tbody td:hover::after {
    display: none !important;
}

/* Botones de acciones más grandes y fáciles de pulsar - SOBRESCRIBIR ESTILOS ANTIGUOS */
.sgt-facturas-system .sgt-action-buttons,
#facturas-tbody .sgt-action-buttons {
    display: flex !important;
    gap: 8px !important;
    justify-content: flex-end !important;
}

.sgt-facturas-system .sgt-action-buttons button,
#facturas-tbody .sgt-action-buttons button {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    border: none !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    font-size: 16px !important;
}


.sgt-facturas-system .sgt-action-buttons button:hover,
#facturas-tbody .sgt-action-buttons button:hover {
    transform: scale(1.1) !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2) !important;
}

.sgt-facturas-system .sgt-action-buttons .sgt-pdf-btn,
#facturas-tbody .sgt-action-buttons .sgt-pdf-btn {
    background: #dc3545 !important;
    color: white !important;
}

.sgt-facturas-system .sgt-action-buttons .sgt-pdf-btn:hover,
#facturas-tbody .sgt-action-buttons .sgt-pdf-btn:hover {
    background: #c82333 !important;
}

.sgt-facturas-system .sgt-action-buttons .sgt-edit-btn,
#facturas-tbody .sgt-action-buttons .sgt-edit-btn {
    background: #2196F3 !important;
    color: white !important;
}

.sgt-facturas-system .sgt-action-buttons .sgt-edit-btn:hover,
#facturas-tbody .sgt-action-buttons .sgt-edit-btn:hover {
    background: #0b7dda !important;
}

.sgt-facturas-system .sgt-action-buttons .sgt-cancel-btn,
#facturas-tbody .sgt-action-buttons .sgt-cancel-btn {
    background: #ff9800 !important;
    color: white !important;
}

.sgt-facturas-system .sgt-action-buttons .sgt-cancel-btn:hover,
#facturas-tbody .sgt-action-buttons .sgt-cancel-btn:hover {
    background: #e68900 !important;
}

.sgt-facturas-system .sgt-action-buttons .sgt-delete-btn,
#facturas-tbody .sgt-action-buttons .sgt-delete-btn {
    background: #6c757d !important;
    color: white !important;
}

.sgt-facturas-system .sgt-action-buttons .sgt-delete-btn:hover,
#facturas-tbody .sgt-action-buttons .sgt-delete-btn:hover {
    background: #5a6268 !important;
}

/* Badges clickeables */
.sgt-badge-info,
.sgt-badge-success {
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.sgt-badge-info:hover {
    background: #bee5eb;
    transform: scale(1.05);
}

.sgt-badge-success:hover {
    background: #c3e6cb;
    transform: scale(1.05);
}

/* Responsive */
@media (max-width: 768px) {
    .sgt-factura-lineas-header,
    .sgt-factura-linea {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .sgt-linea-total-display {
        text-align: left;
        padding-right: 0;
        padding-left: 10px;
    }

    .sgt-modal-large {
        width: 95%;
    }

    .sgt-totales-compact {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .sgt-action-buttons button {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
    }

    .sgt-action-buttons button i {
        font-size: 16px !important;
    }
}

/* Estilos para contadores de envíos */
.sgt-envio-counter {
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 10;
}

.sgt-envio-counter:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

/* Animación para cuando se actualiza un contador */
.sgt-envio-counter.envio-actualizado {
    animation: highlightEnvio 1s ease-in-out;
}

@keyframes highlightEnvio {
    0% {
        transform: scale(1);
        box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    }
    25% {
        transform: scale(1.4);
        box-shadow: 0 6px 12px rgba(255,215,0,0.6);
        filter: brightness(1.3);
    }
    50% {
        transform: scale(1.3);
        box-shadow: 0 4px 8px rgba(255,215,0,0.5);
        filter: brightness(1.2);
    }
    75% {
        transform: scale(1.2);
        box-shadow: 0 3px 6px rgba(255,215,0,0.3);
        filter: brightness(1.1);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 2px 4px rgba(0,0,0,0.2);
        filter: brightness(1);
    }
}

/* Estilos adicionales para botones con contadores */
.sgt-email-btn,
.sgt-whatsapp-btn {
    position: relative !important;
}

/* Tooltip mejorado para mostrar información de envíos */
.sgt-email-btn[title*="enviada"],
.sgt-whatsapp-btn[title*="enviada"] {
    opacity: 0.8;
}

.sgt-email-btn[title*="enviada"]:hover,
.sgt-whatsapp-btn[title*="enviada"]:hover {
    opacity: 1;
}

/* Resaltar botones cuando tienen envíos */
.sgt-envio-counter {
    font-family: Arial, sans-serif;
    font-weight: bold;
    border: 2px solid white;
}