/* ============================================
   POS Cashier — Touch Terminal Interface
   (aligned with Shop Floor / Attendance Kiosk)
   ============================================ */

.pos-cashier {
    --pos-bg: #f3f4f6;
    --pos-card: #ffffff;
    --pos-text: #111827;
    --pos-muted: #6b7280;
    --pos-border: #e5e7eb;
    --pos-primary: #2563eb;
    --pos-success: #16a34a;
    --pos-warning: #ca8a04;
    --pos-danger: #dc2626;
    --pos-radius: 1rem;
    --pos-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);

    background: var(--pos-bg);
    color: var(--pos-text);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    min-height: calc(100vh - 8rem);
    margin: -1rem;
    padding: 0;
}

.pos-cashier-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--pos-card);
    border-bottom: 1px solid var(--pos-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    padding: 0.875rem 1.25rem;
}

.pos-cashier-header-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.pos-cashier-brand {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.pos-cashier-brand small {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--pos-muted);
    margin-top: 1px;
}

.pos-cashier-session {
    flex: 1;
    min-width: 200px;
    max-width: 360px;
}

.pos-cashier-session select {
    width: 100%;
    min-height: 48px;
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid var(--pos-border);
    border-radius: 12px;
    background: var(--pos-bg);
    color: var(--pos-text);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.pos-cashier-session select:focus {
    border-color: var(--pos-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.pos-cashier-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-inline-start: auto;
}

.pos-cashier-clock {
    font-size: 1.375rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--pos-primary);
}

.pos-cashier-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 40px;
    padding: 0.375rem 0.875rem;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 0.875rem;
    font-weight: 700;
}

.pos-offline-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 40px;
    padding: 0.375rem 0.875rem;
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.8125rem;
    font-weight: 600;
}

.pos-offline-sync-btn {
    border: 0;
    border-radius: 999px;
    padding: 0.25rem 0.625rem;
    background: #92400e;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
}

.pos-offline-sync-btn:hover {
    background: #78350f;
}

.pos-cashier-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem;
}

@media (min-width: 1024px) {
    .pos-cashier-body {
        grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr);
        align-items: start;
        min-height: calc(100vh - 11rem);
    }
}

.pos-cashier-panel {
    background: var(--pos-card);
    border-radius: var(--pos-radius);
    box-shadow: var(--pos-shadow);
    border: 1px solid var(--pos-border);
    padding: 1rem;
}

.pos-cashier-search {
    position: relative;
    margin-bottom: 1rem;
}

.pos-cashier-search input {
    width: 100%;
    min-height: 52px;
    padding: 0.875rem 1rem 0.875rem 3rem;
    font-size: 1.125rem;
    border: 2px solid var(--pos-border);
    border-radius: 12px;
    background: var(--pos-bg);
    outline: none;
}

.pos-cashier-search input:focus {
    border-color: var(--pos-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.pos-cashier-search-icon {
    position: absolute;
    inset-inline-start: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.375rem;
    height: 1.375rem;
    color: var(--pos-muted);
    pointer-events: none;
}

.pos-product-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

@media (min-width: 640px) {
    .pos-product-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .pos-product-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.pos-product-tile {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 112px;
    padding: 1rem;
    text-align: start;
    border: 2px solid var(--pos-border);
    border-radius: 14px;
    background: var(--pos-card);
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.pos-product-tile:hover {
    border-color: var(--pos-primary);
    background: #eff6ff;
}

.pos-product-tile:active {
    transform: scale(0.97);
}

.pos-product-name {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--pos-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pos-product-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.pos-product-price {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--pos-primary);
    font-variant-numeric: tabular-nums;
}

.pos-product-stock {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    background: #dcfce7;
    color: #166534;
    font-variant-numeric: tabular-nums;
}

.pos-product-stock-zero {
    background: #fee2e2;
    color: #991b1b;
}

.dark .pos-product-stock {
    background: #14532d;
    color: #86efac;
}

.dark .pos-product-stock-zero {
    background: #7f1d1d;
    color: #fca5a5;
}

.pos-product-code {
    font-size: 0.75rem;
    color: var(--pos-muted);
}

.pos-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--pos-muted);
    font-size: 1rem;
    font-weight: 500;
}

.pos-empty-icon {
    width: 4rem;
    height: 4rem;
    border-radius: 999px;
    background: var(--pos-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
}

.pos-cart-panel {
    display: flex;
    flex-direction: column;
    min-height: 420px;
    max-height: calc(100vh - 11rem);
    position: sticky;
    top: 5.5rem;
}

.pos-cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.875rem;
}

.pos-cart-title {
    font-size: 1.125rem;
    font-weight: 700;
}

.pos-customer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--pos-border);
}

.pos-customer-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--pos-muted);
}

.pos-customer-search input,
.pos-customer-select {
    width: 100%;
    min-height: 48px;
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid var(--pos-border);
    border-radius: 12px;
    background: var(--pos-bg);
    color: var(--pos-text);
    outline: none;
}

