/* ============================================================
   WP Inventory POS — POS Terminal Stylesheet
   Full-screen, touch-optimized, dark theme
   ============================================================ */

/* ── Reset inside POS root ────────────────────────────────── */
#wpip-pos-root * { box-sizing: border-box; margin: 0; padding: 0; }

#wpip-pos-root {
  --pos-bg:         #0F172A;
  --pos-panel:      #1E293B;
  --pos-card:       #263044;
  --pos-border:     #334155;
  --pos-primary:    #3B82F6;
  --pos-success:    #10B981;
  --pos-warning:    #F5A623;
  --pos-danger:     #EF4444;
  --pos-text:       #F1F5F9;
  --pos-muted:      #94A3B8;
  --pos-input-bg:   #1E293B;
  --pos-radius:     10px;
  --pos-radius-sm:  6px;
  --pos-shadow:     0 2px 8px rgba(0,0,0,.4);
  --sidebar-w:      420px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--pos-text);
  background: var(--pos-bg);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 32px); /* minus WP admin bar */
  overflow: hidden;
}

/* ── Top Bar ──────────────────────────────────────────────── */
.pos-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 54px;
  background: var(--pos-panel);
  border-bottom: 1px solid var(--pos-border);
  flex-shrink: 0;
  gap: 12px;
}
.pos-topbar-brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--pos-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.pos-topbar-search {
  flex: 1;
  max-width: 480px;
}
.pos-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pos-warehouse-select {
  padding: 7px 12px;
  background: var(--pos-card);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius-sm);
  color: var(--pos-text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

/* ── Search Input ─────────────────────────────────────────── */
.pos-search-wrap {
  position: relative;
}
.pos-search-input {
  width: 100%;
  padding: 9px 16px 9px 40px;
  background: var(--pos-card);
  border: 1px solid var(--pos-border);
  border-radius: 24px;
  color: var(--pos-text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.pos-search-input::placeholder { color: var(--pos-muted); }
.pos-search-input:focus { border-color: var(--pos-primary); }
.pos-search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--pos-muted);
  font-size: 16px;
  pointer-events: none;
}
.pos-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--pos-panel);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  max-height: 320px;
  overflow-y: auto;
  z-index: 1000;
}
.pos-search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background .1s;
  border-bottom: 1px solid var(--pos-border);
}
.pos-search-item:last-child { border-bottom: none; }
.pos-search-item:hover { background: var(--pos-card); }
.pos-search-item-img {
  width: 40px; height: 40px;
  border-radius: var(--pos-radius-sm);
  object-fit: cover;
  background: var(--pos-border);
  flex-shrink: 0;
}
.pos-search-item-info { flex: 1; min-width: 0; }
.pos-search-item-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-search-item-sku  { font-size: 11.5px; color: var(--pos-muted); }
.pos-search-item-price { font-weight: 700; color: var(--pos-primary); flex-shrink: 0; }
.pos-search-item-stock { font-size: 11px; color: var(--pos-success); }
.pos-search-item-stock.low { color: var(--pos-warning); }
.pos-search-item-stock.out  { color: var(--pos-danger); }

/* ── Main Layout ──────────────────────────────────────────── */
.pos-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Product Grid ─────────────────────────────────────────── */
.pos-products {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pos-category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  flex-shrink: 0;
}
.pos-category-tab {
  padding: 6px 16px;
  border-radius: 20px;
  background: var(--pos-card);
  border: 1px solid var(--pos-border);
  color: var(--pos-muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.pos-category-tab.active, .pos-category-tab:hover {
  background: var(--pos-primary);
  border-color: var(--pos-primary);
  color: #fff;
}
.pos-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.pos-product-card {
  background: var(--pos-card);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius);
  padding: 14px 10px;
  cursor: pointer;
  text-align: center;
  transition: all .15s;
  user-select: none;
  position: relative;
  overflow: hidden;
}
.pos-product-card:hover { border-color: var(--pos-primary); transform: translateY(-1px); box-shadow: var(--pos-shadow); }
.pos-product-card:active { transform: scale(.97); }
.pos-product-card.out-of-stock { opacity: .5; cursor: not-allowed; }
.pos-product-card.out-of-stock::after {
  content: 'OUT OF STOCK';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--pos-danger);
  letter-spacing: 1px;
}
.pos-product-img {
  width: 64px; height: 64px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--pos-border);
  margin: 0 auto 10px;
  display: block;
  font-size: 32px;
  line-height: 64px;
  text-align: center;
}
.pos-product-name  { font-size: 12.5px; font-weight: 600; line-height: 1.3; margin-bottom: 5px; }
.pos-product-price { font-size: 14px; font-weight: 700; color: var(--pos-primary); }
.pos-product-stock { font-size: 11px; color: var(--pos-muted); margin-top: 3px; }

