/**
 * ArrTec POS v2 - Estilos Principales
 */

/* Reset y base */
.arrtec-pos-body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f5f5;
    color: #333;
    overflow-x: hidden;
}

/* Header */
.arrtec-pos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2c3e50;
    color: #fff;
    padding: 12px 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.pos-header-left,
.pos-header-right {
    flex: 1;
}

.pos-header-center {
    flex: 2;
    text-align: center;
}

.pos-header-center h1 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.pos-user {
    font-weight: 500;
}

.pos-logout-btn {
    display: inline-block;
    padding: 6px 12px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.85rem;
    transition: background 0.2s;
    float: right;
}

.pos-logout-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* Contenedor principal */
.arrtec-pos-container {
    display: flex;
    height: calc(100vh - 50px);
    margin-top: 50px;
}

/* Panel de productos */
.pos-products-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    overflow: hidden;
}

/* Barra de búsqueda */
.pos-search-bar {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
}

.pos-search-bar input[type="text"] {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.pos-search-bar input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
}

.pos-stock-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #666;
    cursor: pointer;
    white-space: nowrap;
}

.pos-stock-filter input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

/* Contador de productos */
.pos-products-count {
    padding: 8px 20px;
    font-size: 0.8rem;
    color: #888;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
}

/* Grid de productos */
.pos-products-grid {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    align-content: start;
}

/* Tarjeta de producto */
.pos-product-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.pos-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.pos-product-image {
    height: 120px;
    background: #f8f8f8;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.pos-product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.pos-product-info {
    padding: 12px;
}

.pos-product-name {
    margin: 0 0 6px;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.3;
    height: 36px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.pos-product-price {
    font-size: 1rem;
    font-weight: 600;
    color: #27ae60;
    margin-bottom: 6px;
}

.pos-product-stock {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 12px;
    display: inline-block;
}

.pos-product-stock.instock {
    background: #e8f5e9;
    color: #2e7d32;
}

.pos-product-stock.outofstock {
    background: #ffebee;
    color: #c62828;
}

.pos-add-to-cart {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #3498db;
    color: #fff;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
}

.pos-add-to-cart:hover {
    background: #2980b9;
    transform: scale(1.1);
}

.pos-add-to-cart:active {
    transform: scale(0.95);
}

/* Loading indicator */
.pos-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    gap: 12px;
    color: #666;
}

.pos-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Paginación */
.pos-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 15px;
    background: #fafafa;
    border-top: 1px solid #e0e0e0;
}

.pos-page-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.pos-page-btn:hover:not(:disabled) {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}

.pos-page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#pos-page-info {
    font-size: 0.85rem;
    color: #666;
}

/* Panel del carrito */
.pos-cart-panel {
    width: 380px;
    background: #fff;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #e0e0e0;
    overflow: hidden;
}

/* Sección de cliente */
.pos-customer-section {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    position: relative;
}

.pos-customer-section input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.pos-customer-section input:focus {
    outline: none;
    border-color: #3498db;
}

.pos-customer-results {
    position: absolute;
    top: 100%;
    left: 15px;
    right: 15px;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.pos-customer-result-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.pos-customer-result-item:hover {
    background: #f5f5f5;
}

.pos-customer-result-item .customer-name {
    display: block;
    font-weight: 500;
}

.pos-customer-result-item .customer-email {
    display: block;
    font-size: 0.8rem;
    color: #888;
}

.pos-selected-customer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #e8f5e9;
    border-radius: 6px;
    margin-top: 10px;
}

.pos-selected-customer .customer-name {
    font-weight: 500;
    color: #2e7d32;
}

.pos-remove-customer {
    background: none;
    border: none;
    color: #c62828;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 5px;
}

/* Producto manual */
.pos-manual-product {
    display: flex;
    gap: 8px;
    padding: 12px 15px;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
}

.pos-manual-product input {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
}

.pos-manual-product input[type="text"] {
    flex: 2;
}

.pos-manual-product input[type="number"] {
    flex: 1;
}

.pos-btn-add {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: #27ae60;
    color: #fff;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

.pos-btn-add:hover {
    background: #219a52;
}

/* Items del carrito */
.pos-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.pos-empty-cart {
    text-align: center;
    color: #888;
    padding: 40px 20px;
}

.pos-cart-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #fafafa;
    border-radius: 6px;
    margin-bottom: 8px;
    position: relative;
}

.pos-cart-item-info {
    flex: 1;
    min-width: 0;
}

