/* SPDX-License-Identifier: GPL-3.0-only */
/**
 * @file playground.css
 *
 * @copyright Copyright (C) 2026-2026 SDML (www.srcDiff.org)
 *
 * This file is part of the srcDiff Infrastructure.
 *
 * Styles of the srcDiff playground.
 * Heavily follows the srcML playground and site.
 */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background-color: #3b3a40;
  font-family: sans-serif;
  color: #f6f6f8;
}

:root {
  --playground-height: calc(100vh - 155px - var(--header-height));
  --panel-width: 180px;
  --delete-color: rgba(255, 60, 60, 0.28);
  --delete-ws-color: rgba(255, 60, 60, 0.12);
  --insert-color: rgba(0, 200, 90, 0.30);
  --insert-ws-color: rgba(0, 200, 90, 0.12);
  --move-color: rgba(90, 120, 255, 0.30);
}

:root { --header-height: 100px; }
@media only screen and (min-width: 666px)  { :root { --header-height: 50px; } }
@media only screen and (min-width: 800px)  { :root { --header-height: 65px; } }
@media only screen and (min-width: 1024px) { :root { --header-height: 75px; } }
@media only screen and (min-width: 1280px) { :root { --header-height: 90px; } }
@media only screen and (min-width: 1440px) { :root { --header-height: 100px; } }

body > #container { padding-top: var(--header-height); }
.grid:has(#container) { max-width: none; }
html.full-page body > #container, html.full-page .grid:has(#container) { padding-top: 0; }

/* playground grid */

#container {
  width: 100%;
  padding-right: 16px;
}

#grid {
  display: grid;
  transition: 0.2s;
}

#grid.resizing { transition: none; }

h2 {
  font-family: 'Oswald', sans-serif;
  color: #f6f6f8;
  font-weight: 400;
  font-size: 24px;
  margin: 0;
  line-height: 1.2;
}

label {
  color: #fff;
  cursor: pointer;
  font-size: 14px;
}

#leftmenu, #rightmenu {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 14px;
  min-width: 0;
  overflow: hidden;
  padding: 6px 0;
  flex-wrap: wrap;
}

.menu-item {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  border-radius: 5px;
  padding: 10px 7px 7px;
  position: relative;
}

#leftmenu .menu-item, #rightmenu .menu-item {
  margin: 4px 0 0;
  padding: 4px 7px;
  min-width: 0;
}

#rightmenu #srcdiff-options { margin: 0; padding: 0; }

.menu-item select {
  width: fit-content;
  min-width: 100px;
  background-color: #fdf6e3;
  border-radius: 3px;
}

.menu-item[data-label] { border: 1px solid rgb(113, 113, 113); }

.menu-item[data-label]::after {
  position: absolute;
  top: 0;
  left: 5px;
  transform: translateY(-60%);
  background-color: #3b3a40;
  padding: 3px;
  content: attr(data-label);
  font-size: 12px;
  white-space: nowrap;
}

.menu-item > * { margin: 0; }

.custom-file-button {
  font-size: 14px;
  line-height: normal;
  display: inline-block;
  padding: 4px 10px;
  cursor: pointer;
  background-color: #f0f0f0;
  color: #000;
  border: 1px solid #a9a9a9;
  border-radius: 3px;
  font-family: inherit;
  width: fit-content;
  white-space: nowrap;
}

.custom-file-button:hover { background-color: #e0e0e0; }

/* sidebar */

#sidebar {
  display: flex;
  color: #000;
  overflow-x: hidden;
  position: relative;
}

#panel-resizer {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
  z-index: 11;
}

#sidebar.panel-open #panel-resizer { display: block; }
#panel-resizer:hover, #grid.resizing #panel-resizer { background-color: #007acc66; }

#sidebar-button-column {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 5px;
  text-align: center;
  width: 60px;
  padding-top: 26px;
}

#sidebar-button-column svg {
  filter: invert(0.9);
  width: 24px;
  height: 24px;
}

.sidebar-button {
  opacity: 0.6;
  padding: 4px 0;
  cursor: pointer;
}

.sidebar-button:hover, .sidebar-button.active { opacity: 1; }

