/**
 * Spreadsheet Component Styles
 *
 * Custom styling for react-spreadsheet to match notebook-ui's paper aesthetic
 */

/* Container */
.spreadsheet-container {
  width: 100%;
  overflow: auto;
  background-color: #fafaf9; /* paper-50 */
  border-radius: 0.5rem;
  border: 1px solid #e7e5e4; /* stone-200 */
}

/* Spreadsheet base */
.notebook-spreadsheet {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.875rem;
  color: #1c1917; /* ink-900 */
}

/* Table styling */
.notebook-spreadsheet table {
  border-collapse: separate;
  border-spacing: 0;
  background-color: #ffffff;
  width: 100%;
}

/* Cell styling */
.notebook-spreadsheet td {
  border: 1px solid #e7e5e4; /* stone-200 */
  padding: 0;
  background-color: #ffffff;
  transition: background-color 0.15s ease;
}

/* Cell hover */
.notebook-spreadsheet td:hover {
  background-color: #fafaf9; /* paper-50 */
}

/* Selected cell */
.notebook-spreadsheet td.Spreadsheet__active-cell {
  border: 2px solid #334155; /* primary-700 */
  box-shadow: 0 0 0 1px #334155;
  background-color: #ffffff;
  z-index: 10;
}

/* Header cells (row/column labels) */
.notebook-spreadsheet th {
  background-color: #f5f5f4; /* stone-100 */
  color: #57534e; /* ink-600 */
  border: 1px solid #e7e5e4; /* stone-200 */
  padding: 0.5rem;
  font-weight: 600;
  font-size: 0.75rem;
  text-align: center;
  position: sticky;
  z-index: 5;
}

/* Column headers */
.notebook-spreadsheet thead th {
  top: 0;
  z-index: 10;
}

/* Row headers */
.notebook-spreadsheet tbody th {
  left: 0;
  z-index: 5;
}

/* Corner header (top-left cell) */
.notebook-spreadsheet thead th:first-child {
  left: 0;
  z-index: 15;
}

/* Cell input */
.notebook-spreadsheet .Spreadsheet__data-editor {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  padding: 0.5rem;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background-color: #ffffff;
  box-sizing: border-box;
}

.notebook-spreadsheet .Spreadsheet__data-editor:focus {
  background-color: #ffffff;
  border: 2px solid #334155; /* primary-700 */
  padding: calc(0.5rem - 1px);
}

/* Cell with formula indicator */
.notebook-spreadsheet .Spreadsheet__cell--formula {
  font-style: italic;
  background-color: #f0fdf4; /* success-50 */
}

/* Read-only cells */
.notebook-spreadsheet .Spreadsheet__cell--readonly {
  background-color: #f5f5f4; /* stone-100 */
  color: #78716c; /* ink-500 */
}

/* Selection highlight */
.notebook-spreadsheet .Spreadsheet__cell--selected {
  background-color: #e0f2fe; /* primary-100 */
}

/* Cell error state */
.notebook-spreadsheet .Spreadsheet__cell--error {
  background-color: #fef2f2; /* error-50 */
  color: #991b1b; /* error-800 */
}

/* Cell value display */
.notebook-spreadsheet .Spreadsheet__value {
  padding: 0.5rem;
  min-height: 2rem;
  display: flex;
  align-items: center;
}

/* Number cells - align right */
.notebook-spreadsheet .Spreadsheet__cell--number .Spreadsheet__value {
  justify-content: flex-end;
  font-variant-numeric: tabular-nums;
}

/* Empty cells */
.notebook-spreadsheet .Spreadsheet__cell--empty .Spreadsheet__value {
  color: #a8a29e; /* ink-400 */
}

/* Copy/paste indicator */
.notebook-spreadsheet .Spreadsheet__floating-rect {
  border: 2px dashed #334155; /* primary-700 */
  background-color: rgba(51, 65, 85, 0.1);
  pointer-events: none;
}

/* Scrollbar styling for webkit browsers */
.spreadsheet-container::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.spreadsheet-container::-webkit-scrollbar-track {
  background-color: #fafaf9; /* paper-50 */
  border-radius: 0.5rem;
}

.spreadsheet-container::-webkit-scrollbar-thumb {
  background-color: #d6d3d1; /* stone-300 */
  border-radius: 0.5rem;
  border: 2px solid #fafaf9;
}

.spreadsheet-container::-webkit-scrollbar-thumb:hover {
  background-color: #a8a29e; /* ink-400 */
}

/* Loading state */
.spreadsheet-container.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .notebook-spreadsheet {
    font-size: 0.75rem;
  }

  .notebook-spreadsheet .Spreadsheet__value {
    padding: 0.375rem;
    min-height: 1.75rem;
  }

  .notebook-spreadsheet .Spreadsheet__data-editor {
    padding: 0.375rem;
  }

  .notebook-spreadsheet th {
    padding: 0.375rem;
    font-size: 0.6875rem;
  }
}

/* Print styles */
@media print {
  .spreadsheet-container {
    border: none;
    overflow: visible;
  }

  .notebook-spreadsheet td,
  .notebook-spreadsheet th {
    border-color: #000;
  }

  .notebook-spreadsheet .Spreadsheet__active-cell {
    border: 1px solid #000;
    box-shadow: none;
  }
}
