/*
 * Admin Styles
 * Admin chrome (tabs, dashboard sections) and the primitives that
 * admin surfaces share with the rest of the app: tables, status/source
 * badges, pills, form groups, search, empty state. Surface-specific
 * admin styles live in admin/_<surface>.css — see DESIGN.md §4.
 */

/* ===== Admin Tabs ===== */
.admin-tabs {
  display: flex;
  gap: var(--space-xl);
  margin-bottom: var(--space-xl);
  border-bottom: 1px solid var(--color-border);
}

.admin-tab {
  padding: var(--space-md) 0;
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s;
}

.admin-tab:hover {
  color: var(--color-text);
}

.admin-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Admin tab count badge */
.admin-tab-count {
  display: inline-flex;
  align-items: center;
  margin-left: var(--space-xs);
  padding: 0 var(--space-sm);
  background: var(--color-bg-hover);
  color: var(--color-text-light);
  font-size: var(--font-size-2xs);
  font-weight: 700;
  border-radius: 999px;
  min-width: 18px;
  justify-content: center;
}

.admin-tab.active .admin-tab-count {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
}

/* ===== Admin Dashboard ===== */
.dashboard-section {
  padding: var(--space-xl) 0;
  border-bottom: 1px solid var(--color-border);
}

.dashboard-section:last-child {
  border-bottom: none;
}

.dashboard-section h2 {
  margin-bottom: var(--space-sm);
  font-size: var(--font-size-md);
  font-weight: 600;
}

.dashboard-section .section-description {
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-lg);
}

