/* ============ CosmoStock — Point de Vente ============ */
:root {
  --primary: #7c3aed;
  --primary-dark: #6d28d9;
  --primary-light: #ede9fe;
  --header-bg: linear-gradient(135deg, #1e1b2e, #2a2440);
  --bg: #f4f4f8;
  --surface: #ffffff;
  --border: #e6e6ef;
  --text: #1f2333;
  --text-muted: #6b7280;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(30, 27, 46, .08), 0 4px 16px rgba(30, 27, 46, .06);
  --primary-grad: linear-gradient(135deg, #8b5cf6, #6d28d9);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

/* ---------- Login ---------- */
.login-screen {
  position: fixed; inset: 0;
  background: var(--header-bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.login-screen.hidden { display: none; }

.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 32px 64px rgba(0, 0, 0, .3);
  text-align: center;
  animation: fadeUp .22s ease;
}
@keyframes fadeUp { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-title { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.login-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 10px; }
.login-error.hidden { display: none; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.form-group input,
.form-group select {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit;
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .12);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: all .15s; font-family: inherit;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary-grad); border: none; color: #fff;
  box-shadow: 0 4px 12px rgba(124, 58, 237, .25);
}
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-lg { padding: 13px 20px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

.btn-logout {
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .2);
  color: #fff; font-size: 12.5px;
}
.btn-logout:hover { background: rgba(255, 255, 255, .2); color: #fff; }

/* ---------- Header ---------- */
.pos-header {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--header-bg); color: #fff;
  padding: 0 20px; height: 60px; gap: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
  z-index: 10;
}

.header-left, .header-right { display: flex; align-items: center; gap: 16px; }
.header-center { flex: 1; text-align: center; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: 20px;
  background: var(--primary-grad); border-radius: 10px;
  box-shadow: 0 4px 10px rgba(124, 58, 237, .4);
}
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: .3px; }

.header-clock { font-size: 13px; opacity: .8; }
#clockDate { display: block; font-size: 11.5px; opacity: .65; }

.header-seller { display: flex; align-items: center; gap: 10px; }
.seller-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary); color: #fff;
  font-weight: 700; font-size: 14px;
}
.seller-name { font-weight: 600; font-size: 13.5px; }

/* ---------- Main layout ---------- */
.pos-app { display: flex; flex-direction: column; height: 100vh; }
.pos-app.hidden { display: none; }

.pos-main {
  flex: 1; display: flex; gap: 0;
  overflow: hidden;
}

/* ---------- Products (left) ---------- */
.pos-products {
  flex: 1.3; display: flex; flex-direction: column;
  padding: 18px; overflow: hidden;
  border-right: 1px solid var(--border);
}

.shelf-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.shelf-title { font-size: 17px; font-weight: 700; }
.shelf-badge {
  background: var(--primary-light); color: var(--primary-dark);
  font-size: 12px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
}

.search-box { margin-bottom: 14px; }
.search-input {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 12px;
  font-size: 15px; font-family: inherit;
  background: var(--surface); color: var(--text);
}
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124, 58, 237, .12); }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
  gap: 14px;
  overflow-y: auto;
  padding-right: 6px;
  flex: 1;
}

