/* Vetmivo Phase 8: Point of Sale (POS) Styles */

.pos-container {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: var(--space-4);
    height: calc(100vh - 120px);
    min-height: 600px;
    position: relative;
}

@media (max-width: 1024px) {
    .pos-container {
        grid-template-columns: 1fr 340px;
        gap: var(--space-3);
    }
}

@media (max-width: 860px) {
    .pos-container {
        grid-template-columns: 1fr;
        height: auto;
        padding-bottom: 80px; /* Space for mobile sticky cart bar */
    }
}

/* Left: Product & Catalog Panel */
.pos-catalog-panel {
    display: flex;
    flex-direction: column;
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.pos-topbar {
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.pos-search-row {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.pos-barcode-input-wrapper {
    position: relative;
    flex: 1;
}

.pos-barcode-input-wrapper input {
    width: 100%;
    padding-left: 2.25rem;
    height: 44px;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-color);
    background: var(--surface-card);
    color: var(--text-color);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pos-barcode-input-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    outline: none;
}

.pos-barcode-input-wrapper .pos-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Category Filter Pills */
.pos-categories {
    display: flex;
    gap: var(--space-1);
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.pos-categories::-webkit-scrollbar {
    display: none;
}

.pos-cat-pill {
    padding: 6px 14px;
    font-size: 0.825rem;
    font-weight: 600;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--surface-card);
    color: var(--text-color);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.pos-cat-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.pos-cat-pill.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Product Grid */
.pos-products-grid {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-3);
    align-content: start;
}

@media (max-width: 480px) {
    .pos-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-2);
        padding: var(--space-2);
    }
}

.pos-product-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.pos-product-card:hover {
    transform: translateY(-3px);
    border-color: #18A999;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.pos-product-card.out-of-stock {
    opacity: 0.55;
    cursor: not-allowed;
    background: #f8fafc;
}

.pos-product-card.out-of-stock:hover {
    transform: none;
    border-color: #e2e8f0;
    box-shadow: none;
}

/* Product Card Image & Placeholder */
.pos-card-img-wrap {
    width: 100%;
    height: 125px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: #f1f5f9;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
}

.pos-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.25s ease;
}

.pos-product-card:hover .pos-card-img {
    transform: scale(1.06);
}

.pos-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: transform 0.25s ease;
}

.pos-product-card:hover .pos-card-placeholder {
    transform: scale(1.06);
}

.pos-card-placeholder-icon {
    font-size: 2.2rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.pos-card-placeholder-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
}

.pos-placeholder-food { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); }
.pos-placeholder-retail { background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%); }
.pos-placeholder-medication { background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%); }
.pos-placeholder-vaccine { background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%); }
.pos-placeholder-medical_supply { background: linear-gradient(135deg, #ccfbf1 0%, #99f6e4 100%); }
.pos-placeholder-other { background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%); }

.pos-card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.pos-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.pos-card-type-badge {
    font-size: 0.675rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #0f766e;
    background: #ccfbf1;
    padding: 2px 6px;
    border-radius: 4px;
}

.pos-card-brand-badge {
    font-size: 0.675rem;
    font-weight: 600;
    color: #334155;
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
}

.pos-card-edit-btn {
    opacity: 0.5;
    transition: opacity 0.15s ease, transform 0.15s ease;
    font-size: 0.85rem;
    text-decoration: none;
    color: #64748b;
    padding: 2px 4px;
    border-radius: 4px;
}

.pos-product-card:hover .pos-card-edit-btn {
    opacity: 1;
}

.pos-card-edit-btn:hover {
    transform: scale(1.2);
    color: #18A999;
}

.pos-top-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.pos-btn-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 0.825rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    border: 1px solid #cbd5e1;
}

.pos-btn-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.pos-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.3;
    color: #0f172a;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pos-card-sku {
    font-size: 0.725rem;
    color: #64748b;
    font-family: monospace;
    margin-bottom: 6px;
}

.pos-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border-color);
}

.pos-card-price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

.pos-card-stock {
    font-size: 0.725rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}

.pos-card-stock.low {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
}

