:root {
  --playground-border-size: 1px;
  --playground-border-color: rgba(0, 0, 0, 1);
}

::selection, mark {
  background-color: black;
  color: white;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Source Serif 4', sans-serif;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  background-size: 80%;
  background-attachment: fixed;
  min-height: 100%;
  scroll-behavior: smooth;
}

@media (prefers-color-scheme: light) {
  body {
    background-image: url("/public/images/bg-light.webp");
  }
}

body::-webkit-scrollbar {
  width: .6em;
}

body::-webkit-scrollbar-track {
  background-color: white;
}

body::-webkit-scrollbar-thumb {
  background-color: black;
  border-radius: 5px;
}

@media (prefers-color-scheme: dark) {
  body::-webkit-scrollbar-track {
    background-color: black;
  }

  body::-webkit-scrollbar-thumb {
    background-color: white;
  }

  body {
    background-image: url("/public/images/bg-dark.webp");
    background-color: black;
    filter: invert(95%) hue-rotate(180deg);
  }

  img, video, iframe {
    filter: invert(95%) hue-rotate(180deg);
  }

  .navigation-menu-bars img {
    filter: invert(0);
  }
}

/* General styling.  */

a {
  color: black;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

input[type] {
  outline: none;
  border: var(--playground-border-size) solid var(--playground-border-color);
  height: 25px;
  padding: .5rem;
  background-color: transparent;
}

button:disabled {
  background-color: gray;
}

select {
  outline: none;
  border: var(--playground-border-size) solid var(--playground-border-color);
  -webkit-appearance: none;
  -moz-appearance: none;
  text-indent: 1px;
  text-overflow: '';
}

table {
  width: 100%;
  margin-top: 1rem;
  padding-left: 1rem;
  padding-right: 1rem;
  padding-bottom: 1rem;
  border-spacing: 0;
  border-collapse: collapse;
  border: var(--playground-border-size) solid var(--playground-border-color);
}

table thead tr td,
table tbody tr td {
  height: 30px;
}

table thead tr td {
  padding-left: 1rem;
  font-weight: bolder;
}

table tbody tr td input {
  padding-left: 1rem !important;
  width: 100% !important;
  height: 30px !important;
  border: none !important;
}

table thead tr,
table tbody tr:not(:last-child) td {
  border-bottom: var(--playground-border-size) solid var(--playground-border-color);
}

table thead tr td:not(:last-child),
table tbody tr td:not(:last-child) {
  border-right: var(--playground-border-size) solid var(--playground-border-color);
}

/* Playground structure.  */

.playground {
  width: 90%;
  height: calc(100vh - 6rem);
  min-height: 600px;
  display: block;
  margin: auto auto 6rem;
}

/* Title bar.  */

.playground-title-bar {
  position: relative;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  width: 100%;
  display: flex;
  justify-content: space-between;
}

.playground-title-bar .title-bar-options .logo {
  background-color: black;
  color: white;
  padding: .1rem .5rem .1rem .5rem;
  font-family: 'Source Serif 4', sans-serif;
  font-weight: 700;
}

.playground-title-bar .title-bar-options .logo span {
  font-family: 'Source Serif 4', sans-serif;
  font-weight: 400;
}

.playground-title-bar .title-bar-options ul li {
  display: inline;
  list-style: none;
  padding-right: 1rem;
}

.playground-title-bar .title-bar-window-name {
  width: 200px;
  text-align: center;
  position: absolute;
  left: 0;
  right: 0;
  margin: auto;
}

.playground-title-bar .title-bar-links a {
  font-size: 22px;
}

/* Playground content.  */

.playground-content {
  min-width: 100%;
  height: 100%;
  min-height: 100%;
  max-height: 100%;
  display: flex;
}

/* Collections files.  */

.playground-collection-container {
  border: none;
  width: 0;
  min-width: 0;
  max-width: 0;
  margin: 0;
  padding: 0;
  position: relative;
}

.playground-collection-container .content {
  overflow-y: hidden;
  padding: 0;
}

.playground-collection-container .actions {
  position: absolute;
  bottom: 5.4rem;
  left: calc(-8rem + 1px);
  rotate: -90deg;
  display: flex;
  justify-content: space-between;
  border: 1px solid black;
}

.playground-collection-container .actions button {
  background-color: transparent;
  user-select: none;
  border: none;
  cursor: pointer;
  outline: none;
  height: 25px;
  appearance: none;
  padding: 0 1.5rem;
}

.playground-collection-container .actions button:not(:first-child) {
  border-left: 1px solid black;
}

.playground-collection-container.open {
  width: 300px;
  min-width: 300px;
  max-width: 300px;
  border: 1px solid black;
  margin-right: 1rem;
}

.playground-collection-container.open .content {
  padding: 1rem;
  max-height: 100%;
  overflow: auto;
}

.playground-collection-container.open .actions {
  bottom: 5.3rem;
  left: -8rem;
}

.playground-collection-container .content .no-coll {
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 90%;
  user-select: none;
  pointer-events: none;
  cursor: default;
}

.playground-collection-container .content header {
  margin-bottom: 1rem;
}

.playground-collection-container .content .item {
  cursor: default;
  user-select: none;
}

.playground-collection-container .content .item:not(.folder).selected .name::before {
  content: "\E3D2";
  font-weight: bolder;
}

.playground-collection-container .content .item span.name {
  padding: .1rem 0;
}

.playground-collection-container .content .item .name::before {
  font-family: "Phosphor";
  padding-right: .7rem;
}

.playground-collection-container .content .item > .name::before {
  content: "\E6AC";
}

.playground-collection-container .content .item.folder > span.name::before {
  content: "\E25A";
}

.playground-collection-container .content .item.folder.open > .name::before {
  content: "\E256";
}

.playground-collection-container .content .item {
  min-width: 200px;
}

.playground-collection-container .content .item.folder {
  height: 1.5rem;
  overflow: hidden;
  position: relative;
}

.playground-collection-container .content .item.folder.open {
  height: auto;
}

.playground-collection-container .content .item.folder.open::before {
  content: "";
  position: absolute;
  top: 1.2rem;
  border-left: 1px dashed rgba(0, 0, 0, 0.2);
  height: calc(100% - 1.2rem);
}

.playground-collection-container .content .item.folder .name {
  padding-left: .2rem;
}

.playground-collection-container .content .item > span.name {
  display: inline-block;
  width: 100%;
}

.playground-collection-container .content .item > span.name:hover {
  background-color: rgba(0, 0, 0, .05);
}

.playground-collection-container .content .item .item {
  padding-left: .8rem;
}

.playground-content .canvas {
  width: 100%;
  height: calc(100% - 4.6rem);
  min-height: calc(100% - 4.6rem);
  max-height: calc(100% - 4.6rem);
}

.playground-content .canvas .request-name {
  padding: .5rem 0;
  font-weight: bolder;
  pointer-events: none;
  user-select: none;
}

.playground-content .canvas .request-name .item {
  font-size: 20px;
  position: relative;
  padding-left: 2rem;
}

.playground-content .canvas .request-name .item::before {
  content: "\E13A";
  font-family: "Phosphor";
  position: absolute;
  top: .3rem;
  left: .5rem;
}

.playground-content .canvas .request-name > .item:first-child {
  padding-left: 0;
}

.playground-content .canvas .request-name > .item:first-child::before {
  display: none;
}

/* Request bar */

.request-bar form {
  display: flex;
  justify-content: space-between;
}

.request-bar #http-request-method-picker {
  text-align: center;
  background-color: transparent;
  height: 30px;
  width: 100px;
}

