/* On-screen keyboard — POS / checkout (touch targets ≥ 48px) */

.pos-touch-keyboard {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 12050;
    display: none;
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    pointer-events: none;
}

.pos-touch-keyboard.pos-touch-keyboard--visible {
    display: block;
    pointer-events: auto;
}

.pos-touch-keyboard__inner {
    background: var(--white, #fff);
    border-top: 2px solid var(--border, #e5e7eb);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
    padding: 6px 8px 10px;
    /* No inner max-height / scroll — panel grows; user can drag bar if needed */
    overflow: visible;
    transform: translate(0px, 0px);
    will-change: transform;
}

.pos-touch-keyboard__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 -6px 8px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.pos-touch-keyboard__bar:active {
    cursor: grabbing;
}

.pos-touch-keyboard.pos-touch-keyboard--dragging .pos-touch-keyboard__bar {
    cursor: grabbing;
    background: rgba(45, 90, 61, 0.06);
}

.pos-touch-keyboard__grip {
    flex-shrink: 0;
    width: 22px;
    text-align: center;
    font-size: 15px;
    line-height: 1;
    letter-spacing: -2px;
    color: var(--text-light, #9ca3af);
    font-weight: 700;
    pointer-events: none;
}

.pos-touch-keyboard__label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-mid, #4b5563);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.pos-touch-keyboard__done {
    flex-shrink: 0;
    min-height: clamp(40px, 6.5vh, 48px);
    min-width: 72px;
    padding: 0 16px;
    border-radius: 10px;
    border: none;
    background: var(--forest, #2d5a3d);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    touch-action: manipulation;
}

.pos-touch-keyboard__keys {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Laptop-style deck (chiclet keys) */
.pos-touch-keyboard__keys--laptop {
    padding: 8px 6px 10px;
    border-radius: 10px;
    background: linear-gradient(180deg, #dfe3ea 0%, #cfd4dd 55%, #c5cad4 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.pos-touch-keyboard__keys--numpad {
    padding: 8px 6px 10px;
    border-radius: 10px;
    background: linear-gradient(180deg, #e8ebf0 0%, #d5dae3 100%);
}

/* Calculator-style fixed 4 columns (7-9 row, 0 / 00 / .) */
.pos-touch-keyboard__calc-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    width: 100%;
}

.pos-touch-keyboard__calc-grid .pos-touch-keyboard__key,
.pos-touch-keyboard__calc-grid .pos-touch-keyboard__spacer {
    flex: unset;
    min-width: 0;
    width: 100%;
}

/* Enter occupies two cells under Clear */
.pos-touch-keyboard__key--calc-enter {
    grid-column: 4;
    grid-row: 3 / span 2;
    min-height: calc((clamp(38px, 6.5vh, 48px) * 2) + 5px);
}

.pos-touch-keyboard__row {
    display: flex;
    gap: 5px;
    justify-content: center;
    flex-wrap: nowrap;
    align-items: stretch;
}

.pos-touch-keyboard__row--stagger {
    padding-left: min(14px, 2.5vw);
}

.pos-touch-keyboard__row--stagger2 {
    padding-left: min(22px, 4vw);
}

.pos-touch-keyboard__row--stagger3 {
    padding-left: min(30px, 5.5vw);
}

.pos-touch-keyboard__row--email-extras {
    gap: 6px;
    margin-bottom: 2px;
}

.pos-touch-keyboard__row--wide .pos-touch-keyboard__key {
    flex: 1;
    min-height: clamp(40px, 7vh, 50px);
}

.pos-touch-keyboard__key {
    flex: 1;
    min-width: 0;
    min-height: clamp(38px, 6.5vh, 48px);
    padding: 5px 3px;
    border: 1px solid #9aa3b2;
    border-radius: 5px;
    background: linear-gradient(180deg, #fcfcfd 0%, #e8eaef 45%, #dde1e8 100%);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.9) inset,
        0 1px 2px rgba(0, 0, 0, 0.12);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: clamp(14px, 2.1vh, 16px);
    font-weight: 600;
    color: #1f2937;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.pos-touch-keyboard__key:active {
    background: linear-gradient(180deg, #e8eaef 0%, #d4d8e0 100%);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08) inset;
    transform: translateY(1px);
}

/* Modifier / wide keys (like laptop Fn row) */
.pos-touch-keyboard__key--mod {
    flex: 1.15;
    background: linear-gradient(180deg, #d9dee6 0%, #c4cad5 100%);
    border-color: #8b95a8;
    font-size: clamp(10px, 1.55vh, 12px);
    font-weight: 700;
    color: #374151;
    letter-spacing: 0.02em;
}

.pos-touch-keyboard__key--mod:active {
    background: linear-gradient(180deg, #c9d0da 0%, #b4bcc8 100%);
}

.pos-touch-keyboard__key--latched {
    background: linear-gradient(180deg, #c5e0d0 0%, #9fc9b0 100%);
    border-color: #5a8f6e;
    color: #14532d;
}

.pos-touch-keyboard__key--1-2u {
    flex: 1.25;
}

.pos-touch-keyboard__key--1-3u {
    flex: 1.4;
}

.pos-touch-keyboard__key--1-4u {
    flex: 1.55;
}

.pos-touch-keyboard__key--1-5u {
    flex: 1.75;
}

.pos-touch-keyboard__key--1-6u {
    flex: 2;
}

.pos-touch-keyboard__key--1-8u {
    flex: 2.35;
}

.pos-touch-keyboard__key--2u {
    flex: 2.1;
    min-width: 56px;
}

.pos-touch-keyboard__key--space {
    flex: 5;
    min-width: 120px;
    font-size: clamp(11px, 1.6vh, 13px);
    color: #4b5563;
}

.pos-touch-keyboard__key--wide {
    flex: 2;
}

.pos-touch-keyboard__spacer {
    flex: 1;
    min-height: clamp(38px, 6.5vh, 48px);
    pointer-events: none;
}

.pos-touch-keyboard__spacer--half {
    flex: 0.45;
    min-width: 4px;
    min-height: 0;
}

/* Lift fixed modals / content slightly when keyboard open (optional scroll room) */
body.pos-touch-keyboard-open #paymentModalOverlay > div,
body.pos-touch-keyboard-open .pos-layout {
    padding-bottom: 0;
}

@media (min-width: 900px) {
    .pos-touch-keyboard__inner {
        max-width: 720px;
        margin: 0 auto;
    }
}
