/* ===== POS PAGE ===== */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 370px;
    gap: 20px;
    height: calc(100vh - var(--topbar-height) - 56px);
}

.pos-products {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pos-search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
}

.pos-search-bar .search-box {
    flex: 1;
}

.pos-categories {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.category-btn {
    padding: 7px 16px;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
    background: var(--white);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    color: var(--gray-600);
}

.category-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.category-btn.active {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    overflow-y: auto;
    padding-right: 6px;
    flex: 1;
    align-content: start;
}

.product-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 16px 12px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.product-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.product-card-image {
    width: 52px;
    height: 52px;
    background: var(--accent-light);
    border-radius: 10px;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-card-image svg {
    width: 24px;
    height: 24px;
    color: var(--accent);
}

.product-card-name {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-card-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
}

.product-card-stock {
    font-size: 11px;
    color: var(--gray-400);
    margin-top: 4px;
}

/* ===== CART ===== */
.pos-cart {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.shelved-bar {
    padding: 0 16px;
    border-bottom: 1px solid var(--gray-100);
}

.shelved-bar-btn {
    width: 100%;
    padding: 10px 12px;
    background: #fef9e7;
    border: 1px dashed #f0c040;
    border-radius: 6px;
    margin: 10px 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.shelved-bar-btn:hover {
    background: #fef3c7;
    border-color: #f59e0b;
}

.cart-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cart-header h3 {
    font-size: 15px;
    font-weight: 700;
}

.cart-count {
    background: var(--accent);
    color: var(--white);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 14px 20px;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--gray-800);
}

.cart-item-price {
    font-size: 11.5px;
    color: var(--gray-500);
    margin-top: 2px;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty-btn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
    color: var(--gray-700);
}

.qty-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.cart-item-total {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--gray-800);
    min-width: 65px;
    text-align: right;
}

.cart-item-remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    opacity: 0.4;
}

.cart-item-remove:hover {
    opacity: 1;
    background: var(--danger-light);
}

.cart-item-remove svg {
    width: 14px;
    height: 14px;
    color: var(--danger);
}

.cart-empty {
    text-align: center;
    padding: 36px 20px;
    color: var(--gray-400);
}

.cart-empty svg {
    width: 44px;
    height: 44px;
    margin-bottom: 10px;
    opacity: 0.4;
}

.cart-empty p {
    font-size: 13px;
}

/* ===== CART FOOTER ===== */
.cart-footer {
    padding: 18px 20px 28px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    flex-shrink: 0;
}

.cart-summary {
    margin-bottom: 14px;
}

.cart-summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--gray-600);
}

.cart-summary-row.total {
    font-size: 17px;
    font-weight: 800;
    color: var(--gray-900);
    padding-top: 8px;
    border-top: 1px solid var(--gray-200);
    margin-top: 8px;
}

.cart-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.cart-actions .btn {
    flex: 1;
    padding: 12px 20px;
    font-size: 14px;
}