.product-tile {
  display: flex; flex-direction: column; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 16px 12px 14px;
  cursor: pointer; position: relative;
  transition: border-color .15s, box-shadow .15s, transform .12s;
  height: 280px; justify-content: center; gap: 7px;
}
.product-tile:hover:not(.out) { border-color: var(--primary); box-shadow: 0 4px 16px rgba(124, 58, 237, .12); transform: translateY(-2px); }
.product-tile.in-cart { border-color: var(--primary); background: #faf5ff; }
.product-tile.out { opacity: .45; cursor: not-allowed; }

.stock-tag {
  position: absolute; top: 8px; right: 8px;
  font-size: 11px; font-weight: 700;
  padding: 4px 9px; border-radius: 999px;
}
.stock-tag.ok { background: var(--success-bg); color: var(--success); }
.stock-tag.low { background: var(--warning-bg); color: var(--warning); }
.stock-tag.out { background: var(--danger-bg); color: var(--danger); }

.tile-emoji { font-size: 38px; margin-bottom: 2px; }
.tile-zoom {
  position: absolute; top: 8px; left: 8px; z-index: 3;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255, 255, 255, .92); border: 1px solid var(--border);
  display: grid; place-items: center; cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
  transition: transform .1s;
}
.product-tile:hover .tile-zoom { transform: scale(1.1); }
.tile-name {
  font-weight: 700; font-size: 16px; text-align: center; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 40px;
}
.tile-price { font-weight: 800; color: var(--primary); font-size: 15px; }
.tile-stock { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.tile-plus {
  margin-top: 4px; background: var(--primary); color: #fff;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 19px; font-weight: 700;
  box-shadow: 0 4px 8px rgba(124, 58, 237, .3);
  transition: transform .1s;
}
.product-tile:hover:not(.out) .tile-plus { transform: scale(1.1); }

.empty-state { padding: 30px 14px; text-align: center; color: var(--text-muted); }
.empty-icon { font-size: 32px; display: block; margin-bottom: 6px; }

/* ---------- Cart (right) ---------- */
.pos-cart {
  width: 370px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

.cart-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cart-title { font-size: 16px; font-weight: 700; }
.cart-items { font-size: 12.5px; color: var(--text-muted); }

.cart-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  color: var(--text-muted); font-size: 14px;
}
.cart-empty-icon { font-size: 40px; }

.cart-list {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 10px 14px;
  display: flex; flex-direction: column; gap: 8px;
}

.cart-line {
  display: flex; align-items: center; gap: 10px;
  background: #fbfaff; border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px;
}
.cl-emoji { font-size: 20px; }
.cl-thumb {
  width: 42px; height: 42px; border-radius: 9px;
  object-fit: cover; flex-shrink: 0;
  background: linear-gradient(135deg, #f3f0ff, #ece8f7);
}
.cl-info { flex: 1; min-width: 0; }
.cl-name { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-unit { font-size: 11.5px; color: var(--text-muted); }

.cl-qty { display: flex; align-items: center; gap: 6px; }
.cl-qty-btn {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 16px; font-weight: 700;
  display: grid; place-items: center; cursor: pointer;
  transition: border-color .12s, background .12s;
  font-family: inherit; color: var(--text);
}
.cl-qty-btn:hover { border-color: var(--primary); background: #faf5ff; }
.cl-qty-num { font-weight: 700; font-size: 14px; min-width: 22px; text-align: center; }

.cl-line-total { font-weight: 800; font-size: 13px; white-space: nowrap; }
.cl-remove {
  width: 28px; height: 28px; border-radius: 50%;
  border: none; background: var(--danger-bg);
  color: var(--danger); cursor: pointer;
  display: grid; place-items: center;
  font-size: 13px; transition: background .12s;
}
.cl-remove:hover { background: var(--danger); color: #fff; }

/* Cart foot */
.cart-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
  flex-shrink: 0;
  overflow-y: auto;
}
.cart-foot .form-group { margin-bottom: 8px; }

.payment-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: all .12s; color: var(--text);
}
.pill.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }
.pill:hover:not(.active) { border-color: var(--primary); }

.total-box {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 0; border-top: 1px solid var(--border);
}
.total-label { font-size: 13px; color: var(--text-muted); }
.total-value { font-size: 22px; font-weight: 800; color: var(--primary-dark); }

.btn-confirm {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px;
  background: var(--success); border: none; border-radius: 12px;
  color: #fff; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: filter .12s, transform .1s;
  font-family: inherit;
  box-shadow: 0 6px 16px rgba(22, 163, 74, .28);
}
.btn-confirm:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.btn-confirm:disabled { opacity: .5; cursor: not-allowed; }
.btn-confirm-sm { padding: 11px 16px; font-size: 14px; border-radius: 10px; }
.confirm-icon { font-size: 17px; }

.btn-clear {
  width: 100%; padding: 10px;
  border: none; background: transparent;
  color: var(--text-muted); font-size: 13px;
  cursor: pointer; border-radius: 8px; font-family: inherit;
}
.btn-clear:hover { background: var(--danger-bg); color: var(--danger); }

/* ---------- Confirm modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 12, 30, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
}
.modal.hidden { display: none; }

.modal-content {
  background: var(--surface); border-radius: 16px;
  width: 100%; max-width: 460px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
  padding: 24px; animation: fadeUp .18s ease;
}
.modal-header { margin-bottom: 16px; }
.modal-header h2 { font-size: 18px; }
.modal-sub { font-size: 13px; color: var(--text-muted); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.modal-close {
  background: none; border: none; font-size: 26px; line-height: 1;
  cursor: pointer; color: var(--text-muted); padding: 2px 8px; border-radius: 8px;
}
.modal-close:hover { color: var(--text); background: var(--border); }

/* ---------- Zoom image produit ---------- */
.zoom-content {
  background: var(--surface); border-radius: 16px;
  width: 100%; max-width: 720px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
  padding: 18px; animation: fadeUp .18s ease;
}
.zoom-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.zoom-head h2 { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zoom-image-box {
  background: #0f0c1e; border-radius: 12px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  min-height: 260px; max-height: 70vh;
}
.zoom-image-box img { max-width: 100%; max-height: 70vh; object-fit: contain; }
.zoom-emoji { font-size: 64px; }
.zoom-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.zoom-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.zoom-price { font-size: 16px; font-weight: 800; color: var(--primary); }
.zoom-stock { font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.zoom-stock.ok { background: var(--success-bg); color: var(--success); }
.zoom-stock.low { background: var(--warning-bg); color: var(--warning); }
.zoom-stock.out { background: var(--danger-bg); color: var(--danger); }
.zoom-price { font-size: 16px; font-weight: 800; color: var(--primary); }

.confirm-lines { display: flex; flex-direction: column; gap: 8px; }
.confirm-line { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.confirm-line .q { color: var(--text-muted); font-weight: 500; }
.confirm-line .amount { font-weight: 700; }
.confirm-total-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 12px 0; border-top: 2px solid var(--primary); margin-top: 8px;
  font-size: 15px;
}

/* ---------- Success overlay ---------- */
.success-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 12, 30, .65);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.success-overlay.hidden { display: none; }

.success-card {
  background: var(--surface); border-radius: 20px;
  width: 100%; max-width: 440px;
  box-shadow: 0 32px 64px rgba(0, 0, 0, .3);
  padding: 32px; text-align: center;
  animation: fadeUp .22s ease;
}
.success-check {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--success-bg);
  color: var(--success); font-size: 32px; font-weight: 800;
  display: grid; place-items: center; margin: 0 auto 14px;
}
.success-card h2 { font-size: 20px; margin-bottom: 6px; }
.success-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }
.success-lines { text-align: left; margin-bottom: 14px; }
.success-line { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; }
.success-line .q { color: var(--text-muted); font-weight: 500; }
.success-line .amount { font-weight: 700; }
.success-total {
  display: flex; justify-content: space-between; align-items: baseline;
  border-top: 2px solid var(--primary); padding-top: 12px; margin-bottom: 18px;
  font-size: 16px;
}
.success-actions { display: flex; gap: 10px; }
.success-actions .btn { flex: 1; justify-content: center; font-size: 14px; padding: 13px 10px; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- Print receipt (hidden on screen) ---------- */
.receipt-print {
  display: none;
}
body.printing-invoice .receipt-print {
  display: block !important;
  position: fixed; inset: 0;
  background: #fff; color: #000;
  padding: 24px; font-family: 'Courier New', monospace; font-size: 13px;
  overflow: auto;
}
body.printing-invoice .pos-header,
body.printing-invoice .pos-main,
body.printing-invoice .success-overlay,
body.printing-invoice .modal,
body.printing-invoice .toast-container,
body.printing-invoice .cart-bar {
  display: none !important;
}

/* ---------- Print 6cm thermal ---------- */
@media print {
  @page { size: 60mm auto; margin: 2mm; }
  body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  body.printing-invoice .receipt-print {
    position: static !important;
    width: 56mm !important;
    max-width: 56mm !important;
    padding: 2mm !important;
    font-size: 10px !important;
    line-height: 1.3 !important;
    overflow: visible !important;
  }
  body.printing-invoice .rcp-brand { font-size: 13px !important; margin-bottom: 2px !important; }
  body.printing-invoice .rcp-title { font-size: 11px !important; letter-spacing: 1px !important; margin-bottom: 2px !important; }
  body.printing-invoice .rcp-num,
  body.printing-invoice .rcp-date,
  body.printing-invoice .rcp-seller { font-size: 9px !important; }
  body.printing-invoice .rcp-dash { margin: 4px 0 !important; }
  body.printing-invoice .rcp-lines { font-size: 9px !important; }
  body.printing-invoice .rcp-lines th,
  body.printing-invoice .rcp-lines td { padding: 2px 1px !important; }
  body.printing-invoice .rcp-total { font-size: 11px !important; margin-top: 4px !important; }
  body.printing-invoice .rcp-pay,
  body.printing-invoice .rcp-customer { font-size: 9px !important; margin-top: 2px !important; }
  body.printing-invoice .rcp-foot { font-size: 9px !important; margin-top: 6px !important; }
}

.rcp-head { text-align: center; margin-bottom: 12px; }
.rcp-brand { font-size: 16px; margin-bottom: 4px; }
.rcp-title { font-size: 13px; font-weight: 700; letter-spacing: 2px; margin-bottom: 4px; }
.rcp-num, .rcp-date, .rcp-seller { font-size: 12px; color: #555; }
.rcp-dash { border-top: 1px dashed #ccc; margin: 10px 0; }
.rcp-lines { width: 100%; border-collapse: collapse; font-size: 12px; }
.rcp-lines th, .rcp-lines td { padding: 5px 4px; text-align: left; }
.rcp-lines .r { text-align: right; }
.rcp-lines th { border-bottom: 1px solid #ddd; font-weight: 700; }
.rcp-total { display: flex; justify-content: space-between; font-size: 15px; font-weight: 700; margin-top: 8px; }
.rcp-pay { display: flex; justify-content: space-between; font-size: 12px; color: #555; margin-top: 4px; }
.rcp-customer { font-size: 12px; color: #555; margin-top: 4px; }
.rcp-foot { text-align: center; font-size: 12px; color: #555; margin-top: 14px; }

/* ---------- Toasts ---------- */
.toast-container { position: fixed; top: 72px; right: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 16px; border-radius: 10px;
  background: #1f2333; color: #fff;
  font-size: 13.5px; max-width: 340px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  animation: slideIn .2s ease;
}
.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }
.toast.warning { background: #d97706; }
.toast.fade-out { opacity: 0; transition: opacity .4s; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
.pos-main { flex-direction: column; }
  .pos-products { border-right: none; border-bottom: 1px solid var(--border); max-height: 48vh; }
  .pos-cart { width: 100%; max-height: 52vh; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
@media (max-width: 500px) {
  .pos-header { padding: 0 12px; height: 54px; }
  .brand-name { display: none; }
  .header-clock { display: none; }
  .seller-name { display: none; }
  .pos-products, .pos-cart { padding: 12px; }
  .cart-foot { padding: 12px; }
  .product-tile { height: 205px; padding: 12px 8px; gap: 4px; }
  .tile-media { height: 110px; }
  .tile-emoji { font-size: 30px; }
  .tile-name { font-size: 14px; }
  .tile-price { font-size: 14px; padding: 3px 10px; }
  .tile-plus { width: 32px; height: 32px; font-size: 19px; }
  .tile-stock { font-size: 12.5px; }
}

/* ---------- Filtres catégories ---------- */
.category-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  padding: 6px 14px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; transition: all .15s; font-family: inherit;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary-grad); color: #fff; border-color: transparent; }

/* ---------- Media & photo produit ---------- */
.tile-media {
  position: relative;
  width: 100%; height: 170px;
  border-radius: 12px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f3f0ff, #ece8f7);
  margin-bottom: 6px;
}
.tile-media-emoji { font-size: 38px; }
.tile-thumb {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: 0;
  transition: transform .28s ease;
}
.product-tile:hover:not(.out) .tile-thumb { transform: scale(1.08); }
.tile-thumb { height: 100%; width: 100%; object-fit: cover; }
.tile-price {
  position: absolute; left: 9px; bottom: 9px;
  padding: 4px 12px;
  background: rgba(20, 16, 40, .82);
  color: #fff !important;
  border-radius: 999px;
  font-size: 15px; font-weight: 800;
  letter-spacing: .2px;
  backdrop-filter: blur(2px);
}
.tile-plus {
  position: absolute; right: 9px; bottom: 9px;
  width: 38px; height: 38px;
  background: var(--primary-grad);
  color: #fff;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 23px; font-weight: 700; line-height: 1;
  box-shadow: 0 4px 10px rgba(124, 58, 237, .45);
  transition: transform .15s;
}
.product-tile:hover:not(.out) .tile-plus { transform: scale(1.14) rotate(90deg); }
.product-tile.out .tile-media { filter: grayscale(1); opacity: .55; }
.tile-stock { font-size: 11px; color: var(--text-muted); font-weight: 600; }

/* ---------- Barre panier mobile & panier en feuille ---------- */
.cart-head-right { display: flex; align-items: center; gap: 10px; }
.cart-close {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); font-size: 18px; line-height: 1;
  display: none; place-items: center; cursor: pointer;
  transition: all .12s;
}
.cart-close:hover { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.cart-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 80;
  display: none;
  align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(135deg, #1e1b2e, #2a2440);
  color: #fff;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .22);
}
.cart-bar-info { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.cart-bar-count {
  min-width: 24px; text-align: center;
  padding: 1px 7px; border-radius: 999px;
  background: var(--primary-grad);
  font-weight: 800; font-size: 13px;
}
.cart-bar-label { font-size: 12.5px; color: rgba(255, 255, 255, .75); white-space: nowrap; }
.cart-bar-total { font-weight: 800; font-size: 16px; margin-left: 4px; white-space: nowrap; }
.cart-bar-btn {
  padding: 10px 18px;
  background: var(--primary-grad);
  border: none; border-radius: 10px;
  color: #fff; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 4px 14px rgba(124, 58, 237, .4);
  transition: transform .12s, filter .12s;
  white-space: nowrap;
}
.cart-bar-btn:disabled { opacity: .5; cursor: not-allowed; }
.cart-bar-btn:not(:disabled):hover { filter: brightness(1.1); transform: translateY(-1px); }
.cart-bar-btn:not(:disabled):active { transform: scale(.97); }

/* ---------- Micro-interactions ---------- */
.product-tile { transition: border-color .15s, box-shadow .15s, transform .12s; }
.product-tile:active:not(.out) { transform: scale(.96); }
.cl-qty-btn:active { transform: scale(.92); }
.pill:active { transform: scale(.96); }
.btn-confirm:active:not(:disabled), .tile-plus:active { transform: scale(.96); }
.success-check { animation: popIn .35s cubic-bezier(.2, 1.6, .45, 1); }
@keyframes popIn { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes sheetUp { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }

/* ---------- Responsive : panier mobile ---------- */
@media (max-width: 900px) {
  .cart-close { display: grid; }
  .cart-bar { display: flex; }
  .pos-products { max-height: none; flex: 1; }
  .pos-app:not(.cart-open) .pos-cart { display: none; }
  .pos-app.cart-open .pos-cart {
    position: fixed; left: 0; right: 0; bottom: 0;
    height: 82vh; max-height: 82vh;
    width: 100%;
    z-index: 70;
    border-left: none;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -16px 44px rgba(0, 0, 0, .24);
    animation: sheetUp .26s ease;
  }
  .pos-main { padding-bottom: 64px; }
  .cart-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- Panier mobile : compact ---------- */
@media (max-width: 500px) {
  .cart-head { padding: 12px 14px; }
  .cart-foot { padding: 10px 12px; gap: 8px; }
  .cart-foot .form-group { margin-bottom: 6px; }
  .cart-line { padding: 7px 10px; gap: 8px; }
  .cl-thumb { width: 34px; height: 34px; border-radius: 7px; }
  .cl-qty-btn { width: 28px; height: 28px; }
  .cl-qty-num { min-width: 18px; font-size: 13px; }
  .cl-line-total { font-size: 12px; }
  .cl-remove { width: 26px; height: 26px; }
  .total-value { font-size: 20px; }
  .discount-box { padding: 8px 10px; margin-bottom: 8px; }
}

/* ---------- Remise par ligne produit ---------- */
.discount-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; margin-bottom: 12px; text-align: center; }
.discount-hint { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.bill-cart .cl-amount-col,
.cl-amount-col { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; min-width: 0; }
.cl-amount-col .cl-line-total { cursor: pointer; padding: 2px 4px; border-radius: 6px; user-select: none; }
.cl-amount-col .cl-line-total:active { background: var(--border); }
.cl-remise-badge { font-size: 10px; font-weight: 700; color: var(--danger); background: rgba(231, 76, 60, 0.12); border-radius: 6px; padding: 1px 6px; }
.remise-input-row { display: flex; align-items: center; gap: 8px; width: 100%; }
.discount-input { flex: 1; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 15px; font-weight: 700; }
.discount-unit { font-weight: 600; color: var(--text-muted); }

/* ---------- Succès discount ---------- */
.success-discount { display: flex; justify-content: space-between; padding: 6px 18px; font-size: 13px; color: var(--danger); }
.success-discount.hidden, .success-discount[style*="display:none"] { display: none; }

/* ---------- Login modernisé ---------- */
.login-screen {
  background: linear-gradient(135deg, #1e1b2e 0%, #4c1d95 50%, #1e1b2e 100%);
  background-size: 220% 220%;
  animation: loginShift 16s ease infinite;
}
@keyframes loginShift { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.login-logo {
  width: 68px; height: 68px;
  margin: 0 auto 12px;
  display: grid; place-items: center;
  font-size: 34px; line-height: 1;
  background: var(--primary-grad);
  border-radius: 20px;
  box-shadow: 0 14px 30px rgba(124, 58, 237, .45);
  animation: floatY 3.4s ease-in-out infinite;
}
@keyframes floatY { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.login-card { border-radius: 24px; }

/* ---------- Visibilité conditionnelle ---------- */
.hidden,
.empty-state.hidden,
.cart-empty.hidden,
.discount-fields.hidden { display: none !important; }

/* ---------- Périphériques tactiles : le zoom photo reste accessible ---------- */
@media (hover: none) {
  .tile-zoom { width: 34px; height: 34px; font-size: 17px; top: 7px; left: 7px; }
}

/* ================== Design mobile "app Android" ================== */
* { -webkit-tap-highlight-color: transparent; }
html { overscroll-behavior-y: none; }
body {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  font-family: Roboto, 'Segoe UI', system-ui, -apple-system, sans-serif;
}
input, textarea { -webkit-user-select: text; user-select: text; }

@media (max-width: 900px) {
  .pos-header {
    height: auto;
    padding: calc(env(safe-area-inset-top, 0px) + 8px) 14px 8px;
  }
  .brand-mark { width: 36px; height: 36px; border-radius: 11px; }
  .search-input { border-radius: 999px; padding: 12px 16px; }
  .chip { min-height: 38px; padding: 8px 16px; border-radius: 22px; }
  .product-tile { border-radius: 18px; padding: 12px 8px 10px; box-shadow: var(--shadow); }
  .tile-media { border-radius: 14px; }
  .pos-app.cart-open .pos-cart { border-radius: 22px 22px 0 0; }
  .cart-head { position: relative; padding-top: 18px; }
  .cart-head::before {
    content: ''; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 999px; background: var(--border);
  }
  .modal { padding: 10px; align-items: flex-end; }
  .modal-content, .zoom-content {
    border-radius: 22px 22px 0 0;
    max-height: 92vh; overflow-y: auto;
    border-bottom-left-radius: 0; border-bottom-right-radius: 0;
  }
  .toast-container { top: calc(env(safe-area-inset-top, 0px) + 70px); right: 12px; left: 12px; }
  .toast { max-width: none; }
  .cart-bar { padding-top: 10px; }
  .btn-confirm { min-height: 52px; border-radius: 16px; }
  .confirm-line { padding: 10px 0; }
  #printInvoiceButton { display: none; }
}

/* ---------- Thème sombre ---------- */
body.theme-dark {
  --bg: #0e101f;
  --surface: #181b30;
  --border: #262b46;
  --text: #e8eaf5;
  --text-muted: #9da3c4;
  --primary-light: rgba(139, 92, 246, .18);
  --primary-dark: #8b5cf6;
  --success-bg: rgba(22, 163, 74, .2);
  --warning-bg: rgba(217, 119, 6, .18);
  --danger-bg: rgba(220, 38, 38, .2);
  --header-bg: linear-gradient(135deg, #12142a, #1d1f3a);
  --shadow: 0 1px 3px rgba(0, 0, 0, .45), 0 4px 16px rgba(0, 0, 0, .35);
}
body.theme-dark .product-tile { box-shadow: none; }
body.theme-dark .cart-line { background: #1d2138; }
body.theme-dark .product-tile.in-cart { background: rgba(139, 92, 246, .14); }
body.theme-dark .cl-qty-btn:hover { background: rgba(139, 92, 246, .16); }
body.theme-dark .tile-media { background: linear-gradient(135deg, #232747, #1a1d38); }
body.theme-dark .cl-thumb { background: linear-gradient(135deg, #232747, #1a1d38); }
body.theme-dark .discount-input,
body.theme-dark .discount-select { background: var(--bg); color: var(--text); }
body.theme-dark .toast { background: #262b46; }
body.theme-dark .btn-theme { border-radius: 50%; width: 38px; height: 38px; padding: 0; display: grid; place-items: center; font-size: 15px; }

/* ---------- Thème sombre (compléments logins / caisse) ---------- */
body.theme-dark .tile-zoom { background: rgba(30, 29, 44, .92); border-color: var(--border); }
body.theme-dark .zoom-image-box { background: #090a14; }
body.theme-dark .success-card { background: var(--surface); }
body.theme-dark .login-card { background: var(--surface); }
body.theme-dark .success-check { background: var(--success-bg); color: var(--success); }

/* ---------- RTL (arabe) ---------- */
html[dir="rtl"] .tile-price,
html[dir="rtl"] .tile-stock,
html[dir="rtl"] .cl-line-total,
html[dir="rtl"] .total-value { text-align: left; }
html[dir="rtl"] .cl-qty-num { direction: ltr; }
html[dir="rtl"] .discount-input { text-align: left; }
html[dir="rtl"] .cart-bar { direction: ltr; }

/* ---------- Bouton danger ---------- */
.btn-danger {
  background: var(--danger); border: none; color: #fff;
}
.btn-danger:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Mes ventes ---------- */
.my-sales-filter { display: flex; gap: 8px; margin-bottom: 12px; }
.my-sales-list { max-height: 52vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.my-sale-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
  background: var(--surface);
}
.ms-info { flex: 1; min-width: 0; }
.ms-name { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-sub { font-size: 11.5px; color: var(--text-muted); }
.ms-amount { font-weight: 800; font-size: 13px; color: var(--primary); }
.ms-amount .ms-ref { display: block; font-size: 10.5px; font-weight: 600; color: var(--text-muted); }
.ms-badge {
  font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: var(--success-bg); color: var(--success);
}
.ms-badge.cancelled { background: var(--danger-bg); color: var(--danger); }
.ms-cancel-btn {
  flex-shrink: 0;
  border: 1px solid var(--danger); border-radius: 9px;
  background: transparent; color: var(--danger);
  padding: 7px 11px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.ms-cancel-btn:hover { background: var(--danger); color: #fff; }
#cancelInfo .confirm-line { padding: 8px 0; }
body.theme-dark .my-sale-item { background: #1d2138; }
/* ---------- Multi-stocks : nom du stock dans l'en-tête ---------- */
.store-pill { display: inline-flex; align-items: center; padding: 3px 11px; margin-left: 10px; border-radius: 999px; background: rgba(124, 58, 237, .14); color: var(--primary); font-size: 12px; font-weight: 600; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.back-link { display: block; text-align: center; margin-top: 14px; font-size: 12.5px; color: var(--text-muted); text-decoration: none; }
.back-link:hover { color: var(--primary); }
