/* Table Card */

.table-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(148, 163, 184, 0.18);
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: calc(100vh - 110px);
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 4px 8px;
}

/* Filter bar */

.filter-container {
  margin-left: auto;
}

.filter-input {
  border-radius: 999px;
  border: 1px solid #d4d7ea;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.8rem;
  min-width: 180px;
  background: #ffffff;
}

.filter-input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.record-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.table-container {
  flex: 1;
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

/* Table */

.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: #fff;
}

.crm-table thead {
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 5;
}

.crm-table th,
.crm-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #edf0f7;
  text-align: left;
}

.crm-table th {
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  user-select: none;
}

.crm-table th.sortable {
  cursor: pointer;
}

.crm-table th.sortable::after {
  content: " ";
  margin-left: 4px;
  border: 4px solid transparent;
  border-top-color: #cbd5f5;
  display: inline-block;
  transform: translateY(2px);
  opacity: 0.6;
}

.crm-table th.sortable.asc::after {
  border-top-color: transparent;
  border-bottom-color: #4f46e5;
  transform: translateY(-2px);
  opacity: 1;
}

.crm-table th.sortable.desc::after {
  border-top-color: #4f46e5;
  border-bottom-color: transparent;
  transform: translateY(2px);
  opacity: 1;
}

.crm-table tbody tr:hover {
  background: #f9fafb;
}

/* Empty state */

.empty-state {
  padding: 20px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* New row (add) */

.new-row {
  background: #f9fafb;
}

.new-row td {
  border-top: 1px solid #e5e7f3;
}

/* shared input base already applied from base.css */
.new-row input,
.new-row select {
  width: 100%;
}

/* Add button – base pill styling comes from base.css */

.add-btn {
  border: none;
  padding: 6px 10px;
  background: var(--accent);
  color: #ffffff;
  white-space: nowrap;
}

.add-btn:hover {
  filter: brightness(1.05);
}

/* Secondary button – base pill styling from base.css */

.secondary-btn {
  border: 1px solid var(--border-subtle);
  background: #f8fafc;
  padding: 6px 12px;
  color: var(--text-main);
}

.secondary-btn:hover {
  border-color: var(--accent-soft);
}

/* Inline edit inputs – base from shared input rules */

.cell-input {
  width: 100%;
  padding: 3px 5px; /* slightly tighter without breaking base */
}

/* Row actions */

.row-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.icon-btn {
  border: none;
  background: transparent;
  padding: 4px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.7;
}

.icon-btn:hover {
  opacity: 1;
}

.icon-btn.danger:hover {
  color: var(--danger);
}

.icon-btn.done-btn:hover {
  color: #16a34a; /* soft green on hover */
}

/* Dark theme overrides for table */
:root[data-theme="dark"] .crm-table {
  background: #020617;
}

:root[data-theme="dark"] .crm-table thead {
  background: #020617;
}

:root[data-theme="dark"] .crm-table tbody tr:hover {
  background: #020617;
}

:root[data-theme="dark"] .new-row {
  background: #020617;
}

:root[data-theme="dark"] .crm-table th,
:root[data-theme="dark"] .crm-table td {
  border-bottom-color: #1f2937;
}
