/**
 * @file
 * FlowDrop Data Viewer Component Styles
 *
 * Provides styling for JSON data display with collapsible sections,
 * syntax highlighting, and copy functionality.
 */

.fd-data-viewer {
  overflow: hidden;
  border: var(--fd-border-width) solid var(--fd-border);
  border-radius: var(--fd-radius-lg);
  background-color: var(--fd-card);
}

/* ========================================================================
 * HEADER / TOGGLE BUTTON
 * ======================================================================== */

.fd-data-viewer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 0;
  padding: var(--fd-space-3) var(--fd-space-4);
  cursor: pointer;
  transition: background-color var(--fd-transition-fast);
  text-align: left;
  border: none;
  background-color: var(--fd-muted);
}

.fd-data-viewer__header:hover {
  background-color: var(--fd-subtle);
}

.fd-data-viewer__header:focus-visible {
  outline: 2px solid var(--fd-primary);
  outline-offset: -2px;
}

.fd-data-viewer__label {
  letter-spacing: var(--fd-letter-spacing-wide);
  text-transform: uppercase;
  color: var(--fd-foreground);
  font-size: var(--fd-text-sm);
  font-weight: var(--fd-font-weight-semibold);
}

.fd-data-viewer__chevron {
  width: 1.25rem;
  height: 1.25rem;
  transition: transform var(--fd-transition-fast);
  color: var(--fd-muted-foreground);
}

.fd-data-viewer__header[aria-expanded="true"] .fd-data-viewer__chevron {
  transform: rotate(180deg);
}

/* ========================================================================
 * CONTENT AREA
 * ======================================================================== */

.fd-data-viewer__content {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows var(--fd-transition-normal);
}

.fd-data-viewer__content--collapsed {
  grid-template-rows: 0fr;
}

.fd-data-viewer__content--collapsed > * {
  overflow: hidden;
}

/* Toolbar */
.fd-data-viewer__toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: var(--fd-space-2) var(--fd-space-4);
  border-block-end: var(--fd-border-width) solid var(--fd-foreground);
  background-color: var(--fd-foreground);
  gap: var(--fd-space-2);
}

.fd-data-viewer__copy-btn {
  display: inline-flex;
  align-items: center;
  padding: var(--fd-space-1) var(--fd-space-2);
  cursor: pointer;
  transition: all var(--fd-transition-fast);
  color: var(--fd-border-muted);
  border: var(--fd-border-width) solid var(--fd-muted-foreground);
  border-radius: var(--fd-radius-md);
  background-color: transparent;
  font-size: var(--fd-text-xs);
  font-weight: var(--fd-font-weight-medium);
  gap: var(--fd-space-1);
}

.fd-data-viewer__copy-btn:hover {
  color: var(--fd-subtle);
  border-color: var(--fd-muted-foreground);
  background-color: var(--fd-foreground);
}

.fd-data-viewer__copy-btn svg {
  width: 0.875rem;
  height: 0.875rem;
}

/* Code container */
.fd-data-viewer__pre {
  overflow: auto;
  max-height: var(--fd-data-viewer-max-height, 300px);
  margin: 0;
  padding: var(--fd-space-4);
  background-color: var(--fd-foreground);
}

.fd-data-viewer__code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--fd-subtle);
  font-family: var(--fd-font-family-mono);
  font-size: var(--fd-text-xs);
  line-height: var(--fd-line-height-relaxed);
}

/* JSON syntax highlighting classes (applied via JS) */
.fd-json-key {
  color: #7dd3fc; /* Cyan for keys */
}

.fd-json-string {
  color: #86efac; /* Green for strings */
}

.fd-json-number {
  color: #fcd34d; /* Yellow for numbers */
}

.fd-json-boolean {
  color: #f472b6; /* Pink for booleans */
}

.fd-json-null {
  color: #94a3b8; /* Gray for null */
}

.fd-json-bracket {
  color: #cbd5e1; /* Light gray for brackets */
}

/* Empty state */
.fd-data-viewer__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--fd-space-2);
  padding: var(--fd-space-6);
  color: var(--fd-muted-foreground);
  font-size: var(--fd-text-sm);
}

.fd-data-viewer__empty svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* ========================================================================
 * VARIANT STYLES
 * ======================================================================== */

.fd-data-viewer--success .fd-data-viewer__header {
  background-color: var(--fd-success-muted);
}

.fd-data-viewer--success .fd-data-viewer__label {
  color: var(--fd-success-hover);
}

.fd-data-viewer--warning .fd-data-viewer__header {
  background-color: var(--fd-warning-muted);
}

.fd-data-viewer--warning .fd-data-viewer__label {
  color: var(--fd-warning-hover);
}

.fd-data-viewer--error .fd-data-viewer__header {
  background-color: var(--fd-error-muted);
}

.fd-data-viewer--error .fd-data-viewer__label {
  color: var(--fd-error-hover);
}

.fd-data-viewer--info .fd-data-viewer__header {
  background-color: var(--fd-info-muted);
}

.fd-data-viewer--info .fd-data-viewer__label {
  color: var(--fd-info);
}

/* Scrollbar styling for dark code area */
.fd-data-viewer__pre::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.fd-data-viewer__pre::-webkit-scrollbar-track {
  background: var(--fd-foreground);
}

.fd-data-viewer__pre::-webkit-scrollbar-thumb {
  border-radius: var(--fd-radius-full);
  background: var(--fd-muted-foreground);
}

.fd-data-viewer__pre::-webkit-scrollbar-thumb:hover {
  background: var(--fd-muted-foreground);
}