.pos-customer-search input:focus,
.pos-customer-select:focus {
    border-color: var(--pos-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.pos-customer-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 0.875rem;
    font-weight: 700;
}

.dark .pos-customer-chip {
    background: #1e3a5f;
    color: #93c5fd;
}

.pos-cart-lines {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-inline-end: 0.25rem;
    margin-bottom: 1rem;
}

.pos-cart-line {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    padding: 0.875rem;
    border-radius: 12px;
    background: var(--pos-bg);
    border: 1px solid var(--pos-border);
}

.pos-cart-line-name {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.3;
}

.pos-cart-line-meta {
    font-size: 0.8125rem;
    color: var(--pos-muted);
    margin-top: 0.25rem;
}

.pos-cart-line-total {
    font-size: 1.0625rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    text-align: end;
}

.pos-qty {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.625rem;
}

.pos-touch-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    min-width: 48px;
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.pos-touch-btn:active {
    transform: scale(0.96);
}

.pos-touch-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.pos-touch-btn-sm {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem;
    font-size: 1.25rem;
    line-height: 1;
}

.pos-touch-btn-primary {
    background: var(--pos-primary);
    color: #fff;
}

.pos-touch-btn-success {
    background: var(--pos-success);
    color: #fff;
}

.pos-touch-btn-danger {
    background: var(--pos-danger);
    color: #fff;
}

.pos-touch-btn-outline {
    background: var(--pos-card);
    border: 2px solid var(--pos-border);
    color: var(--pos-text);
}

.pos-touch-btn-ghost {
    background: transparent;
    color: var(--pos-danger);
    min-height: 40px;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.pos-qty-value {
    min-width: 2.5rem;
    text-align: center;
    font-size: 1.125rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.pos-cart-footer {
    border-top: 1px solid var(--pos-border);
    padding-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.pos-total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1.25rem;
    font-weight: 800;
}

.pos-total-row span:last-child {
    color: var(--pos-primary);
    font-variant-numeric: tabular-nums;
}

.pos-change-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--pos-success);
}

.pos-cash-input {
    width: 100%;
    min-height: 52px;
    padding: 0.75rem 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    border: 2px solid var(--pos-border);
    border-radius: 12px;
    background: var(--pos-bg);
    outline: none;
}

.pos-cash-input:focus {
    border-color: var(--pos-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.pos-cash-quick {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
}

.pos-cash-quick .pos-touch-btn {
    min-height: 44px;
    padding: 0.5rem;
    font-size: 0.875rem;
}

.pos-pay-btn {
    width: 100%;
    min-height: 56px;
    font-size: 1.125rem;
}

.pos-last-sale {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--pos-border);
    background: var(--pos-bg);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.pos-last-sale-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--pos-muted);
}

.pos-last-sale-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.95rem;
    font-weight: 600;
}

.pos-last-sale-row span:last-child {
    font-variant-numeric: tabular-nums;
}

.pos-last-sale-actions {
    margin-top: 0.35rem;
}

.pos-open-session-btn {
    margin-top: 0.5rem;
    width: 100%;
}

.pos-warning {
    margin-top: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.875rem;
    font-weight: 600;
}

.dark .pos-cashier {
    --pos-bg: #111827;
    --pos-card: #1f2937;
    --pos-text: #f9fafb;
    --pos-muted: #9ca3af;
    --pos-border: #374151;
}

.dark .pos-product-tile:hover {
    background: #1e3a5f;
}

.dark .pos-cashier-badge {
    background: #1e3a5f;
    color: #93c5fd;
}

.dark .pos-warning {
    background: #78350f;
    color: #fde68a;
}

/* Receipt overlay */
.pos-receipt-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    padding: 1rem;
}

.pos-receipt {
    background: #fff;
    color: #111;
    border-radius: 12px;
    width: 100%;
    max-width: 360px;
    padding: 1.5rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 90vh;
    overflow-y: auto;
}

.pos-receipt-header {
    text-align: center;
    border-bottom: 1px dashed #d1d5db;
    padding-bottom: 0.75rem;
}

.pos-receipt-brand {
    font-size: 1.125rem;
    font-weight: 800;
}

.pos-receipt-order {
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    margin-top: 0.25rem;
}

.pos-receipt-date {
    font-size: 0.75rem;
    color: #9ca3af;
}

.pos-receipt-customer {
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 0.35rem;
}

.pos-receipt-lines {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.pos-receipt-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
}

.pos-receipt-line span:last-child {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.pos-receipt-line-total {
    font-size: 1rem;
    font-weight: 800;
}

.pos-receipt-totals {
    border-top: 1px dashed #d1d5db;
    padding-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.pos-receipt-payments {
    border-top: 1px dashed #d1d5db;
    padding-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.pos-receipt-payments-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #6b7280;
}

.pos-receipt-note {
    font-size: 0.75rem;
    font-style: italic;
    color: #6b7280;
    text-align: center;
}

.pos-receipt-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.pos-exchange-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.pos-exchange-line-name {
    font-size: 0.875rem;
    font-weight: 600;
    flex: 1;
}

.pos-exchange-line-controls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.pos-exchange-qty-input {
    width: 60px;
    padding: 0.35rem 0.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    border: 2px solid var(--pos-border);
    border-radius: 8px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.pos-exchange-qty-input:focus {
    border-color: var(--pos-primary);
    outline: none;
}

.pos-exchange-max {
    font-size: 0.75rem;
    color: var(--pos-muted);
    font-variant-numeric: tabular-nums;
}

@media print {
    body * {
        visibility: hidden;
    }

    #pos-receipt-printable,
    #pos-receipt-printable * {
        visibility: visible;
    }

    #pos-receipt-printable {
        position: absolute;
        inset: 0;
        margin: auto;
        box-shadow: none;
        border-radius: 0;
        max-width: 80mm;
    }

    .pos-receipt-actions {
        display: none;
    }

    .pos-receipt-overlay {
        background: transparent;
        backdrop-filter: none;
    }
}

@media (max-width: 1023px) {
    .pos-cart-panel {
        position: static;
        max-height: none;
    }
}
