/* Kirin HTML Representation Styles - Shared across all widgets */
:root {
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%;
  --card-foreground: 222.2 84% 4.9%;
  --primary: 221.2 83.2% 53.3%;
  --primary-foreground: 210 40% 98%;
  --secondary: 210 40% 96%;
  --secondary-foreground: 222.2 84% 4.9%;
  --muted: 210 40% 96%;
  --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 210 40% 96%;
  --accent-foreground: 222.2 84% 4.9%;
  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;
  --ring: 221.2 83.2% 53.3%;
  --radius: 0.5rem;
}

* {
  border-color: hsl(var(--border));
  box-sizing: border-box;
}

body {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  margin: 0;
  padding: 0;
}

/* Layout */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-4 {
  gap: 1rem;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mt-2 {
  margin-top: 0.5rem;
}

.mt-4 {
  margin-top: 1rem;
}

.pt-4 {
  padding-top: 1rem;
}

.p-4 {
  padding: 1rem;
}

.border-t {
  border-top: 1px solid hsl(var(--border));
}

/* Typography */
.text-sm {
  font-size: 0.875rem;
}

.text-lg {
  font-size: 1.125rem;
}

.font-medium {
  font-weight: 500;
}

.font-semibold {
  font-weight: 600;
}

.text-muted-foreground {
  color: hsl(var(--muted-foreground));
}

.text-primary {
  color: hsl(var(--primary));
}

/* Components */
.panel {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
}

.panel-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--muted));
}

.panel-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
  color: hsl(var(--foreground));
}

.panel-content {
  padding: 1.5rem;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  transition: all 0.2s;
  margin-bottom: 0.5rem;
  cursor: pointer;
}

.file-item:hover {
  border-color: hsl(var(--ring));
  background: hsl(var(--accent));
}

.file-item .copy-code-btn {
  margin-left: auto;
  margin-right: 0.5rem;
}

.file-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: hsl(var(--muted-foreground));
  opacity: 0.6;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-name {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.file-size {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.commit-item {
  padding: 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  margin-bottom: 0.5rem;
}

.commit-item:last-child {
  border-bottom: none;
}

.commit-hash {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875rem;
  background: hsl(var(--muted));
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  color: hsl(var(--primary));
  display: inline-block;
}

.commit-message {
  font-weight: 500;
  margin: 0.25rem 0;
  color: hsl(var(--foreground));
}

.commit-timestamp {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: calc(var(--radius) / 2);
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.space-y-4 > * + * {
  margin-top: 1rem;
}

.hidden {
  display: none;
}

/* Buttons - matching web UI */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  box-sizing: border-box;
  line-height: 1.5;
  height: 2.5rem;
  vertical-align: top;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  background: transparent;
  color: hsl(var(--foreground));
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

.btn-primary:hover:not(:disabled) {
  background: hsl(var(--primary) / 0.9);
}

.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
}

.btn-secondary:hover:not(:disabled) {
  background: hsl(var(--secondary) / 0.8);
}

.btn-ghost {
  background: transparent;
  color: hsl(var(--foreground));
  border-color: transparent;
  height: auto;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

.btn-ghost:hover:not(:disabled) {
  background: hsl(var(--accent));
}

.btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  height: auto;
}

/* Copy button styles */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  background-color: transparent;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: all 0.2s ease;
  height: auto;
}

.copy-btn:hover {
  color: hsl(var(--foreground));
  background-color: hsl(var(--muted));
  border-color: hsl(var(--border));
}

.copy-btn:active {
  transform: translateY(1px);
}

.copy-btn.copied {
  color: hsl(var(--primary));
  background-color: hsl(var(--primary) / 0.1);
  border-color: hsl(var(--primary));
}

.copy-code-btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  height: auto;
  min-height: 1.75rem;
}

.copy-code-btn.copied {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

/* Code snippet styles */
.code-snippet {
  position: relative;
  background-color: transparent;
  border: none;
  overflow: hidden;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  width: 100%;
  padding-left: 1.75rem;
}

.code-snippet.hidden {
  display: none;
}

.code-snippet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background-color: hsl(var(--muted));
  border-bottom: 1px solid hsl(var(--border));
}

.code-snippet-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.code-snippet-content {
  padding: 0;
  background-color: transparent;
}

.code-snippet pre {
  margin: 0;
  padding: 0.75rem 1rem;
  background-color: transparent;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  color: hsl(var(--foreground));
  overflow-x: auto;
  white-space: pre;
}

.code-snippet code {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* File actions */
.file-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Widget-specific view containers */
.kirin-dataset-view,
.kirin-commit-view,
.kirin-catalog-view {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  color: hsl(var(--foreground));
}

.kirin-file-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* File preview styles */
.file-preview {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.file-preview .panel {
  margin: 0;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background-color: hsl(var(--card));
}

.file-preview .panel-header {
  background-color: hsl(var(--muted));
  border-bottom: 1px solid hsl(var(--border));
  padding: 0.75rem 1rem;
}

.file-preview .panel-header .panel-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  margin: 0;
}

.file-preview .panel-content {
  padding: 1rem;
}

/* CSV table preview styles */
.file-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background-color: hsl(var(--card));
}

.file-preview table thead {
  background-color: hsl(var(--muted));
}

.file-preview table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 500;
  color: hsl(var(--foreground));
  border-bottom: 2px solid hsl(var(--border));
  white-space: nowrap;
}

.file-preview table td {
  padding: 0.75rem 1rem;
  color: hsl(var(--foreground));
  border-bottom: 1px solid hsl(var(--border));
}

.file-preview table tbody tr {
  transition: background-color 0.15s ease;
}

.file-preview table tbody tr:hover {
  background-color: hsl(var(--muted));
}

.file-preview table tbody tr:last-child td {
  border-bottom: none;
}

.file-preview .overflow-auto {
  max-height: 400px;
  overflow-y: auto;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--border));
}

/* JSON/text preview styles */
.file-preview pre {
  margin: 0;
  padding: 1rem;
  background-color: hsl(var(--muted));
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--border));
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
}

.file-preview pre code {
  font-family: "SF Mono", "Monaco", "Inconsolata", "Roboto Mono",
    "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  color: hsl(var(--foreground));
  background: transparent;
  padding: 0;
  border: none;
  white-space: pre;
  word-wrap: normal;
}
