/**
 * DistroERP - Modern Mobile-First Styles for Sales Reps & Field Invoicing
 */

/* Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    z-index: 1040;
    padding: 6px 2px calc(6px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #64748b;
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 4px 1px;
    border-radius: 8px;
    transition: all 0.15s ease-in-out;
    white-space: nowrap;
}

.mobile-nav-item i {
    font-size: 1.25rem;
    margin-bottom: 2px;
}

.mobile-nav-item.active {
    color: #2563eb;
    background-color: #eff6ff;
}

.mobile-nav-item.active i {
    transform: scale(1.08);
}

/* Mobile Sticky Checkout Bar */
.mobile-sticky-checkout {
    position: fixed;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    background: #0f172a;
    color: #ffffff;
    padding: 10px 14px;
    z-index: 1030;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Touch-friendly Product Item */
.pos-product-item {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
    user-select: none;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.pos-product-item:active {
    transform: scale(0.98);
}

.pos-product-item.in-cart {
    border-color: #2563eb;
    background-color: #f8faff;
    box-shadow: 0 0 0 1px #2563eb;
}

/* Out of stock products stay visible for reference but cannot be billed */
.pos-product-item.is-out-of-stock {
    background: #fef2f2;
    border-color: #fecaca;
    border-style: dashed;
    cursor: not-allowed;
    opacity: 0.85;
}

.pos-product-item.is-out-of-stock .pos-product-title,
.pos-product-item.is-out-of-stock .pos-price-text {
    color: #991b1b;
    text-decoration: line-through;
}

.pos-oos-note {
    margin-top: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    color: #b91c1c;
    letter-spacing: 0.01em;
}

.pos-add-btn.is-disabled,
.pos-add-btn:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    pointer-events: none;
}

/* Cart line flagged when the billable quantity has consumed all available stock */
.cart-item-card.is-stock-maxed {
    border-color: #fca5a5;
    box-shadow: 0 0 0 1px #ef4444 inset;
}

.cart-stock-strip {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    padding: 4px 8px;
    color: #64748b;
    font-size: 0.72rem;
}

/* Product Card Elements: Badges Row */
.pos-badge-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    min-width: 0;
    width: 100%;
    margin-bottom: 6px;
}

.product-sku-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    padding: 2px 6px;
    max-width: 52%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
    border-radius: 6px;
    line-height: 1.2;
}

.stock-badge {
    font-size: 0.68rem;
    padding: 2px 6px;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    border-radius: 6px;
    line-height: 1.2;
}

/* Product Card Elements: Title & Packaging */
.pos-product-title {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.85rem;
    line-height: 1.25;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pos-product-unit {
    font-size: 0.725rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Product Card Elements: Price & Add Button */
.pos-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    min-width: 0;
    width: 100%;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid #f1f5f9;
}

.pos-price-wrap {
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.pos-price-text {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: #2563eb;
    font-size: 0.92rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.pos-add-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background-color: #2563eb;
    color: #ffffff;
    border: none;
    padding: 0;
    font-size: 0.85rem;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.pos-add-btn:active {
    transform: scale(0.9);
    background-color: #1d4ed8;
}

/* Category Horizontal Scroll Pills */
.pos-category-scroll {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 6px 8px 6px;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.pos-category-scroll::-webkit-scrollbar {
    display: none;
}

.cat-pill {
    flex-shrink: 0;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 9999px;
    transition: all 0.15s ease;
}

/* Cart Line Item Card */
.cart-item-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    position: relative;
}

.cart-item-card.is-amended {
    border-left: 4px solid #f59e0b;
}

/* Stepper buttons & Inputs in Cart */
.stepper-btn {
    width: 32px;
    height: 32px;
    min-width: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #1e293b;
    padding: 0;
    flex-shrink: 0;
}

.stepper-btn:active {
    background: #e2e8f0;
}

.editable-price-input {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: #0f172a;
    background: #fefce8;
    border: 1px dashed #ca8a04;
    border-radius: 6px;
    padding: 4px 6px;
    text-align: right;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-size: 0.85rem;
}

.free-issue-input {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: #6d28d9;
    background: #f5f3ff;
    border: 1px dashed #7c3aed;
    border-radius: 6px;
    padding: 4px 6px;
    text-align: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-size: 0.85rem;
}

/* Customer selector pill */
.customer-badge-active {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 8px 12px;
}

/* Mobile Cart Offcanvas Bottom Sheet */
.mobile-cart-sheet {
    height: 82vh !important;
    max-height: 88vh;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.15);
}

.mobile-cart-sheet .offcanvas-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Payment Mode Buttons */
.pay-mode-btn {
    min-height: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    text-align: center;
}

/* Optional List View Mode for POS Catalog */
.pos-products-list.is-list-view .pos-grid-col {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
}

.pos-products-list.is-list-view .pos-product-item {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px;
}

.pos-products-list.is-list-view .pos-product-title {
    height: auto !important;
    -webkit-line-clamp: 1 !important;
    margin-bottom: 2px;
}

.pos-products-list.is-list-view .pos-price-row {
    border-top: none !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
    width: auto !important;
    justify-content: flex-end !important;
}

/* Media Queries for Small Screens */
@media (max-width: 576px) {
    .pos-product-item {
        padding: 8px 8px;
        border-radius: 10px;
    }

    /* Prevent product grid columns from stretching cards vertically */
    .pos-products-list .pos-grid-col {
        display: flex;
        align-items: flex-start;
    }

    .pos-products-list .pos-product-item {
        width: 100%;
    }

    /* Compact product list height on mobile so more cards are visible */
    .pos-products-list {
        max-height: 58vh !important;
    }

    .pos-badge-row {
        gap: 3px;
        margin-bottom: 4px;
    }

    .product-sku-badge {
        font-size: 0.62rem;
        padding: 1px 4px;
        max-width: 50%;
    }

    .stock-badge {
        font-size: 0.62rem;
        padding: 1px 4px;
    }

    /* In small mobile cards, hide 'In Stock ' label so it cleanly shows '✓ (15)' or '✓ 15' without overflow! */
    .pos-product-item .stock-badge .stock-label {
        display: none !important;
    }

    .pos-product-item .stock-badge .stock-qty {
        font-weight: 700;
    }

    .pos-product-title {
        font-size: 0.78rem;
        line-height: 1.2;
        margin-bottom: 2px;
    }

    .pos-product-unit {
        font-size: 0.68rem;
    }

    .pos-price-text {
        font-size: 0.85rem;
    }

    .pos-add-btn {
        width: 26px;
        height: 26px;
        min-width: 26px;
        font-size: 0.78rem;
    }
}

@media (max-width: 380px) {
    .pos-price-text {
        font-size: 0.78rem;
    }

    .pos-add-btn {
        width: 24px;
        height: 24px;
        min-width: 24px;
        font-size: 0.72rem;
    }

    .mobile-nav-item span {
        font-size: 0.6rem;
    }
}

@media (max-width: 768px) {
    body {
        padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px));
    }

    body.has-sticky-checkout {
        padding-bottom: calc(135px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .mobile-bottom-nav {
        display: flex;
    }

    .hide-on-mobile {
        display: none !important;
    }

    .container-mobile-flush {
        padding-left: 8px;
        padding-right: 8px;
    }
}

@media (min-width: 769px) {
    .mobile-sticky-checkout {
        bottom: 0;
    }

    .hide-on-desktop {
        display: none !important;
    }
}
