/**
 * @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-color);
  border-radius: var(--fd-radius-lg);
  background-color: var(--fd-surface-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-color-gray-50);
  cursor: pointer;
  text-align: left;
  transition: background-color var(--fd-transition-fast);
}

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

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

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

.fd-data-viewer__chevron {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--fd-color-gray-500);
  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-color-gray-900);
  border-block-end: var(--fd-border-width) solid var(--fd-color-gray-700);
}

.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-font-size-xs);
  font-weight: var(--fd-font-weight-medium);
  color: var(--fd-color-gray-300);
  background-color: transparent;
  border: var(--fd-border-width) solid var(--fd-color-gray-600);
  border-radius: var(--fd-radius-md);
  cursor: pointer;
  transition: all var(--fd-transition-fast);
}

.fd-data-viewer__copy-btn:hover {
  color: var(--fd-color-gray-100);
  background-color: var(--fd-color-gray-800);
  border-color: var(--fd-color-gray-500);
}

.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-color-gray-900);
}

.fd-data-viewer__code {
  font-family: var(--fd-font-family-mono);
  font-size: var(--fd-font-size-xs);
  line-height: var(--fd-line-height-relaxed);
  color: var(--fd-color-gray-100);
  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-color-gray-400);
  font-size: var(--fd-font-size-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-color-success-50);
}

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

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

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

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

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

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

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

/* 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-color-gray-800);
}

.fd-data-viewer__pre::-webkit-scrollbar-thumb {
  background: var(--fd-color-gray-600);
  border-radius: var(--fd-radius-full);
}

.fd-data-viewer__pre::-webkit-scrollbar-thumb:hover {
  background: var(--fd-color-gray-500);
}
