/* Mobile layout: below 768px wide, or below 500px high (phone landscape).
   Only the products frame (3 columns) or the receipt is shown, with a bottom navigation.
   The buttons of a page are read like a book and placed below each other; empty slots are skipped. */

#pagedots,
#bottomnav {
    display: none;
}

@media (max-width: 767px), (max-height: 499px) {

    /* Top bar: only the status dot, no text */
    #lblStatus {
        display: none;
    }

    /* Page dots */
    #pagedots {
        flex: none;
        display: flex;
        justify-content: center;
        gap: 6px;
        padding-block: 8px 2px;
    }

    .page-dot {
        width: 6px;
        height: 6px;
        border-radius: 3px;
        background: #4a4d55;
        transition: width 0.2s;
    }

    .page-dot.active {
        width: 18px;
        background: var(--text);
    }

    body[data-view="receipt"] #pagedots {
        display: none;
    }

    /* Frames: one view at a time */
    /* One cell: the visible frame and the scroll hints lie on top of each other. */
    #register {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr);
    }

    #register > * {
        grid-column: 1 !important;
        grid-row: 1 !important;
    }

    body[data-view="receipt"] .scroll-hints {
        display: none;
    }

    /* Larger receipt lines to tap */
    .receipt-line {
        padding-block: 13px;
        font-size: 15px;
    }

    .receipt-name {
        font-weight: 600;
    }

    #register .frame,
    #employees {
        display: none !important;
    }

    body[data-view="products"] #register .frame[data-frame="products"] {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-auto-rows: auto;
        align-content: start;
    }

    .frame[data-frame="products"] x-button {
        grid-row: auto;
        grid-column: auto;
        aspect-ratio: 1.15;
    }

    body[data-view="receipt"] #register .frame[data-frame="receipt"] {
        display: flex !important;
    }

    /* Bottom navigation */
    #bottomnav {
        flex: none;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: var(--gap);
        padding: var(--gap);
        padding-bottom: calc(var(--gap) + env(safe-area-inset-bottom, 0px));
        background: var(--surface);
        border-top: 1px solid #23252b;
    }

    .nav-button {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 7px;
        height: 56px;
        border-radius: 10px;
        color: var(--text-muted);
        font-size: 12px;
        font-weight: 600;
    }

    /* The icons are drawn differently inside their box (the receipt is upright and fills its height, the
       sliders and the card lie down and fill 75% of a square box, the grid 87.5%). The icon library sizes an
       icon by its width only, so each gets the width that makes the visible drawing 19px high: the same
       visual weight for all four. */
    .nav-button v-icon {
        width: 19px;
    }

    /* Every icon in a box of the same height, centred, so the texts below stay on one line. */
    .nav-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 26px;
    }

    /* Fine-tuned by eye: the receipt 1px bigger, the sliders 1px smaller (they feel the heaviest). */
    .nav-button[data-view="receipt"] v-icon {
        width: 15px;
    }

    .nav-button[data-action="pay"] v-icon {
        width: 25.3px;
    }

    .nav-button[data-action="functions"] v-icon {
        width: 24px;
    }

    .nav-button.active {
        background: var(--surface-raised);
        color: var(--text);
    }

    .nav-badge {
        position: absolute;
        top: 4px;
        left: calc(50% + 6px);
        min-width: 18px;
        height: 18px;
        padding-inline: 5px;
        border-radius: 9px;
        background: var(--badge-color);
        color: #111214;
        font-size: 11px;
        font-weight: 800;
        line-height: 18px;
    }

    .nav-badge[hidden] {
        display: none;
    }
}
