/* ── Stock Page — Inventory Theme ── */
.stock-page {
  --st-accent: #0284c7;
  --st-accent-soft: #e0f2fe;
  --st-accent-border: #bae6fd;
  --st-warn: #d97706;
  --st-warn-soft: #fffbeb;
  --st-warn-border: #fde68a;
  --st-danger: #dc2626;
  --st-danger-soft: #fef2f2;
  --st-danger-border: #fecaca;
  --st-ok: #16a34a;
  --st-value-soft: #f0fdfa;
  --st-value-border: #99f6e4;
  min-height: 100%;
}

/* ── Header ── */
.stock-page .st-title-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  border-left-color: var(--st-accent) !important;
}

.stock-page .page-title-back:hover {
  background: var(--st-accent-soft);
  color: var(--st-accent);
}

.stock-page .st-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Stat Cards ── */
.st-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.st-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 transparent;
  min-height: 88px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.st-stat-card[data-filter] {
  cursor: pointer;
}

.st-stat-card[data-filter]:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.st-stat-card[data-filter]:focus-visible {
  outline: 2px solid var(--st-accent);
  outline-offset: 2px;
}

.st-stat-card.is-active-filter {
  box-shadow: 0 0 0 2px var(--st-accent);
}

.st-stat-card.is-total {
  background: var(--st-accent-soft);
  border-color: var(--st-accent-border);
}

.st-stat-card.is-low {
  background: var(--st-warn-soft);
  border-color: var(--st-warn-border);
}

.st-stat-card.is-out {
  background: var(--st-danger-soft);
  border-color: var(--st-danger-border);
}

.st-stat-card.is-value {
  background: var(--st-value-soft);
  border-color: var(--st-value-border);
}

.st-stat-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.st-stat-label {
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
}

.st-stat-value {
  font-family: var(--font-en);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text-deep);
  letter-spacing: -0.02em;
}

.st-stat-card.is-total .st-stat-value { color: var(--st-accent); }
.st-stat-card.is-low .st-stat-value { color: var(--st-warn); }
.st-stat-card.is-out .st-stat-value { color: var(--st-danger); }
.st-stat-card.is-value .st-stat-value { color: #0f766e; }

.st-stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.7);
}

.st-stat-icon svg {
  width: 22px;
  height: 22px;
}

.st-stat-card.is-total .st-stat-icon { color: var(--st-accent); }
.st-stat-card.is-low .st-stat-icon { color: var(--st-warn); }
.st-stat-card.is-out .st-stat-icon { color: var(--st-danger); }
.st-stat-card.is-value .st-stat-icon { color: #0d9488; }

/* ── Toolbar ── */
.st-toolbar-card {
  margin-top: var(--space-lg);
}

.st-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.st-filter-tabs {
  display: inline-flex;
  padding: 4px;
  background: var(--color-border-light);
  border-radius: var(--radius-md);
  gap: 2px;
}

.st-filter-tab {
  height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

.st-filter-tab:hover {
  color: var(--color-text-primary);
}

.st-filter-tab.is-active {
  background: var(--color-surface);
  color: var(--st-accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.st-search-box {
  flex: 1;
  min-width: 200px;
}

/* ── Table ── */
.st-table-meta {
  margin-bottom: var(--space-sm);
}

.st-table-card.is-hidden {
  display: none;
}

.st-table-scroll {
  overflow-x: auto;
}

.stock-page .st-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.stock-page .st-table thead th {
  background: linear-gradient(180deg, #fffbeb, #fff8e1);
  color: var(--color-text-secondary);
}

.stock-page .st-table tbody tr {
  cursor: pointer;
}

.stock-page .st-table tbody tr:hover {
  background: var(--st-accent-soft);
}

.st-product-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.st-product-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--st-accent-soft);
  color: var(--st-accent);
  font-family: var(--font-bn);
  font-size: var(--text-md);
  font-weight: 700;
  flex-shrink: 0;
}

.st-product-meta {
  min-width: 0;
}

.st-product-name {
  display: block;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.st-product-barcode {
  display: block;
  font-family: var(--font-en);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.st-stock-cell {
  min-width: 120px;
}

.st-stock-qty {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.st-stock-qty.is-out { color: var(--st-danger); }
.st-stock-qty.is-low { color: var(--st-warn); }

.st-stock-bar {
  height: 6px;
  background: var(--color-border-light);
  border-radius: 999px;
  overflow: hidden;
}

.st-stock-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--st-ok);
  transition: width 0.3s ease;
}

.st-stock-bar-fill.is-low { background: var(--st-warn); }
.st-stock-bar-fill.is-out { background: var(--st-danger); width: 0 !important; }

.st-cell-money {
  font-family: var(--font-en);
  white-space: nowrap;
}

.st-cell-value {
  font-family: var(--font-en);
  font-weight: 700;
  white-space: nowrap;
}

.st-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: var(--font-bn);
}

.st-badge.is-ok { background: #f0fdf4; color: var(--st-ok); }
.st-badge.is-low { background: var(--st-warn-soft); color: var(--st-warn); }
.st-badge.is-out { background: var(--st-danger-soft); color: var(--st-danger); }

/* ── Mobile List ── */
.st-mobile-list {
  display: none;
  flex-direction: column;
  gap: var(--space-sm);
}

.st-mobile-list.is-visible {
  display: flex;
}

.st-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);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.st-mobile-card:hover {
  border-color: var(--st-accent-border);
  box-shadow: var(--shadow-md);
}

.st-mobile-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.st-mobile-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  font-family: var(--font-en);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

/* ── Empty State ── */
.st-empty-state {
  display: none;
  text-align: center;
  padding: var(--space-xl);
}

.st-empty-state.is-visible {
  display: block;
}

.st-empty-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  margin-bottom: var(--space-md);
}

.st-empty-icon-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--st-accent-soft);
  border-radius: 50%;
  opacity: 0.6;
}

