/**
 * Waiter add/edit order — tablet portrait & landscape.
 * Cart lines scroll; trash/remove + Place Order always visible.
 */

body.waiter-pos-page {
    overflow: hidden;
    height: 100dvh;
    height: 100vh;
    margin: 0;
}

body.waiter-pos-page .pos-container {
    height: 100dvh;
    height: 100vh;
    max-height: 100dvh;
    max-height: 100vh;
    overflow: hidden;
}

body.waiter-pos-page .pos-header {
    flex-shrink: 0;
}

body.waiter-pos-page .pos-content {
    flex: 1 1 auto;
    min-height: 0;
    height: calc(100dvh - 4.5rem);
    height: calc(100vh - 4.5rem);
    overflow: hidden;
    align-items: stretch;
}

body.waiter-pos-page .pos-left {
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.waiter-pos-page .pos-left .category-tabs {
    flex-shrink: 0;
}

body.waiter-pos-page .pos-left .menu-grid {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

body.waiter-pos-page .pos-right {
    min-height: 0;
    height: 100%;
    max-height: 100%;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Cart panel: pinned footer at bottom */
body.waiter-pos-page .cart-panel {
    position: relative !important;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    padding-bottom: 0 !important;
}

body.waiter-pos-page .cart-header,
body.waiter-pos-page .order-type-section,
body.waiter-pos-page .dining-fields-grid,
body.waiter-pos-page .customer-info,
body.waiter-pos-page .order-meta-row {
    flex-shrink: 0;
}

body.waiter-pos-page .cart-items {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    margin-bottom: 0 !important;
    padding-bottom: 6.25rem !important;
}

body.waiter-pos-page .cart-footer {
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    margin-top: 0 !important;
    flex: 0 0 auto;
    flex-shrink: 0;
    padding: 0.4rem 0.65rem 0.55rem;
    background: #fff !important;
    border-top: 2px solid #e5e7eb;
    z-index: 25;
    box-shadow: 0 -8px 20px rgba(15, 23, 42, 0.12);
}

body.waiter-pos-page .cart-footer .cart-total {
    margin-top: 0;
    padding-top: 0.35rem;
    flex-shrink: 0;
}

body.waiter-pos-page .cart-footer .btn-checkout {
    flex-shrink: 0;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin-top: 0.4rem !important;
    margin-bottom: 0 !important;
    width: 100%;
    min-height: 44px !important;
}

/* Cart row: keep remove/trash visible on narrow screens */
body.waiter-pos-page .cart-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    row-gap: 0.35rem;
}

body.waiter-pos-page .cart-item-info {
    flex: 1 1 45%;
    min-width: 0;
}

body.waiter-pos-page .cart-item > div:last-child,
body.waiter-pos-page .cart-item-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 0.3rem;
    flex: 0 0 auto;
    max-width: 100%;
    margin-left: auto;
}

body.waiter-pos-page .cart-item-amount {
    white-space: nowrap;
    flex-shrink: 0;
}

body.waiter-pos-page .qty-btn {
    flex-shrink: 0;
    min-width: 30px;
    min-height: 30px;
}

body.waiter-pos-page .cart-remove-btn {
    flex-shrink: 0;
    min-width: 34px !important;
    min-height: 34px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    visibility: visible !important;
    opacity: 1 !important;
    background: #ef4444 !important;
    color: #fff !important;
}

@media (min-width: 521px) and (max-width: 1400px) {
    body.waiter-pos-page .cart-items {
        min-height: 0 !important;
        max-height: none !important;
    }

    body.waiter-pos-page .cart-panel {
        max-height: 100% !important;
    }
}

/* Touch tablet landscape */
@media (orientation: landscape) and (min-width: 768px) and (max-height: 960px) and (hover: none) {
    html.waiter-tablet-ui {
        font-size: 75%;
    }

    body.waiter-pos-page .pos-content {
        height: calc(100dvh - 3.75rem);
        height: calc(100vh - 3.75rem);
        padding: 0.5rem 0.75rem;
        gap: 0.65rem;
        grid-template-columns: minmax(0, 1fr) minmax(250px, min(300px, 30vw)) !important;
    }

    body.waiter-pos-page .cart-items {
        padding-bottom: 5.75rem !important;
    }

    body.waiter-pos-page .cart-footer .btn-checkout {
        min-height: 42px !important;
    }
}

/* Portrait: stacked — sticky checkout, compact cart scroll */
@media (orientation: portrait) and (max-width: 900px) {
    body.waiter-pos-page {
        overflow: auto;
        height: auto;
    }

    body.waiter-pos-page .pos-container {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    body.waiter-pos-page .pos-content {
        height: auto;
        overflow: visible;
    }

    body.waiter-pos-page .pos-right {
        min-height: 280px;
    }

    body.waiter-pos-page .cart-panel {
        height: auto !important;
        min-height: 280px;
        max-height: none !important;
        overflow: visible !important;
    }

    body.waiter-pos-page .cart-items {
        max-height: min(28dvh, 240px) !important;
        flex: 0 1 auto !important;
        padding-bottom: 0.5rem !important;
        overflow-x: auto !important;
        overflow-y: auto !important;
    }

    body.waiter-pos-page .cart-footer {
        position: sticky !important;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 30;
    }

    /* Portrait: stack actions under name so trash/remove is never clipped */
    body.waiter-pos-page .cart-item {
        flex-direction: column;
        align-items: stretch;
    }

    body.waiter-pos-page .cart-item-info {
        flex: none;
        width: 100%;
    }

    body.waiter-pos-page .cart-item-actions {
        width: 100%;
        justify-content: space-between;
        margin-left: 0;
        padding-top: 0.25rem;
        border-top: 1px dashed rgba(0, 119, 182, 0.15);
    }
}

@media (orientation: landscape) and (max-height: 720px) {
    body.waiter-login-page {
        padding: 0.75rem;
        align-items: flex-start;
        padding-top: 1rem;
    }
}

@media (orientation: landscape) and (min-width: 900px) and (max-height: 960px) and (hover: none) {
    html.waiter-tablet-ui .content-area {
        padding: 0.85rem 1rem;
    }

    html.waiter-tablet-ui .table-responsive {
        max-height: calc(100dvh - 220px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}
