/* source_code_20260120_0853/static/css/inventory/pos_touch.css */

/* --- LAYOUT & RESPONSIVENESS --- */
:root {
    --sidebar-width: 240px; 
    --ticket-width: 400px;
    --btn-gap: 10px;
}

/* Portrait / narrow screen — shrink fixed columns */
@media (max-width: 1200px) {
    :root { --sidebar-width: 180px; --ticket-width: 320px; }
    .btn-macro { height: 55px; font-size: 0.75rem; }
    .btn-quick { min-width: 70px; }
    .btn-quick img { width: 28px; height: 28px; }
    .btn-quick span { font-size: 0.65rem; }
    .grid-area { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); grid-auto-rows: 120px; gap: 8px; }
    .pos-card.is-product .img-box { height: 55px; }
    .pos-card.is-product .prod-name { font-size: 0.72rem; }
    .pos-card.is-product .price-tag { font-size: 0.82rem; }
}

/* Mobile / tablet (≤992px) — ONE breakpoint for both collapses. The old
   extra 1024px block hid the sidebar while the cart toggle (d-lg-none)
   only appears <992, leaving a 993–1024 dead band with NO category
   navigation and NO cart toggle; 8" tablets (533–960 CSS px in both
   orientations) lost the sidebar entirely. Category access below this
   width is the grid HOME (#pos-tablet, renderHomeCategories). */
@media (max-width: 992px) {
    :root { --sidebar-width: 0px; --ticket-width: 0px; }
    #macro-container { display: none; }
    /* Floating recent orders button in portrait */
    #btnRecentOrders { display: flex !important; }
    /* #pos-tablet — cart pill: with the ticket hidden, this is the ONLY
       visible cart feedback. Tap opens the overlay. JS hides it when the
       cart is empty; the overlay covers it (z-index) when open. */
    #posCartPill { display: flex !important; }
}
#posCartPill {
    display: none;               /* shown only ≤992px (rule above) */
    position: fixed;
    left: 12px; right: 12px; bottom: 12px;
    z-index: 1040;               /* under the .ticket-panel overlay (1050) */
    align-items: center; justify-content: space-between;
    background: #0A3D2C; color: #fff;
    border-radius: 999px;
    padding: 12px 20px;
    font-weight: 800; font-size: 1.05rem;
    box-shadow: 0 6px 18px rgba(0,0,0,.35);
    cursor: pointer;
}
@media (min-width: 993px) {
    #btnRecentOrders { display: none !important; }
}

#pos-container {
    display: grid;
    /* minmax(0,1fr) — NOT bare 1fr: a grid track's default min-width is
       min-CONTENT, so the center header row (back arrow + notifications +
       user chip + toggles, none of which wrap) forced the track wider than
       the viewport and the ticket column was CLIPPED off the right edge on
       ~1024px tablets (8" landscape, DPR 1.25). */
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--ticket-width);
    grid-template-rows: 80px 60px 1fr 80px;
    height: calc(100vh - 60px);
    gap: var(--btn-gap);
    padding: 10px;
    background-color: #f0f2f5;
    overflow: hidden;
    max-width: 100vw;
    box-sizing: border-box;
}
/* Blowout guards for the stretchable middle column's children. */
.center-header, .grid-area, .quick-access-bar { min-width: 0; }