.cart-actions-secondary {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.btn-text-action {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.btn-text-action svg {
    width: 14px;
    height: 14px;
}

.btn-text-action.hold-action:hover {
    color: var(--warning);
    background: var(--warning-light);
}

.btn-text-action.clear-action:hover {
    color: var(--danger);
    background: var(--danger-light);
}

/* ===== BARCODE INPUT ===== */
.barcode-input-wrapper {
    position: relative;
}

.barcode-input-wrapper input {
    padding-left: 40px;
}

.barcode-input-wrapper .barcode-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
    color: var(--gray-400);
}

@media (max-width: 1024px) {
    .pos-layout {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .pos-cart {
        height: auto;
        max-height: none;
    }

    .cart-items {
        max-height: 200px;
        overflow-y: auto;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        max-height: 40vh;
    }
}

@media (max-width: 768px) {
    .pos-layout {
        gap: 0;
        overflow: visible;
        display: flex;
        flex-direction: column;
    }

    .pos-products {
        padding-bottom: 12px;
    }

    .pos-cart {
        height: auto;
        max-height: none;
        border-radius: 14px 14px 0 0;
        border-bottom: none;
        position: relative;
    }

    .cart-items {
        max-height: 150px;
        overflow-y: auto;
        padding: 10px 16px;
    }

    .cart-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 50;
        background: var(--white);
        border-top: 1px solid var(--gray-200);
        padding: 12px 16px 20px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
        border-radius: 0;
    }

    .cart-summary {
        margin-bottom: 10px;
    }

    .cart-summary-row {
        font-size: 12px;
    }

    .cart-summary-row.total {
        font-size: 16px;
        margin-top: 4px;
        padding-top: 6px;
    }

    .cart-actions {
        margin-bottom: 6px;
    }

    .cart-actions .btn {
        padding: 12px 16px;
        font-size: 14px;
    }

    .cart-actions-secondary {
        margin-top: 4px;
        gap: 16px;
    }

    /* Add bottom padding to page so content isn't hidden behind fixed footer */
    .pos-cart {
        margin-bottom: 160px;
    }

    .pos-categories {
        gap: 6px;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
    }

    .category-btn {
        padding: 6px 12px;
        font-size: 11.5px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;
        max-height: 32vh;
    }

    .product-card {
        padding: 10px 8px;
    }

    .product-card-image {
        width: 36px;
        height: 36px;
        margin-bottom: 6px;
    }

    .product-card-image svg {
        width: 18px;
        height: 18px;
    }

    .product-card-name {
        font-size: 11px;
    }

    .product-card-price {
        font-size: 11.5px;
    }

    .product-card-stock {
        font-size: 9.5px;
    }

    .cart-header {
        padding: 12px 16px;
    }

    .cart-header h3 {
        font-size: 14px;
    }

    .shelved-bar {
        padding: 0 12px;
    }

    .shelved-bar-btn {
        padding: 8px 10px;
        font-size: 11px;
        margin: 8px 0;
    }

    .cart-item {
        padding: 8px 0;
        gap: 8px;
    }

    .cart-item-name {
        font-size: 12px;
    }

    .cart-item-price {
        font-size: 10.5px;
    }

    .cart-item-total {
        font-size: 12px;
        min-width: 55px;
    }

    .qty-btn {
        width: 24px;
        height: 24px;
        font-size: 13px;
    }

    .cart-item-remove svg {
        width: 12px;
        height: 12px;
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        max-height: 28vh;
    }

    .pos-search-bar {
        margin-bottom: 10px;
    }

    .pos-categories {
        margin-bottom: 10px;
    }

    .cart-footer {
        padding: 10px 12px 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    .cart-actions .btn {
        padding: 11px 14px;
        font-size: 13px;
    }

    .cart-summary-row.total {
        font-size: 15px;
    }

    .cart-items {
        max-height: 120px;
    }

    .pos-cart {
        margin-bottom: 150px;
    }
}

/* ===== CUSTOMER FACING DISPLAY ===== */
.customer-screen {
    position: fixed;
    top: 0;
    right: -480px;
    width: 480px;
    height: 100vh;
    background: #0a1f0a;
    color: var(--white);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: right 0.35s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,0.2);
}

.customer-screen.active {
    right: 0;
}

.customer-screen-header {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.customer-screen-logo {
    font-size: 18px;
    font-weight: 800;
    color: #5ee89c;
    letter-spacing: -0.5px;
}

.customer-screen-close {
    background: rgba(255,255,255,0.1);
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.customer-screen-close:hover {
    background: rgba(255,255,255,0.15);
}

.customer-screen-close svg {
    width: 18px;
    height: 18px;
    color: rgba(255,255,255,0.6);
}

.customer-screen-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.customer-screen-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    color: rgba(255,255,255,0.5);
    font-size: 16px;
    font-weight: 500;
}

.customer-items-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.customer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.06);
    transition: all 0.3s ease;
}

.customer-item.latest {
    background: rgba(34, 164, 93, 0.12);
    border-color: rgba(34, 164, 93, 0.25);
    animation: itemSlideIn 0.3s ease;
}

@keyframes itemSlideIn {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.customer-item-num {
    width: 28px;
    height: 28px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,0.5);
    flex-shrink: 0;
}

.customer-item.latest .customer-item-num {
    background: var(--accent);
    color: var(--white);
}

.customer-item-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.customer-item-name {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255,255,255,0.85);
}

.customer-item-qty {
    font-size: 12px;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
}

.customer-item-price {
    font-size: 14px;
    font-weight: 700;
    color: #5ee89c;
}

.customer-screen-footer {
    padding: 24px;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.2);
}

.customer-screen-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.customer-screen-total span:first-child {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.customer-screen-total span:last-child {
    font-size: 32px;
    font-weight: 800;
    color: #5ee89c;
    letter-spacing: -1px;
}

#custScreenBtn.active {
    background: var(--accent-light);
    border-color: var(--accent);
}

#custScreenBtn.active svg {
    color: var(--accent);
}

@media (max-width: 768px) {
    .customer-screen {
        width: 100%;
        right: -100%;
    }
}

/* ===== CAMERA BARCODE SCANNER ===== */
#scannerOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.scanner-modal {
    width: 90%;
    max-width: 400px;
    background: var(--white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.scanner-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--gray-200);
}

.scanner-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.scanner-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    color: var(--gray-500);
}

.scanner-close-btn:hover {
    background: var(--gray-100);
}

.scanner-viewport {
    position: relative;
    width: 100%;
    height: 280px;
    background: #000;
    overflow: hidden;
}

.scanner-viewport video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-viewport canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.scanner-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 220px;
    height: 140px;
    z-index: 10;
}

.scanner-corner {
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: var(--accent);
    border-style: solid;
    border-width: 0;
}

.scanner-corner.tl { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-radius: 4px 0 0 0; }
.scanner-corner.tr { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-radius: 0 4px 0 0; }
.scanner-corner.bl { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-radius: 0 0 0 4px; }
.scanner-corner.br { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 4px 0; }

.scanner-line {
    position: absolute;
    top: 50%;
    left: 10px;
    right: 10px;
    height: 2px;
    background: var(--accent);
    opacity: 0.8;
    animation: scanLine 2s ease-in-out infinite;
}

@keyframes scanLine {
    0%, 100% { top: 20%; opacity: 0.5; }
    50% { top: 80%; opacity: 1; }
}

.scanner-status {
    padding: 14px 20px;
    text-align: center;
    font-size: 13px;
    color: var(--gray-600);
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}

.scan-cam-btn {
    padding: 10px 12px !important;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .scanner-viewport {
        height: 240px;
    }

    .scanner-modal {
        width: 95%;
    }
}
