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

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

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

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

.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 {
  font-size: var(--fd-text-sm);
  font-weight: var(--fd-font-weight-semibold);
  color: var(--fd-foreground);
  text-transform: uppercase;
  letter-spacing: var(--fd-letter-spacing-wide);
}

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

.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;
  gap: var(--fd-space-2);
  padding: var(--fd-space-2) var(--fd-space-4);
  background-color: var(--fd-foreground);
  border-block-end: var(--fd-border-width) solid var(--fd-foreground);
}

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

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

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

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

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

/* 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 {
  background: var(--fd-muted-foreground);
  border-radius: var(--fd-radius-full);
}

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