@use '../styles/tokens' as *;

.state-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;

  &__toolbar {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 12px;
    height: 28px;
    padding: 0 $spacing-12;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 11px;
    color: var(--fg-muted);
    white-space: nowrap;
    overflow-x: auto;

    b {
      font-weight: 600;
      color: var(--fg);
    }
  }

  &__spacer {
    flex: 1;
  }

  &__mono {
    font-family: monospace;
  }

  &__split {
    display: flex;
    flex: 1;
    min-height: 0;
  }

  // --- Rail ---

  &__rail {
    flex-shrink: 0;
    width: 250px;
    padding: $spacing-4 0;
    border-right: 1px solid var(--border);
    overflow-y: auto;
  }

  &__rail-item {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 24px;
    padding: 0 10px;
    border-left: 2px solid transparent;
    font-size: 11px;
    cursor: pointer;

    &:hover {
      background: var(--bg-hover);
    }

    &--selected {
      background: var(--bg-selected);
      border-left-color: var(--accent);

      &:hover {
        background: var(--bg-selected);
      }
    }
  }

  &__rail-divider {
    margin: $spacing-4 0;
    border-bottom: 1px solid var(--border-subtle);
  }

  &__rail-name {
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  &__rail-badges {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 4px;
    margin-left: auto;
  }

  &__badge {
    padding: 0 4px;
    border-radius: $radius-sm;
    font-family: monospace;
    font-size: 10px;
    font-weight: 600;
    line-height: 14px;

    &--add {
      background: color-mix(in srgb, var(--color-success) 14%, transparent);
      color: var(--color-success);
    }

    &--del {
      background: color-mix(in srgb, var(--color-error) 14%, transparent);
      color: var(--color-error);
    }

    &--chg {
      background: color-mix(in srgb, var(--color-warning) 16%, transparent);
      color: var(--color-warning);
    }

    &--data {
      background: color-mix(in srgb, var(--accent) 14%, transparent);
      color: var(--accent);
    }

    &--none {
      background: none;
      font-weight: 400;
      color: var(--fg-muted);
    }
  }

  // --- Inspector ---

  &__inspector {
    flex: 1;
    min-width: 0;
    padding: 10px $spacing-16 $spacing-16;
    overflow-y: auto;
  }

  &__inspector-title {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--fg);
  }

  &__inspector-sub {
    margin: 1px 0 10px;
    font-size: 11px;
    color: var(--fg-muted);
  }

  &__subtabs {
    display: flex;
    gap: 2px;
    margin-bottom: $spacing-8;
    border-bottom: 1px solid var(--border-subtle);
  }

  &__subtab {
    padding: 3px 8px 4px;
    border: none;
    background: none;
    font-size: 11px;
    color: var(--fg-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;

    &:hover {
      color: var(--fg);
    }

    &--active {
      color: var(--accent);
      border-bottom-color: var(--accent);
      font-weight: 600;
    }
  }

  &__note {
    margin-top: 10px;
    font-size: 10.5px;
    color: var(--fg-muted);
  }

  &__empty-note {
    padding: $spacing-8 0;
    font-size: 11.5px;
    color: var(--fg-muted);
  }

  // --- Tree ---

  &__tree {
    font-size: 11.5px;
  }

  &__tree-row {
    display: flex;
    align-items: baseline;
    gap: $spacing-6;
    padding: 2px $spacing-6;
    border-radius: $radius-sm;

    &--new {
      background: color-mix(in srgb, var(--color-success) 10%, transparent);
    }
  }

  &__tree-caret {
    flex-shrink: 0;
    width: 10px;
    font-size: 9px;
    text-align: center;
    color: var(--fg-muted);
    cursor: pointer;
  }

  &__tree-key {
    font-family: monospace;
    font-weight: 600;
    color: var(--fg);

    &--index {
      font-weight: 400;
      color: var(--fg-muted);
    }
  }

  &__tree-sep {
    color: var(--fg-muted);
  }

  &__tree-value {
    font-family: monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  &__tree-preview {
    font-family: monospace;
    color: var(--fg-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  &__tree-chip {
    margin-left: auto;
    flex-shrink: 0;
  }

  &__tree-children {
    margin-left: 15px;

    &--new {
      border-left: 2px solid color-mix(in srgb, var(--color-success) 40%, transparent);
    }
  }

  // --- Chips ---

  &__chip {
    display: inline-block;
    padding: 0 5px;
    border-radius: $radius-sm;
    font-family: monospace;
    font-size: 9.5px;
    font-weight: 600;
    line-height: 15px;
    white-space: nowrap;

    &--access,
    &--phase {
      background: color-mix(in srgb, var(--accent) 14%, transparent);
      color: var(--accent);
    }

    &--submission {
      background: color-mix(in srgb, var(--color-success) 14%, transparent);
      color: var(--color-success);
    }

    &--default,
    &--other {
      background: color-mix(in srgb, var(--fg-muted) 16%, transparent);
      color: var(--fg-muted);
    }
  }
}
