/* ============================================
   POS-Shop — POS Terminal Styles
   Staff-facing point of sale interface
   ============================================ */

/* === POS Layout === */
.pos-layout {
  display: flex;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

.pos-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pos-sidebar {
  width: var(--pos-sidebar-width);
  background: var(--color-bg-secondary);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* === POS Top Bar === */
.pos-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.pos-search {
  flex: 1;
  position: relative;
}

.pos-search .form-input {
  background: var(--color-bg-primary);
  padding-left: var(--space-10);
  height: 44px;
  font-size: var(--text-base);
}

.pos-search .search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
}

.pos-search-results {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  right: 0;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
  max-height: 400px;
  overflow-y: auto;
}

.pos-search-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.pos-search-item:hover {
  background: var(--color-bg-hover);
}

.pos-search-item-image {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg-tertiary);
  flex-shrink: 0;
}

.pos-search-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pos-search-item-info {
  flex: 1;
}

.pos-search-item-name {
  font-weight: var(--weight-medium);
  font-size: var(--text-sm);
}

.pos-search-item-sku {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

.pos-search-item-price {
  font-weight: var(--weight-bold);
  color: var(--color-primary-400);
}

/* === Scanner Button === */
.pos-scanner-btn {
  height: 44px;
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}

.pos-scanner-btn:hover {
  border-color: var(--color-primary-500);
  color: var(--color-primary-400);
}

.pos-scanner-btn.active {
  background: var(--color-primary-600);
  border-color: var(--color-primary-500);
  color: white;
}

/* === POS Product Grid === */
.pos-products {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
}

.pos-category-tabs {
  display: flex;
  gap: var(--space-2);
  padding-bottom: var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
}

.pos-category-tabs::-webkit-scrollbar {
  display: none;
}

.pos-category-tab {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.pos-category-tab:hover {
  border-color: var(--color-primary-500);
  color: var(--color-primary-400);
}

.pos-category-tab.active {
  background: var(--color-primary-600);
  border-color: var(--color-primary-500);
  color: white;
}

.pos-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
}

.pos-product-tile {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.pos-product-tile:hover {
  border-color: var(--color-primary-500);
  background: var(--color-bg-hover);
  transform: translateY(-1px);
}

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

.pos-product-tile-image {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg-tertiary);
  margin-bottom: var(--space-2);
}

.pos-product-tile-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pos-product-tile-name {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-1);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pos-product-tile-price {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-primary-400);
}

/* === POS Cart Sidebar === */
.pos-cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.pos-cart-title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

.pos-cart-count {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

.pos-cart-items {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-4);
}

.pos-cart-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition-fast);
}

.pos-cart-item:hover {
  background: var(--color-bg-hover);
}

.pos-cart-item:last-child {
  border-bottom: none;
}

.pos-cart-item-info {
  flex: 1;
  min-width: 0;
}

.pos-cart-item-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pos-cart-item-variant {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.pos-cart-item-qty {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.pos-cart-item-qty button {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}

.pos-cart-item-qty button:hover {
  background: var(--color-primary-600);
  color: white;
}

.pos-cart-item-qty span {
  width: 28px;
  text-align: center;
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
}

.pos-cart-item-price {
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.pos-cart-item-remove {
  color: var(--color-text-muted);
  opacity: 0;
  transition: all var(--transition-fast);
}

.pos-cart-item:hover .pos-cart-item-remove {
  opacity: 1;
}

.pos-cart-item-remove:hover {
  color: var(--color-danger-400);
}

/* === POS Cart Footer / Payment === */
.pos-cart-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-5);
  background: var(--color-bg-primary);
}

.pos-cart-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  padding: var(--space-1) 0;
}

.pos-cart-total {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  padding: var(--space-3) 0;
  margin: var(--space-2) 0 var(--space-4);
  border-top: 1px solid var(--color-border);
}

.pos-payment-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.pos-payment-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  transition: all var(--transition-fast);
}

.pos-pay-cash {
  background: linear-gradient(135deg, var(--color-success-700), var(--color-success-600));
  color: white;
}

.pos-pay-cash:hover {
  background: linear-gradient(135deg, var(--color-success-600), var(--color-success-500));
}

.pos-pay-card {
  background: linear-gradient(135deg, var(--color-primary-700), var(--color-primary-600));
  color: white;
}

.pos-pay-card:hover {
  background: linear-gradient(135deg, var(--color-primary-600), var(--color-primary-500));
}

.pos-pay-qr {
  background: linear-gradient(135deg, var(--color-accent-700), var(--color-accent-600));
  color: white;
  grid-column: span 2;
}

.pos-pay-qr:hover {
  background: linear-gradient(135deg, var(--color-accent-600), var(--color-accent-500));
}

/* === Cash Payment Modal === */
.cash-modal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  margin: var(--space-4) 0;
}

.cash-quick-btn {
  padding: var(--space-3);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
  transition: all var(--transition-fast);
}

.cash-quick-btn:hover {
  border-color: var(--color-primary-500);
  background: var(--color-bg-hover);
}

.cash-change-display {
  text-align: center;
  padding: var(--space-4);
  background: var(--color-bg-primary);
  border-radius: var(--radius-xl);
  margin-top: var(--space-4);
}

.cash-change-label {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-2);
}

.cash-change-amount {
  font-family: var(--font-heading);
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  color: var(--color-success-400);
}

/* === Receipt === */
.receipt-preview {
  background: white;
  color: #000;
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  font-family: var(--font-mono);
  font-size: 12px;
  max-width: 300px;
  margin: var(--space-4) auto;
}

.receipt-preview .receipt-header {
  text-align: center;
  margin-bottom: var(--space-4);
}

.receipt-preview .receipt-store-name {
  font-size: 16px;
  font-weight: bold;
}

.receipt-preview .receipt-divider {
  border-top: 1px dashed #ccc;
  margin: var(--space-2) 0;
}

.receipt-preview .receipt-item {
  display: flex;
  justify-content: space-between;
  margin: var(--space-1) 0;
}

.receipt-preview .receipt-total {
  font-weight: bold;
  font-size: 14px;
  margin-top: var(--space-2);
}

/* === Camera / Barcode Scanner === */
.scanner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.scanner-viewport {
  width: 90%;
  max-width: 500px;
  aspect-ratio: 4/3;
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: relative;
  border: 2px solid var(--color-primary-500);
}

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

.scanner-guide {
  position: absolute;
  inset: 20%;
  border: 2px solid var(--color-accent-400);
  border-radius: var(--radius-md);
  animation: scanPulse 2s ease-in-out infinite;
}

@keyframes scanPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.scanner-status {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

/* === POS Keyboard Shortcuts Hint === */
.keyboard-hints {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-primary);
  overflow-x: auto;
}

.keyboard-hint {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 var(--space-2);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--weight-bold);
  color: var(--color-text-secondary);
}

/* === Inventory Management === */
.inventory-layout {
  padding: var(--space-6);
  max-width: var(--max-width);
  margin: 0 auto;
}

.inventory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.inventory-filters {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.inventory-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.inventory-stat-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
}

.inventory-stat-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-2);
}

.inventory-stat-value {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
}

@media (max-width: 768px) {
  .pos-layout {
    flex-direction: column;
    height: auto;
  }

  .pos-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--color-border);
    max-height: 50vh;
  }

  .pos-product-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }

  .pos-payment-actions {
    grid-template-columns: 1fr 1fr;
  }

  .inventory-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}