.request-bar #http-request-target {
  flex-grow: 1;
  margin-left: 1rem;
  margin-right: 1rem;
  height: 30px;
  font-weight: bold;
}

.request-bar #http-request-send-button {
  background-color: black;
  width: 100px;
  color: white;
  cursor: pointer;
  outline: none;
  border: none;
  height: 30px;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* Workbench.  */

.workbench {
  max-width: 100%;
  display: flex;
  border: var(--playground-border-size) solid var(--playground-border-color);
  height: 100%;
  min-height: 100%;
  max-height: 100%;
  margin-bottom: 2rem;
}

.workbench .request-response-panel {
  position: relative;
  height: 100%;
  width: 50%;
}

.workbench .response-panel {
  height: 100%;
  width: 50%;
  border-left: var(--playground-border-size) solid var(--playground-border-color);
}

.workbench .tabs-panel {
  padding-left: 1rem;
  padding-right: 1rem;
  border-bottom: var(--playground-border-size) solid var(--playground-border-color);
}

.workbench .tabs-panel .tab.active {
  text-decoration: underline;
}

.workbench .tabs-panel .tab {
  height: 40px;
  line-height: 40px;
  display: inline-block;
  list-style: none;
  cursor: default;
}

.workbench .tabs-panel ul li:not(:last-child) {
  padding-right: 1rem;
}

