/* ══════════════════════════════════════════════
   POS Layout (Écran Caisse)
   Desktop-first, tablet overrides via media query
   ══════════════════════════════════════════════ */

/* ── Desktop defaults ── */
.pos-grid {
  display: grid;
  gap: var(--gap-md);
  grid-template-columns: 1.3fr 0.7fr;
  margin-top: var(--gap-md);
  min-height: calc(100vh - 100px);
}

.pos-catalog {
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
  min-width: 0;
  overflow: hidden;
}

.pos-catalog__header {
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
  min-width: 0;
}

.pos-toolbar {
  display: flex;
  gap: var(--gap-sm);
  align-items: center;
}
.pos-toolbar .input { flex: 1; }

.pos-categories {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--gap-sm);
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.pos-products {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: start;
}
.pos-products .product-card {
  width: calc(25% - 5px);
  flex-shrink: 0;
  flex-grow: 0;
}

/* ── Cart side (desktop) ── */
.pos-cart {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--gap-md);
  max-height: calc(100vh - 100px);
}
.pos-cart .card {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.pos-cart__header {
  font-weight: 900;
  font-size: var(--font-xl);
  margin-bottom: var(--gap-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pos-cart__count {
  font-size: var(--font-sm);
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid var(--accent-border);
  padding: 2px 10px;
  border-radius: var(--radius-pill);
}
.pos-cart__lines {
  flex: 1;
  overflow-y: auto;
  min-height: 80px;
}
.pos-cart__footer {
  display: grid;
  gap: var(--gap-md);
  margin-top: var(--gap-md);
  padding-top: var(--gap-md);
  border-top: 1px solid var(--border-light);
}

.pos-pay-methods {
  display: flex;
  gap: var(--gap-sm);
  flex-wrap: wrap;
}
.pos-pay-methods .btn {
  flex: 1;
  min-width: 90px;
}
.pos-pay-methods .btn.active {
  border-color: var(--accent-border);
  background: var(--accent-glow);
  color: var(--accent);
}

.pos-last-order {
  font-size: var(--font-sm);
  color: var(--muted);
  padding-top: var(--gap-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}
.pos-last-order a { color: var(--accent); text-decoration: underline; }
.btn-print {
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: 14px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  animation: pulse-print 1.5s ease-in-out 3;
}
@keyframes pulse-print {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); box-shadow: 0 0 12px rgba(212,166,71,0.5); }
}

/* ── Favorites bar (desktop) ── */
.favorites-section {
  margin-bottom: var(--gap-sm);
}
.favorites-list {
  display: flex;
  gap: var(--gap-sm);
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.favorite-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: var(--radius-md);
  background: var(--accent-glow);
  border: 1px solid var(--accent-border);
  white-space: nowrap;
  min-height: 44px;
  font-size: var(--font-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
}
.favorite-btn:hover {
  background: rgba(212,166,71,0.25);
}
.favorite-btn:active {
  transform: scale(0.96);
}
.favorite-btn.sold-out {
  opacity: 0.4;
  cursor: not-allowed;
}
.favorite-btn__img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}
.favorite-btn__name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.favorite-btn__price {
  color: var(--accent);
  font-weight: 800;
}

/* Checkout success flash */
.btn-success-flash {
  animation: success-flash 0.8s ease;
}
@keyframes success-flash {
  0% { box-shadow: 0 0 0 0 rgba(92, 224, 155, 0.7); }
  50% { box-shadow: 0 0 20px 10px rgba(92, 224, 155, 0.4); }
  100% { box-shadow: none; }
}

/* Product card add-to-cart feedback */
.product-card.added {
  box-shadow: 0 0 0 2px rgba(92, 224, 155, 0.7);
  transition: box-shadow 0.15s ease;
}

/* Persistent highlight for products in cart */
.product-card.in-cart {
  border-color: rgba(92, 224, 155, 0.6);
  box-shadow: 0 0 0 2px rgba(92, 224, 155, 0.35), 0 0 12px rgba(92, 224, 155, 0.1);
}
.product-card.in-cart .product-card__overlay {
  border-top: 2px solid rgba(92, 224, 155, 0.5);
}
.product-card.in-cart .product-card__qty-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(92, 224, 155, 0.9);
  color: #0a0a0f;
  font-size: 12px;
  font-weight: 900;
  border-radius: var(--radius-pill);
  z-index: 3;
}

/* Floating cart button */
.fab-cart {
  position: fixed;
  bottom: 24px;
  right: 24px;
  min-width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, rgba(92,224,155,0.2), rgba(92,224,155,0.08));
  border: 1px solid rgba(92,224,155,0.5);
  color: var(--success);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 20px rgba(92,224,155,0.1);
  z-index: 100;
  transition: all var(--duration) var(--ease-out);
  backdrop-filter: blur(12px);
}
.fab-cart:hover {
  background: linear-gradient(135deg, rgba(92,224,155,0.3), rgba(92,224,155,0.15));
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 24px rgba(92,224,155,0.15);
}
.fab-cart:active {
  transform: scale(0.95);
}
.fab-cart.visible {
  display: flex;
}
.fab-cart__icon {
  font-size: 20px;
  line-height: 1;
}

/* ── Offline queue banner ── */
.offline-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(240,192,64,0.15);
  border: 1px solid rgba(240,192,64,0.4);
  border-radius: var(--radius-md);
  color: var(--warning);
  font-size: var(--font-sm);
  font-weight: 600;
}
.offline-banner.visible { display: flex; }

