/* =============================================
   POS Verdulería — POS (Point of Sale)
   ============================================= */

.pos-container {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: var(--space-lg);
}

/* ---- POS Left: Products ---- */
.pos-products {
    display: flex;
    flex-direction: column;
}

.pos-products-header {
    display: flex;
    align-items: center;
    gap: var(--space-base);
    margin-bottom: var(--space-base);
    flex-wrap: wrap;
}

.pos-products-header .search-bar {
    flex: 1;
    min-width: 200px;
}

.pos-categories {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-base);
    flex-wrap: wrap;
}

.pos-products-scroll-container {
    height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    padding: var(--space-md);
}

.pos-products-scroll-container::-webkit-scrollbar {
    width: 8px;
}

.pos-products-scroll-container::-webkit-scrollbar-track {
    background: var(--color-bg);
    border-radius: var(--radius-sm);
}

.pos-products-scroll-container::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-sm);
}

.pos-products-scroll-container::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

.pos-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 130px);
    justify-content: center;
    gap: var(--space-md);
}

/* Pagination inside POS */
.pos-pagination-top,
.pos-pagination-bottom {
    padding: var(--space-sm) 0;
    flex-shrink: 0;
}

/* Product Card (POS) */
.pos-product-card {
    background: var(--color-surface);
    border: 1.5px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    overflow: hidden;
    user-select: none;
}

.pos-product-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.pos-product-card:active {
    transform: translateY(0) scale(0.98);
}

.pos-product-card.out-of-stock {
    opacity: 0.55;
    pointer-events: none;
    cursor: not-allowed;
    filter: grayscale(40%);
    position: relative;
}

.pos-product-card.out-of-stock .pos-product-img img {
    filter: grayscale(70%);
}

.pos-product-out-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(231, 76, 60, 0.88);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

.pos-product-img {
    position: relative;
    width: 100%;
    height: 100px;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: 2rem;
    overflow: hidden;
}

.pos-product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pos-product-info {
    padding: var(--space-md);
}

