/* Modal layer (js/modal.js) */

.modal-layer {
    position: fixed;
    inset: 0;
    z-index: 50;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.25s;
}

.modal-layer.open .modal-backdrop {
    opacity: 1;
}

div.modal-panel {
    position: absolute;
    background: var(--surface);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    transition: translate 0.25s ease-out, opacity 0.25s, scale 0.25s;
}

/* Popover: under the top bar, centered */
.modal-layer[data-type="popover"] .modal-panel {
    top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px) + 4px);
    left: 50%;
    width: min(420px, calc(100vw - 32px));
    max-height: 70dvh;
    overflow-y: auto;
    padding: 12px;
    border-radius: 16px;
    translate: -50% -8px;
    opacity: 0;
}

.modal-layer[data-type="popover"].open .modal-panel {
    translate: -50% 0;
    opacity: 1;
}

/* Drawer: from the left */
.modal-layer[data-type="drawer"] .modal-panel {
    top: 0;
    bottom: 0;
    left: 0;
    width: min(300px, 85vw);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    translate: -100% 0;
}

.modal-layer[data-type="drawer"].open .modal-panel {
    translate: 0 0;
}

/* Dialog: centered */
.modal-layer[data-type="dialog"] .modal-panel {
    top: 50%;
    left: 50%;
    width: min(420px, calc(100vw - 32px));
    padding: 20px;
    border-radius: 16px;
    translate: -50% -50%;
    scale: 0.96;
    opacity: 0;
}

.modal-layer[data-type="dialog"].open .modal-panel {
    scale: 1;
    opacity: 1;
}

/* Sheet: x-sheet animates itself */
.modal-layer[data-type="sheet"] x-sheet {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--sheet-background, #1c1d22);
}

/* Dialog */

.dialog-title {
    font-weight: 800;
    font-size: 19px;
    margin-bottom: 8px;
}

.dialog-text {
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 20px;
}

.dialog-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
}

.dialog-button {
    height: 48px;
    padding-inline: 8px;
    border-radius: 12px;
    background: var(--surface-raised);
    font-weight: 700;
}

.dialog-button:disabled {
    opacity: 0.35;
    cursor: default;
}

.dialog-button.danger {
    background: var(--offline);
    color: #fff;
}

.dialog-button:not(:disabled):active {
    filter: brightness(0.85);
}

/* Page modal: tiles */

.page-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 56px;
    gap: var(--gap);
}

.page-tiles x-button {
    --text-size: 15px;
}

/* Product detail */

.product-detail-rows {
    margin-bottom: 20px;
}

.product-detail-row {
    display: flex;
    justify-content: space-between;
    padding-block: 10px;
    border-bottom: 1px solid var(--surface-raised);
    font-size: 15px;
}

.product-detail-row span:first-child {
    color: var(--text-muted);
}

.product-detail-row span:last-child {
    font-weight: 700;
}

.product-detail-close {
    width: 100%;
}

/* Functions (mobile): the functions frame as a grid */

.function-grid {
    display: grid;
    grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
    grid-auto-rows: 64px;
    gap: var(--gap);
}

.function-grid x-button {
    --text-size: 14px;
}

/* Payment */

.payment-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 14px;
    font-weight: 800;
    font-size: 24px;
}

/* Number pad modal: narrow; the display and OK are exactly as wide as the keys */

/* Every window with a number pad (discount, price, PIN, ...) has the same width. */
.modal-layer[data-type="dialog"] .modal-panel:has(.pin-keys) {
    width: min(300px, calc(100vw - 32px));
}

.number {
    --pad-width: calc(3 * 72px + 2 * var(--gap));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.number .dialog-title {
    width: var(--pad-width);
    margin-bottom: 0;
}

.number-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: var(--pad-width);
    min-height: 60px;
    padding: 8px;
    border-radius: 12px;
    background: var(--surface-raised);
}

.number-value {
    font-weight: 800;
    font-size: 28px;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.number-preview {
    color: var(--text-muted);
    font-size: 13px;
}

.number-preview[hidden] {
    display: none;
}

.number-ok {
    width: var(--pad-width);
    background: var(--pay) !important;
    color: #111214;
}

/* "Op [n] van 4": on how many of a line the discount comes */
.number-count {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: var(--pad-width);
    color: var(--text-muted);
}

.number-count[hidden] {
    display: none;
}

.number-count-value {
    min-width: 2ch;
    color: var(--text);
    font-weight: 800;
    font-size: 20px;
    text-align: center;
}

.number-step {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 40px;
    border-radius: 10px;
    background: var(--surface-raised);
}

.number-step v-icon {
    width: 14px;
    height: 14px;
}

.payment-checkout {
    width: 100%;
    margin-top: 14px;
    background: var(--pay) !important;
    color: #111214;
}

.payment-checkout:disabled {
    opacity: 0.35;
}

.payment .dialog-text {
    margin-bottom: 14px;
}

.panel-tab:disabled {
    opacity: 0.35;
    cursor: default;
}

/* Mailen bij betalen */
.mail-input {
    width: 100%;
    height: 48px;
    margin-bottom: 8px;
    padding-inline: 14px;
    border: none;
    border-radius: 12px;
    background: var(--surface-raised);
    color: var(--text);
    font: inherit;
    font-size: 16px;
    outline: none;
    user-select: text;
}

.mail-input:focus {
    box-shadow: inset 0 0 0 2px #3b6fd8;
}

.mail-error {
    margin-bottom: 8px;
    color: var(--offline);
    font-size: 13px;
}

.mail-error[hidden] {
    display: none;
}

.mail .dialog-buttons {
    margin-top: 12px;
}

.dialog-button.primary {
    background: var(--pay);
    color: #111214;
}

/* Bon heropenen */
.open-receipts-list {
    max-height: min(55dvh, 460px);
    margin-top: 8px;
    overflow-y: auto;
    touch-action: pan-y;
}

.open-receipts-list .relation-row {
    grid-template-columns: 8px 1fr auto;
}

.open-receipts-amount {
    font-weight: 700;
}
