/* Table View Styles */

.main--wide {
  max-width: 1400px;
}

/* Toolbar */
.table-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: center;
}

.table-toolbar .filter-chip {
  font-size: 0.68rem;
}

/* Table wrapper */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.74rem;
  line-height: 1.35;
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--bg-warm);
  border-bottom: 2px solid var(--border-strong, #d5d0c8);
  padding: 0.5rem 0.65rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.data-table th {
  position: relative;
}
.data-table th:hover .th-label {
  color: var(--accent);
}
.th-label {
  cursor: pointer;
}
.th-resize {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  background: transparent;
  z-index: 2;
}
.th-resize:hover,
.th-resize:active {
  background: var(--accent);
  opacity: 0.3;
}

.data-table th .sort-arrow {
/* legacy sort arrow styles */
  margin-left: 0.25rem;
  opacity: 0.4;
}

.data-table th .sort-arrow.active {
  opacity: 1;
  color: var(--accent);
}

.data-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  max-width: 300px;
}

.data-table tbody tr {
  transition: background 0.1s;
}

.data-table tbody tr:hover {
  background: var(--bg-warm);
}

.data-table tbody tr.hidden {
  display: none;
}

/* Editable cells */
.cell-edit {
  width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 0.15rem 0.25rem;
  border-radius: 4px;
  resize: none;
  min-height: 1.6em;
  outline: none;
}

.cell-edit:focus {
  background: #fffdf5;
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.cell-edit:hover:not(:focus) {
  background: rgba(139, 105, 20, 0.04);
}

/* Status cell */
.cell-status {
  font-size: 0.72rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

.cell-status:focus {
  border-color: var(--accent);
  outline: none;
}

/* Priority badge in table */
.priority-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 0.3rem;
  vertical-align: middle;
}

.priority-dot.high { background: #dc2626; }
.priority-dot.medium { background: var(--accent); }
.priority-dot.low { background: var(--text-muted); }

/* Status dot in table */
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
}

/* Title link */
.cell-title {
  color: var(--text-primary, #2c2825);
  text-decoration: none;
  font-weight: 500;
}

.cell-title:hover {
  color: var(--accent);
}

/* Notes cell */
.cell-notes {
  color: var(--text-muted);
  font-size: 0.72rem;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Table footer */
.table-footer {
  padding: 0.6rem 0.75rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Save flash */
.cell-saved {
  animation: cell-flash 0.6s ease;
}

@keyframes cell-flash {
  0% { background: rgba(45, 106, 79, 0.15); }
  100% { background: transparent; }
}

.cell-error {
  animation: cell-error-flash 0.6s ease;
}

@keyframes cell-error-flash {
  0% { background: rgba(220, 38, 38, 0.15); }
  100% { background: transparent; }
}

/* Toolbar select */
.toolbar-select {
  font-size: 0.72rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  font-family: inherit;
  color: var(--text-primary, #2c2825);
  cursor: pointer;
}

.toolbar-select:focus {
  border-color: var(--accent);
  outline: none;
}

/* Add record button */
.btn-add {
  font-size: 0.72rem;
  padding: 0.25rem 0.65rem;
  border: 1px dashed var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(139, 105, 20, 0.04);
}

/* Group header row */
.group-header td {
  background: var(--bg-warm);
  padding: 0.5rem 0.65rem;
  font-weight: 600;
  font-size: 0.75rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.group-header:hover td {
  background: #f0ece4;
}

.group-arrow {
  display: inline-block;
  margin-right: 0.4rem;
  transition: transform 0.15s;
  font-size: 0.65rem;
}

.group-arrow.collapsed {
  transform: rotate(-90deg);
}

.group-name {
  color: var(--text-primary, #2c2825);
}

.group-count {
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 0.4rem;
  font-size: 0.68rem;
}

/* Delete button */
.cell-delete {
  width: 28px;
  text-align: center;
}

.btn-delete {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.72rem;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  opacity: 0;
  transition: all 0.15s;
}

.data-table tbody tr:hover .btn-delete {
  opacity: 0.5;
}

.btn-delete:hover {
  opacity: 1 !important;
  color: #dc2626;
  background: rgba(220, 38, 38, 0.08);
}

/* Linked record pills */
.cell-linked {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: center;
  min-height: 1.6em;
}

.linked-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(139, 105, 20, 0.08);
  border: 1px solid rgba(139, 105, 20, 0.15);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.68rem;
  color: var(--text-primary, #2c2825);
  max-width: 160px;
  white-space: nowrap;
}

.linked-pill__text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.linked-pill__x {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0 1px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.1s;
}

.linked-pill:hover .linked-pill__x {
  opacity: 0.6;
}

.linked-pill__x:hover {
  opacity: 1 !important;
  color: #dc2626;
}

.linked-add {
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.72rem;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  flex-shrink: 0;
}

.linked-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(139, 105, 20, 0.04);
}

/* Link picker dropdown */
.link-picker {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  width: 240px;
  max-height: 280px;
  display: flex;
  flex-direction: column;
}

.link-picker__search {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.6rem;
  font-size: 0.72rem;
  font-family: inherit;
  outline: none;
}

.link-picker__search:focus {
  background: #fffdf5;
}

.link-picker__list {
  overflow-y: auto;
  max-height: 220px;
}

.link-picker__item {
  padding: 0.35rem 0.6rem;
  font-size: 0.72rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-picker__item:hover {
  background: rgba(139, 105, 20, 0.06);
  color: var(--accent);
}

.link-picker__empty,
.link-picker__more {
  padding: 0.4rem 0.6rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Email cell */
.cell-email__link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.72rem;
}
.cell-email__link:hover { text-decoration: underline; }

/* URL cell */
.cell-url__link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.68rem;
}
.cell-url__link:hover { color: var(--accent); text-decoration: underline; }

/* Flag/checkbox cell */
.cell-flag {
  text-align: center;
}
.cell-flag input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Responsive */
@media (max-width: 900px) {
  .main--wide {
    padding: 1rem;
  }
  .data-table {
    font-size: 0.72rem;
  }
  .data-table td, .data-table th {
    padding: 0.35rem 0.5rem;
  }
}
