/* The till and the points-of-sale page on phones (≤ 640px). Tablets and desktops keep styles.css as is:
   outside the phone query the cart bar and the cart sheet header are simply hidden. */
.cart-bar, .cart-head { display: none; }

@keyframes cb-bump { 0% { transform: scale(1); } 35% { transform: scale(1.35); } 100% { transform: scale(1); } }

@media (max-width: 640px) {
  /* ── Till top bar: one row, icon buttons, the name shortens ── */
  .pos-bar { flex-wrap: nowrap; gap: 6px; padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); min-height: 50px; }
  .pos-bar > * { flex-shrink: 0; }
  .pos-bar .pos-title { flex: 1 1 auto; flex-shrink: 1; min-width: 0; }
  .pos-bar .pos-title strong { max-width: none; font-size: 15px; }
  .pos-bar .back-btn, .pos-bar .btn.danger { width: 40px; height: 40px; min-height: 40px; padding: 0; }
  .pos-bar .switch-chip { padding: 4px 8px; font-size: 12px; max-width: 34vw; }
  .pos-bar .switch-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* ── Products: search and categories stay at the top, the grid scrolls under them ── */
  .pos { display: flex !important; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
  .catalog { flex: 1; min-height: 0; gap: 8px; padding: 8px 8px 0; }
  .catalog .search-wrap, .catalog .cats { flex-shrink: 0; }
  .cats { gap: 6px; padding-bottom: 4px; scrollbar-width: none; }
  .cats::-webkit-scrollbar { display: none; }
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: 72px;
    gap: 6px;
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
    overscroll-behavior: contain;
  }
  .tile { padding: 7px 8px; border-radius: 10px; gap: 2px; min-width: 0; }
  .tile:hover { transform: none; }
  .tile-name { font-size: 13px; line-height: 1.3; }
  .tile-price { font-size: 13px; }
  .tile-variants { font-size: 11px; }
  .tile-stock { font-size: 10px; padding: 0 4px; }
  .tile-foot { flex-wrap: wrap; row-gap: 0; }
  .tile.has-img .tile-name, .tile.has-img .tile-foot { padding: 0 7px; }
  .tile.has-img .tile-foot { padding-bottom: 5px; }
  .tile-img { height: 70px; }

  /* ── The cart folds into a bar at the bottom ── */
  .pos > .cart { display: none; }
  .cart-bar {
    display: flex; align-items: center; gap: 8px;
    position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
    padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom));
    padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right));
    background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -6px 18px #0b1b3314;
  }
  .cart-bar .cb-open {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
    height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--tint);
    color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-align: start;
  }
  .cart-bar .cb-open .ic, .cart-bar .cb-open svg { color: var(--primary); flex-shrink: 0; }
  .cart-bar .cb-count {
    min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
    background: var(--primary); color: #fff; font-size: 13px; font-weight: 700; direction: ltr; flex-shrink: 0;
  }
  .cart-bar .cb-label { font-size: 14px; }
  .cart-bar .cb-total { margin-inline-start: auto; font-size: 16px; white-space: nowrap; direction: ltr; }
  .cart-bar .cb-pay { height: 48px; min-height: 48px; padding: 0 18px; font-size: 16px; flex-shrink: 0; }
  .cart-bar.empty .cb-open { background: #fff; color: var(--muted); }
  .cart-bar.empty .cb-count { background: #c5ccd6; }
  .cart-bar.bump .cb-count { animation: cb-bump .32s var(--ease, ease-out); }

  /* ── Tapping the bar opens the cart full screen ── */
  .pos.cart-open > .cart-bar { display: none; }
  .pos.cart-open > .cart {
    display: flex; flex-direction: column;
    position: fixed; inset: 0; z-index: 40; max-height: none; height: 100%;
    background: #fff; border: 0;
    padding-top: env(safe-area-inset-top);
    padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
    animation: cart-up .2s var(--ease, ease-out);
  }
  .pos.cart-open > .cart .cart-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--line); min-height: 52px; flex-shrink: 0;
  }
  .pos.cart-open > .cart .cart-head strong { font-size: 17px; }
  .pos.cart-open > .cart .cart-close { width: 42px; height: 42px; }
  .pos.cart-open > .cart .cust-bar { flex-shrink: 0; }
  .pos.cart-open > .cart .lines { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .pos.cart-open > .cart .sums, .pos.cart-open > .cart .pay { flex-shrink: 0; }
  .pos.cart-open > .cart .cart-tools { flex-shrink: 0; padding-bottom: max(10px, env(safe-area-inset-bottom)); }

  /* ── Points-of-sale page: two compact tiles per row ── */
  .picker-page { padding: 12px 10px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .reg-branches { gap: 6px; margin-bottom: 10px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .reg-branches::-webkit-scrollbar { display: none; }
  .reg-branches > * { flex-shrink: 0; }
  .reg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .reg-card { min-height: 0; padding: 14px 8px 10px; gap: 4px; border-radius: 14px; min-width: 0; align-content: start; }
  .reg-card:hover { transform: none; }
  .reg-card .reg-ic { width: 38px; height: 38px; border-radius: 11px; }
  .reg-card .reg-ic svg { width: 20px; height: 20px; }
  .reg-card strong { font-size: 14px; line-height: 1.3; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .reg-card small { font-size: 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .reg-card .pill { font-size: 11px; padding: 1px 8px; }
  .reg-card > .btn, .reg-card .reg-actions .btn { width: 100%; min-height: 38px; height: 38px; padding: 0 8px; font-size: 13px; margin-top: 4px; }
  .reg-card .reg-actions { gap: 4px; margin-top: 2px; }
  .reg-card > .btn.reg-gear { position: absolute; top: 6px; inset-inline-end: 6px; width: 30px; height: 30px; min-height: 30px; padding: 0; margin: 0; }
  .reg-card.reg-add { justify-content: center; align-content: center; }
  .reg-card.reg-add small { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}

@keyframes cart-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
