/* ===================================
   POS System Layout
   =================================== */

/* Container resets */
.pos-container {
    height: calc(100vh - 70px);
    /* Full height minus nav */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-secondary);
}

/* 
   LEFT PANEL: Item Grid & Search
   ------------------------------ 
*/
.pos-left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: var(--space-md);
}

.pos-search-bar {
    margin-bottom: var(--space-md);
    position: sticky;
    top: 0;
    z-index: 10;
}

.pos-search-input {
    width: 100%;
    padding: var(--space-md);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-base);
    background: white;
    box-shadow: var(--shadow-sm);
}

.pos-search-input:focus {
    border-color: var(--primary);
    outline: none;
}

.pos-grid-scroll {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 80px;
    /* Space for mobile bar */
}

.pos-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-md);
}

/* Product Card */
.pos-product-card {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-md);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    height: 100%;
}

.pos-product-card:active {
    transform: scale(0.96);
}

.pos-product-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.pos-product-card .icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.pos-product-card .name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pos-product-card .price {
    color: var(--primary);
    font-weight: 700;
    font-size: 0.9rem;
}

.pos-product-card .stock {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.pos-product-card.out-of-stock {
    opacity: 0.6;
    background: var(--gray-50);
}

/* 
   RIGHT PANEL: Cart & Actions
   --------------------------- 
*/
.pos-right-panel {
    background: white;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--gray-200);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.05);
    z-index: 50;
}

/* Desktop/Tablet Sticky Behavior */
@media (min-width: 768px) {
    .pos-container {
        flex-direction: row;
        overflow: hidden;
        /* Lock scroll */
    }

    .pos-left-panel {
        padding: var(--space-lg);
    }

    .pos-grid-scroll {
        padding-bottom: 0;
    }

    .pos-right-panel {
        width: 350px;
        /* Tablet Width */
        height: 100%;
        flex-shrink: 0;
    }

    .pos-mobile-action-bar {
        display: none !important;
    }
}

/* Desktop specific */
@media (min-width: 1024px) {
    .pos-right-panel {
        width: 400px;
        /* Desktop width */
    }

    .pos-product-grid {
        gap: var(--space-lg);
    }
}

/* Mobile: Bottom Sheet Behavior */
@media (max-width: 767px) {
    .pos-container {
        height: auto;
        /* Let body scroll */
        min-height: calc(100vh - 150px);
    }

    .pos-left-panel {
        overflow: visible;
        flex: none;
        /* Auto height */
    }

    .pos-grid-scroll {
        overflow: visible;
        padding-bottom: 80px;
    }

    .pos-right-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 85vh;
        /* Sheet height */
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        transform: translateY(110%);
        /* Hidden by default */
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
        z-index: 2000;
        border: 1px solid var(--gray-200);
    }

    .pos-right-panel.open {
        transform: translateY(0);
    }

    /* Overlay Backdrop */
    .pos-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1500;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }

    .pos-backdrop.active {
        opacity: 1;
        pointer-events: auto;
    }

    .pos-cart-header .close-btn {
        display: block !important;
    }
}

/* Cart Panel Content */
.pos-cart-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--gray-50);
}

.pos-cart-header .close-btn {
    display: none;
    font-size: 1.5rem;
    padding: 0.5rem;
    line-height: 1;
    background: none;
    border: none;
    cursor: pointer;
}

.pos-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

.pos-cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
    border-bottom: 1px dashed var(--gray-200);
}

.pos-cart-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.pos-summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.pos-total-row {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    font-size: 1.25rem;
    margin: 1rem 0;
    color: var(--primary);
}

.pos-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

/* Mobile Sticky Bottom Bar */
.pos-mobile-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--gray-200);
    padding: var(--space-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.pos-bar-summary {
    display: flex;
    flex-direction: column;
}

.pos-bar-items {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.pos-bar-total {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}