/* table.css - Virtualized Spreadsheet DataGrid */
#grid-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background-color: var(--bg-main);
}

/* Header Row */
#grid-header-viewport {
  overflow: hidden;
  background-color: var(--bg-surface);
  border-bottom: 2px solid var(--border-color);
  flex-shrink: 0;
  user-select: none;
}

#grid-header {
  display: flex;
  height: var(--row-height);
  position: relative;
}

.grid-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-right: 1px solid var(--border-color);
  position: relative;
  box-sizing: border-box;
  flex-shrink: 0;
  cursor: pointer;
}

.grid-col-header:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.grid-col-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-col-sort {
  font-size: 9px;
  margin-left: 4px;
  opacity: 0.8;
}

.grid-col-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 5;
}

.grid-col-resizer:hover {
  background-color: var(--accent);
}

/* Body & Virtual Scroll */
#grid-body-viewport {
  flex: 1;
  overflow: auto;
  position: relative;
  outline: none;
}

#grid-scroll-content {
  position: relative;
  width: 100%;
}

#grid-rows-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}

/* Grid Row */
.grid-row {
  display: flex;
  height: var(--row-height);
  position: absolute;
  left: 0;
  right: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  background-color: var(--bg-main);
  box-sizing: border-box;
  cursor: default;
}

.grid-row:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.015);
}

.grid-row:hover {
  background-color: var(--bg-hover);
}

.grid-row.selected {
  background-color: var(--bg-selected);
  color: var(--text-main);
}

.grid-row.selected.focused {
  background-color: var(--bg-selected-focus);
  color: var(--text-invert);
}

.grid-row.modified {
  border-left: 3px solid var(--warning);
}

/* Grid Cell */
.grid-cell {
  display: flex;
  align-items: center;
  padding: 0 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  box-sizing: border-box;
  flex-shrink: 0;
  position: relative;
}

.grid-cell:hover:not(.cell-checkbox) {
  outline: 1px dashed rgba(59, 130, 246, 0.4);
  outline-offset: -1px;
}

.grid-cell.cell-checkbox {
  justify-content: center;
  align-items: center;
  padding: 0;
}

.grid-cell.cell-checkbox input[type="checkbox"],
.grid-col-header input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  background-color: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all var(--transition-fast);
  margin: 0;
  outline: none;
}

.grid-cell.cell-checkbox input[type="checkbox"]:hover,
.grid-col-header input[type="checkbox"]:hover {
  border-color: var(--accent);
  background-color: var(--bg-hover);
}

.grid-cell.cell-checkbox input[type="checkbox"]:checked,
.grid-col-header input[type="checkbox"]:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

.grid-cell.cell-checkbox input[type="checkbox"]:checked::after,
.grid-col-header input[type="checkbox"]:checked::after {
  content: '';
  width: 3px;
  height: 7px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  position: absolute;
  top: 1px;
}

.grid-cell.cell-numeric {
  justify-content: flex-end;
  font-family: var(--font-mono);
  font-size: 11px;
}

.grid-cell.cell-modified {
  color: var(--warning);
  font-weight: 500;
}

/* Inline Edit Input */
.grid-cell.editing {
  padding: 0;
  overflow: visible;
  z-index: 50;
}

.grid-cell-input {
  width: 100%;
  height: 100%;
  background: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border: 2px solid var(--accent) !important;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
  padding: 0 6px;
  font-size: 12px;
  font-family: inherit;
  box-sizing: border-box;
  outline: none;
  border-radius: 2px;
  margin: 0;
}

/* Empty State / Dropzone */
#grid-empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  pointer-events: auto;
  border: 2px dashed transparent;
  transition: all var(--transition-normal);
}

#grid-empty-state.dragover {
  border-color: var(--accent);
  background-color: var(--accent-light);
  color: var(--text-main);
}

.empty-icon {
  width: 64px;
  height: 64px;
  opacity: 0.4;
  fill: currentColor;
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-desc {
  font-size: 13px;
  max-width: 360px;
  text-align: center;
  line-height: 1.5;
}
