/* ========== ESTILOS EXISTENTES (SE MANTIENEN) ========== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f5f5f5;
    margin: 0;
    padding: 20px;
    color: #333;
    line-height: 1.6;
}
h2 {
    text-align:center;
    margin-bottom:20px;
    color: #2c3e50;
    font-weight: 600;
}
.grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 768px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (min-width: 1024px) {
    .grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    overflow: hidden;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    position: relative;
}
.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}
.card img {
    width: 100%;
    height: 180px;
    object-fit: contain;
    background: #fafafa;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    padding: 10px;
}
.info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
}
.sku {
    font-size: 0.8rem;
    color: #777;
    margin-bottom: 5px;
}
.title {
    font-size: 1rem;
    font-weight: bold;
    margin: 5px 0;
    line-height: 1.2;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.price {
    font-size: 1.1rem;
    color: #28a745;
    margin: 0;
    font-weight: bold;
}
.store {
    font-size: 0.8rem;
    color: #666;
    margin: 3px 0;
}
.details {
    font-size: 0.75rem;
    color: #777;
    margin: 3px 0;
}
.minQty {
    font-size: 0.7rem;
    color: #e74c3c;
    margin-top: 5px;
    font-weight: bold;
}
.card-cart-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #28a745;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    transition: transform 0.2s, background 0.2s;
}
.card-cart-btn:hover {
    transform: scale(1.1);
    background: #218838;
}
#cart-toggle-btn, #search-toggle-btn {
    position: fixed;
    bottom: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    cursor: pointer;
    z-index: 101;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transition: transform 0.2s, opacity 0.2s;
}
#cart-toggle-btn {
    right: 20px;
    background: #28a745;
}
#search-toggle-btn {
    right: 90px;
    background: #B2529A;
}
#cart-toggle-btn:hover, #search-toggle-btn:hover {
    transform: scale(1.1);
}
.cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}
#cart, #searchPanel {
    display: none;
    position: fixed;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    padding: 15px;
    z-index: 100;
    transition: all 0.3s ease;
}
#cart {
    right: 20px;
    bottom: 100px;
    width: 350px;
    max-height: 70vh;
    overflow-y: auto;
}
#searchPanel {
    right: 20px;
    bottom: 170px;
    width: 300px;
    max-height: 60vh;
    overflow-y: auto;
}
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    #cart-toggle-btn, #search-toggle-btn {
        position: fixed;
        bottom: 15px;
        width: 50px;
        height: 50px;
        font-size: 18px;
    }
    #cart-toggle-btn {
        right: 15px;
    }
    #search-toggle-btn {
        right: 75px;
    }
    #cart, #searchPanel {
        width: 90vw;
        max-width: 400px;
        left: 50%;
        transform: translateX(-50%);
        bottom: 80px;
        max-height: 60vh;
    }
    #cart {
        max-height: 65vh;
    }
    .card img {
        height: 150px;
    }
    .card-cart-btn {
        width: 35px;
        height: 35px;
        font-size: 16px;
        bottom: 8px;
        right: 8px;
    }
}
#searchPanel input, #searchPanel select {
    width: 100%;
    margin-bottom: 10px;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 0.95rem;
}
.store-section {
    margin-bottom: 20px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    background: #fff;
}
.store-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}
.store-name {
    font-weight: bold;
    color: #2c3e50;
    font-size: 1.1rem;
}
.store-total {
    font-weight: bold;
    color: #28a745;
    text-align: right;
}
.store-minimum-status {
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: 5px;
    text-align: center;
}
.store-minimum-status.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}
.store-minimum-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.cart-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    position: relative;
}
.cart-item img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    margin-right: 10px;
    border-radius: 6px;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
.cart-item .info {
    flex: 1;
    font-size: 0.9rem;
    padding: 0;
    text-align: left;
}
.cart-item .qty {
    width: 50px;
    font-size: 1rem;
    text-align: center;
    padding: 4px;
    border-radius: 4px;
    border: 1px solid #ccc;
    margin-right: 5px;
}
.cart-item button {
    background: #fff;
    color: #e63946;
    border: none;
    font-weight: bold;
    padding: 4px 7px;
    border-radius: 4px;
    cursor: pointer;
}
.totals {
    font-weight: bold;
    text-align: right;
    margin-top: 10px;
    line-height: 1.4;
    border-top: 1px solid #ddd;
    padding-top: 10px;
}
#checkoutForm {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 200;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}
#checkoutForm input, #checkoutForm textarea, #checkoutForm select {
    width: 100%;
    margin-bottom: 10px;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ccc;
}
#checkoutForm button {
    width: 100%;
    margin-top: 5px;
    padding: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}
.cancel-btn {
    background: #e63946;
    color: white;
}
.confirm-btn {
    background: #28a745;
    color: white;
}
.clear-btn {
    background: #777;
    color: white;
}
.option-group {
    margin-bottom: 10px;
}
.option-group label {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    cursor: pointer;
    font-size: 14px;
}
.option-group input[type="radio"] {
    display: none;
}
.option-group .circle {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #ccc;
    margin-right: 8px;
    transition: 0.2s;
}
.option-group input[type="radio"]:checked + .circle {
    background: green;
    border-color: green;
}
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: slideInRight 0.3s ease;
    max-width: 300px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.notification.success {
    background: #28a745;
    color: white;
}
.notification.warning {
    background: #ffc107;
    color: black;
}
.notification.error {
    background: #dc3545;
    color: white;
}
.notification.info {
    background: #17a2b8;
    color: white;
}
@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; }
}
.filter-section {
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}
.filter-section h4 {
    margin: 0 0 10px 0;
    font-size: 1rem;
    color: #2c3e50;
}
.price-range {
    display: flex;
    gap: 10px;
    align-items: center;
}
.price-range input {
    flex: 1;
}
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}
.empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    color: #ccc;
}
.autocomplete {
    position: relative;
    display: inline-block;
    width: 100%;
}
.autocomplete-items {
    position: absolute;
    border: 1px solid #d4d4d4;
    border-bottom: none;
    border-top: none;
    z-index: 99;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    max-height: 200px;
    overflow-y: auto;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.autocomplete-items div {
    padding: 10px;
    cursor: pointer;
    background-color: #fff;
    border-bottom: 1px solid #d4d4d4;
    transition: background-color 0.2s;
}
.autocomplete-items div:hover {
    background-color: #e9e9e9;
}
.autocomplete-active {
    background-color: DodgerBlue !important;
    color: #ffffff;
}
.minimum-info {
    font-size: 0.9rem;
    margin: 10px 0;
    padding: 8px;
    border-radius: 6px;
    text-align: center;
}
.minimum-ok {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.minimum-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}
.checkout-btn:disabled {
    background-color: #ccc !important;
    cursor: not-allowed !important;
}
.load-more-container {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: 20px;
}
#loadMoreBtn {
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}
#loadMoreBtn:hover {
    background: #218838;
}
#loadMoreBtn:disabled {
    background: #ccc;
    cursor: not-allowed;
}
.store-selector {
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}
.store-selector select {
    width: 100%;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 0.95rem;
    background: white;
}
.store-checkout-btn {
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}
.store-checkout-btn.primary {
    background: #28a745;
    color: white;
}
.store-checkout-btn.secondary {
    background: #6c757d;
    color: white;
}
.store-checkout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.store-checkout-btn:disabled {
    background: #ccc !important;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.store-selected {
    border-color: #28a745 !important;
    background-color: #f8fff9 !important;
}
.store-selected .store-section-header {
    border-bottom-color: #28a745;
}
.store-selected-indicator {
    display: inline-block;
    background: #28a745;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    margin-left: 8px;
}
.product-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}
.tag {
    background: #e9ecef;
    color: #495057;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
}
.tag.liquidacion {
    background: #ffc107;
    color: black;
}
.tag.outlet {
    background: #dc3545;
    color: white;
}
.tag.descuento {
    background: #28a745;
    color: white;
}
.required-field {
    font-weight: bold;
    color: #2c3e50;
}
.required-field::after {
    content: " *";
    color: #e74c3c;
}
.form-error {
    color: #e74c3c;
    font-size: 0.8rem;
    margin-top: -5px;
    margin-bottom: 10px;
    display: none;
}

/* ========== ESTILOS NUEVOS PARA SISTEMA ESCALABLE ========== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.9);
    display: none; /* Inicialmente oculto */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    flex-direction: column;
    gap: 20px;
}
.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #28a745;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.stats-bar {
    background: #fff;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #666;
}