/* ── Product List Page Theme ── */
.product-list-page {
  --pl-accent: #d97706;
  --pl-accent-soft: #fff8e1;
  --pl-accent-border: #fde68a;
  --pl-warn: #d97706;
  --pl-warn-soft: #fffbeb;
  --pl-warn-border: #fde68a;
  --pl-danger: #dc2626;
  --pl-danger-soft: #fef2f2;
  --pl-danger-border: #fecaca;
  --pl-ok: #16a34a;
  --pl-ok-soft: #f0fdf4;
  --pl-ok-border: #bbf7d0;
  min-height: 100%;
}

.product-list-page .pl-list-title-wrap {
  border-left-color: var(--pl-accent);
}

.product-list-page .page-title-back:hover {
  background: var(--pl-accent-soft);
  color: var(--pl-accent);
}

.pl-table-meta {
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.pl-table-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.pl-table-scroll {
  overflow-x: auto;
}

.product-list-page .pl-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}

.product-list-page .pl-table thead th {
  padding: 14px var(--space-md);
  text-align: left;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  background: linear-gradient(180deg, #fafafa, #ffffff);
  border-bottom: 1px solid var(--color-border);
  font-family: var(--font-bn);
  white-space: nowrap;
}

.product-list-page .pl-table thead th.pl-th-money {
  text-align: right;
}

.product-list-page .pl-table thead th:last-child {
  text-align: center;
}

.product-list-page .pl-table tbody td {
  padding: 14px var(--space-md);
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}

.product-list-page .pl-table tbody tr:last-child td {
  border-bottom: none;
}

.product-list-page .pl-table tbody tr:hover {
  background: var(--pl-accent-soft);
}

.pl-table-card.is-hidden { display: none; }

/* Product cell */
.pl-product-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.pl-product-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--pl-accent-soft);
  color: var(--pl-accent);
  font-family: var(--font-bn);
  font-size: var(--text-md);
  font-weight: 700;
  flex-shrink: 0;
}

.pl-product-meta {
  min-width: 0;
}

.pl-product-name {
  display: block;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pl-product-barcode {
  display: block;
  font-family: var(--font-en);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

/* Stock cell */
.pl-stock-cell {
  min-width: 130px;
}

.pl-stock-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.pl-stock-qty {
  font-weight: 600;
  font-family: var(--font-en);
}

.pl-stock-qty.is-out { color: var(--pl-danger); }
.pl-stock-qty.is-low { color: var(--pl-warn); }

.pl-stock-badge {
  font-size: var(--text-xs);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

.pl-stock-badge.is-out {
  background: var(--pl-danger-soft);
  color: var(--pl-danger);
  border: 1px solid var(--pl-danger-border);
}

.pl-stock-badge.is-low {
  background: var(--pl-warn-soft);
  color: var(--pl-warn);
  border: 1px solid var(--pl-warn-border);
}

.pl-stock-badge.is-ok {
  background: var(--pl-ok-soft);
  color: var(--pl-ok);
  border: 1px solid var(--pl-ok-border);
}

.pl-stock-bar {
  height: 6px;
  background: var(--color-border-light);
  border-radius: 999px;
  overflow: hidden;
}

.pl-stock-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--pl-ok);
  transition: width 0.3s ease;
}

.pl-stock-bar-fill.is-low { background: var(--pl-warn); }
.pl-stock-bar-fill.is-out { background: var(--pl-danger); width: 0 !important; }

.pl-cell-money {
  font-family: var(--font-en);
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pl-cell-money.is-empty {
  color: var(--color-text-muted);
}

.pl-cell-barcode {
  font-family: var(--font-en);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pl-cell-actions {
  text-align: center;
  white-space: nowrap;
}

.pl-cell-tags {
  white-space: normal;
}

.pl-tag-chip {
  display: inline-block;
  font-size: var(--text-xs);
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
  margin: 2px 4px 2px 0;
  font-family: var(--font-bn);
}

.pl-tag-chip.is-online {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.pl-tag-chip.is-expired {
  background: var(--pl-danger-soft);
  color: var(--pl-danger);
  border: 1px solid var(--pl-danger-border);
}

.pl-tag-chip.is-soon {
  background: var(--pl-warn-soft);
  color: var(--pl-warn);
  border: 1px solid var(--pl-warn-border);
}

.pl-cell-tags-empty {
  color: var(--color-text-muted);
}

.pl-online-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  cursor: pointer;
}

.pl-online-toggle input { width: 16px; height: 16px; cursor: pointer; }

.pl-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  margin: 0 2px;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.pl-action-btn:hover { border-color: var(--pl-accent); color: var(--color-brand-dark); background: var(--pl-accent-soft); }
.pl-delete-btn:hover { border-color: var(--pl-danger); color: var(--pl-danger); background: var(--pl-danger-soft); }
.pl-action-btn svg { width: 15px; height: 15px; }

.pl-mobile-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  min-height: var(--touch-min);
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
}

.pl-mobile-action-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.pl-mobile-action-btn.pl-edit-btn:hover { border-color: var(--pl-accent); color: var(--color-brand-dark); background: var(--pl-accent-soft); }
.pl-mobile-action-btn.pl-delete-btn:hover { border-color: var(--pl-danger); color: var(--pl-danger); background: var(--pl-danger-soft); }

.pl-product-thumb {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.pl-list-mobile-header .pl-product-thumb {
  width: 44px;
  height: 44px;
}

/* ── Image Upload (drawer) ── */
.pl-image-upload {
  margin-bottom: var(--space-lg);
}

.pl-upload-zone.is-hidden {
  display: none;
}

.pl-upload-zone.is-uploading {
  pointer-events: none;
  opacity: 0.7;
}

.pl-image-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fafafa;
}

.pl-image-preview.is-hidden {
  display: none;
}

.pl-image-preview img {
  width: 120px;
  height: 120px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.pl-image-preview-actions {
  display: flex;
  gap: var(--space-sm);
  width: 100%;
  justify-content: center;
}

.pl-image-action-btn {
  padding: 8px 14px;
  font-size: var(--text-sm);
}

.pl-image-remove-btn:hover {
  border-color: var(--pl-danger);
  color: var(--pl-danger);
  background: var(--pl-danger-soft);
}

.pl-upload-status {
  margin-top: var(--space-sm);
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  text-align: center;
}

.pl-upload-status.is-hidden {
  display: none;
}

.pl-upload-status.is-error {
  color: var(--pl-danger);
}

.pl-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  z-index: 300;
  padding: 12px 20px;
  background: #111827;
  color: #fff;
  border-radius: var(--radius-md);
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  transition: transform 0.3s ease;
}

.pl-toast.is-visible { transform: translateX(-50%) translateY(0); }
.pl-toast.is-error { background: #991b1b; }

.pl-empty-subtext {
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: -8px 0 var(--space-md);
  text-align: center;
}

.pl-empty-state {
  background: linear-gradient(180deg, var(--pl-accent-soft), #ffffff);
}

/* ── Product list page stats & mobile ── */
.product-list-page .pl-list-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.pl-list-stat-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  min-height: 88px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.pl-list-stat-card[data-filter]:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.pl-list-stat-card[data-filter]:focus-visible {
  outline: 2px solid var(--pl-accent);
  outline-offset: 2px;
}

.pl-list-stat-card.is-active-filter {
  box-shadow: 0 0 0 2px var(--pl-accent);
  border-color: var(--pl-accent);
}

.pl-list-stat-card.is-total {
  background: var(--pl-ok-soft);
  border-color: var(--pl-ok-border);
}

.pl-list-stat-card.is-low {
  background: var(--pl-warn-soft);
  border-color: var(--pl-warn-border);
}

.pl-list-stat-card.is-out {
  background: var(--pl-danger-soft);
  border-color: var(--pl-danger-border);
}

.pl-list-stat-label {
  display: block;
  font-family: var(--font-bn);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.pl-list-stat-value {
  font-family: var(--font-en);
  font-size: var(--text-lg);
  font-weight: 700;
}

.pl-list-stat-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.85);
}

.pl-list-stat-card.is-total .pl-list-stat-icon svg { color: var(--pl-ok); }
.pl-list-stat-card.is-low .pl-list-stat-icon svg { color: var(--pl-warn); }
.pl-list-stat-card.is-out .pl-list-stat-icon svg { color: var(--pl-danger); }

.pl-list-stat-icon svg { width: 24px; height: 24px; }

.pl-list-mobile-list {
  display: none;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.pl-list-mobile-card {
  padding: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--pl-ok);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pl-list-mobile-card.is-low { border-left-color: var(--pl-warn); }
.pl-list-mobile-card.is-out { border-left-color: var(--pl-danger); }

.pl-list-mobile-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--pl-accent-border);
}

.pl-list-mobile-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: var(--space-sm);
}

.pl-list-mobile-header .pl-product-avatar {
  width: 44px;
  height: 44px;
}

.pl-list-mobile-header-text {
  flex: 1;
  min-width: 0;
}

.pl-list-mobile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: 4px;
}