.sidebar-menu {
  display: none;
  background-color: #fff;
  z-index: 10;
  height: calc(var(--playground-height) + 26px);
  width: var(--panel-width);
  min-width: var(--panel-width);
  padding: 5px;
  margin-right: 10px;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.sidebar-menu.open { display: flex; }

.sidebar-menu .menu-item {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

#sidebar .menu-item[data-label]::after { background-color: #fff; color: #000; }
.sidebar-menu label { color: #000; }
.sidebar-menu select { width: 100%; }

.sidebar-menu input[type=text], .sidebar-menu input[type=url] {
  width: 100%;
  padding: 6px;
  font-size: 14px;
}

.sidebar-menu button { cursor: pointer; }

#open-status, #share-status { font-size: 12px; overflow-wrap: anywhere; }

#example-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.example {
  text-align: left;
  border: none;
  background: none;
  padding: 4px;
  border-radius: 3px;
  font-size: 14px;
}

.example:hover { background-color: #e8e8ee; }
.example.selected { background-color: #d6e9f8; }
.example-language { color: #777; font-size: 11px; display: block; }

.example-group {
  margin-top: 8px;
  padding: 0 4px;
  color: #555;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
}

.example-group:first-child { margin-top: 0; }

.panel-toolbar {
  position: sticky;
  top: -5px;
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
  background: #fff;
  z-index: 12;
  padding: 2px 0;
}

.panel-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #aaa;
  border-radius: 3px;
  background: #fff;
  color: #333;
  font-size: 18px;
  line-height: 1;
}

.panel-close:hover { background: #eee; }

/* panes */

#source-panes, #output-pane {
  margin-top: 5px;
  min-width: 0;
}

.tab {
  display: inline-block;
  min-width: 150px;
  padding: 2px 10px;
  background-color: #444;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  cursor: pointer;
  border: 1px outset #ddd;
  font-size: 15px;
  white-space: nowrap;
}

.tab svg { filter: invert(0.9); margin: 0 5px 0 3px; }
.tab-selected { background-color: #666; }
.source-pane .tab { cursor: default; }

.filename {
  background: transparent;
  border: none;
  border-bottom: 1px dashed #999;
  color: #f6f6f8;
  font: inherit;
  font-size: 13px;
  width: 14em;
  margin-left: 6px;
}

.filename:focus { outline: none; border-bottom-color: #2ac5c7; }

.editor {
  position: relative;
  margin: 0;
}

.source-pane .editor { height: calc(var(--playground-height) / 2 - 13px); }

#output-body {
  display: flex;
  flex-direction: column;
  height: var(--playground-height);
}

#srcdiff-editor, #view-frame {
  flex: 1 1 auto;
  min-height: 0;
}

#view-frame {
  display: block;
  width: 100%;
  border: none;
  background-color: #fff;
}

#view-frame[hidden], #srcdiff-editor[hidden] { display: none; }

#output-tabs { display: flex; align-items: center; gap: 0; }
#loading-spinner { margin-left: 10px; }
#loading-spinner[hidden] { display: none; }

#view-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  flex: none;
  gap: 4px 14px;
  min-height: 30px;
  padding: 3px 6px;
  background-color: #48474d;
  font-size: 13px;
}

#view-options[hidden] { display: none; }
#view-options label { font-size: 13px; }

.resizer {
  cursor: ew-resize;
  background-color: #48474d;
  margin-top: 30px;
}

.resizer:hover, #grid.resizing .resizer { background-color: #2ac5c7; }

/* difference markers in the Ace editors */

.ace_marker-layer .diff-delete    { position: absolute; background-color: var(--delete-color); }
.ace_marker-layer .diff-delete-ws { position: absolute; background-color: var(--delete-ws-color); }
.ace_marker-layer .diff-insert    { position: absolute; background-color: var(--insert-color); }
.ace_marker-layer .diff-insert-ws { position: absolute; background-color: var(--insert-ws-color); }
.ace_marker-layer .diff-move      { position: absolute; background-color: var(--move-color); }

/* status line */

#status-line {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 8px 0 8px 60px;
  min-height: 24px;
  font-size: 13px;
}

#error-display {
  font-family: monospace;
  background-color: #fffa;
  color: #650000;
  padding: 3px;
}

#error-display:empty { display: none; }

#legend { display: flex; gap: 8px; }
#legend.hidden { visibility: hidden; }

.legend-item {
  padding: 1px 6px;
  border-radius: 3px;
  color: #f6f6f8;
}

.legend-delete { background-color: rgba(255, 60, 60, 0.55); }
.legend-insert { background-color: rgba(0, 200, 90, 0.55); }
.legend-move   { background-color: rgba(90, 120, 255, 0.6); }

#timing { color: #aaa; margin-left: auto; }

/* full page */

html.full-page #header { display: none; }
html.full-page { --playground-height: calc(100vh - 110px); }

/* dialogs */

dialog {
  max-width: min(900px, 90vw);
  max-height: 85vh;
  padding: 16px 24px;
  background-color: #2b2a30;
  color: #d3d0d8;
  border: 1px solid rgb(113, 113, 113);
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
}

dialog::backdrop { background-color: #00000080; }
dialog form { position: sticky; top: 0; float: right; }
dialog form button { padding: 0 8px; font-size: 20px; line-height: 1.2; cursor: pointer; }
dialog h3 { margin: 0 0 8px; color: #f6f6f8; font-size: 20px; font-weight: 400; }
dialog p { margin: 8px 0; }
dialog table { width: 100%; margin: 8px 0; border-collapse: collapse; }

dialog th, dialog td {
  padding: 4px 8px;
  border: 1px solid rgb(113, 113, 113);
  text-align: left;
  vertical-align: top;
}

dialog th { background-color: #3b3a40; color: #f6f6f8; font-weight: 600; }
dialog td { font-weight: 400; }
dialog td:last-child { word-break: break-all; }
dialog code { color: #95ec90; font-family: 'Source Code Pro', monospace; }
dialog a, dialog a code { color: #6be7f2; }