/* ── Cart Sidebar ─────────────────────────────────────────── */
.pos-cart {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--pos-panel);
  border-left: 1px solid var(--pos-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pos-cart-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--pos-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pos-cart-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pos-cart-count {
  background: var(--pos-primary);
  color: #fff;
  border-radius: 12px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
}
.pos-cart-clear { font-size: 12px; color: var(--pos-danger); cursor: pointer; }

/* Customer selector */
.pos-customer-bar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--pos-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.pos-customer-icon { font-size: 18px; }
.pos-customer-name { font-size: 13px; font-weight: 500; color: var(--pos-text); }
.pos-customer-search { flex: 1; font-size: 12.5px; background: transparent; border: none; outline: none; color: var(--pos-text); }
.pos-customer-search::placeholder { color: var(--pos-muted); }

/* Cart items list */
.pos-cart-items { flex: 1; overflow-y: auto; padding: 8px 0; }
.pos-cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--pos-muted);
  gap: 12px;
  font-size: 13px;
}
.pos-cart-empty-icon { font-size: 48px; opacity: .3; }

.pos-cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--pos-border);
  transition: background .1s;
}
.pos-cart-item:hover { background: var(--pos-card); }
.pos-cart-item-info { flex: 1; min-width: 0; }
.pos-cart-item-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-cart-item-sku  { font-size: 11px; color: var(--pos-muted); }
.pos-cart-item-price { font-size: 13.5px; font-weight: 700; color: var(--pos-primary); text-align: right; }
.pos-cart-item-subtotal { font-size: 12px; color: var(--pos-muted); text-align: right; }

.pos-qty-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.pos-qty-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--pos-border);
  background: var(--pos-card);
  color: var(--pos-text);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}
.pos-qty-btn:hover { background: var(--pos-primary); border-color: var(--pos-primary); }
.pos-qty-input {
  width: 40px;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  color: var(--pos-text);
  font-size: 14px;
  font-weight: 700;
}
.pos-cart-item-remove { color: var(--pos-danger); cursor: pointer; font-size: 16px; flex-shrink: 0; }

/* Totals */
.pos-cart-totals {
  padding: 14px 20px;
  border-top: 1px solid var(--pos-border);
  background: var(--pos-card);
}
.pos-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 13.5px;
  color: var(--pos-muted);
}
.pos-total-row.grand {
  font-size: 18px;
  font-weight: 700;
  color: var(--pos-text);
  padding-top: 10px;
  border-top: 1px solid var(--pos-border);
  margin-top: 6px;
}
.pos-total-row .pos-discount-input {
  width: 80px;
  text-align: right;
  background: transparent;
  border: 1px solid var(--pos-border);
  border-radius: 4px;
  color: var(--pos-text);
  padding: 3px 8px;
  font-size: 13px;
  outline: none;
}

/* Payment section */
.pos-payment-section { padding: 14px 20px; border-top: 1px solid var(--pos-border); }
.pos-payment-methods {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.pos-pay-method {
  padding: 10px 6px;
  border-radius: var(--pos-radius-sm);
  border: 2px solid var(--pos-border);
  background: var(--pos-card);
  cursor: pointer;
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--pos-muted);
  transition: all .15s;
}
.pos-pay-method:hover, .pos-pay-method.active {
  border-color: var(--pos-primary);
  background: rgba(59,130,246,.1);
  color: var(--pos-primary);
}
.pos-pay-method-icon { font-size: 20px; display: block; margin-bottom: 4px; }
.pos-amount-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.pos-amount-label { font-size: 12.5px; color: var(--pos-muted); white-space: nowrap; }
.pos-amount-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--pos-card);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius-sm);
  color: var(--pos-text);
  font-size: 18px;
  font-weight: 700;
  outline: none;
  text-align: right;
  transition: border-color .15s;
}
.pos-amount-input:focus { border-color: var(--pos-primary); }
.pos-change-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
  color: var(--pos-success);
  font-weight: 600;
}