/* ===== Admin Tables (Shared) ===== */
.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.admin-table th {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table .actions {
  white-space: nowrap;
}

.admin-table .actions > * {
  display: inline;
  vertical-align: middle;
  margin-right: var(--space-sm);
}

.admin-table .actions > *:last-child {
  margin-right: 0;
}

/* Legacy table class aliases — map old classes to admin-table pattern */
.reviews-table,
.providers-table,
.producers-table,
.users-table,
.sync-history-table,
.wines-bulk-table {
  width: 100%;
  border-collapse: collapse;
}

.reviews-table th,
.reviews-table td,
.providers-table th,
.providers-table td,
.producers-table th,
.producers-table td,
.users-table th,
.users-table td,
.sync-history-table th,
.sync-history-table td,
.wines-bulk-table th,
.wines-bulk-table td {
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.reviews-table th,
.providers-table th,
.producers-table th,
.users-table th,
.sync-history-table th,
.wines-bulk-table th {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.reviews-table tbody tr:last-child td,
.providers-table tbody tr:last-child td,
.producers-table tbody tr:last-child td,
.users-table tbody tr:last-child td,
.sync-history-table tbody tr:last-child td,
.wines-bulk-table tbody tr:last-child td {
  border-bottom: none;
}

.reviews-table .actions,
.providers-table .actions,
.producers-table .actions,
.users-table .actions,
.sync-history-table .actions,
.wines-bulk-table .actions {
  white-space: nowrap;
}

.reviews-table .actions > *,
.providers-table .actions > *,
.producers-table .actions > *,
.users-table .actions > *,
.sync-history-table .actions > *,
.wines-bulk-table .actions > * {
  display: inline;
  vertical-align: middle;
  margin-right: var(--space-sm);
}

.reviews-table .actions > *:last-child,
.providers-table .actions > *:last-child,
.producers-table .actions > *:last-child,
.users-table .actions > *:last-child,
.sync-history-table .actions > *:last-child,
.wines-bulk-table .actions > *:last-child {
  margin-right: 0;
}

.reviews-table .wine-meta {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
}

.reviews-table .confidence {
  font-weight: 600;
}

.actions-cell {
  white-space: nowrap;
}

.actions-cell > * {
  display: inline;
  vertical-align: middle;
  margin-right: var(--space-sm);
}

.actions-cell > *:last-child {
  margin-right: 0;
}

/* ===== Producer-specific Styles ===== */
.producers-table .producer-name {
  font-weight: 500;
}

.producers-table .producer-name a {
  color: inherit;
  text-decoration: none;
}

.producers-table .producer-name a:hover {
  color: var(--color-primary);
}

/* ===== Status Badge — dot + text ===== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.status-badge::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--color-text-muted);
}

.status-badge.completed::before,
.status-badge.active::before,
.status-badge.sent::before,
.status-badge.matched::before {
  background: var(--color-success);
}

.status-badge.completed,
.status-badge.active,
.status-badge.sent,
.status-badge.matched {
  color: var(--color-success);
}

/* `enqueued` is a Solid Queue batch that is still fanning out — in flight, like running. */
.status-badge.running::before,
.status-badge.enqueued::before {
  background: var(--color-primary);
}

.status-badge.running,
.status-badge.enqueued {
  color: var(--color-primary);
}

.status-badge.failed::before,
.status-badge.error::before {
  background: var(--color-danger);
}

.status-badge.failed,
.status-badge.error {
  color: var(--color-danger);
}

.status-badge.pending::before,
.status-badge.cancelled::before,
.status-badge.inactive::before,
.status-badge.not_found::before,
.status-badge.sold-out::before {
  background: var(--color-text-muted);
}

.status-badge.pending,
.status-badge.cancelled,
.status-badge.inactive,
.status-badge.not_found,
.status-badge.sold-out {
  color: var(--color-text-light);
}

.status-badge.skipped::before,
.status-badge.suppressed::before,
.status-badge.paused::before,
.status-badge.monthly-cellar::before {
  background: var(--color-warning);
}

.status-badge.skipped,
.status-badge.suppressed,
.status-badge.paused,
.status-badge.monthly-cellar {
  color: var(--color-warning);
}

.status-badge.preview::before {
  background: var(--color-info);
}

.status-badge.preview {
  color: var(--color-info);
}

.status-badge.special-offer::before {
  background: var(--color-promo);
}

.status-badge.special-offer {
  color: var(--color-promo);
}

/* ===== Source Badge ===== */
/* Dynamic providers compose .source-badge .provider-chip — the chip primitive
   in application.css paints the brand colour via --provider-color and adds the
   theme-aware ring. Producer dots still use .source-badge.producer (class-
   based, no dynamic wiring needed). */
.source-badge {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Producer still uses a class since it's not yet a dynamic provider */
.source-badge.producer {
  background: var(--color-producer);
}

/* ===== Form Group ===== */
.form-group {
  flex: 1;
}

.form-group label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-light);
  margin-bottom: var(--space-sm);
}

.form-group input,
.form-group select {
  width: 100%;
  height: 36px;
  padding: 0 var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: var(--font-size-base);
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--color-primary);
}

.form-group input[type="number"] {
  -moz-appearance: textfield;
}

.form-group select {
  width: 100%;
  height: 36px;
  padding: 0 var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

/* ===== Filter Label ===== */
.filter-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
}

.empty-state p {
  margin-bottom: var(--space-md);
  color: var(--color-text-light);
}

/* ===== Page Description ===== */
.page-description {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.page-description .page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.page-description .results-count {
  margin-bottom: 0;
}

/* ===== Admin Search Form ===== */
.search-form {
  margin-bottom: var(--space-lg);
}

.search-form .search-input-wrapper {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

.search-form .search-input {
  flex: 1;
  max-width: 300px;
  height: 36px;
  padding: 0 var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: var(--font-size-base);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-appearance: none;
  appearance: none;
}

.search-form .search-input:focus {
  border-color: var(--color-primary);
}

.results-count {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
}

/* ===== User/Tier Badges — small pills ===== */
.badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius);
  font-size: var(--font-size-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.badge-admin {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
}

.badge-active {
  background: color-mix(in srgb, var(--color-success) 12%, transparent);
  color: var(--color-success);
}

.badge-inactive {
  background: color-mix(in srgb, var(--color-text-muted) 12%, transparent);
  color: var(--color-text-muted);
}

.badge-tier-free {
  background: color-mix(in srgb, var(--color-text-muted) 12%, transparent);
  color: var(--color-text-muted);
}

.badge-tier-plus {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
}

.badge-tier-pro {
  background: color-mix(in srgb, var(--color-warning) 12%, transparent);
  color: var(--color-warning);
}

.badge-missing {
  background: color-mix(in srgb, var(--color-warning) 12%, transparent);
  color: var(--color-warning);
}