.workbench .work-panel {
  height: calc(100% - 40px);
  padding: 1rem;
}

.workbench .work-panel .work-panel-tab {
  display: none;
}

.workbench .work-panel .work-panel-tab.active {
  display: block;
}

.workbench .work-panel .work-panel-tab .workspace-tab-content {
  position: relative;
  height: 100%;
  min-height: 100%;
  max-height: 100%;
  scrollbar-color: transparent transparent;
  scrollbar-width: none;
  overflow: auto;
}

.workbench .work-panel .work-panel-tab .workspace-tab-content h3 {
  text-align: center;
  font-weight: bolder;
  border-top: 2px solid black;
  border-bottom: 1px solid black;
  background-color: rgba(255, 255, 255, 0.5);
  padding: .5rem .5rem;
  margin-bottom: 1rem;
}

.workbench .work-panel .work-panel-tab .workspace-tab-content .centered-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.workbench .work-panel .work-panel-tab .workspace-tab-content .centered-label p {
  text-align: center;
  font-family: "Inconsolata", system-ui;
  font-size: 13px;
}

.workbench .work-panel .work-panel-tab .workspace-tab-content .disable {
  display: none;
}

/* Workbench request section.  */

.workbench .request-panel .work-panel {
  background-size: 20px 20px;
  background-image: radial-gradient(rgba(0, 0, 0, 0.2) 1px, transparent 1px), radial-gradient(rgba(0, 0, 0, 0.2) 1px, transparent 1px);
}

.workbench .request-panel .work-panel table {
  background-color: rgba(255, 255, 255, 0.6);
}

.workbench .request-panel .box-decoration {
  position: absolute;
  width: 70px;
  height: 70px;
  bottom: 1rem;
  z-index: -1;
}

.workbench .request-panel .http-request-body-textarea {
  width: 100%;
  min-height: calc(100% - 130px - 1rem);
  background-color: rgba(255, 255, 255, 0.7);
  resize: none;
  padding: 1rem;
  font-family: "Inconsolata", system-ui;
  font-size: 16px;
}

.workbench .request-panel .box-decoration.left {
  left: 1rem;
}

.workbench .request-panel .box-decoration.right {
  right: 1rem;
}

.workbench .request-panel .box-decoration div.center {
  width: 25%;
  height: 25%;
  background-color: black;

  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.workbench .request-panel .box-decoration .dot {
  width: 30%;
  height: 30%;
  border-color: black;
  border-width: 2px;
  border-style: solid;
  position: absolute;
}

.workbench .request-panel .box-decoration .dot.top-left {
  top: 0;
  left: 0;
  border-bottom: none;
  border-right: none;
}

.workbench .request-panel .box-decoration .dot.top-right {
  top: 0;
  right: 0;
  border-bottom: none;
  border-left: none;
}

.workbench .request-panel .box-decoration .dot.bottom-left {
  bottom: 0;
  left: 0;
  border-top: none;
  border-right: none;
}

.workbench .request-panel .box-decoration .dot.bottom-right {
  bottom: 0;
  right: 0;
  border-top: none;
  border-left: none;
}

/* Response styles.  */

.workbench .response-panel .work-panel.with-diagonal {
  background-size: 20px 20px;
  background-image: repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.1) 0, rgba(0, 0, 0, 0.1) 1px, transparent 0, transparent 50%);
}

.workbench .response-panel .response-body {
  position: relative;
  background-size: 25px 25px;
  background-image: linear-gradient(rgba(0, 0, 0, 0.06) 1px, transparent 1px),
  linear-gradient(to right, rgba(0, 0, 0, 0.06) 1px, rgba(255, 255, 255, 0) 1px);
  height: 100%;
  width: 100%;
  max-width: 100%;
  min-width: 100%;
  overflow: unset;
  border: var(--playground-border-size) solid var(--playground-border-color);
  padding: 1.7rem 1.9rem 1rem 1rem;
}

.workbench .response-panel .response-body .htmx-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.workbench .response-panel .response-body .htmx-indicator .spinner {
  width: 30px;
  height: 30px;
  border: 2px solid black;
  border-bottom-color: transparent;
  border-radius: 50%;
  box-sizing: border-box;
  animation: rotation 1s linear infinite;
  display: block;
}

.workbench .response-panel .response-body .htmx-request .htmx-indicator {
  opacity: 1;
  display: block;
}