/* ── Edit order banner ── */
.edit-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(212,166,71,0.15);
  border: 1px solid rgba(212,166,71,0.4);
  border-radius: var(--radius-md);
  color: var(--accent);
  font-size: var(--font-sm);
  font-weight: 700;
}
.btn-edit {
  background: var(--accent) !important;
  color: #000 !important;
}

/* ── Swipeable cart lines ── */
.cart-line-wrap {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
}
.cart-line-wrap .cart-line {
  position: relative;
  transition: transform 0.2s var(--ease-out);
  background: var(--bg-card);
  z-index: 1;
}
.cart-line-delete {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--danger);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.cart-line-wrap:active .cart-line-delete,
.cart-line-wrap .cart-line-delete.visible {
  opacity: 1;
}

/* ══════════════════════════════════════════════
   TABLET MODE (≤1280px) — Honor Pad X8a etc.
   Full-viewport, compact, touch-optimized
   ══════════════════════════════════════════════ */
@media (max-width: 1280px) {
  body.pos-body {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
  }

  .pos-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding: 6px 8px;
    gap: 6px;
    overflow: hidden;
  }

  /* Compact header */
  .pos-page > .header {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: var(--radius-md);
  }
  .pos-page .brand__logo { height: 28px; }
  .pos-page .brand b { font-size: 14px; }
  .pos-page .brand span { display: none; }
  .pos-page .pills { gap: 4px; }
  .pos-page .pills .pill {
    min-height: 32px;
    padding: 4px 12px;
    font-size: 12px;
  }

  /* Grid fills remaining space */
  .pos-grid {
    grid-template-columns: 1fr 290px;
    grid-template-rows: 1fr;
    gap: 6px;
    flex: 1;
    overflow: hidden;
    margin-top: 0;
    min-height: 0;
  }

  .pos-catalog {
    gap: 6px;
    overflow: hidden;
    min-height: 0;
    height: 100%;
  }
  .pos-catalog__header {
    gap: 6px;
    flex-shrink: 0;
  }
  .pos-catalog__header.card {
    padding: var(--gap-sm);
    border-radius: var(--radius-md);
  }

  .pos-toolbar .input {
    padding: 7px 12px;
    font-size: 13px;
    min-height: 36px;
  }
  .pos-toolbar .btn {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 12px;
  }

  /* Category pills compact */
  .pos-categories {
    gap: 5px;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .pos-categories::-webkit-scrollbar { display: none; }
  .pos-categories .pill {
    min-height: 34px;
    padding: 5px 14px;
    font-size: 13px;
  }

  /* Product grid: scrolls independently */
  .pos-products {
    gap: 6px;
    overflow-y: auto;
    min-height: 0;
    padding-right: 2px;
    -webkit-overflow-scrolling: touch;
  }

  /* Cart compact */
  .pos-cart {
    position: static;
    max-height: none;
    overflow: hidden;
  }
  .pos-cart .card {
    padding: 10px 12px;
  }
  .pos-cart__header {
    font-size: 15px;
    margin-bottom: 6px;
  }
  .pos-cart__lines {
    min-height: 30px;
    -webkit-overflow-scrolling: touch;
  }
  .pos-cart__footer {
    gap: 5px;
    margin-top: 6px;
    padding-top: 6px;
  }
  .cart-total {
    font-size: 15px;
    margin-top: 6px;
    padding-top: 6px;
  }

  .pos-pay-methods { gap: 4px; }
  .pos-pay-methods .btn {
    min-width: 0;
    min-height: 36px;
    padding: 5px 8px;
    font-size: 12px;
  }

  .pos-cart__footer .input:not(textarea) {
    padding: 7px 10px;
    font-size: 13px;
    min-height: 34px;
  }
  .pos-cart__footer textarea.input {
    min-height: 32px;
    padding: 5px 10px;
    font-size: 12px;
    resize: none;
  }
  .pos-cart__footer label.text-sm { font-size: 11px; }
  .pos-cart__footer .btn-lg {
    min-height: 44px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 800;
  }

  .pos-last-order { font-size: 11px; padding-top: 4px; }

  /* Cart lines compact for tablet */
  .cart-line { gap: var(--gap-sm); padding: 6px 0; }
  .cart-line__name { font-size: var(--font-sm); }
  .cart-line__meta { font-size: 11px; }
  .qty-row { gap: 6px; margin-top: 2px; }

  /* Hide floating cart on tablet (cart always visible) */
  .fab-cart { display: none !important; }

  /* Favorites compact */
  .favorites-section { margin-bottom: 0; }
  .favorites-list {
    gap: 5px;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .favorites-list::-webkit-scrollbar { display: none; }
  .favorite-btn {
    padding: 3px 10px 3px 3px;
    min-height: 40px;
    font-size: 12px;
    gap: 6px;
  }
  .favorite-btn__img {
    width: 34px;
    height: 34px;
  }
  .favorite-btn__name { max-width: 100px; }
}

/* ── Mobile / portrait tablet & phone ── */
@media (max-width: 700px) {
  body.pos-body {
    overflow: auto;
    height: auto;
  }
  .pos-page {
    height: auto;
    overflow: visible;
  }
  .pos-grid {
    grid-template-columns: 1fr;
    overflow: visible;
  }
  .pos-cart {
    position: static;
    max-height: none;
    overflow: visible;
  }
  .pos-products {
    overflow-y: visible;
    max-height: none;
    height: auto;
  }
  .pos-products .product-card {
    width: calc(50% - 3px);
  }
  .pos-page .brand span { display: block; }

  /* Re-enable floating cart button (cart is below, need to scroll) */
  .fab-cart.visible { display: flex !important; }
}

/* ── Large desktop (5 columns) ── */
@media (min-width: 1281px) {
  .pos-products .product-card {
    width: calc(20% - 5px);
  }
}
