body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    color: #333;
}

header {
    background-color: #333;
    color: #fff;
    padding: 1rem 0;
    text-align: center;
}

header h1 {
    margin: 0;
}

nav ul {
    list-style: none;
    padding: 0;
    display: flex;
    justify-content: center;
    gap: 20px;
}

nav a {
    color: #fff;
    text-decoration: none;
    font-weight: bold;
}

main {
    padding: 20px;
}

section {
    background-color: #fff;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: none; /* Por defecto ocultamos todas las secciones */
}

section.section-active {
    display: block; /* Solo mostramos la sección activa */
}

#product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.product-card {
    background-color: #e9e9e9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.product-card h3 {
    margin-top: 0;
    color: #0056b3;
}

.product-card p {
    margin: 5px 0;
}

.product-card button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    margin: 5px;
}

.product-card button:hover {
    background-color: #0056b3;
}

#addProductBtn {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    margin-bottom: 20px;
}

#addProductBtn:hover {
    background-color: #218838;
}

/* Estilos para el formulario de agregar/modificar producto */
.product-form {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
    display: none; /* Oculto por defecto */
}

.product-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.product-form input {
    width: calc(100% - 20px);
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.product-form button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    margin-right: 10px;
}

.product-form button.cancel {
    background-color: #6c757d;
}

.product-form button:hover {
    opacity: 0.9;
}


/* Estilos del Modal */
.modal {
    display: none; /* Oculto por defecto */
    position: fixed; /* Posición fija para cubrir toda la ventana */
    z-index: 1000; /* Estar por encima de otros elementos */
    left: 0;
    top: 0;
    width: 100%; /* Ancho completo */
    height: 100%; /* Alto completo */
    overflow: auto; /* Habilitar scroll si el contenido es muy largo */
    background-color: rgba(0,0,0,0.4); /* Fondo semi-transparente */
    justify-content: center; /* Centrar horizontalmente */
    align-items: center; /* Centrar verticalmente */
}

.modal-content {
    background-color: #fefefe;
    margin: auto; /* Centrar en la pantalla */
    padding: 20px;
    border: 1px solid #888;
    width: 80%; /* Ancho del contenido del modal */
    max-width: 500px; /* Ancho máximo para pantallas grandes */
    border-radius: 10px;
    position: relative;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.close-button, .cancel-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    margin-left: 10px;
}

.close-button:hover,
.close-button:focus,
.cancel-button:hover,
.cancel-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal-content h2 {
    margin-top: 0;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.modal-content label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}

.modal-content input[type="text"],
.modal-content input[type="number"] {
    width: calc(100% - 22px); /* Ajustar el ancho considerando el padding y border */
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box; /* Incluir padding y border en el ancho total */
}

.modal-content button[type="submit"],
.modal-content .cancel-button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

.modal-content button[type="submit"]:hover {
    background-color: #0056b3;
}

.modal-content .cancel-button {
    background-color: #6c757d;
    margin-left: 10px;
}

.modal-content .cancel-button:hover {
    background-color: #5a6268;
}


/* Estilos para alertas de stock en las tarjetas de producto */
.product-card h3.stock-orange {
    color: orange;
    border: 1px solid orange;
    padding: 5px;
    border-radius: 5px;
}

.product-card h3.stock-red {
    color: red;
    border: 1px solid red;
    padding: 5px;
    border-radius: 5px;
}


/* Estilos para la sección de Facturación (Punto de Venta) */
.sale-container {
    display: flex;
    flex-wrap: wrap; /* Permite que los elementos se envuelvan en pantallas pequeñas */
    gap: 30px;
    margin-top: 20px;
}

.product-selection, .cart-summary {
    background-color: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    flex: 1; /* Permite que ocupen el espacio disponible */
    min-width: 300px; /* Ancho mínimo para cada columna */
}

.product-selection h3, .cart-summary h3 {
    margin-top: 0;
    color: #0056b3;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

#productSearch {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 1rem;
}

.search-results {
    border: 1px solid #eee;
    max-height: 200px;
    overflow-y: auto;
    background-color: #fff;
    border-radius: 5px;
    margin-bottom: 10px;
}

.search-result-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: #e0f2f7; /* Un azul claro al pasar el ratón */
}

.selected-product-info {
    border: 1px dashed #ccc;
    padding: 15px;
    margin-top: 15px;
    border-radius: 8px;
    background-color: #e9f5ff; /* Fondo más claro para información de producto */
}

.selected-product-info label {
    display: block;
    margin-top: 10px;
    margin-bottom: 5px;
    font-weight: bold;
}

.selected-product-info input[type="number"] {
    width: calc(100% - 22px);
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-sizing: border-box;
}

#addToCartBtn {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
}

#addToCartBtn:hover {
    background-color: #218838;
}

/* Estilos del Carrito */
#cartItems {
    min-height: 150px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #eee;
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 5px;
    background-color: #fff;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed #eee;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-info span {
    display: block;
    font-size: 0.9em;
    color: #666;
}

.cart-item-actions button {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    margin-left: 5px;
}

.cart-item-actions button:hover {
    background-color: #c82333;
}

.cart-totals {
    border-top: 2px solid #ddd;
    padding-top: 15px;
    margin-top: 15px;
    text-align: right;
}

.cart-totals p {
    margin: 5px 0;
    font-size: 1.1em;
}

.cart-totals h3 {
    font-size: 1.5em;
    color: #0056b3;
}

.action-button {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 10px;
    margin-right: 10px;
}

.action-button.primary-button {
    background-color: #007bff;
}

.action-button:hover {
    opacity: 0.9;
}

.action-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Ajustes responsivos */
@media (max-width: 768px) {
    .sale-container {
        flex-direction: column;
    }
}


