.django_json_schema_editor {
  clear: both;
  flex-grow: 1;
}

.django_json_schema_editor > textarea {
  display: none;
}

/* Hide the first title since it's useless */
.django_json_schema_editor
  > :not([data-schematype="array"])
  > .je-header:first-child {
  display: none;
}

.django_json_schema_editor .je-object__title {
  display: block;
  background: var(--darkened-bg);
  border-bottom: 1px solid var(--hairline-color);
  margin: 0;
}

.django_json_schema_editor .je-object__title label {
  float: none;
  display: inline;
  padding: 0;
  margin: 0;
  width: auto;
}

.django_json_schema_editor .je-object__controls {
  margin: 0;
  padding: 4px 0;
}

.django_json_schema_editor .button {
  padding: 5px 10px;
}

.django_json_schema_editor .button span {
  white-space: nowrap;
}

.django_json_schema_editor .row {
  display: flex;
  flex-flow: row wrap;
  margin: 0.5rem 0;
}

/* Remove margin from first row ... */
.django_json_schema_editor .row:first-child {
  margin-top: 0;
}

/* ... but add it back to the first object container */
.django_json_schema_editor
  .row:first-child
  > .je-object__container:first-child {
  margin-top: 0.5rem;
}

.django_json_schema_editor .row + .row:not(:has(> [data-schematype="array"])) {
  border-top: 1px solid var(--hairline-color);
}

.django_json_schema_editor .je-object__title ~ .indented-panel {
  margin-top: -12px;
}

/* See above; first title is hidden, reset the negative top margin in this case */
.django_json_schema_editor
  > :not([data-schematype="array"])
  > .je-header:first-child
  ~ .indented-panel {
  margin-top: 0;
}

.django_json_schema_editor [data-schematype="boolean"] .form-control label {
  float: none;
  width: auto;
}

.django_json_schema_editor
  [data-schematype="boolean"]
  .form-control
  input[type="checkbox"] {
  margin-right: 0.5rem;
}

/*
 * ARRAYS (TABLES & TABS)
 */

.django_json_schema_editor .je-button-holder {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 8px;
}

.django_json_schema_editor .je-modal textarea {
  min-width: min(70vw, 300px);
  min-height: 150px;
}
.django_json_schema_editor .je-modal .button {
  margin-right: 4px;
}

.django_json_schema_editor .je-object__container {
  border: 1px solid var(--hairline-color);
}

.django_json_schema_editor [data-schematype="array"] {
  border: 1px solid var(--hairline-color);
  border-top: none;
}

.django_json_schema_editor
  [data-schematype="array"]
  > .je-header:has(+ .indented-panel > div > table) {
  display: none;
}

.django_json_schema_editor
  [data-schematype="array"]
  .je-object__container
  + .je-object__container {
  border-top: none;
}

.django_json_schema_editor
  .je-object__container
  .je-object__container
  .json-editor-btntype-editjson {
  display: none;
}

.django_json_schema_editor .je-object__container > .indented-panel {
  padding: 0 10px;
}

.django_json_schema_editor [data-schematype="array"] > h3.je-header {
  display: flex;
  background: var(--primary) !important;
  align-items: center;
  padding: 3px 10px 0 10px;
  margin: 0;
}

.django_json_schema_editor [data-schematype="array"] > h3.je-header label {
  padding: 0;
}

.django_json_schema_editor [data-schematype="array"] > .je-header label {
  color: var(--body-bg);
}

.django_json_schema_editor [data-schematype="array"] > .je-header .button {
  border: 1px solid var(--body-bg);
  margin: 0 0.3rem;
}

/*
 * ARRAYS (TABLES)
 */

.django_json_schema_editor [data-schematype="array"] table {
  width: 100%;
}

.django_json_schema_editor .je-textarea {
  height: 70px;
}
.django_json_schema_editor .je-textarea,
.django_json_schema_editor
  [data-schematype="array"]
  [data-schematype="string"]
  input:not(.vForeignKeyRawIdAdminField) {
  width: calc(100% - 16px);
}

.django_json_schema_editor
  [data-schematype="array"]
  [data-schematype="object"]
  [data-schematype="string"]:not(td)
  input {
  width: 20em;
}

.django_json_schema_editor [data-schematype="boolean"] .form-control {
  padding-top: 4px;
}

.django_json_schema_editor table .form-control {
  padding: 0;
  border: none;
}

/*
 * ARRAYS (TABS)
 */

.django_json_schema_editor .je-tab-holder {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--body-bg);
}

.django_json_schema_editor .je-tab-holder > .je-tabs {
  padding: 10px;
  min-width: 10%;
  background-color: var(--darkened-bg);
}

.django_json_schema_editor .je-tab-holder > .je-content {
  flex-grow: 1;
  padding: 0.5rem;
}

.django_json_schema_editor .je-tab-holder > .je-tabs .je-tab {
  margin: 0;
  padding: 0 0.5rem;
  border-radius: 3px;
}

.django_json_schema_editor .je-tab-holder > .je-tabs .je-tab.active {
  background: var(--primary) !important;
  color: var(--body-bg);
}

/* Hide label if it's empty */
label:empty:has(+ .django_json_schema_editor) {
  display: none;
}
