/****************************************************************************
 ** @license
 ** This demo file is part of yFiles for HTML 3.1.0.4.
 ** Copyright (c) 2026 by yWorks GmbH, Vor dem Kreuzberg 28,
 ** 72070 Tuebingen, Germany. All rights reserved.
 **
 ** yFiles demo files exhibit yFiles for HTML functionalities. Any redistribution
 ** of demo files in source code or binary form, with or without
 ** modification, is not permitted.
 **
 ** Owners of a valid software license for a yFiles for HTML version that this
 ** demo is shipped with are allowed to use the demo source code as basis
 ** for their own yFiles for HTML powered applications. Use of such programs is
 ** governed by the rights and conditions as set out in the yFiles for HTML
 ** license agreement.
 **
 ** THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESS OR IMPLIED
 ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
 ** NO EVENT SHALL yWorks BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 ** TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 ** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 ** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 **
 ***************************************************************************/
/****************************************************************************
 ** @license
 ** This demo file is part of yFiles for HTML 3.1.0.4.
 ** Copyright (c) 2026 by yWorks GmbH, Vor dem Kreuzberg 28,
 ** 72070 Tuebingen, Germany. All rights reserved.
 **
 ** yFiles demo files exhibit yFiles for HTML functionalities. Any redistribution
 ** of demo files in source code or binary form, with or without
 ** modification, is not permitted.
 **
 ** Owners of a valid software license for a yFiles for HTML version that this
 ** demo is shipped with are allowed to use the demo source code as basis
 ** for their own yFiles for HTML powered applications. Use of such programs is
 ** governed by the rights and conditions as set out in the yFiles for HTML
 ** license agreement.
 **
 ** THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESS OR IMPLIED
 ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
 ** NO EVENT SHALL yWorks BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 ** TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 ** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 ** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 **
 ***************************************************************************/
:root[data-theme='light'] {
  .editor-panel {
    --switch-bg-color: #0004;
    --switch-bg-color-hover: #aec3d5;
  }
}

:root[data-theme='dark'] {
  .editor-panel {
    --switch-bg-color: #fff4;
    --switch-bg-color-hover: #aec3d5;
  }
}

.editor-panel {
  --editor-bg-color: #ffffff;

  --apply-color-accent: #00adcc;
  --apply-color-hover: #ffffff;
  --slider-bg-color: #ffffff;

  --editor-font-size: 13px;
  --editor-border: 1px solid #ddd;

  --error-text-color: #ffffff;
  --error-bg-color: #f44336;

  display: flex;
  flex-direction: column;

  box-sizing: border-box;

  .heading-row {
    margin: 2ex 0 1ex;

    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;

    &:first-child {
      margin-block-start: 0;
    }

    h2 {
      margin: 0;
    }
  }

  .editorText {
    font-family: 'Consolas', 'Courier New', Courier, mono, serif;
    font-size: var(--editor-font-size);
  }

  #templateEditorContainer {
    flex: 0 1 70%;
    min-height: 0;
  }

  #tagEditorContainer {
    flex: 0 1 fit-content;
    min-height: 0;
  }

  .cm-editor {
    height: 100% !important;
    background-color: var(--editor-bg-color);
    border: var(--editor-border);
  }

  .error {
    display: none;
    color: var(--error-text-color);
    font-size: 1rem;
    font-weight: bold;
    vertical-align: baseline;
    text-align: center;
    height: 0;
    margin-left: 1rex;
    transition:
      height 0.3s ease,
      display 0.3s ease allow-discrete;

    &.open-error {
      display: flex;
      height: 1.5rem;
      background-color: var(--error-bg-color);
      padding: 2px 4px;
    }
  }

  @starting-style {
    .error.open-error {
      height: 0;
    }
  }

  #template-text-area-error {
    bottom: 250px;
  }

  #tag-text-area-error {
    bottom: 15px;
  }

  .apply-button {
    margin: 1ex 0 1ex 0;
    padding: 4px 8px;

    color: var(--apply-color-accent);
    background-color: transparent;
    border: 1px solid var(--apply-color-accent);
    border-radius: 99px;
    cursor: pointer;

    &:hover {
      color: var(--apply-color-hover);
      background-color: var(--apply-color-accent);
    }

    &:disabled {
      color: var(--apply-color-hover);
      background-color: #a0a0a0;
      border-color: #a0a0a0;
    }
  }
}

/*
 Displays labels to the left and right of the .switch.
 To make it possible to toggle the switch on the label texts, make this element the <label>.
 */
.labeled-switch {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

/*
 An iOS-style switch based on an invisible checkbox.
 For user interaction to work, either this element or .labeled-switch must be a <label>.
 */
.switch {
  position: relative;
  display: block;
  height: 1.25em;
  aspect-ratio: 2;

  box-sizing: border-box;
  padding: 3px;
  container-type: size;

  background-color: var(--switch-bg-color);
  border-radius: 99px;
  transition: 0.4s;
  user-select: none;
  cursor: pointer;

  /* Hide the checkbox and move it out of the way */
  input {
    position: absolute;
    width: 0;
    height: 0;
  }

  &:before {
    display: block;
    height: 100%;
    aspect-ratio: 1;
    content: '';
    background-color: var(--slider-bg-color);
    transition: 0.4s;
    border-radius: 99px;
  }

  &:hover {
    background-color: var(--switch-bg-color-hover);
  }

  &:has(input:checked):before {
    transform: translateX(calc(100cqw - 100%));
  }
}

/* Styles specific to this demo */

.main-container {
  display: flex;

  /* The graph component and the code editor should get the same width */
  .graph-panel,
  .interaction-panel {
    flex: 1 1 0;
  }

  .interaction-panel {
    .switch input[type='checkbox'] {
      display: none !important;
    }

    .collapse-anchor {
      width: 0;
    }

    .heading-row:first-child {
      margin-right: 24px;
    }
  }

  .editor-panel {
    height: 100%;
    display: flex;
  }
}