/* --- QUICK ACCESS --- */
.quick-access-bar {
    grid-column: 1 / -2; 
    grid-row: 1;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
}
.btn-quick {
    min-width: 90px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.btn-quick img { width: 35px; height: 35px; object-fit: cover; border-radius: 6px; margin-bottom: 4px; }
.btn-quick span { font-size: 0.75rem; font-weight: bold; text-align: center; line-height: 1.1; }

/* --- SIDEBAR --- */
.macro-col {
    grid-column: 1;
    grid-row: 2 / -1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-right: 5px; /* Room for shadow/drag */
}

.macro-item-wrapper {
    position: relative;
    width: 100%;
    transition: transform 0.2s;
}

.btn-macro {
    width: 100%;
    height: 70px;
    font-size: 0.9rem;
    font-weight: 800;
    text-transform: uppercase;
    border: none;
    border-radius: 12px;
    color: white;
    background-color: #6c757d; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: 0.2s;
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.2;
}

.btn-macro.active { border: 3px solid white; box-shadow: 0 0 0 3px #333; transform: scale(1.02); }

/* Edit Overlay for Sidebar */
.macro-item-wrapper .edit-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    border-radius: 12px;
    display: none !important; /* Force hide by default */
    align-items: center;
    justify-content: center;
    z-index: 10;
}

body.edit-mode .macro-item-wrapper .edit-overlay { display: flex !important; }
body.edit-mode .macro-item-wrapper { cursor: grab; }
body.edit-mode .macro-item-wrapper:active { cursor: grabbing; }

/* --- CENTER GRID --- */
.center-header {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.grid-area {
    grid-column: 2;
    grid-row: 3 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    grid-auto-rows: 140px; 
    gap: 12px;
    overflow-y: auto;
    padding-bottom: 20px;
    align-content: start;
}

/* --- PRODUCT CARD STYLES --- */
.pos-card {
    position: relative;
    background: white;
    border: 1px solid #dee2e6; 
    border-radius: 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden; 
    transition: transform 0.1s;
    height: 100%; 
    width: 100%;
    cursor: pointer;
    user-select: none;
}
.pos-card:active { transform: scale(0.96); }

.pos-card.is-category {
    justify-content: center;
    align-items: center;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    padding: 10px;
}

.pos-card.is-product .img-box {
    height: 70px; 
    width: 100%;
    background-color: white; 
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #f0f0f0;
    padding-top: 15px; /* Add space for top badges */
}
.pos-card.is-product .img-box img { 
    width: 100%; 
    height: 100%; 
    object-fit: contain; 
    padding: 4px; 
}

/* FLEXIBLE INFO BOX */
.pos-card.is-product .info-box {
    padding: 6px 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Pushes Name top, Price bottom */
    align-items: center; /* Center items horizontally */
    text-align: center;
    background: white;
    min-height: 0;
}

.pos-card.is-product .prod-name {
    font-size: 0.85rem;
    font-weight: bold;
    color: #212529;
    width: 100%;
    margin-bottom: 2px;
    line-height: 1.08;
    text-align: center;
    /* Wrap onto up to TWO lines instead of clipping a long name at ~10 chars.
       JS (fitProductName in pos_touch.js) then shrinks the font-size until the
       name fits inside these two lines, so short names stay full-size and long
       names auto-scale down. Below the JS floor the clamp ellipsizes line 2. */
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.pos-card.is-product .price-tag { 
    font-weight: 800; 
    color: #198754; 
    font-size: 0.95rem; /* Smaller Font */
    line-height: 1;
    /* align-self is controlled by parent align-items: center */
}

/* --- STOCK BADGES (TOP) --- */
.pos-card .badge-container {
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    display: flex;
    justify-content: space-between;
    pointer-events: none; 
    z-index: 5;
}

.pos-card .stock-badge {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 4px;
    padding: 1px 4px;
    font-size: 0.6rem;
    font-weight: 800;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    color: #495057;
    display: flex;
    align-items: center;
    line-height: 1;
    border: 1px solid rgba(0,0,0,0.1);
}

.badge-low { color: #dc3545 !important; border-color: #dc3545; }
/* terma #475 — kitchen daily-portion counter on the tile */
.badge-daily { color: #b8860b !important; background: #fff8e1 !important; }
.badge-daily-out { color: #fff !important; background: #dc3545 !important; }
.badge-delay { color: #92400e !important; background: #fef3c7 !important; }
.pos-card.oos-daily { opacity: 0.45; filter: grayscale(0.6); }
.pos-card.cat-closed { opacity: 0.45; filter: grayscale(0.7); }
.stock-badge.badge-closed { background: #ff9500; color: #fff; }
.badge-par { color: #0d6efd !important; }

/* Ensure old stats class is hidden */
.stock-stats { display: none !important; }

/* --- EDIT MODE STYLES --- */
.edit-overlay {
    display: none !important; /* Force Hide */
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 10;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: white;
}

body.edit-mode .pos-card .edit-overlay { display: flex !important; } /* Show only in edit mode */
body.edit-mode .pos-card { border: 2px dashed #ffc107 !important; animation: none; cursor: grab; }
body.edit-mode .pos-card:active { cursor: grabbing; }

/* Color Picker */
.color-picker-wrapper {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 2px solid white;
    overflow: hidden;
    position: relative;
    margin-top: 10px;
    cursor: pointer;
    pointer-events: auto; 
}
.color-picker-wrapper input {
    position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; 
    cursor: pointer;
    pointer-events: auto;
}

/* --- TICKET PANEL --- */
.ticket-panel {
    grid-column: 3;
    grid-row: 1 / -1;
    background: white;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 15px rgba(0,0,0,0.05);
    /* #pos-sticky-pay: the panel is the clip; ONLY the sections marked
       below may scroll. Without this, a tall cart (or the expanded staff
       duties) grew the flex stack past the panel and pushed the PAY
       footer out of view. */
    overflow: hidden;
    min-height: 0;
}
/* min-height:0 breaks the flexbox min-content trap — flex:1 + overflow
   alone does NOT shrink below the content's natural height. */
.ticket-items { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 10px; }
/* Staff duties can be a long list — cap it so it scrolls instead of
   eating the cart + footer. */
#taskListContainer { max-height: 160px; overflow-y: auto; }
/* The PAY footer never shrinks and pins to the bottom even when the
   panel content is short. */
.ticket-footer { flex-shrink: 0; margin-top: auto; padding: 15px; background: #212529; color: white; border-radius: 0 0 12px 12px; }
/* ≤992px the ticket is an overlay opened by the cart pill / its ✕. It lives
   HERE, after the base .ticket-panel rule: in the ≤992 block above, the base
   rule's later display:flex won, so on phones and portrait tablets the ticket
   covered the whole screen for good — the ✕ did nothing and the category
   home under it was unreachable (found 29/09). */
@media (max-width: 992px) {
    .ticket-panel { display: none; position: fixed; top: 0; right: 0; width: 100%; height: 100%; z-index: 1050; border-radius: 0; }
    .ticket-panel.show { display: flex; }
}

/* Return / Custom / Staff 50% / Issue / Chat — five buttons are wider than a
   phone or the 320–400px ticket column: the row scrolls sideways instead of
   clipping the last ones (Issue and Chat were unreachable). */
.pos-quick-row { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.pos-quick-row::-webkit-scrollbar { display: none; }
.pos-quick-row > .btn { flex: 1 0 0 !important; min-width: min-content; padding-left: 6px; padding-right: 6px; }

/* «Απλήρωτες» pulses while a partner-stand order waits unseen (posStandNew) */
#btnPosTabs.pulse-ring { animation: posTabsPulse 1.6s ease-in-out infinite; }
@keyframes posTabsPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(25, 135, 84, .65); }
    60% { box-shadow: 0 0 0 9px rgba(25, 135, 84, 0); }
}
/* A set's coffee: its own «Ζάχαρη» / «Γάλα» under the pick (one row per person) */
.pos-sub { background: #f8f9fa; padding: 6px 12px 10px 2.6rem; }
.pos-sub-group { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; }
.pos-sub-name { flex: 0 0 4.6rem; font-size: .78rem; font-weight: 700; color: #6c757d; }
.pos-sub-chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.pos-sub-chip { border: 1px solid #ced4da; background: #fff; color: #212529; border-radius: 999px;
                padding: 7px 13px; font-size: .92rem; line-height: 1.2; cursor: pointer; }
.pos-sub-chip small { opacity: .75; }
.pos-sub-chip.on { background: #212529; border-color: #212529; color: #fff; }
.pos-sub.pos-sub-bad { box-shadow: inset 3px 0 0 #dc3545; background: #fff5f5; }