@keyframes rotation {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.workbench .response-panel .response-body > pre {
  width: 100%;
  max-width: 100%;
  min-width: 100%;
  overflow: auto;
  height: 100%;
  scrollbar-color: transparent transparent;
  scrollbar-width: none;
}

.workbench .response-panel .response-body > pre code {
  display: inline-block;
  width: 100%;
  max-width: 0;
}

.workbench .response-panel .response-body * {
  font-family: "Inconsolata", system-ui;
  font-size: 14px;
}

.workbench .response-panel .response-body #response-status,
.workbench .response-panel .response-body #response-stats {
  display: none;
}

.workbench .response-panel .response-body #response-status.active,
.workbench .response-panel .response-body #response-stats.active {
  display: block;
}

.workbench .response-panel .response-body #response-status {
  position: absolute;
  top: .5rem;
  right: 1rem;
}

.workbench .response-panel .response-body #response-status *,
.workbench .response-panel .response-body #response-stats * {
  font-size: 16px;
}

.workbench .response-panel .response-body #response-stats {
  position: absolute;
  bottom: 1rem;
  right: .5rem;
  writing-mode: vertical-lr;
  -ms-writing-mode: lr;
  -webkit-writing-mode: vertical-lr;
}

.workbench .response-panel .response-body #response-stats p {
  display: inline;
  margin: .5rem;
}

.workbench .response-panel .response-body .decoration {
  position: absolute;
  background-color: transparent;
  z-index: -1;
  border-radius: 4px;
}

.workbench .response-panel .response-body .decoration.top-right {
  right: -4px;
  top: -4px;
  width: 25%;
  height: 50%;
  border-top: 4px solid black;
  border-right: 4px solid black;
}

.workbench .response-panel .response-body .decoration.bottom-left {
  bottom: -4px;
  left: -4px;
  width: 15%;
  height: 70%;
  border-bottom: 4px solid black;
  border-left: 4px solid black;
}

@media screen and (max-width: 1420px) {
  .playground-content {
    flex-wrap: wrap;
  }

  .playground-collection-container .actions {
    rotate: 0deg;
    left: 0;
    top: 0 !important;
    height: 27px;
    bottom: unset;
    justify-content: space-between;
  }

  .playground-collection-container.open {
    width: 100%;
    min-width: 100%;
    max-height: 100vh;
    margin: 2rem 0 0;
  }

  .playground-collection-container.open .actions {
    left: -1px;
    top: calc(-2rem - 1px) !important;
  }

  .playground-content .canvas {
    margin-top: 2rem;
  }

  .playground-content:has(.collection-files.open) .canvas {
    margin-top: .4rem !important;
  }
}

@media screen and (max-width: 1120px) {
  .workbench {
    flex-direction: column;
    max-height: initial;
    height: auto;
  }

  .workbench .request-response-panel {
    width: 100%;
  }

  .workbench .work-panel .work-panel-tab .workspace-tab-content {
    position: initial;
  }

  .workbench .request-response-panel .tabs-panel {
    text-align: center;
  }

  .workbench .request-panel .work-panel {
    min-height: 450px;
  }

  .workbench .request-panel .http-request-body-textarea {
    min-height: 280px !important;
  }

  .workbench .response-panel .work-panel {
    min-height: 500px;
  }

  .workbench .response-panel .response-body {
    height: auto;
  }

  .workbench .response-panel .response-body > pre {
    min-height: 500px;
    max-height: calc(60vh - 150px);
  }

  .workbench .response-panel {
    border: var(--playground-border-size) solid var(--playground-border-color);
  }
}

@media screen and (max-width: 650px) {
  .title-bar-window-name {
    display: none;
  }
}

@media screen and (max-width: 520px) {
  #http-request-form {
    flex-direction: column;
    row-gap: .3rem;
  }

  #http-request-method-picker {
    width: 100% !important;
  }

  #http-request-target {
    margin: 0 !important;
  }

  #http-request-send-button {
    width: 100% !important;
  }
}

dialog {
  width: 40ch;
  margin: auto;
  border: 1px solid black;
  padding: 1rem;
}

dialog form {
  padding-top: 1rem;
  display: flex;
  gap: .5rem;
  flex-direction: column;
}

dialog button {
  background-color: black;
  color: white;
  cursor: pointer;
  outline: none;
  border: none;
  height: 30px;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

dialog form button:last-child {
  background-color: transparent;
  color: black;
  border: 1px solid black;
}


input[type="file"] {
  border: none;
  height: 40px;
}
