/* FastGrid Styles */

.fast-grid {
  display: flex;
  flex-direction: column;
  /* height removed - let container control its own height */
  width: 100%;
  border: 1px solid #ddd;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

.grid-header {
  overflow: hidden;
  border-bottom: 2px solid #ccc;
  background: #f5f5f5;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.grid-header-row {
  display: flex;
  min-width: fit-content;
}

/* Scroll container for horizontal scrolling */
.grid-scroll-container {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
}

/* Inner container with actual width */
.grid-inner-container {
  display: flex;
  flex-direction: column;
  min-width: fit-content;
  height: 100%;
}

.grid-header-cell {
  display: flex;
  align-items: center;
  padding: 0 36px 0 12px; /* Extra padding on right for menu button */
  font-weight: 600;
  border-right: 1px solid #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #f5f5f5;
  box-sizing: border-box;
}

.grid-header-cell:last-child {
  border-right: none;
}

.grid-header-cell:hover {
  background: #e8e8e8;
}

.grid-header-cell.sorted {
  background: #e0e7ff;
  color: #3730a3;
}

.grid-header-cell.pinned-left {
  background: #fff3e0;
  position: sticky !important;
  left: 0;
  z-index: 3;
}

.grid-cell.pinned-left {
  background: #fffaf3;
  z-index: 2;
  position: relative;
  /* No transition - we want instant response to scroll */
}

.grid-filter-cell.pinned-left,
.grid-footer-cell.pinned-left {
  background: #fff8f0;
  position: sticky !important;
  left: 0;
  z-index: 2;
}

/* Border only on the last pinned column */
.grid-header-cell.pinned-left.last-pinned {
  border-right: 3px solid #ff9800;
}

.grid-cell.pinned-left.last-pinned {
  border-right: 3px solid #ff9800;
}

.grid-filter-cell.pinned-left.last-pinned {
  border-right: 3px solid #ff9800;
}

.grid-footer-cell.pinned-left.last-pinned {
  border-right: 3px solid #ff9800;
}

/* Resize handle */
.grid-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
}

.grid-resize-handle:hover {
  background: rgba(55, 48, 163, 0.2);
}

.grid-resize-handle:active {
  background: rgba(55, 48, 163, 0.4);
}

/* Filter row styles */
.grid-filter-row {
  display: flex;
  min-width: fit-content;
  border-bottom: 1px solid #ddd;
  background: #fafafa;
}

.grid-filter-cell {
  display: flex;
  align-items: center;
  padding: 0;
  margin: 0;
  border-right: 1px solid #ddd;
  box-sizing: border-box;
}

.grid-filter-cell:last-child {
  border-right: none;
}

.grid-filter-input {
  width: 100%;
  height: 100%;
  padding: 6px 12px;
  margin: 0;
  border: none;
  border-radius: 0;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
  background: #fafafa;
}

.grid-filter-input:focus {
  background: #fff;
  box-shadow: inset 0 -2px 0 #3730a3;
}

.grid-filter-input::placeholder {
  color: #aaa;
  font-size: 12px;
}

.grid-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: fit-content;
}

.grid-row {
  display: flex;
  border-bottom: 1px solid #eee;
  min-width: fit-content;
}

.grid-row:hover {
  background: #f9f9f9;
}

.grid-cell {
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-right: 1px solid #f0f0f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.grid-cell:last-child {
  border-right: none;
}

/* Selection styles */
.grid-row.selected {
  background: #e3f2fd;
}

.grid-row.selected:hover {
  background: #bbdefb;
}

/* Cell selection for keyboard navigation */
.grid-cell.selected {
  background: #e3f2fd !important;
  position: relative;
}

/* Selection range border styling */
.grid-cell.selection-top {
  border-top: 2px solid #1976d2 !important;
}

.grid-cell.selection-bottom {
  border-bottom: 2px solid #1976d2 !important;
}

.grid-cell.selection-left {
  border-left: 2px solid #1976d2 !important;
}

.grid-cell.selection-right {
  border-right: 2px solid #1976d2 !important;
}

.grid-cell.focused {
  outline: 2px solid #1976d2 !important;
  outline-offset: -2px;
  z-index: 2;
}

/* Make grid focusable */
.grid-body:focus {
  outline: none;
}

/* Visual feedback for multi-selection */
.grid-cell.selection-start {
  background: #c5cae9 !important;
}

.grid-cell.selection-anchor {
  outline: 2px dashed #3f51b5 !important;
  outline-offset: -2px;
}