.pl-list-mobile-top strong {
  font-family: var(--font-bn);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text-primary);
}

.pl-list-mobile-barcode {
  font-family: var(--font-en);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pl-list-mobile-badge {
  font-size: var(--text-xs);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  flex-shrink: 0;
}

.pl-list-mobile-badge.is-low { background: var(--pl-warn-soft); color: var(--pl-warn); border: 1px solid var(--pl-warn-border); }
.pl-list-mobile-badge.is-out { background: var(--pl-danger-soft); color: var(--pl-danger); border: 1px solid var(--pl-danger-border); }
.pl-list-mobile-badge.is-ok { background: var(--pl-ok-soft); color: var(--pl-ok); border: 1px solid var(--pl-ok-border); }

.pl-list-mobile-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

.pl-list-mobile-prices {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  margin-bottom: var(--space-sm);
  padding: var(--space-sm);
  background: #fafafa;
  border-radius: var(--radius-sm);
}

.pl-list-mobile-prices span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pl-list-mobile-prices .pl-price-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.pl-list-mobile-prices .pl-price-value {
  font-family: var(--font-en);
  font-weight: 600;
}

.pl-list-mobile-prices .pl-price-value.is-empty {
  color: var(--color-text-muted);
  font-weight: 500;
}

.pl-list-mobile-actions {
  display: flex;
  gap: var(--space-sm);
}

@media (max-width: 992px) {
  .product-list-page #plTableCard { display: none !important; }
  .product-list-page .pl-list-mobile-list.is-visible { display: flex; }
  .product-list-page .search-box { min-width: 0; }
}

@media (max-width: 768px) {
  .product-list-page .pl-list-stats-grid { grid-template-columns: 1fr; }

  .product-list-page .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .product-list-page .search-box,
  .product-list-page .toolbar-select {
    width: 100%;
    min-width: 0;
  }

  .product-list-page .toolbar-btn {
    width: 100%;
    justify-content: center;
  }

  .product-list-page #plTableCard { display: none; }
  .product-list-page .pl-list-mobile-list.is-visible { display: flex; }

  .pl-action-btn {
    width: var(--touch-min);
    height: var(--touch-min);
  }
}
