/* Consolidated and cleaned version */

body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background: #fff1f5; 
    overflow-x: hidden;
    touch-action: manipulation;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1 {
    text-align: center;
    color: #d81b60;
    margin: 10px 0;
    font-size: 2.5em;
}

.screen {
    display: none;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    max-width: none;
    overflow-x: hidden;
    padding: 10px;
    box-sizing: border-box;
}

.screen.active {
    display: flex;
}

.grid {
    display: grid;
    grid-template-columns: repeat(4fr, minmax(140px, 1fr));
    gap: 12px;
    row-gap: 12px;
    flex-grow: 1;
    padding: 10px 5px;
    overflow-y: auto;
    touch-action: manipulation;
    max-width: none;
    width: 100%;
    max-width: none;
    margin: 0 auto;
    box-sizing: border-box;
    align-content: start;   /* Prevents excessive vertical stretching */
}

.grid button {
    background: #f06292;
    color: white;
    border: none;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    word-wrap: break-word;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: clamp(14px, 4vw, 24px) clamp(8px, 2vw, 12px);
    gap: 8px;
    min-height: 110px;
    font-size: clamp(1.6rem, 5vw, 2.2rem);   /* Larger base */
    line-height: 1.3;
    width: 100%;
    box-sizing: border-box;
}

.grid button strong {
    font-size: clamp(1.6rem, 4.8vw, 2.1rem);
    font-weight: bold;
}

.nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px 8px;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}

.nav-left {
    width: 50px;
    height: 1px;
}

.back-btn,
.cart-btn {
    position: absolute;
    font-size: 2.5em;
    background: none;
    border: none;
    color: #d81b60;
    padding: 0;
    margin: 0;
    z-index: 10;
}

.back-btn { left: 10px; top: 10px; }
.cart-btn { right: 10px; top: 10px; display: flex; align-items: center; gap: 8px; }

/* Cart item count badge */
.cart-btn::after {
    content: attr(data-count);
    font-size: 0.5em;
    background: #c51162;
    color: white;
    border-radius: 50%;
    padding: 4px 8px;
    min-width: 20px;
    position: absolute;
    top: -8px;
    right: -12px;
    display: none;
}

.cart-btn[data-count]:not([data-count=""])::after {
    display: block;
}

/* Keypad */
.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 20px 0;
    flex-shrink: 0;
    padding: 0 10px;
}

.keypad button {
    font-size: clamp(2.5rem, 8vw, 3.5rem);
    padding: clamp(20px, 6vw, 30px);
    background: #ff94c2;
    color: white;
    border: none;
    border-radius: 15px;
}

.keypad button.backspace { background: #ff6f91; }
.keypad button.add { background: #4caf50; }
.keypad button.equals { background: #c51162 !important; grid-column: span 3; }

#current-qty {
    font-size: 4em;
    text-align: center;
    margin: 20px 0;
    color: #c51162;
    font-weight: bold;
    flex-shrink: 0;
}

#cart-items {
    flex-grow: 1;
    overflow-y: auto;
    font-size: 1.8em;
    margin-bottom: 10px;
}

#cart-items div {
    padding: 15px;
    background: #fce4ec;
    margin: 8px 0;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    cursor: pointer;
}

#total {
    font-size: 2.5em;
    text-align: center;
    color: #c51162;
    margin: 10px 0;
}

.big-btn {
    font-size: 2.2em;
    padding: 20px;
    margin: 10px 0;
    background: #c51162;
    color: white;
    border: none;
    border-radius: 15px;
}

#receipt-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    background: white;
    margin: 10px 0;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    font-size: 1.6em;
    line-height: 1.6;
}

#receipt-content h1 {
    text-align: center;
    color: #d81b60;
    font-size: 2.8em;
    margin: 10px 0 20px;
}

#receipt-content .date {
    text-align: center;
    font-size: 1.8em;
    margin: 10px 0;
    color: #555;
}

#receipt-content .customer {
    text-align: center;
    font-size: 1.6em;
    margin: 15px 0;
}

#receipt-content hr {
    border: none;
    border-top: 2px dashed #d81b60;
    margin: 20px 0;
}

#receipt-content .items div {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    font-size: 1.7em;
}

#receipt-content .total {
    text-align: center;
    font-size: 2.6em;
    color: #c51162;
    font-weight: bold;
    margin: 20px 0;
}

#receipt-content .thanks {
    text-align: center;
    font-size: 1.8em;
    margin: 30px 0 10px;
    color: #d81b60;
}

.receipt-actions .full-width {
    width: 100%;
    margin: 0;
    font-size: 2.2em;
    padding: 25px;
    background: #4caf50;  /* Green to stand out as main action */
}

.receipt-actions {
    padding: 20px;
}

#receipt-content h1 {
    font-size: 2.8em;
    text-align: center;
    color: #d81b60;
    margin: 0 0 15px 0;
    font-weight: bold;
}

#receipt-content .date {
    text-align: center;
    font-size: 1.6em;
    color: #777;
    margin: 10px 0 20px 0;
}

