﻿/* The point of sale's own styles, on top of MudBlazor's: touch-sized, and laid out for a till's screen */

html, body {
    margin: 0;
    height: 100%;
    background: var(--mud-palette-background);
    -webkit-tap-highlight-color: transparent;
    /* The page itself never scrolls nor bounces (a pull does not reload it): only the screen in the shell does */
    overflow: hidden;
    overscroll-behavior: none;
}

/* The shell: as tall as what the screen shows (dvh: without the bars of a phone's browser, nor its keyboard) */
.pos-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* The bar on top, in the flow of the shell instead of over the page; clear of the notch when drawn edge to edge */
.pos-shell > .mud-appbar {
    position: relative;
    flex: none;
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* The screen: what is left between the two bars, and the only part that scrolls */
.pos-shell > .mud-main-content {
    flex: 1 1 auto;
    min-height: 0;
    padding-top: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.pos-content {
    padding: 16px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
}

@media (max-width: 600px) {
    .pos-content {
        padding: 12px;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
}

.pos-page {
    max-width: 1400px;
    margin: 0 auto;
}

.pos-narrow {
    max-width: 460px;
    margin: 24px auto;
}

.pos-muted {
    color: var(--mud-palette-text-secondary);
}

/* A promotion given on a line or the sale */
.pos-promotion {
    color: var(--mud-palette-success);
}

.pos-strong td {
    font-weight: 600;
}

.pos-nav {
    white-space: nowrap;
    flex: none;
}

/* The name of the app in the bar: shrinks before the buttons do, cut short if the screen is narrow */
.pos-title {
    min-width: 0;
    flex: 0 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 600px) {
    .pos-title {
        font-size: 1.05rem !important;
        margin-right: 8px !important;
    }
}

/* The store and till of the terminal, in the app bar */
.pos-terminal {
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    padding: 1px 10px;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Sale: the basket on the left, the total and the payment on the right; one above the other on narrow screens */
.pos-sale {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 16px;
    align-items: start;
}

.pos-basket {
    max-height: calc(100vh - 220px);
    max-height: calc(100dvh - 220px);
    overflow-y: auto;
}

.pos-pay {
    min-height: 64px;
    font-size: 1.25rem;
}

@media (max-width: 900px) {
    .pos-sale {
        grid-template-columns: minmax(0, 1fr);
    }

    .pos-basket {
        max-height: none;
    }

    /* Only the icons in the app bar */
    .pos-nav-text {
        display: none;
    }

    .pos-nav {
        min-width: 0;
    }

    .pos-nav .mud-button-icon-start,
    .pos-nav .mud-button-icon-end {
        margin: 0;
    }
}

/* Keypad for the operator code and the PIN */
.pos-pinpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.pos-pinpad .mud-button-root {
    min-height: 56px;
    font-size: 1.4rem;
}

.pos-pairing-code {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 2.6rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    text-indent: 0.3em;
    padding: 16px;
    border: 2px dashed var(--mud-palette-primary);
    border-radius: 8px;
    word-break: break-all;
}

.pos-receipt {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 0.8rem;
    background: #fff;
    border: 1px solid var(--mud-palette-lines-default);
    padding: 12px;
    max-height: 320px;
    overflow: auto;
    white-space: pre;
}

/* The receipt's paper, as wide as the printer's, centered in the box that fills the dialog */
.pos-receipt .pos-receipt-paper {
    margin: 0 auto;
}

.pos-search-results {
    max-height: 50vh;
    overflow-y: auto;
}

/* A receipt as printed: its lines, and its QR code */
.pos-receipt .pos-receipt-line {
    min-height: 1.2em;
}

.pos-receipt .pos-receipt-center {
    text-align: center;
}

.pos-receipt .pos-receipt-bold {
    font-weight: 700;
}

.pos-receipt .pos-receipt-qr {
    display: flex;
    justify-content: center;
    padding: 6px 0;
}

/* Shown by Blazor only when the screens stop on an error nothing handled */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    padding: 12px 16px;
    background: #b00020;
    color: #fff;
}

#blazor-error-ui .reload {
    color: #fff;
    font-weight: 600;
    margin-left: 12px;
}

/* The status bar, at the foot of every screen (of the shell: it does not scroll); clear of the home bar of a phone */
.pos-statusbar {
    flex: none;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 28px;
    box-sizing: border-box;
    padding: 0 max(12px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(12px, env(safe-area-inset-left));
    font-size: 0.75rem;
    background: var(--mud-palette-surface);
    border-top: 1px solid var(--mud-palette-lines-default);
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
    overflow: hidden;
}

.pos-statusbar-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.pos-statusbar-stale {
    color: var(--mud-palette-warning-darken);
}

.pos-statusbar .pos-statusbar-spinner {
    width: 14px !important;
    height: 14px !important;
}

.pos-statusbar-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.pos-statusbar-dot.pos-online {
    background: var(--mud-palette-success);
}

.pos-statusbar-dot.pos-offline-dot {
    background: var(--mud-palette-warning);
}

/* The first copy of the store's data, after the pairing */
.pos-sync-steps {
    list-style: none;
    margin: 0;
    padding: 0;
}

.pos-sync-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.pos-sync-step:last-child {
    border-bottom: none;
}

.pos-sync-icon {
    display: inline-flex;
    width: 24px;
    justify-content: center;
}

.pos-sync-name {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.pos-sync-pending .pos-sync-name {
    color: var(--mud-palette-text-secondary);
}

.pos-sync-running .pos-sync-name {
    font-weight: 600;
}

.pos-sync-error {
    font-size: 0.8rem;
    color: var(--mud-palette-error);
}

.pos-sync-count {
    font-size: 0.85rem;
    white-space: nowrap;
}

/* In full screen (Windows) the window has no title bar: its buttons show at the top edge, with the mouse or a touch */
.pos-window-edge {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    z-index: 1500;
}

.pos-window-bar {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1501;
    display: flex;
    gap: 2px;
    padding: 4px 6px;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-top: none;
    border-radius: 0 0 0 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.pos-window-bar .pos-window-close:hover {
    background: #c42b1c;
    color: #fff;
}

.pos-clock strong {
    color: var(--mud-palette-text-primary);
    font-size: 0.85rem;
}