.pos-card-stock.out {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

/* Right: Cart & Checkout Panel */
.pos-cart-panel {
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: sticky;
    top: 80px;
}

@media (max-width: 860px) {
    .pos-cart-panel {
        display: none; /* Shown via mobile drawer */
    }
}

.pos-cart-header {
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
}

.pos-customer-picker {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.pos-customer-picker select,
.pos-customer-picker input {
    width: 100%;
    height: 38px;
    font-size: 0.875rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 0 10px;
    background: var(--surface-card);
    color: var(--text-color);
}

.pos-cart-items-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.pos-cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-align: center;
    padding: var(--space-4);
}

.pos-cart-empty-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-2);
    opacity: 0.4;
}

/* Cart Item Row */
.pos-cart-item {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pos-cart-item-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-2);
}

.pos-cart-item-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    line-height: 1.25;
}

.pos-cart-item-del {
    color: var(--danger);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 1rem;
    line-height: 1;
    border-radius: 4px;
}

.pos-cart-item-del:hover {
    background: rgba(239, 68, 68, 0.1);
}

.pos-cart-item-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pos-qty-group {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface-card);
    overflow: hidden;
}

.pos-qty-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: none;
    cursor: pointer;
    font-weight: 700;
    color: var(--text-color);
}

.pos-qty-btn:hover {
    background: var(--border-color);
}

.pos-qty-input {
    width: 44px;
    height: 28px;
    text-align: center;
    border: none;
    font-size: 0.85rem;
    font-weight: 600;
    background: transparent;
    color: var(--text-color);
}

.pos-cart-item-price {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-color);
}

/* Cart Summary & Checkout Footer */
.pos-cart-summary {
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pos-summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pos-summary-row.grand-total {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-color);
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1.5px solid var(--border-color);
}

.pos-checkout-btn {
    width: 100%;
    height: 46px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    margin-top: var(--space-2);
    transition: background 0.15s ease, transform 0.1s ease;
}

.pos-checkout-btn:hover {
    background: var(--primary-hover, #1d4ed8);
}

.pos-checkout-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile Sticky Bottom Cart Bar */
.pos-mobile-cart-bar {
    display: none;
}

@media (max-width: 860px) {
    .pos-mobile-cart-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--surface-card);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
        padding: 0 var(--space-3);
        align-items: center;
        justify-content: space-between;
        z-index: 99;
    }

    .pos-mobile-cart-info {
        display: flex;
        flex-direction: column;
    }

    .pos-mobile-cart-count {
        font-size: 0.75rem;
        color: var(--text-muted);
    }

    .pos-mobile-cart-total {
        font-size: 1.1rem;
        font-weight: 800;
        color: var(--primary);
    }

    .pos-mobile-open-cart-btn {
        padding: 8px 18px;
        background: var(--primary);
        color: #fff;
        font-weight: 700;
        font-size: 0.9rem;
        border-radius: var(--radius-md);
        border: none;
        cursor: pointer;
    }
}

/* Checkout Drawer / Modal */
.pos-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.75) !important;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
}

.pos-modal-overlay.active {
    display: flex;
}

.pos-modal-card {
    background: #ffffff !important;
    color: #0f172a !important;
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
}

.pos-modal-header {
    padding: 16px 22px;
    background: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #0f172a !important;
}

.pos-modal-header h3,
.pos-modal-header .font-weight-700 {
    color: #0f172a !important;
    font-size: 1.15rem !important;
}

.pos-modal-body {
    padding: 22px;
    background: #ffffff !important;
    color: #0f172a !important;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pos-modal-body label.form-label {
    color: #334155 !important;
    font-weight: 600 !important;
    font-size: 0.825rem !important;
    margin-bottom: 4px;
    display: block;
}

.pos-modal-body input.form-control,
.pos-modal-body select.form-control,
.pos-modal-body textarea.form-control {
    background: #ffffff !important;
    color: #0f172a !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 8px !important;
    padding: 8px 12px !important;
    font-size: 0.875rem !important;
}

.pos-modal-body input.form-control:focus,
.pos-modal-body select.form-control:focus,
.pos-modal-body textarea.form-control:focus {
    border-color: #18A999 !important;
    box-shadow: 0 0 0 3px rgba(24, 169, 153, 0.18) !important;
    outline: none !important;
}

.pos-payment-method-pills {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

@media (max-width: 480px) {
    .pos-payment-method-pills {
        grid-template-columns: repeat(2, 1fr);
    }
}

.pos-pay-pill {
    padding: 10px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    font-weight: 600;
    font-size: 0.85rem;
    color: #334155;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.pos-pay-pill.active {
    border-color: #18A999;
    background: rgba(24, 169, 153, 0.1);
    color: #0f766e;
}
