/* Data file card (inline in chat) */
.data-file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.data-file-card:hover {
  background: var(--bg-secondary, #1e1e1e);
}

.data-file-card-icon {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}

.data-file-card-info {
  flex: 1;
  min-width: 0;
}

.data-file-card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-file-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.data-file-format-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.data-file-size {
  font-size: 11px;
  color: var(--text-muted);
}

.data-file-card-save {
  flex-shrink: 0;
  color: var(--text-muted);
  opacity: 0.5;
  transition: opacity 0.15s;
}

.data-file-card:hover .data-file-card-save {
  opacity: 1;
}

/* Data file modal overlay */
.data-file-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.data-file-modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 85%;
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.data-file-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-secondary, #1e1e1e);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 1;
}

.data-file-modal-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.data-file-modal-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-file-modal-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Modal body */
.data-file-modal-body {
  flex: 1;
  overflow: auto;
  padding: 20px 24px;
}

/* Markdown body — reuse markdown-detail-modal styles */
.data-file-body-md {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

.data-file-body-md h1 { font-size: 20px; font-weight: 600; margin: 0 0 12px 0; }
.data-file-body-md h2 { font-size: 16px; font-weight: 600; margin: 16px 0 8px 0; }
.data-file-body-md h3 { font-size: 14px; font-weight: 600; margin: 12px 0 6px 0; }
.data-file-body-md p { margin: 0 0 10px 0; }
.data-file-body-md ul, .data-file-body-md ol { margin: 0 0 10px 0; padding-left: 24px; }
.data-file-body-md li { margin-bottom: 4px; }
.data-file-body-md a { color: var(--accent); }
.data-file-body-md strong { font-weight: 600; }
.data-file-body-md code { background: rgba(255,255,255,0.06); padding: 2px 5px; border-radius: 3px; font-family: 'SF Mono', Monaco, monospace; font-size: 13px; }
.data-file-body-md pre { background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 6px; padding: 12px; overflow-x: auto; margin: 0 0 10px 0; }
.data-file-body-md pre code { background: none; padding: 0; }
.data-file-body-md table { width: 100%; border-collapse: collapse; margin: 0 0 10px 0; font-size: 13px; }
.data-file-body-md th, .data-file-body-md td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.data-file-body-md th { font-weight: 500; color: var(--text-muted); }

/* Text/JSON body */
.data-file-body-text pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  font-family: 'SF Mono', Monaco, monospace;
}

/* Table body (CSV) */
.data-file-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.data-file-body-table {
  overflow: auto;
}

.data-file-table th,
.data-file-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-file-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-file-table th {
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.data-file-table .data-file-row-num {
  color: var(--text-muted);
  text-align: right;
  width: 40px;
  min-width: 40px;
  white-space: nowrap;
  padding-right: 8px;
  user-select: none;
}

.data-file-table th:first-child {
  border-left: 1px solid var(--border);
  border-radius: 6px 0 0 6px;
}

.data-file-table th:last-child {
  border-right: 1px solid var(--border);
  border-radius: 0 6px 6px 0;
}

/* Sortable column headers */
.data-file-sortable-th {
  cursor: pointer;
  user-select: none;
}

.data-file-sortable-th:hover {
  color: var(--text);
}

.data-file-sort-arrow {
  font-size: 10px;
  opacity: 0.7;
}

/* Clickable links in data files */
.data-file-link {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.data-file-link:hover {
  text-decoration: underline;
}

/* HTML iframe body */
.data-file-iframe {
  width: 100%;
  height: 100%;
  min-height: 500px;
  border: none;
  background: #fff;
  border-radius: 4px;
}

.data-file-body-html {
  padding: 0;
}
