/* ==============================================================================
   STYLES TERMINAL POINT DE VENTE (POS / CAISSE TACTILE) - GESTIVA
   ============================================================================== */

/* Empêche le scroll de page sur le POS — le scroll se fait à l'intérieur des panneaux */
body:has(.pos-container) .main-content {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pos-container {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 18px;
  /* topbar 60px + padding-top 24px + page-header ~78px + padding-bottom 24px = 186px */
  height: calc(100vh - 186px);
  min-height: 0;
  flex: 1;
}

@media (max-width: 1024px) {
  .pos-container {
    grid-template-columns: 1fr;
    height: auto;
  }
}

/* ─── Volet Gauche : Catalogue Produits ────────────────────────────────────── */
.pos-catalog-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-light, #e2e8f0);
  border-radius: 14px;
  padding: 16px;
  overflow: hidden;
  min-height: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.pos-search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.pos-barcode-group {
  display: flex;
  align-items: center;
  position: relative;
  width: 200px;
  flex-shrink: 0;
}

.pos-barcode-group i {
  position: absolute;
  left: 10px;
  color: var(--txt-muted, #64748b);
  font-size: 14px;
}

.pos-barcode-group input {
  padding-left: 32px;
  font-family: monospace;
  font-size: 12px;
}

/* Category Chips Horizontal Bar */
.pos-category-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 12px;
  scrollbar-width: thin;
}

.pos-category-chips::-webkit-scrollbar {
  height: 4px;
}

.pos-category-chips::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.pos-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  background: #f1f5f9;
  color: var(--txt-muted, #475569);
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  user-select: none;
}

.pos-chip:hover {
  background: #e2e8f0;
  color: var(--txt, #0f172a);
}

.pos-chip.active {
  background: var(--primary, #2563eb);
  color: #ffffff;
  border-color: var(--primary, #2563eb);
  box-shadow: 0 2px 6px rgba(37,99,235,0.25);
}

.pos-chip-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(0,0,0,0.08);
}

.pos-chip.active .pos-chip-badge {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

/* Grille des articles */
.pos-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 12px;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

.pos-product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-hover, #ffffff);
  border: 1px solid var(--border-light, #e2e8f0);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.16s ease;
  user-select: none;
}

.pos-product-card:hover {
  border-color: var(--primary, #2563eb);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(37,99,235,0.1);
}

.pos-product-card:active {
  transform: scale(0.97);
}

.pos-product-img-wrap {
  position: relative;
  width: 100%;
  height: 100px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.pos-product-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.pos-product-card:hover .pos-product-img {
  transform: scale(1.05);
}

.pos-product-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  color: #64748b;
}

.pos-stock-pill {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  backdrop-filter: blur(4px);
}

.pos-stock-pill.in-stock {
  background: rgba(16, 185, 129, 0.9);
  color: #ffffff;
}

.pos-stock-pill.low-stock {
  background: rgba(245, 158, 11, 0.9);
  color: #ffffff;
}

.pos-stock-pill.out-stock {
  background: rgba(239, 68, 68, 0.9);
  color: #ffffff;
}

.pos-stock-pill.service {
  background: rgba(59, 130, 246, 0.9);
  color: #ffffff;
}

.pos-product-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
}

.pos-product-ref {
  font-size: 10.5px;
  color: var(--txt-muted, #64748b);
  font-family: monospace;
  margin-bottom: 2px;
}

.pos-product-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--txt, #0f172a);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
  min-height: 31px;
}

.pos-product-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

.pos-product-price {
  font-size: 13.5px;
  font-weight: 800;
  color: #059669;
}

.pos-product-add-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f1f5f9;
  color: var(--primary, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.15s ease;
}

.pos-product-card:hover .pos-product-add-icon {
  background: var(--primary, #2563eb);
  color: #ffffff;
}

/* ─── Volet Droit : Ticket de Caisse ────────────────────────────────────────── */
.pos-ticket-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-light, #e2e8f0);
  border-radius: 14px;
  padding: 16px;
  overflow: hidden;
  min-height: 0;
  box-shadow: 0 4px 20px rgba(0,0,0,0.03);
}

.pos-ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 2px dashed var(--border-light, #e2e8f0);
}

.pos-client-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 10px;
  margin-top: 10px;
}

.pos-client-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--txt, #0f172a);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  padding: 0;
}

.pos-client-btn:hover {
  color: var(--primary, #2563eb);
}

.pos-ticket-lines {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
}

.pos-ticket-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-hover, #f8fafc);
  border-radius: 8px;
  border: 1px solid var(--border-light, #e2e8f0);
  transition: background 0.15s ease;
}

.pos-ticket-line:hover {
  background: #f1f5f9;
}

.pos-ticket-line-img {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  object-fit: cover;
  background: #e2e8f0;
  flex-shrink: 0;
}

.pos-ticket-line-fallback {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 13px;
  flex-shrink: 0;
}

.pos-qty-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

.pos-qty-btn {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: 1px solid var(--border-light, #cbd5e1);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: bold;
  font-size: 13px;
}

.pos-qty-btn:hover {
  background: var(--primary, #2563eb);
  color: #fff;
  border-color: var(--primary, #2563eb);
}

/* Récapitulatif Totaux */
.pos-ticket-totals {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.pos-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  margin-bottom: 3px;
  color: var(--txt-muted, #475569);
}

.pos-grand-total {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary, #2563eb);
  border-top: 1px dashed var(--border-light, #cbd5e1);
  padding-top: 6px;
  margin-top: 6px;
}

/* Modes de Paiement */
.pos-payment-methods {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.pos-pay-btn {
  padding: 8px 4px;
  border-radius: 8px;
  border: 1px solid var(--border-light, #cbd5e1);
  background: #fff;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.pos-pay-btn i {
  font-size: 14px;
  display: block;
  margin-bottom: 3px;
}

.pos-pay-btn.active {
  background: var(--primary, #2563eb);
  color: #fff;
  border-color: var(--primary, #2563eb);
  box-shadow: 0 2px 6px rgba(37,99,235,0.2);
}

/* Billets rapides */
.pos-quick-cash-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  overflow-x: auto;
}

.pos-quick-cash-btn {
  flex: 1;
  padding: 5px 4px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
}

.pos-quick-cash-btn:hover {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

/* ─── Ticket Thermique (Receipt 80mm) ───────────────────────────────────────── */
.pos-thermal-receipt {
  background: #ffffff;
  border: 1px dashed #94a3b8;
  padding: 20px;
  border-radius: 6px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  color: #0f172a;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.02);
}

.pos-thermal-receipt hr {
  border: none;
  border-top: 1px dashed #64748b;
  margin: 8px 0;
}

.pos-thermal-header {
  text-align: center;
  margin-bottom: 10px;
}

.pos-thermal-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 0;
}

.pos-thermal-sub {
  font-size: 11px;
  color: #475569;
}

.pos-thermal-barcode {
  text-align: center;
  font-family: 'Libre Barcode 39', monospace;
  font-size: 32px;
  letter-spacing: 4px;
  margin: 8px 0;
  user-select: none;
}

/* ─── Sous-parties Catégories en accordéon (Comme "Mon entreprise") ────────── */
.pos-subparts-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 4px;
}

.pos-subpart {
  border: 1px solid var(--border-light, #e2e8f0);
  border-radius: 10px;
  background: var(--bg-card, #ffffff);
  overflow: hidden;
  transition: all 0.2s ease;
}

.pos-subpart-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f8fafc;
  border: none;
  cursor: pointer;
  text-align: left;
  user-select: none;
  font-family: inherit;
  transition: background 0.15s ease;
}

.pos-subpart-header:hover {
  background: #f1f5f9;
}

.pos-subpart-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pos-subpart-icon {
  font-size: 16px;
  color: var(--primary, #2563eb);
}

.pos-subpart-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--txt, #0f172a);
}

.pos-subpart-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  background: #e2e8f0;
  color: #475569;
}

.pos-subpart-arrow {
  font-size: 13px;
  color: #64748b;
  transition: transform 0.25s ease;
}

.pos-subpart.open .pos-subpart-arrow {
  transform: rotate(180deg);
  color: var(--primary, #2563eb);
}

.pos-subpart-content {
  display: none;
  padding: 12px;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
}

.pos-subpart.open .pos-subpart-content {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 12px;
}

/* Actions de dépliement global */
.pos-subparts-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 0 2px;
}

/* ─── Scanner Caméra Barcode & Mobile ───────────────────────────────────────── */
.scanner-container {
  position: relative;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  border-radius: 14px;
  overflow: hidden;
  background: #000000;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scanner-target-box {
  position: relative;
  width: 72%;
  height: 55%;
  border: 2px solid rgba(59, 130, 246, 0.9);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.scanner-laser-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
  animation: sweepLaser 1.8s infinite ease-in-out alternate;
}

@keyframes sweepLaser {
  0% { top: 5%; }
  100% { top: 92%; }
}

.scanner-hud {
  margin-top: 10px;
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

.scanner-controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
}

/* ─── Media Print (pour impression directe du ticket de caisse) ─────────────── */
@media print {
  body * {
    visibility: hidden;
  }
  #posThermalPrintSection,
  #posThermalPrintSection * {
    visibility: visible;
  }
  #posThermalPrintSection {
    position: absolute;
    left: 0;
    top: 0;
    width: 80mm;
    margin: 0 auto;
    padding: 0;
  }
}