.pos-cart-item-name {
    display: block;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pos-cart-item-price {
    display: block;
    font-size: 0.8rem;
    color: #888;
}

.pos-cart-item-qty {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pos-qty-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.pos-qty-btn:hover {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}

.pos-cart-item-qty input {
    width: 45px;
    text-align: center;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.pos-cart-item-qty input:focus {
    outline: none;
    border-color: #3498db;
}

.pos-stock-warning {
    background: #ffebee;
}

.pos-cart-item-total {
    font-weight: 600;
    color: #27ae60;
    min-width: 70px;
    text-align: right;
}

.pos-cart-item-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    color: #c62828;
    font-size: 1rem;
    cursor: pointer;
    padding: 5px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.pos-cart-item-remove:hover {
    opacity: 1;
}

/* Resumen del carrito */
.pos-cart-summary {
    padding: 15px;
    background: #f8f8f8;
    border-top: 1px solid #e0e0e0;
}

.pos-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.pos-summary-row input {
    width: 70px;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    font-size: 0.9rem;
}

.pos-summary-divider {
    height: 1px;
    background: #ddd;
    margin: 12px 0;
}

.pos-subtotal {
    color: #666;
}

.pos-discount-value {
    color: #27ae60;
}

.pos-fee-value {
    color: #c0392b;
}

.pos-total {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
}

/* Botón de checkout */
.pos-checkout-btn {
    width: calc(100% - 30px);
    margin: 15px;
    padding: 15px;
    background: #27ae60;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.pos-checkout-btn:hover:not(:disabled) {
    background: #219a52;
}

.pos-checkout-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.pos-checkout-btn:active:not(:disabled) {
    transform: scale(0.98);
}

/* Nota del cliente */
.pos-customer-note {
    padding: 0 15px 15px;
}

.pos-customer-note textarea {
    width: 100%;
    height: 60px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.85rem;
    resize: none;
    box-sizing: border-box;
    font-family: inherit;
}

.pos-customer-note textarea:focus {
    outline: none;
    border-color: #3498db;
}

/* Modales */
.pos-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.pos-modal-content {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.pos-modal-content h3 {
    margin: 0 0 20px;
    font-size: 1.2rem;
}

.pos-form-group {
    margin-bottom: 15px;
}

.pos-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

.pos-form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    box-sizing: border-box;
}

.pos-form-group input:focus {
    outline: none;
    border-color: #3498db;
}

.pos-modal-summary {
    background: #f8f8f8;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.pos-modal-summary p {
    margin: 5px 0;
    font-size: 0.9rem;
}

.pos-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.pos-btn-cancel,
.pos-btn-confirm {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.pos-btn-cancel {
    background: #fff;
    border: 1px solid #ddd;
    color: #666;
}

.pos-btn-cancel:hover {
    background: #f5f5f5;
}

.pos-btn-confirm {
    background: #3498db;
    border: none;
    color: #fff;
}

.pos-btn-confirm:hover {
    background: #2980b9;
}

/* Controles de cantidad en modal */
.pos-qty-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.pos-qty-controls .pos-qty-btn {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    border-radius: 8px;
}

.pos-qty-controls input {
    width: 80px;
    text-align: center;
    padding: 12px;
    font-size: 1.5rem;
    border: 1px solid #ddd;
    border-radius: 6px;
}

/* Toast notifications */
.pos-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 8px;
    color: #fff;
    font-size: 0.9rem;
    z-index: 3000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.pos-toast-success {
    background: #27ae60;
}

.pos-toast-error {
    background: #c0392b;
}

.pos-toast-info {
    background: #3498db;
}

/* No products */
.pos-no-products {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #888;
}

/* Error message */
.pos-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #c62828;
    background: #ffebee;
    border-radius: 8px;
    margin: 20px;
}

/* Responsive */
@media (max-width: 1024px) {
    .arrtec-pos-container {
        flex-direction: column;
    }
    
    .pos-products-panel {
        flex: 1;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
    
    .pos-cart-panel {
        width: 100%;
        height: 50%;
        border-left: none;
    }
    
    .pos-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

@media (max-width: 768px) {
    .arrtec-pos-header {
        padding: 10px 15px;
    }
    
    .pos-header-center h1 {
        font-size: 1rem;
    }
    
    .pos-search-bar {
        flex-direction: column;
        gap: 10px;
    }
    
    .pos-search-bar input[type="text"] {
        width: 100%;
    }
    
    .pos-stock-filter {
        justify-content: flex-start;
    }
    
    .pos-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }
    
    .pos-product-image {
        height: 80px;
    }
    
    .pos-product-info {
        padding: 8px;
    }
    
    .pos-product-name {
        font-size: 0.75rem;
        height: 32px;
    }
    
    .pos-product-price {
        font-size: 0.9rem;
    }
    
    .pos-add-to-cart {
        width: 30px;
        height: 30px;
        bottom: 8px;
        right: 8px;
        font-size: 1.2rem;
    }
    
    .pos-cart-panel {
        height: auto;
        max-height: 50vh;
    }
    
    .pos-cart-item {
        flex-wrap: wrap;
    }
    
    .pos-cart-item-qty {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 8px;
    }
    
    .pos-cart-item-total {
        order: 2;
        margin-left: auto;
    }
}

@media (max-width: 480px) {
    .pos-products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .pos-manual-product {
        flex-wrap: wrap;
    }
    
    .pos-manual-product input[type="text"] {
        flex: 1 1 100%;
    }
    
    .pos-manual-product input[type="number"] {
        flex: 1;
    }
    
    .pos-btn-add {
        flex: 0 0 100%;
        margin-top: 8px;
    }
}

/* Scrollbar styles */
.pos-products-grid::-webkit-scrollbar,
.pos-cart-items::-webkit-scrollbar,
.pos-customer-results::-webkit-scrollbar {
    width: 8px;
}

.pos-products-grid::-webkit-scrollbar-track,
.pos-cart-items::-webkit-scrollbar-track,
.pos-customer-results::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.pos-products-grid::-webkit-scrollbar-thumb,
.pos-cart-items::-webkit-scrollbar-thumb,
.pos-customer-results::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.pos-products-grid::-webkit-scrollbar-thumb:hover,
.pos-cart-items::-webkit-scrollbar-thumb:hover,
.pos-customer-results::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}