/* Estilos para la cuadrícula de productos disponibles en la sección de venta */
.available-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); /* Columnas más pequeñas para más productos */
    gap: 15px;
    margin-top: 15px;
    max-height: 400px; /* Limitar altura y permitir scroll */
    overflow-y: auto;
    padding-right: 5px; /* Para evitar que la barra de scroll se monte en el contenido */
}

.available-product-card {
    background-color: #f0f8ff; /* Un color ligeramente distinto para diferenciar */
    border: 1px solid #cceeff;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.available-product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.available-product-card h4 {
    margin-top: 5px;
    margin-bottom: 5px;
    color: #007bff;
    font-size: 1.1em;
}

.available-product-card p {
    margin: 3px 0;
    font-size: 0.9em;
    color: #555;
}

/* Estilos para cuando un producto no tiene stock */
.available-product-card.no-stock {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #fdd;
    border-color: #fbb;
}

.available-product-card.no-stock h4 {
    color: #cc0000;
}


/* Estilos para la sección de Métodos de Pago */
.payment-options {
    background-color: #e6f7ff; /* Fondo ligeramente diferente para esta sección */
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-top: 30px;
    border: 1px solid #b3e0ff;
}

.payment-options h3 {
    margin-top: 0;
    color: #004d80;
    border-bottom: 1px solid #cceeff;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.payment-method-selection {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    justify-content: center;
}

.payment-button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background-color 0.3s ease, transform 0.1s ease;
    flex: 1; /* Permite que los botones ocupen espacio equitativamente */
    max-width: 200px;
}

.payment-button:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

.payment-button.active {
    background-color: #004085;
    border: 2px solid #002752;
    transform: translateY(0);
}


.payment-details {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #ddd;
    margin-top: 20px;
}

.payment-details h4 {
    color: #333;
    margin-top: 0;
    margin-bottom: 15px;
}

.payment-details label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

.payment-details input[type="number"] {
    width: calc(100% - 22px);
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 1rem;
}

.payment-details p {
    margin: 10px 0;
    font-size: 1.1em;
}

.payment-details .action-button {
    width: 100%;
    margin-top: 20px;
    padding: 12px;
    font-size: 1.2rem;
}

/* Animación POS (Pago con tarjeta) */
.pos-animation {
    text-align: center;
    padding: 30px 0;
    border: 2px dashed #007bff;
    border-radius: 10px;
    background-color: #f8fcff;
    margin-bottom: 20px;
}

.pos-animation p {
    font-size: 1.3rem;
    font-weight: bold;
    color: #0056b3;
    margin-bottom: 15px;
}

.spinner {
    border: 6px solid #f3f3f3; /* Light grey */
    border-top: 6px solid #3498db; /* Blue */
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 2s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Estilos para el modal de la factura */
.modal-content.invoice-content {
    max-width: 600px; /* Ancho más adecuado para una factura */
    text-align: left;
}

.printable-invoice {
    padding: 20px;
    border: 1px dashed #ccc;
    margin-bottom: 20px;
    background-color: #fcfcfc;
}

.printable-invoice h3 {
    text-align: center;
    color: #333;
    margin-bottom: 20px;
}

.printable-invoice hr {
    border: 0;
    border-top: 1px dashed #eee;
    margin: 20px 0;
}

.printable-invoice ul {
    list-style: none;
    padding: 0;
    margin-bottom: 20px;
}

.printable-invoice ul li {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px dotted #eee;
    font-size: 0.95em;
}

.printable-invoice ul li:last-child {
    border-bottom: none;
}

.invoice-summary {
    text-align: right;
    border-top: 1px dashed #ccc;
    padding-top: 15px;
    margin-top: 20px;
}

.invoice-summary p {
    margin: 5px 0;
    font-size: 1.1em;
}

.invoice-summary strong {
    font-size: 1.3em;
    color: #0056b3;
}

/* Estilos para impresión (ocultar botones, etc.) */
/* Estilos para impresión (ocultar elementos no deseados) */
@media print {
    body {
        margin: 0;
        padding: 0;
        background-color: #fff; /* Asegurarse de un fondo blanco al imprimir */
    }
    header, nav, main section:not(#invoiceModal), .modal-content button, .modal-content .close-button, .modal-content .cancel-button {
        display: none !important; /* Oculta header, nav, secciones principales excepto el modal y botones del modal */
    }

    #invoiceModal {
        position: static !important; /* Permite que el modal fluya normalmente para impresión */
        display: block !important; /* Asegura que el modal sea visible */
        background-color: transparent !important; /* Fondo transparente para que solo se vea la factura */
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    .modal-content.invoice-content {
        width: 100% !important;
        max-width: 100% !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    .printable-invoice {
        border: none !important; /* Quita el borde punteado para la impresión final */
        background-color: white !important;
        padding: 0 !important;
    }
}




/* Estilos para la sección de Historial */
.filters-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-weight: bold;
    margin-bottom: 5px;
    color: #555;
}

.filters-container input, .filters-container select {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 0.95em;
}

.history-summary-box {
    text-align: right;
    margin-bottom: 15px;
    font-size: 1.1em;
    color: #333;
}

.table-container {
    overflow-x: auto;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#historyTable {
    width: 100%;
    border-collapse: collapse;
}

#historyTable thead {
    background-color: #007bff;
    color: white;
}

#historyTable th, #historyTable td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
    font-size: 0.95em;
}

#historyTable tbody tr:hover {
    background-color: #f1f8ff;
}

#historyTable td button {
    padding: 6px 12px;
    font-size: 0.9em;
}

#historyTable td button.view-details-btn {
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}