/* Complete button */
.pos-complete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--pos-success), #059669);
  border: none;
  border-radius: var(--pos-radius);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .3px;
  box-shadow: 0 4px 12px rgba(16,185,129,.3);
  transition: all .15s;
}
.pos-complete-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(16,185,129,.4); }
.pos-complete-btn:active { transform: scale(.98); }
.pos-complete-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* ── Receipt Modal ────────────────────────────────────────── */
.pos-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pos-modal {
  background: #fff;
  color: #111;
  border-radius: var(--pos-radius);
  padding: 32px;
  max-width: 440px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,.3);
}
.pos-receipt-header { text-align: center; margin-bottom: 20px; }
.pos-receipt-logo   { font-size: 40px; margin-bottom: 8px; }
.pos-receipt-business { font-size: 18px; font-weight: 700; }
.pos-receipt-address  { font-size: 12px; color: #6B7280; }
.pos-receipt-divider  { border: none; border-top: 1px dashed #E5E7EB; margin: 14px 0; }
.pos-receipt-table { width: 100%; font-size: 13px; }
.pos-receipt-table td { padding: 5px 4px; }
.pos-receipt-table td:last-child { text-align: right; font-weight: 600; }
.pos-receipt-total-row { font-weight: 700; font-size: 15px; }
.pos-receipt-footer { text-align: center; font-size: 13px; color: #6B7280; margin-top: 20px; }
.pos-modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.pos-modal-btn { flex: 1; padding: 12px; border-radius: 8px; border: none; font-weight: 600; cursor: pointer; font-size: 14px; }
.pos-modal-btn-primary { background: #3B82F6; color: #fff; }
.pos-modal-btn-secondary { background: #F1F5F9; color: #111; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .pos-body { flex-direction: column; }
  .pos-cart { width: 100%; max-height: 50vh; border-left: none; border-top: 1px solid var(--pos-border); }
  .pos-payment-methods { grid-template-columns: repeat(2, 1fr); }
}
@media print {
  /* BUG 5 FIX: #pos-receipt-content's print sizing (width/@page/padding/
     font-size/box-sizing) used to be declared here too, hardcoded to 80mm
     regardless of the paper-width setting — a second, conflicting source of
     truth alongside wpip-ui.css's own (different) copy and the dynamic one in
     page-pos.php. That's now the ONLY place it's declared; see the big
     comment in templates/page-pos.php for why. This block keeps only the
     generic "hide everything except the receipt" rules, which don't hardcode
     any dimension and so can't conflict with it. */
  #wpip-pos-root, #wpip-pos-terminal { display: none !important; }
  body * { visibility: hidden !important; }
  #pos-receipt-content, #pos-receipt-content * { visibility: visible !important; }
}

/* On-screen preview of the receipt (before printing) — mirrors the print
   width so what you see in the modal matches what comes out of the printer,
   rather than a wide desktop-style preview that reflows differently at
   print time. */
#pos-receipt-content {
  max-width: 80mm;
  margin: 0 auto;
  background: #fff;
  color: #000;
  border-radius: 4px;
}


/* ── Dual-screen display indicator (topbar) ───────────────── */
.pos-display-link {
  font-size: 12px;
  color: var(--pos-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--pos-card);
  border: 1px solid var(--pos-border);
  border-radius: 6px;
  padding: 5px 10px;
  text-decoration: none;
  transition: border-color .15s;
}
.pos-display-link:hover { border-color: var(--pos-success); color: var(--pos-success); }
.pos-display-link.connected { color: var(--pos-success); border-color: rgba(16,185,129,.4); }
.pos-display-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pos-muted);
  flex-shrink: 0;
}
.pos-display-dot.connected { background: var(--pos-success); }

/* ── Sale success banner (receipt modal) ─────────────────── */
.wpip-sale-success {
  text-align: center;
  padding: 6px 0 20px;
  margin-bottom: 4px;
  border-bottom: 1px dashed #E5E7EB;
}
.wpip-sale-success-check {
  width: 64px;
  height: 64px;
  margin: 0 auto 10px;
  display: block;
}
.wpip-check-circle {
  stroke: #10B981;
  stroke-width: 3;
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
}
.wpip-check-mark {
  stroke: #10B981;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 32;
  stroke-dashoffset: 32;
}
.wpip-sale-success-check.animate .wpip-check-circle {
  animation: wpip-check-circle-draw .45s ease-out forwards;
}
.wpip-sale-success-check.animate .wpip-check-mark {
  animation: wpip-check-mark-draw .35s .4s ease-out forwards;
}
@keyframes wpip-check-circle-draw { to { stroke-dashoffset: 0; } }
@keyframes wpip-check-mark-draw   { to { stroke-dashoffset: 0; } }
.wpip-sale-success-title {
  font-size: 20px;
  font-weight: 700;
  color: #065F46;
  margin-bottom: 4px;
}
.wpip-sale-success-sub {
  font-size: 13px;
  color: #6B7280;
}
