/**
 * JsonPathBrowser styles
 * @countermeasure/web-components/visualization/json-path-browser
 */

/* ============================================================================
   Base
   ============================================================================ */
.cmm-json-path {
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* ============================================================================
   Toolbar
   ============================================================================ */
.cmm-json-path__toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--muted));
}

.cmm-json-path__btn {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.cmm-json-path__btn:hover {
  border-color: hsl(var(--primary));
  color: hsl(var(--foreground));
}

.cmm-json-path__btn:focus-visible {
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: 2px;
}

.cmm-json-path__search {
  flex: 1;
  min-width: 120px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-family: inherit;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition-fast);
}

.cmm-json-path__search:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 2px hsl(var(--focus-ring) / 0.3);
}

.cmm-json-path__search::placeholder {
  color: hsl(var(--muted-foreground));
}

/* ============================================================================
   Path bar
   ============================================================================ */
.cmm-json-path__path-bar {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted));
  border-bottom: 1px solid hsl(var(--border));
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  user-select: all;
}

.cmm-json-path__path-bar:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--accent));
}

.cmm-json-path__path-bar--copied {
  color: hsl(142 71% 45%);
}

/* ============================================================================
   Tree
   ============================================================================ */
.cmm-json-path__tree {
  padding: 0.5rem;
  overflow: auto;
  max-height: 600px;
}

.cmm-json-path__node {
  /* depth-based indent applied via inline style */
}

.cmm-json-path__node--highlight {
  background: hsl(48 96% 53% / 0.12);
  border-radius: var(--radius-sm);
}

.cmm-json-path__row {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  padding: 0.125rem 0.25rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.cmm-json-path__row:hover {
  background: hsl(var(--muted));
}

/* ============================================================================
   Arrow toggle
   ============================================================================ */
.cmm-json-path__arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  cursor: pointer;
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  user-select: none;
  transition: color var(--transition-fast);
}

.cmm-json-path__arrow:hover {
  color: hsl(var(--foreground));
}

.cmm-json-path__arrow-spacer {
  display: inline-block;
  width: 1rem;
  flex-shrink: 0;
}

/* ============================================================================
   Key & colon
   ============================================================================ */
.cmm-json-path__key {
  color: hsl(var(--foreground));
  font-weight: 500;
  cursor: pointer;
}

.cmm-json-path__key:hover {
  text-decoration: underline;
}

.cmm-json-path__colon {
  color: hsl(var(--muted-foreground));
}

/* ============================================================================
   Values (color-coded by type)
   ============================================================================ */
.cmm-json-path__value {
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.cmm-json-path__value:hover {
  opacity: 0.75;
}

.cmm-json-path__value--copied {
  color: hsl(142 71% 45%) !important;
}

.cmm-json-path__value--string {
  color: hsl(142 60% 40%);
}

.cmm-json-path__value--number {
  color: hsl(221 83% 53%);
}

.cmm-json-path__value--boolean {
  color: hsl(280 65% 55%);
}

.cmm-json-path__value--null {
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

/* ============================================================================
   Type badges
   ============================================================================ */
.cmm-json-path__type-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.625rem;
  font-weight: 600;
  padding: 0.0625rem 0.375rem;
  border-radius: var(--radius-sm);
  margin-left: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.cmm-json-path__type-badge--object {
  background: hsl(var(--accent));
  color: hsl(var(--muted-foreground));
}

.cmm-json-path__type-badge--array {
  background: hsl(221 83% 53% / 0.1);
  color: hsl(221 83% 53%);
}

.cmm-json-path__type-badge--string {
  background: hsl(142 60% 40% / 0.1);
  color: hsl(142 60% 40%);
}

.cmm-json-path__type-badge--number {
  background: hsl(221 83% 53% / 0.1);
  color: hsl(221 83% 53%);
}

.cmm-json-path__type-badge--boolean {
  background: hsl(280 65% 55% / 0.1);
  color: hsl(280 65% 55%);
}

.cmm-json-path__type-badge--null {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}

/* ============================================================================
   Children container
   ============================================================================ */
.cmm-json-path__children {
  /* Children are indented via inline paddingLeft on the node */
}

/* ============================================================================
   Responsive
   ============================================================================ */
@media (max-width: 640px) {
  .cmm-json-path__toolbar {
    flex-wrap: wrap;
  }

  .cmm-json-path__search {
    width: 100%;
    min-width: 0;
  }
}
