/* ============================================================
   SwiftPOS — POS Terminal Pages
   (pos_sales.html, pos_grid.html, barcode_pos.html)
   SaaS Modern Design Language
   ============================================================ */

/* ── POS sticky right panel (Classic / List POS) ─────────── */
@media (min-width: 992px) {
    .sp-cpos-panel {
        position: sticky;
        top: 66px;
        height: calc(100vh - 82px);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        background: var(--sp-color-bg-white, #fff);
        border: 1px solid var(--sp-color-border, #e5e7eb);
        border-radius: var(--sp-radius, 16px);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    }
}

.sp-cpos-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--sp-color-border, #e5e7eb);
    flex-shrink: 0;
    background: var(--sp-color-bg-grey, #f9fafb);
    border-radius: var(--sp-radius, 16px) var(--sp-radius, 16px) 0 0;
}

.sp-cpos-cart-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.sp-cpos-totals {
    flex-shrink: 0;
    padding: 0.8rem 1rem;
    border-top: 1px solid var(--sp-color-border, #e5e7eb);
    border-bottom: 1px solid var(--sp-color-border, #e5e7eb);
    background: var(--sp-color-bg-grey, #f9fafb);
}

.sp-cpos-promo {
    flex-shrink: 0;
    padding: 0.55rem 1rem;
    border-bottom: 1px solid var(--sp-color-border, #e5e7eb);
}

.sp-cpos-payment {
    flex-shrink: 0;
    padding: 0.8rem 1rem;
    overflow-y: auto;
    max-height: 46vh;
    -webkit-overflow-scrolling: touch;
}

/* ── Grid POS: product grid cards ────────────────────────── */
.pos-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.85rem;
}

.pos-product-card {
    background: var(--sp-color-bg-white, #fff);
    border: 1.5px solid var(--sp-color-border, #e5e7eb);
    border-radius: var(--sp-radius-sm, 8px);
    padding: 0.85rem;
    cursor: pointer;
    transition: all 0.18s ease;
    text-align: center;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.pos-product-card:hover {
    border-color: var(--sp-color-primary, #6d28d9);
    background: var(--sp-color-bg-tint, #f5f3ff);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(109, 40, 217, 0.12);
}

.pos-product-card:active {
    transform: translateY(0) scale(0.97);
}

.pos-product-card.out-of-stock {
    opacity: 0.45;
    cursor: not-allowed;
}

.pos-product-card.out-of-stock:hover {
    transform: none;
    border-color: var(--sp-color-border, #e5e7eb);
    background: var(--sp-color-bg-white, #fff);
    box-shadow: none;
}

.pos-product-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--sp-color-text-main, #111827);
    line-height: 1.3;
    margin-bottom: 0.4rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.pos-product-price {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--sp-color-primary, #6d28d9);
}

.pos-product-stock {
    font-size: 0.68rem;
    color: var(--sp-color-text-muted, #9ca3af);
    margin-top: 0.25rem;
}

.pos-stock-low {
    color: var(--sp-color-warning, #f59e0b);
    font-weight: 600;
}

.pos-stock-out {
    color: var(--sp-color-danger, #ef4444);
    font-weight: 600;
}

/* ── Barcode POS layout ───────────────────────────────────── */
.barcode-pos-panel {
    background: var(--sp-color-bg-white, #fff);
    border: 1px solid var(--sp-color-border, #e5e7eb);
    border-radius: var(--sp-radius, 16px);
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.barcode-scan-input {
    background: var(--sp-color-bg-light, #f3f4f6);
    border: 2px dashed var(--sp-color-border, #e5e7eb);
    border-radius: var(--sp-radius-sm, 8px);
    padding: 1.5rem;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.barcode-scan-input:focus-within {
    border-color: var(--sp-color-primary, #6d28d9);
    background: var(--sp-color-bg-tint, #f5f3ff);
}

/* ── Cart item row ────────────────────────────────────────── */
.pos-cart-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--sp-color-bg-light, #f3f4f6);
    font-size: 0.82rem;
    transition: background 0.12s ease;
}

.pos-cart-item:last-child {
    border-bottom: none;
}

.pos-cart-item:hover {
    background: var(--sp-color-bg-grey, #f9fafb);
}

.pos-cart-item-name {
    flex: 1;
    font-weight: 600;
    color: var(--sp-color-text-main, #111827);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pos-cart-item-price {
    font-weight: 700;
    color: var(--sp-color-primary, #6d28d9);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Quantity control buttons ─────────────────────────────── */
.pos-qty-btn {
    width: 24px; height: 24px;
    border-radius: 6px;
    border: 1px solid var(--sp-color-border, #e5e7eb);
    background: var(--sp-color-bg-light, #f3f4f6);
    color: var(--sp-color-text-main, #111827);
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.pos-qty-btn:hover {
    background: var(--sp-color-primary, #6d28d9);
    border-color: var(--sp-color-primary, #6d28d9);
    color: #fff;
}

.pos-qty-input {
    width: 38px;
    text-align: center;
    border: 1px solid var(--sp-color-border, #e5e7eb);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.18rem 0.25rem;
    background: var(--sp-color-bg-white, #fff);
    color: var(--sp-color-text-main, #111827);
    -moz-appearance: textfield;
    flex-shrink: 0;
}

.pos-qty-input::-webkit-outer-spin-button,
.pos-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

/* ── Payment complete button ──────────────────────────────── */
.pos-complete-btn {
    background: linear-gradient(135deg,
        var(--sp-color-accent, #10b981) 0%,
        #059669 100%);
    border: none;
    border-radius: var(--sp-radius-sm, 8px);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.88rem;
    width: 100%;
    cursor: pointer;
    transition: all 0.22s ease;
    font-family: inherit;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.pos-complete-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(16, 185, 129, 0.4);
}

.pos-complete-btn:active {
    transform: translateY(0);
}

/* ── Post-sale overlay ────────────────────────────────────── */
.pos-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.pos-overlay.show {
    display: flex;
}

.pos-overlay-card {
    background: var(--sp-color-bg-white, #fff);
    border-radius: var(--sp-radius, 16px);
    overflow: hidden;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.4);
    animation: pos-overlay-in 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes pos-overlay-in {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .sp-cpos-panel {
        border-radius: var(--sp-radius-sm, 8px);
    }
    .pos-product-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

@media (max-width: 575.98px) {
    .pos-product-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.6rem;
    }
    .pos-product-card {
        padding: 0.6rem;
    }
    .pos-product-name {
        font-size: 0.72rem;
    }
}
