/**
 * DealerTable Styles
 * Following STYLE_GUIDE.md dark theme specification
 */

.container {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--color-border, rgba(148, 163, 184, 0.25));
  border-radius: 20px;
  box-shadow: 0 30px 50px -40px rgba(8, 47, 73, 0.8);
  /* overflow: visible allows QuickActionsMenu dropdown to extend beyond container */
  overflow: visible;
}

.tableWrapper {
  min-height: 348px; /* 5 rows (~60px each) + header (~48px) for dropdown visibility */
  overflow-x: auto;
  overflow-y: visible;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  padding: var(--spacing-md, 16px);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-tertiary, rgba(148, 163, 184, 0.85));
  background: rgba(15, 23, 42, 0.5);
  border-bottom: 1px solid var(--color-border, rgba(148, 163, 184, 0.25));
}

/* Sortable column header button */
.sortButton {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-tertiary, rgba(148, 163, 184, 0.85));
  cursor: pointer;
  transition: color 0.15s;
  white-space: nowrap;
}

.sortButton:hover {
  color: var(--color-text-primary, #f8fafc);
}

.sortButton:hover .sortArrow {
  opacity: 1;
}

/* Sort direction arrow indicator */
.sortArrow {
  font-size: 0.5rem;
  opacity: 0.3;
  transition: opacity 0.15s;
  line-height: 1;
}

/* Active sort column styling */
.sortActive .sortButton {
  color: var(--color-primary-accent, #38bdf8);
}

.sortActive .sortArrow {
  opacity: 1;
  color: var(--color-primary-accent, #38bdf8);
}

.table td {
  padding: var(--spacing-md, 16px);
  border-bottom: 1px solid var(--color-border, rgba(148, 163, 184, 0.25));
  font-size: 0.875rem;
  color: var(--color-text-primary, #f8fafc);
  vertical-align: middle;
}

.table tbody tr:hover {
  background: rgba(148, 163, 184, 0.08);
}

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

/* Clickable dealer info button */
.dealerInfoButton {
  background: transparent;
  border: none;
  padding: var(--spacing-xs, 4px) var(--spacing-sm, 8px);
  margin: calc(-1 * var(--spacing-xs, 4px)) calc(-1 * var(--spacing-sm, 8px));
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.dealerInfoButton:hover {
  background: rgba(56, 189, 248, 0.08);
}

.dealerInfoButton:hover .dealerPrimary {
  color: var(--color-primary-accent, #38bdf8);
}

/* Dealer info cell */
.dealerInfo {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dealerPrimary {
  font-weight: 500;
  color: var(--color-text-primary, #f8fafc);
}

.dealerSecondary {
  font-size: 0.8125rem;
  color: var(--color-text-secondary, rgba(203, 213, 225, 0.9));
}

.dealerNumber {
  font-size: 0.75rem;
  color: var(--color-text-tertiary, rgba(148, 163, 184, 0.85));
  font-family: 'Monaco', 'Courier New', monospace;
}

/* Subdomain cell */
.subdomainCell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.subdomain {
  font-size: 0.8125rem;
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: var(--spacing-xs, 4px) var(--spacing-sm, 8px);
  border-radius: 6px;
  color: var(--color-primary-accent, #38bdf8);
}

.noSubdomain {
  color: var(--color-text-tertiary, rgba(148, 163, 184, 0.85));
  font-style: italic;
}

/* Clickable subdomain button */
.subdomainButton {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: opacity 0.15s;
}

.subdomainButton:hover {
  opacity: 0.8;
}

.subdomainButton:hover .subdomain {
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

.subdomainButton:hover .noSubdomain {
  color: var(--color-primary-accent, #38bdf8);
  text-decoration: underline;
}

/* External link icon */
.externalLink {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  color: var(--color-text-tertiary, rgba(148, 163, 184, 0.85));
  border-radius: 4px;
  transition: all 0.15s;
}

.externalLink:hover {
  color: var(--color-primary-accent, #38bdf8);
  background: rgba(56, 189, 248, 0.12);
}

/* Icon button (copy, external link) */
.iconButton {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--color-text-tertiary, rgba(148, 163, 184, 0.85));
  cursor: pointer;
  transition: all 0.15s;
}

.iconButton:hover {
  color: var(--color-primary-accent, #38bdf8);
  background: rgba(56, 189, 248, 0.12);
}

.iconButton.copied {
  color: var(--color-success, #34d399);
}

/* Tier badge */
.badge {
  display: inline-block;
  padding: var(--spacing-xs, 4px) var(--spacing-sm, 8px);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  text-transform: capitalize;
}

/* Status badge */
.statusBadge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: var(--spacing-xs, 4px) 12px;
  border: 1px solid var(--color-border, rgba(148, 163, 184, 0.25));
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
  color: var(--color-text-secondary, rgba(203, 213, 225, 0.9));
  background: rgba(15, 23, 42, 0.5);
}

.statusDot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
}

/* Clickable status button */
.statusButton {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: all 0.15s;
}

.statusButton:hover .statusBadge {
  border-color: rgba(148, 163, 184, 0.5);
  box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.15);
}

/* Date cell */
.dateCell {
  white-space: nowrap;
  color: var(--color-text-secondary, rgba(203, 213, 225, 0.9));
}

/* Impersonate button */
.impersonateButton {
  padding: var(--spacing-sm, 8px) var(--spacing-md, 16px);
  background: var(--color-primary-accent, #38bdf8);
  color: #0f172a;
  border: none;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.impersonateButton:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px -15px rgba(14, 165, 233, 0.95);
}

.impersonateButton:active:not(:disabled) {
  transform: translateY(0);
}

.impersonateButton:disabled {
  background: rgba(71, 85, 105, 0.4);
  color: rgba(226, 232, 240, 0.65);
  cursor: not-allowed;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md, 16px);
  border-top: 1px solid var(--color-border, rgba(148, 163, 184, 0.25));
  background: rgba(15, 23, 42, 0.5);
}

.paginationInfo {
  font-size: 0.875rem;
  color: var(--color-text-secondary, rgba(203, 213, 225, 0.9));
}

.paginationControls {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm, 8px);
}

.pageButton {
  padding: var(--spacing-sm, 8px) var(--spacing-md, 16px);
  background: transparent;
  border: 1px solid var(--color-border, rgba(148, 163, 184, 0.25));
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary, rgba(203, 213, 225, 0.9));
  cursor: pointer;
  transition: all 0.2s;
}

.pageButton:hover:not(:disabled) {
  background: rgba(148, 163, 184, 0.15);
  border-color: rgba(148, 163, 184, 0.4);
}

.pageButton:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pageIndicator {
  font-size: 0.875rem;
  color: var(--color-text-tertiary, rgba(148, 163, 184, 0.85));
}

/* Subtle loading state when table already has data */
.tableLoading {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

/* Loading state */
.loadingContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-2xl, 48px) var(--spacing-xl, 32px);
  gap: var(--spacing-md, 16px);
  color: var(--color-text-secondary, rgba(203, 213, 225, 0.9));
}

.spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--color-border, rgba(148, 163, 184, 0.25));
  border-top-color: var(--color-primary-accent, #38bdf8);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Empty state */
.emptyState {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-2xl, 48px) var(--spacing-xl, 32px);
  color: var(--color-text-secondary, rgba(203, 213, 225, 0.9));
}

.emptyIcon {
  width: 3rem;
  height: 3rem;
  margin-bottom: var(--spacing-md, 16px);
  color: var(--color-text-tertiary, rgba(148, 163, 184, 0.85));
}

.emptyState p {
  font-size: 1rem;
  font-weight: 500;
  margin: 0;
  color: var(--color-text-primary, #f8fafc);
}

.emptyHint {
  font-size: 0.875rem;
  margin-top: var(--spacing-xs, 4px);
  color: var(--color-text-tertiary, rgba(148, 163, 184, 0.85));
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .pagination {
    flex-direction: column;
    gap: var(--spacing-md, 16px);
    text-align: center;
  }

  .table th,
  .table td {
    padding: var(--spacing-sm, 8px);
  }

  .table th:nth-child(5),
  .table td:nth-child(5) {
    display: none; /* Hide created date on mobile */
  }
}