#receipt-content .customer {
    background: #fce4ec;
    padding: 15px;
    border-radius: 12px;
    margin: 20px 0;
    text-align: center;
    font-size: 1.4em;
}

#receipt-content .customer strong {
    color: #c51162;
}

#receipt-content hr {
    border: none;
    border-top: 3px dashed #d81b60;
    margin: 30px 0;
}

#receipt-content .category {
    font-size: 1.8em;
    font-weight: bold;
    color: #d81b60;
    margin: 30px 0 15px 0;
    text-align: left;
    padding-bottom: 8px;
    border-bottom: 2px solid #f06292;
}

#receipt-content .items div {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    font-size: 1.7em;
    border-bottom: 1px dotted #eee;
}

#receipt-content .items .desc {
    flex: 1;
    padding-right: 20px;
    word-wrap: break-word;
}

#receipt-content .items .amount {
    font-weight: bold;
    color: #c51162;
    min-width: 120px;
    text-align: right;
}

#receipt-content .total {
    font-size: 3.2em !important;
    font-weight: bold;
    color: #c51162;
    text-align: right !important;
    margin: 40px 0 20px 0;
    padding: 20px;
    background: #fce4ec;
    border-radius: 15px;
}

#receipt-content .thanks {
    text-align: center;
    font-size: 1.8em;
    color: #d81b60;
    margin: 40px 0 20px 0;
    font-style: italic;
}



/* Ensure full content in PDF generation */
#receipt-content * {
    max-width: 100%;
    word-wrap: break-word;
    page-break-inside: avoid;
}

@media print {
    @page {
        size: a4 portrait;
        margin: 0.5in;
    }

    body, html {
        margin: 0;
        padding: 0;
        background: white;
    }

    #receipt-content {
        width: 100%;
        font-size: 0.9em !important;
        line-height: 1.2 !important;
        padding: 0.5in !important;
        margin: 0 auto;
    }

    #receipt-content h1 {
        font-size: 2.2em;
    }

    #receipt-content .date {
        font-size: 1.4em;
    }

    #receipt-content .category {
        font-size: 1.6em;
        margin: 15px 0 5px 0;
    }

    #receipt-content .items div {
        padding: 6px 0;
        font-size: 1.5em;
    }

    #receipt-content .total {
        font-size: 2.5em !important;
        margin: 20px 0 10px 0;
        padding: 10px;
    }

    #receipt-content .thanks {
        font-size: 1.5em;
        margin: 20px 0 0 0;
    }

    /* Ensure no page breaks inside groups */
    .category, .items div {
        page-break-inside: avoid;
    }
}

/* Custom POS Modal - Mobile-Friendly */
/* Custom POS Modal - Mobile-Friendly with Full Scrolling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: flex-end;     /* Bottom-aligned on mobile */
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 500px;
    height: 90vh;              /* Fixed height for consistent scrolling */
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.3);
}

.modal-content h2 {
    background: #d81b60;
    color: white;
    margin: 0;
    padding: 18px;
    text-align: center;
    font-size: 2em;
    flex-shrink: 0;
}

.modal-body {
    padding: 20px;
    flex: 1;                   /* Takes available space */
    overflow-y: auto;          /* Always scrollable */
    -webkit-overflow-scrolling: touch;
}

.modal-body label {
    display: block;
    margin: 15px 0 6px 0;
    font-size: 1.5em;
    color: #c51162;
    font-weight: bold;
}

.modal-body input {
    width: 100%;
    padding: 14px;
    font-size: 1.6em;
    border: 2px solid #f06292;
    border-radius: 12px;
    box-sizing: border-box;
}

#existing-customer-info {
    background: #fce4ec;
    padding: 15px;
    border-radius: 12px;
    margin: 15px 0;
    font-size: 1.4em;
}

.modal-actions {
    display: flex;
    gap: 12px;
    padding: 20px;
    background: #f8bbd0;
    flex-shrink: 0;            /* Buttons always visible */
    border-radius: 0 0 20px 20px;
}

.modal-actions button {
    flex: 1;
    font-size: 1.8em;
    padding: 16px;
}

/* On larger screens (tablets+), center the modal */
@media (min-width: 600px) {
    .modal {
        align-items: center;
    }
    .modal-content {
        border-radius: 20px;
        height: auto;
        max-height: 85vh;
    }
    .modal-actions {
        border-radius: 0 0 20px 20px;
    }
}


/* Custom POS Modal */
/* .modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    overflow: hidden;
}

.modal-content h2 {
    background: #d81b60;
    color: white;
    margin: 0;
    padding: 20px;
    text-align: center;
    font-size: 2.2em;
}

.modal-body {
    padding: 20px;
}

.modal-body label {
    display: block;
    margin: 15px 0 8px 0;
    font-size: 1.6em;
    color: #c51162;
    font-weight: bold;
}

.modal-body input {
    width: 100%;
    padding: 15px;
    font-size: 1.8em;
    border: 2px solid #f06292;
    border-radius: 12px;
    box-sizing: border-box;
}

.modal-actions {
    display: flex;
    gap: 15px;
    padding: 20px;
    background: #f8bbd0;
}

.modal-actions button {
    flex: 1;
    font-size: 1.8em;
    padding: 18px;
} */