.st-empty-icon-wrap .empty-state-icon {
  position: relative;
  width: 40px;
  height: 40px;
  color: var(--st-accent);
}

.st-empty-subtext {
  color: var(--color-text-muted);
  margin: 8px 0 var(--space-md);
  font-family: var(--font-bn);
}

/* ── Toast ── */
.st-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;
}

.st-toast.is-visible { transform: translateX(-50%) translateY(0); }
.st-toast.is-error { background: #991b1b; }

/* ── Detail Drawer ── */
.st-detail-hero {
  padding: var(--space-md);
  margin: calc(-1 * var(--space-md)) calc(-1 * var(--space-md)) var(--space-md);
  background: linear-gradient(180deg, var(--st-accent-soft), #fff);
  border-bottom: 1px solid var(--st-accent-border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.st-detail-hero-top {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.st-detail-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  color: var(--st-accent);
  font-family: var(--font-bn);
  font-size: var(--text-lg);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.st-detail-hero-text {
  min-width: 0;
}

.st-detail-hero-name {
  font-family: var(--font-bn);
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0 0 6px;
  line-height: 1.3;
}

.st-detail-hero-stock {
  text-align: center;
}

.st-detail-hero-qty {
  display: block;
  font-family: var(--font-en);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text-deep);
  margin-bottom: var(--space-sm);
}

.st-detail-bar {
  max-width: 280px;
  margin: 0 auto;
}

.st-detail-meta {
  margin-bottom: var(--space-md);
}

.st-detail-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border-light);
  font-family: var(--font-bn);
  font-size: var(--text-sm);
}

.st-detail-row span:last-child {
  font-family: var(--font-en);
  font-weight: 600;
  text-align: right;
}

.st-detail-note {
  font-family: var(--font-bn);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: var(--space-md) 0;
  padding: var(--space-sm);
  background: #f8fafc;
  border-radius: var(--radius-sm);
  line-height: 1.5;
}

.st-adjust-section {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

.st-adjust-section.is-hidden { display: none; }

.st-adjust-type {
  display: flex;
  gap: 8px;
  margin-bottom: var(--space-md);
  padding: 4px;
  background: var(--color-border-light);
  border-radius: var(--radius-md);
}

.st-adjust-type-btn {
  flex: 1;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.st-adjust-type-btn.is-active[data-type="add"] {
  background: var(--st-ok);
  color: #fff;
}

.st-adjust-type-btn.is-active[data-type="subtract"] {
  background: var(--st-danger);
  color: #fff;
}

/* ── Responsive ── */
@media (max-width: 992px) {
  .st-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .st-table-card { display: none !important; }
  .st-mobile-list.is-visible { display: flex; }
  .st-search-box { min-width: 0; }
}

@media (max-width: 768px) {
  .st-stats-grid {
    grid-template-columns: 1fr;
  }

  .st-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .st-filter-tabs {
    width: 100%;
    justify-content: stretch;
  }

  .st-filter-tab {
    flex: 1;
    padding: 0 8px;
    font-size: var(--text-xs);
  }

  .st-search-box {
    width: 100%;
    min-width: 0;
  }

  .stock-page .toolbar-select {
    width: 100%;
  }

  .st-table-card {
    display: none !important;
  }

  .st-mobile-list.is-visible {
    display: flex;
  }
}
