/* Spreadsheet viewer styles (mirrors chem-viewer patterns) */

/* === Shared container === */
.sheet-viewer-container {
  position: relative;
  border: 1px solid var(--color-secondary);
  border-radius: var(--border-radius);
  background: var(--color-body);
  margin: 0;
  overflow: hidden;
}

.sheet-viewer-container .format-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 3px;
  background: var(--color-accent);
  color: #fff;
  opacity: 0.85;
  pointer-events: none;
}

/* === Loading state === */
.sheet-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 16px;
  font-size: 14px;
  color: var(--color-text-light);
}

.sheet-loading::before {
  content: '';
  width: 18px;
  height: 18px;
  border: 2px solid var(--color-secondary);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: chem-spin 0.8s linear infinite;
}

/* === Error state === */
.sheet-error {
  padding: 16px;
  font-size: 14px;
  color: var(--color-error-text, var(--color-red));
  background: var(--color-error-bg, rgba(255, 0, 0, 0.05));
  border-radius: var(--border-radius);
  text-align: center;
}

/* === Tab bar === */
.sheet-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid var(--color-secondary);
  background: var(--color-bg, var(--color-body));
  padding: 0 8px;
}

.sheet-tab {
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--color-text-light);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.sheet-tab:hover {
  color: var(--color-text);
}

.sheet-tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
  font-weight: 600;
}

/* === Scrollable content area === */
.sheet-content {
  max-height: 600px;
  overflow: auto;
}

/* === Table === */
table.sheet-table {
  border-collapse: collapse;
  font-size: 13px;
  width: max-content;
  min-width: 100%;
}

table.sheet-table th,
table.sheet-table td {
  padding: 4px 10px;
  white-space: nowrap;
  border: 1px solid var(--color-secondary-alpha-40, rgba(0,0,0,0.06));
  text-align: left;
}

table.sheet-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-box-header);
  font-weight: 600;
  border-bottom: 2px solid var(--color-secondary);
}

/* === Row number gutter === */
.sheet-row-num {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--color-box-header, var(--color-bg));
  color: var(--color-text-light);
  font-size: 12px;
  text-align: right;
  padding-right: 8px !important;
  min-width: 40px;
  user-select: none;
  border-right: 1px solid var(--color-secondary) !important;
}

/* Corner cell: sticky both ways */
table.sheet-table thead th.sheet-row-num {
  z-index: 3;
  left: 0;
}

/* === Truncation warning === */
.sheet-truncated {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--color-text-light);
  text-align: center;
  background: var(--color-box-header, var(--color-bg));
  border-top: 1px solid var(--color-secondary);
}

/* === Info line === */
.sheet-info {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--color-text-light);
  border-top: 1px solid var(--color-secondary);
}

/* === Inline modifier (markdown embeds) === */
.sheet-inline {
  margin: 16px 0;
}

.sheet-inline .sheet-content {
  max-height: 400px;
}

/* === Caption === */
.sheet-caption {
  padding: 6px 12px;
  font-size: 13px;
  color: var(--color-text-light);
  text-align: center;
  border-top: 1px solid var(--color-secondary);
}