/* Phones (small screens) - 2 columns, like your iPhone 7 */
@media (max-width: 480px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        row-gap: 10px;
    }

    .cart-btn { 
        font-size: 2.2em; 
        top: 8px; 
        right: 8px; 
        gap: 6px; }

    .grid button {
        min-height: 100px;
        padding: 12px 8px;
        font-size: clamp(1.3rem, 4.5vw, 1.6rem);
    }

    .grid button strong {
        font-size: clamp(1.4rem, 5vw, 1.7rem);
    }

    .keypad {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 0 16px;
    }

    .keypad button {
        font-size: 2.8rem !important;
        padding: 18px !important;
        min-height: 70px;
        line-height: 1.1;
        width: 100%;
        box-sizing: border-box;
    }

    .keypad button.backspace {
        font-size: 2.5rem !important;
    }

    .keypad button.equals {
        padding: 20px !important;
    }

    #current-qty {
        font-size: 3.0rem !important;
        margin: 10px 0;
    }

    #product-title {
        font-size: 2rem !important;
        line-height: 1.3;
    }

    #product-title strong {
        font-size: 2.2rem !important;
    }

    #screen-quantity {
        padding: 10px;
    }

    .back-btn,
    .cart-btn {
        font-size: 2.2em !important;
    }

    .modal {
        align-items: center;
        justify-content: center;
    }

    .modal-content {
        height: 90vh;
        max-height: 90vh;
        display: flex;
        flex-direction: column;
        overflow: hidden; /* prevents growth */
    }

    .modal-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-actions {
        flex-shrink: 0;
    }}
}

/* Tablets and medium devices - max 3 columns */
@media (min-width: 481px) and (max-width: 1024px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 14px;
        row-gap: 14px;
    }
}

/* Large desktops only (iMac etc.) - 4 columns */
@media (min-width: 1200px) {
    .grid {
        grid-template-columns: repeat(4, 1fr);
        max-width: 1000px;
        margin: 0 auto;
    }
}

/* Extra large text on tablets/old iPads */
/* @media (min-width: 481px) and (max-width: 1024px) {
    .grid button {
        font-size: clamp(2rem, 7vw, 3rem) !important;
        padding: clamp(20px, 6vw, 40px) clamp(12px, 4vw, 20px) !important;
        min-height: 140px !important;
    }
    .grid button strong {
        font-size: clamp(2.4rem, 8vw, 3.6rem) !important;
    }
} */

/* Old iPads – PORTRAIT (768 × 1024) */
@media (orientation: portrait) and (max-width: 820px) and (min-width: 700px) {

    .grid {
        grid-template-columns: repeat(3, 1fr);
        padding: 16px;
        gap: 16px;
    }

    .grid button {
        min-height: 150px !important;
        padding: 24px 20px !important;
        font-size: 1.8rem !important;
        line-height: 1.25;
    }

    .grid button strong {
        font-size: 1.8rem !important;
    }

    .keypad {
        gap: 15px;
        margin: 25px 0;
        padding: 0 20px;
    }

    .keypad button {
        font-size: 3.5rem !important;     
        padding: 30px !important;         
        min-height: 90px;
    }

    .keypad button.backspace {
        font-size: 3rem !important;
    }

    #current-qty {
        font-size: 3.0rem !important;
        margin: 10px 0;
    }

    #product-title {
        font-size: 2rem !important;
        line-height: 1.3;
    }

    #product-title strong {
        font-size: 2.2rem !important;
    }

    #screen-quantity {
        padding: 10px;
    }

    .back-btn,
    .cart-btn {
        font-size: 2.2em !important;
    }
}

/* Old iPads – LANDSCAPE font lock */
@media (orientation: landscape) and (max-width: 1024px) and (min-width: 700px) {

    #current-qty {
        margin: 6px 0;
    }

    .grid {
        grid-template-columns: repeat(3, 1fr);
        padding: 16px;
        gap: 16px;
    }

    .grid button {
        min-height: 150px !important;
        padding: 24px 20px !important;
        font-size: 1.8rem !important;
        line-height: 1.25;
    }

    .grid button strong {
        font-size: 1.8rem !important;
    }

    .keypad {
        gap: 10px;
        margin: 15px 0;
        padding: 0 16px;
    }

    .keypad button {
        font-size: 2.8rem !important;
        padding: 18px !important;
        min-height: 70px;
        line-height: 1.1;
    }

    .keypad button.backspace {
        font-size: 2.5rem !important;
    }

    .keypad button.equals {
        padding: 20px !important;
    }

    #current-qty {
        font-size: 3.0rem !important;
        margin: 10px 0;
    }

    #product-title {
        font-size: 2rem !important;
        line-height: 1.3;
    }

    #product-title strong {
        font-size: 2.2rem !important;
    }

    #screen-quantity {
        padding: 10px;
    }

    .back-btn,
    .cart-btn {
        font-size: 2.2em !important;
    }
}