/* Footer styles */
.grid-footer {
  border-top: 2px solid #ccc;
  background: #f5f5f5;
  flex-shrink: 0;
  min-width: fit-content;
}

.grid-footer-row {
  display: flex;
  min-width: fit-content;
}

.grid-footer-cell {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-weight: 600;
  border-right: 1px solid #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #f5f5f5;
  box-sizing: border-box;
  color: #3730a3;
}

.grid-footer-cell:last-child {
  border-right: none;
}

/* Column Menu Styles */
.grid-column-menu-button {
  margin-right: 0px;
  position: absolute;
  right: 1px; /* Very close to the right edge, near resize handle */
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: transparent;
  color: #666;
  cursor: pointer;
  display: flex; /* Always visible */
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.grid-column-menu-button:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #333;
}

.grid-column-menu-button:active {
  background: rgba(0, 0, 0, 0.2);
}

.grid-column-menu-dropdown {
  position: fixed;
  background: white;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  min-width: 200px;
  max-width: 300px;
  max-height: 400px;
  overflow-y: auto;
  font-size: 13px;
  z-index: 10000;
}

.grid-column-menu-section {
  padding: 8px 12px 4px;
  font-weight: 600;
  color: #666;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.grid-column-menu-item {
  padding: 6px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  transition: background 0.1s;
}

.grid-column-menu-item:hover,
.grid-column-menu-item.focused {
  background: #f5f5f5;
}

.grid-column-menu-item:active {
  background: #e8e8e8;
}

.grid-column-menu-item input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

.menu-item-icon {
  width: 16px;
  text-align: center;
  color: #666;
  font-size: 14px;
  flex-shrink: 0;
}

.menu-item-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grid-column-menu-separator {
  height: 1px;
  background: #e0e0e0;
  margin: 4px 0;
}

/* Pinned columns structure */
.grid-pinned-left {
  flex-shrink: 0;
  overflow: hidden;
  border-right: 2px solid #999;
  background: #fafafa;
  position: relative;
  z-index: 2;
}

.grid-pinned-right {
  flex-shrink: 0;
  overflow: hidden;
  border-left: 2px solid #999;
  background: #fafafa;
  position: relative;
  z-index: 2;
}

.grid-center {
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

.grid-pinned-section {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.grid-pinned-header {
  display: flex;
  background: #f5f5f5;
}

.grid-pinned-body {
  flex: 1;
  overflow: hidden;
}

.grid-pinned-footer {
  display: flex;
  background: #f5f5f5;
  border-top: 2px solid #ccc;
}

/* Toolbar styles */
.grid-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  background: #fafafa;
  border-bottom: 1px solid #ddd;
  flex-shrink: 0;
}

.grid-toolbar-left {
  display: flex;
  align-items: center;
}

.grid-toolbar-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.grid-toolbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.grid-toolbar-rowcount {
  font-size: 14px;
  color: #666;
  font-weight: 500;
}

.grid-toolbar-export {
  position: relative;
}

.grid-toolbar-export-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  background: #2196f3;
  color: white;
  transition: background 0.2s;
}

.grid-toolbar-export-btn:hover {
  background: #1976d2;
}

.grid-toolbar-export-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  min-width: 180px;
  z-index: 1000;
}

.grid-toolbar-export-option {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.1s;
}

.grid-toolbar-export-option:hover {
  background: #f5f5f5;
}

.grid-toolbar-export-option:active {
  background: #e8e8e8;
}

/* Group row styles */
.grid-group-row {
  background: #f0f7ff;
  font-weight: 600;
}

.grid-group-row:hover {
  background: #e3f2fd;
}

.grid-group-cell {
  color: #1976d2;
}

.group-expand-icon {
  display: inline-block;
  width: 16px;
  font-size: 12px;
  text-align: center;
}

/* Row selection column styles */
.grid-selection-header,
.grid-selection-cell,
.grid-selection-filter {
  min-width: 60px;
  max-width: 60px;
  flex-shrink: 0;
  background: #fafafa !important;
  border-right: 1px solid #e0e0e0 !important;
}

.grid-selection-header {
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-select-all-checkbox,
.grid-row-checkbox {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.grid-selection-cell .row-number {
  user-select: none;
  min-width: 20px;
  text-align: right;
}

/* Make selection column always visible when pinned */
.grid-selection-header.pinned-left,
.grid-selection-cell.pinned-left,
.grid-selection-filter.pinned-left {
  position: sticky;
  left: 0;
  z-index: 3;
}