.pos-product-name {
    font-size: var(--font-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    margin-bottom: var(--space-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pos-product-category {
    font-size: var(--font-xs);
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.pos-product-price {
    font-family: var(--font-heading);
    font-size: var(--font-md);
    font-weight: var(--font-weight-bold);
    color: var(--color-primary);
}

.pos-product-price small {
    font-size: var(--font-xs);
    font-weight: var(--font-weight-normal);
    color: var(--color-text-muted);
}

/* ---- POS Right: Cart ---- */
.pos-cart {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.pos-cart-header {
    padding: var(--space-base) var(--space-lg);
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pos-cart-title {
    font-family: var(--font-heading);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.pos-cart-count {
    background: var(--color-primary);
    color: white;
    font-size: var(--font-xs);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: var(--font-weight-semibold);
}

/* Remito Banner */
.pos-remito-banner {
    background: linear-gradient(135deg, #FFF8E1 0%, #FFF3CD 100%);
    border-bottom: 2px solid var(--color-warning);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.pos-remito-badge {
    background: var(--color-warning);
    color: #fff;
    font-size: var(--font-xs);
    font-weight: var(--font-weight-bold);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.pos-remito-client {
    font-size: var(--font-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    word-break: break-word;
}

.pos-remito-client span {
    color: var(--color-text-secondary);
    font-weight: var(--font-weight-normal);
}

/* Cart Items - ensure at least 3 items visible */
.pos-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm);
    min-height: 0;
}

.pos-cart-item {
    display: grid;
    grid-template-columns: 1fr 70px auto auto;
    gap: var(--space-sm);
    align-items: center;
    padding: var(--space-md);
    border-bottom: 1px solid var(--color-border-light);
    animation: fadeIn var(--transition-fast) both;
}

.pos-cart-item:last-child {
    border-bottom: none;
}

.pos-cart-item-name {
    font-size: var(--font-sm);
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pos-cart-item-detail {
    font-size: var(--font-xs);
    color: var(--color-text-muted);
    margin-top: 2px;
}

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

.pos-cart-item-qty input {
    width: 64px;
    padding: 5px 8px;
    text-align: center;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--font-sm);
    font-family: var(--font-family);
    color: var(--color-text);
    outline: none;
    transition: border-color var(--transition-fast);
}

.pos-cart-item-qty input:focus {
    border-color: var(--color-primary);
}

.pos-cart-item-subtotal {
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-sm);
    text-align: right;
    white-space: nowrap;
    min-width: 80px;
}

.pos-cart-item-remove {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    grid-column: 3;
}

.pos-cart-item-remove:hover {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.pos-cart-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    color: var(--color-text-muted);
    text-align: center;
}

.pos-cart-empty i {
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-base);
    opacity: 0.3;
}

.pos-cart-empty p {
    font-size: var(--font-sm);
}

/* Cart Footer */
.pos-cart-footer {
    border-top: 2px solid var(--color-border-light);
    padding: var(--space-base) var(--space-lg);
    background: var(--color-bg);
}

.pos-cart-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.pos-cart-total-label {
    font-size: var(--font-md);
    font-weight: var(--font-weight-semibold);
}

.pos-cart-total-value {
    font-family: var(--font-heading);
    font-size: var(--font-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-primary);
}

.pos-remito-date {
    margin-bottom: var(--space-md);
}

.pos-remito-date label {
    font-size: var(--font-sm);
    font-weight: var(--font-weight-medium);
    margin-bottom: var(--space-xs);
    display: block;
    color: var(--color-text-secondary);
}

.pos-remito-date input[type="date"] {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    outline: none;
    color: var(--color-text);
}

.pos-remito-date input[type="date"]:focus {
    border-color: var(--color-primary);
}

/* ---- RESPONSIVE POS ---- */

/* Sidebar visible + medium screen (sidebar takes ~160px, leaves ~1100px) */
@media (max-width: 1350px) {
    .pos-container {
        grid-template-columns: 1fr 340px;
        gap: var(--space-base);
    }
}

/* Sidebar visible but tight — reduce further */
@media (max-width: 1200px) {
    .pos-container {
        grid-template-columns: 1fr 310px;
    }

    .pos-products-grid {
        gap: var(--space-sm);
    }

    .pos-product-info {
        padding: var(--space-sm);
    }

    .pos-product-name {
        font-size: 12px;
    }

    .pos-product-price {
        font-size: var(--font-sm);
    }
}

/* Sidebar hidden (<=1150px), full width available */
@media (max-width: 1150px) {
    .pos-container {
        grid-template-columns: 1fr 340px;
        gap: var(--space-base);
    }

    .pos-products-grid {
        gap: var(--space-md);
    }

    .pos-product-info {
        padding: var(--space-md);
    }

    .pos-product-name {
        font-size: var(--font-sm);
    }
}

/* Narrow — stack layout */
@media (max-width: 900px) {
    .pos-container {
        grid-template-columns: 1fr;
        height: auto;
    }
}

/* Very small screens */
@media (max-width: 600px) {
    .pos-products-grid {
        gap: var(--space-sm);
    }

    .pos-product-info {
        padding: var(--space-sm);
    }

    .pos-product-name {
        font-size: 11px;
    }

    .pos-product-category {
        font-size: 9px;
        margin-bottom: 2px;
    }

    .pos-cart-item {
        grid-template-columns: 1fr 60px auto auto;
        padding: var(--space-sm);
        gap: var(--space-xs);
    }

    .pos-cart-item-name {
        font-size: 12px;
    }

    .pos-cart-item-subtotal {
        min-width: 60px;
        font-size: 12px;
    }

    .pos-cart-item-qty input {
        width: 50px;
        padding: 3px 4px;
        font-size: 12px;
    }
}
