/* Sales Counter — full-screen POS (scroll + search) */
body.page-pos {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

body.page-pos .stock-alert-banner {
    display: none !important;
}

body.page-pos .platform-credit-wrap--app {
    display: none;
}

body.page-pos #mainContent,
body.page-pos .main-content {
    margin-left: 268px;
    padding: 8px 10px !important;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

body.page-pos .main-content.expanded {
    margin-left: 72px;
}

body.page-pos .top-bar:first-of-type {
    display: none;
}

.pos-page-header {
    background: linear-gradient(135deg, var(--primary, #047857) 0%, var(--primary-dark, #065f46) 100%);
    color: #fff;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.pos-page-header h4 {
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    margin: 0;
}

.pos-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.pos-step {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
}

.pos-step.active {
    background: #fff;
    color: var(--primary-dark, #065f46);
}

.pos-shell {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pos-wrap {
    display: flex;
    gap: 10px;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.pos-products {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border-radius: 12px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.pos-search-bar {
    flex-shrink: 0;
    margin-bottom: 8px;
}

.pos-search-bar .form-control {
    font-size: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 2px solid var(--border, #e2e8f0);
}

.pos-search-bar .form-control:focus {
    border-color: var(--primary, #047857);
    box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.15);
}

.pos-search-hint {
    font-size: 11px;
    color: var(--text-muted, #64748b);
    margin-top: 4px;
}

/* Main scroll area — categories + products */
.pos-scroll-pane {
    flex: 1 1 auto;
    min-height: 120px;
    height: 0;
    overflow-y: scroll !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-right: 6px;
    padding-bottom: 12px;
}

.pos-scroll-pane::-webkit-scrollbar {
    width: 8px;
}

.pos-scroll-pane::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 4px;
}

#posProductView:not(.d-none):not([hidden]) {
    display: block !important;
}

#posCategoryView.d-none,
#posCategoryView[hidden] {
    display: none !important;
}

.pos-category-intro {
    font-size: 12px;
    color: var(--text-muted, #64748b);
    margin-bottom: 8px;
}

.category-pick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    width: 100%;
}

.category-pick-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 88px;
    padding: 10px 8px;
    border: none;
    border-radius: 12px;
    background: #fff;
    color: var(--text-primary, #0f172a);
    font-weight: 700;
    font-size: 12px;
    line-height: 1.25;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(4, 120, 87, 0.15);
    user-select: none;
}

.category-pick-card.is-hidden {
    display: none !important;
}

.category-pick-card * {
    pointer-events: none;
}

.category-pick-card:hover,
.category-pick-card:focus {
    transform: translateY(-2px);
    box-shadow: 0 0 0 2px var(--primary, #047857);
    outline: none;
}

.category-pick-card .cat-icon-wrap {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary-light, #d1fae5);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
}

.category-pick-card .cat-icon-wrap i {
    font-size: 1.1rem;
    color: var(--primary, #047857);
}

.category-pick-card .cat-count {
    margin-top: 4px;
    font-size: 10px;
    font-weight: 600;
    color: var(--primary, #047857);
    background: var(--primary-light, #d1fae5);
    padding: 2px 8px;
    border-radius: 20px;
}

#posProductView .pos-product-toolbar {
    background: #f8fafc;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 8px;
}

#posNoProductsMsg {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted, #64748b);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 8px;
}

.product-card {
    border-radius: 10px;
    padding: 8px 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    min-height: 72px;
    cursor: pointer;
    border: 2px solid var(--border, #e2e8f0);
    background: var(--bg-surface-2, #fff);
}

.product-card.is-hidden {
    display: none !important;
}

.product-card .cat-icon {
    font-size: 1.1rem !important;
    color: var(--primary, #047857);
    margin-bottom: 4px !important;
    display: block;
}

.product-card .pname {
    font-size: 11px;
    font-weight: 700;
    min-height: 26px;
    line-height: 1.2;
    word-break: break-word;
}

.product-card .product-price {
    font-size: 10px;
    font-weight: 700;
}

.product-stock-badge {
    font-size: 9px !important;
    margin-top: 2px;
}

.product-card.active-picker {
    border-color: var(--primary, #047857);
    box-shadow: 0 0 0 2px rgba(4, 120, 87, 0.3);
}

/* Override global style.css product cards on POS */
body.page-pos .product-card {
    padding: 8px 6px !important;
    transform: none;
}

body.page-pos .product-card:hover,
body.page-pos .product-card:active {
    transform: none;
}

/* Cart column (desktop sidebar) */
.pos-cart-column {
    flex: 0 0 300px;
    width: 300px;
    max-width: 32vw;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-surface);
    border-radius: 12px;
    border: 1px solid var(--border);
}

/* Desktop: cart + checkout = one right sidebar */
@media (min-width: 993px) {
    body.page-pos .pos-sidebar-wrap {
        flex: 0 0 300px;
        width: 300px;
        max-width: 32vw;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        background: var(--bg-surface);
        border-radius: 12px;
        border: 1px solid var(--border);
    }

    body.page-pos .pos-cart-column {
        flex: 1 1 auto;
        width: 100%;
        max-width: none;
        min-height: 0;
        border: none;
        border-radius: 0;
        background: transparent;
    }

    body.page-pos .pos-checkout-dock {
        position: static;
        flex-shrink: 0;
        width: 100%;
        border-radius: 0;
        border: none;
        border-top: 1px solid var(--border, #e2e8f0);
        box-shadow: none;
    }
}

.pos-cart {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 10px 10px 0;
    background: transparent;
    border: none;
    border-radius: 0;
    width: 100%;
    max-width: none;
}

.pos-checkout-dock {
    flex-shrink: 0;
    padding: 8px 10px 10px;
    border-top: 1px solid var(--border, #e2e8f0);
    background: var(--bg-surface);
}

.pos-cart-customer {
    flex-shrink: 0;
}

.pos-cart-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
}

.pos-cart-empty i {
    font-size: 1.25rem;
}

.pos-cart-footer {
    flex-shrink: 0;
    padding-top: 8px;
    border-top: 1px solid var(--border, #e2e8f0);
    margin-top: 8px;
}

.pos-customer-select {
    font-size: 12px;
    line-height: 1.35;
}

.pos-customer-select option[hidden] {
    display: none;
}

body.page-pos .pos-cart-sidebar .btn-complete-sale {
    padding: 0.65rem 0.75rem;
    font-size: 1rem;
    font-weight: 700;
    width: 100%;
}

.btn-complete-sale {
    padding: 0.55rem 0.75rem;
    font-size: 0.95rem;
    font-weight: 700;
}

.btn-pos-secondary {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
}

/* Checkout sidebar (desktop right + mobile bottom) — same styling */
body.page-pos .pos-cart-sidebar .pos-total-box {
    padding: 14px;
    margin-bottom: 0;
    text-align: center;
    background: var(--primary-dark, #065f46);
    color: #fff;
    border-radius: var(--radius-sm, 8px);
}

body.page-pos .pos-cart-sidebar .pos-total-box .amount {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.2;
}

body.page-pos .pos-cart-sidebar .pos-total-box small {
    font-size: 11px;
    opacity: 0.9;
}

body.page-pos .pos-cart-footer .small {
    font-size: 11px;
}

body.page-pos .pos-cart-footer .form-control-sm,
body.page-pos .pos-cart-footer .form-select-sm {
    font-size: 11px;
    padding: 0.2rem 0.35rem;
}

/* Discount / paid inputs (desktop + mobile) */
.pos-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.pos-line-label {
    flex-shrink: 0;
}

.pos-discount-inputs {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.pos-discount-type {
    width: 64px;
    min-width: 64px;
    flex: 0 0 64px;
    padding: 0.25rem 1.5rem 0.25rem 0.4rem;
    font-size: 12px;
}

.pos-discount-value {
    width: 80px;
    min-width: 80px;
    flex: 0 0 80px;
    font-size: 12px;
}

.pos-paid-input {
    width: 96px;
    min-width: 96px;
    flex: 0 0 96px;
    font-size: 12px;
}

.pos-paid-row {
    justify-content: space-between;
}

.pos-checkout-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pos-checkout-actions .pos-total-box {
    margin-bottom: 0;
}

.pos-checkout-actions #paymentMethod,
.pos-checkout-actions #completeBtn,
.pos-checkout-actions .btn-pos-secondary {
    width: 100%;
}

body.dark-mode .category-pick-card {
    background: #1e293b;
    color: #e2e8f0;
}

body.dark-mode #posProductView .pos-product-toolbar {
    background: #1e293b;
    border-color: #334155;
}

body.dark-mode .pos-checkout-dock {
    background: var(--bg-surface, #1e293b);
    border-color: #334155;
}

/* ——— Mobile / tablet: full page scroll — same blocks as desktop ——— */
@media (max-width: 1024px) {
    body.page-pos {
        height: auto;
        min-height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto;
    }

    body.page-pos .mobile-menu-btn {
        top: max(6px, env(safe-area-inset-top));
        left: max(6px, env(safe-area-inset-left));
        width: 36px;
        height: 36px;
        font-size: 15px;
        border-radius: 10px;
    }

    body.page-pos #mainContent,
    body.page-pos .main-content {
        margin-left: 0 !important;
        height: auto !important;
        min-height: 100dvh;
        max-height: none !important;
        overflow: visible !important;
        display: block !important;
        padding: 46px 8px calc(68px + env(safe-area-inset-bottom)) 8px !important;
        box-sizing: border-box;
    }

    body.page-pos .pos-page-header {
        padding: 6px 8px 6px 42px;
        margin-bottom: 8px;
        border-radius: 8px;
    }

    body.page-pos .pos-page-header .pos-title {
        font-size: 0.95rem;
    }

    body.page-pos .pos-steps {
        gap: 4px;
        margin-top: 6px;
    }

    body.page-pos .pos-step {
        font-size: 9px;
        padding: 2px 7px;
    }

    body.page-pos .pos-shell,
    body.page-pos .pos-wrap {
        height: auto;
        min-height: 0;
        overflow: visible;
        flex: none;
    }

    body.page-pos .pos-wrap {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    /* Products block — fixed height window, scroll inside */
    body.page-pos .pos-products {
        flex: none;
        width: 100%;
        height: auto;
        min-height: 280px;
        max-height: min(52vh, 480px);
        padding: 8px;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        margin-bottom: 0;
    }

    body.page-pos .pos-scroll-pane {
        flex: 1 1 auto;
        min-height: 200px;
        height: auto;
        max-height: min(46vh, 420px);
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    body.page-pos #posProductView:not(.d-none):not([hidden]) {
        display: block !important;
    }

    body.page-pos .product-grid {
        display: grid !important;
        width: 100%;
    }

    /* Right sidebar = full width card below products (never hidden) */
    body.page-pos .pos-sidebar-wrap {
        display: flex;
        flex-direction: column;
        width: 100%;
        flex: none;
        min-height: 0;
        overflow: visible;
        background: var(--bg-surface);
        border-radius: 12px;
        border: 1px solid var(--border);
        box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
    }

    body.page-pos .pos-cart-column {
        display: flex !important;
        flex: none;
        width: 100%;
        max-width: 100%;
        max-height: none;
        border: none;
        border-radius: 0;
        background: transparent;
    }

    body.page-pos .pos-cart.pos-cart-sidebar {
        display: flex !important;
        flex-direction: column;
        width: 100%;
        padding: 10px 10px 0;
        overflow: visible;
    }

    body.page-pos .pos-cart-sidebar .pos-cart-scroll {
        flex: none;
        min-height: 52px;
        max-height: 100px;
        overflow-y: auto;
    }

    body.page-pos .pos-cart-sidebar .pos-cart-footer {
        flex-shrink: 0;
        padding-top: 8px;
        margin-top: 8px;
        border-top: 1px solid var(--border, #e2e8f0);
    }

    /* Checkout: in flow (not fixed) — always complete like desktop */
    body.page-pos .pos-checkout-dock {
        position: static !important;
        display: block !important;
        width: 100%;
        flex-shrink: 0;
        z-index: auto;
        left: auto;
        right: auto;
        bottom: auto;
        margin: 0;
        padding: 8px 10px 12px;
        border: none;
        border-top: 1px solid var(--border, #e2e8f0);
        border-radius: 0 0 12px 12px;
        background: var(--bg-surface);
        box-shadow: none;
    }

    body.page-pos .pos-checkout-dock .pos-total-box .amount {
        font-size: 1.75rem;
    }

    body.page-pos:not(.demo-app) .mobile-nav a.pos-fab {
        margin-top: 0;
    }

    body.page-pos:not(.demo-app) .mobile-nav a.pos-fab span {
        width: 36px;
        height: 36px;
        font-size: 16px;
        margin-bottom: 2px;
    }

    body.page-pos .category-pick-card {
        min-height: 76px;
        font-size: 11px;
    }

    body.page-pos .product-card {
        min-height: 62px;
    }

    body.page-pos .product-card .pname {
        font-size: 10px;
    }
}

@media (max-width: 992px) and (max-height: 620px) {
    body.page-pos .pos-products {
        max-height: min(46vh, 380px);
    }

    body.page-pos .pos-scroll-pane {
        max-height: min(40vh, 320px);
    }

    body.page-pos .pos-no-customer-hint {
        padding: 6px 8px !important;
        font-size: 11px;
    }
}

@media (max-width: 576px) {
    body.page-pos #mainContent,
    body.page-pos .main-content {
        padding-left: 6px !important;
        padding-right: 6px !important;
        padding-top: 42px !important;
    }

    body.page-pos .category-pick-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    body.page-pos .product-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }

    body.page-pos .pos-step:nth-child(3),
    body.page-pos .pos-step:nth-child(4) {
        display: none;
    }
}

@media (max-width: 380px) {
    body.page-pos .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    body.page-pos .pos-step {
        font-size: 7px;
        padding: 2px 5px;
    }
}
