/* Copyright (c) Microsoft Corporation.
   Licensed under the MIT License. */

/* Circuit panel */
.qs-circuit-panel {
  p {
    padding: 10px 0px;
  }

  /* Error div in circuit panel */
  .qs-circuit-error {
    padding: 10px 0px;
  }

  .qs-circuit-error p {
    padding: 10px 0px;
  }

  /*
  Styles for Q# circuits.
  Copied and modified from the default CSS generated by
  https://github.com/microsoft/quantum-viz.js/blob/288e0cb506ee866ecca1b414c522e2d634f7b36d/src/styles.ts
*/

  /* Background color for the circuit diagram */
  .qs-circuit {
    background: var(--main-background);
  }

  /* Wires and gate outlines */
  .qs-circuit line,
  .qs-circuit circle,
  .qs-circuit rect {
    stroke: var(--main-color);
    stroke-width: 1;
  }

  /* Text for qubit labels */
  .qs-circuit text {
    fill: var(--main-color);
    dominant-baseline: middle;
    text-anchor: middle;
  }

  /* When run in VS Code, the "KaTeX_Main" and "KaTeX_Math" fonts are already present */
  /* When run in Jupyter in the browser, the MJX* (MathJax) fonts are used and present */
  .qs-maintext {
    font-family: "KaTeX_Main", "MJXZERO", "MJXTEX", sans-serif;
    font-style: normal;
  }

  .qs-mathtext {
    font-family: "KaTeX_Math", "MJXZERO", "MJXTEX-I", serif;
  }

  /* The math font used in KaTex (thus in VS Code) needs italic applied also, whereas
   the font used in MathJax (thus Jupyter web) doesn't. So apply if in VS Code  */
  [data-vscode-theme-kind] .qs-mathtext {
    font-style: italic;
  }

  /* Background for gates */
  .qs-circuit .gate-unitary {
    fill: var(--vscode-button-secondaryBackground, #333333);
  }

  /* Text for gates */
  .qs-circuit .gate text {
    fill: var(--vscode-button-secondaryForeground, #ffffff);
  }

  /* Default style for arg-button */
  .qs-circuit .arg-button {
    fill: var(--vscode-editor-foreground, #ffffff);
    text-decoration: none;
    cursor: default;
    pointer-events: none;
    word-spacing: -0.2em;
  }

  /* Edit mode style for arg-button (hyperlink appearance) */
  .qs-circuit .arg-button.edit-mode {
    fill: var(--vscode-textLink-foreground, #0066cc);
    text-decoration: underline;
    cursor: pointer;
    pointer-events: all;
  }

  /* Hover style for arg-button in edit mode */
  .qs-circuit .arg-button.edit-mode:hover {
    fill: var(--vscode-textLink-activeForeground, #004499); /* Hover color */
  }

  /* Dot and line for controlled gates */
  .qs-circuit .gate > line,
  .qs-circuit .control-dot {
    fill: var(--main-color);
  }

  /* X gate */
  .qs-circuit .gate > .oplus > line,
  .qs-circuit .gate > .oplus > circle {
    fill: var(--main-background);
    stroke: var(--main-color);
    stroke-width: 2;
  }

  /* Measurement gate */
  .qs-circuit .gate-measure {
    fill: var(--vscode-button-background, #007acc);
  }

  /* Measurement gate icon */
  .qs-circuit .gate > g > line,
  .qs-circuit .arc-measure {
    stroke: var(--vscode-button-foreground, #ffffff);
    fill: none;
    stroke-width: 1;
  }

  /* Ket gate */
  .qs-circuit .gate-ket {
    fill: var(--vscode-button-background, #007acc);
  }

  /* Ket gate text */
  .qs-circuit text.ket-text {
    fill: var(--vscode-button-foreground, #ffffff);
    stroke: none;
  }

  /* SWAP gate */
  .qs-circuit rect.gate-swap {
    fill: transparent;
    stroke: transparent;
  }

  /* Classical wire */
  .qs-circuit .register-classical {
    stroke-width: 0.5;
  }

  /*
  The following styles are unused so they are unthemed.
  They relate to conditional circuits which are not currently supported.
*/

  .qs-circuit .hidden {
    display: none;
  }

  .qs-circuit .classically-controlled-unknown {
    opacity: 0.25;
  }

  .qs-circuit .classically-controlled-one .classical-container,
  .qs-circuit .classically-controlled-one .classical-line {
    stroke: #4059bd;
    stroke-width: 1.3;
    fill: #4059bd;
    fill-opacity: 0.1;
  }

  .qs-circuit .classically-controlled-zero .classical-container,
  .qs-circuit .classically-controlled-zero .classical-line {
    stroke: #c40000;
    stroke-width: 1.3;
    fill: #c40000;
    fill-opacity: 0.1;
  }

  .qs-circuit .classically-controlled-btn {
    cursor: pointer;
  }

  .qs-circuit .classically-controlled-unknown .classically-controlled-btn {
    fill: #e5e5e5;
  }

  .qs-circuit .classically-controlled-one .classically-controlled-btn {
    fill: #4059bd;
  }

  .qs-circuit .classically-controlled-zero .classically-controlled-btn {
    fill: #c40000;
  }

  .qs-circuit .classically-controlled-btn text {
    dominant-baseline: middle;
    text-anchor: middle;
    stroke: none;
    font-family: Arial;
  }

  .qs-circuit .classically-controlled-unknown .classically-controlled-btn text {
    fill: #000000;
  }

  .qs-circuit .classically-controlled-one .classically-controlled-btn text {
    fill: #ffffff;
  }

  .qs-circuit .classically-controlled-zero .classically-controlled-btn text {
    fill: #ffffff;
  }

  .qs-circuit .qviz .gate-collapse,
  .qs-circuit .qviz .gate-expand {
    opacity: 0;
    transition: opacity 1s;
  }

  .qs-circuit .qviz:hover .gate-collapse,
  .qs-circuit .qviz:hover .gate-expand {
    visibility: visible;
    opacity: 0.2;
    transition: visibility 1s;
    transition: opacity 1s;
  }

  .qs-circuit .gate-expand,
  .gate-collapse {
    cursor: pointer;
  }

  .qs-circuit .gate-collapse circle,
  .qs-circuit .gate-expand circle {
    fill: white;
    stroke-width: 2px;
    stroke: black;
  }

  .qs-circuit .gate-collapse path,
  .qs-circuit .gate-expand path {
    stroke-width: 4px;
    stroke: black;
  }

  .qs-circuit .gate:hover > .gate-collapse,
  .qs-circuit .gate:hover > .gate-expand {
    visibility: visible;
    opacity: 1;
    transition: opacity 1s;
  }

  text {
    user-select: none;
    pointer-events: none;
  }
  .dropzone-layer {
    display: none;
  }
  .dropzone {
    fill-opacity: 0%;
    stroke-opacity: 0%;
  }
  .dropzone:hover {
    fill: var(--vscode-editor-selectionBackground, #ec7063);
    fill-opacity: 50%;
  }
  .dropzone-full-wire {
    fill-opacity: 0%;
    stroke-opacity: 0%;
  }
  .dropzone-full-wire:hover {
    fill: var(--vscode-editor-selectionBackground, #ec7063);
    fill-opacity: 50%;
  }
  .grab {
    cursor: grab;
  }
  .moving {
    cursor: move;
  }
  .copying {
    cursor: copy;
  }

  .panel {
    display: flex;
    flex-direction: row;
  }

  .container {
    display: flex;
  }

  .edit-panel {
    display: flex;
    flex-direction: column;
  }

  .title {
    margin: 0 0 4px;
    font-size: 1.2rem;
    user-select: none;
  }

  .block {
    display: block;
  }

  .target-input,
  .controls-input,
  .parameters-input {
    margin-bottom: 8px;
  }

  .toolbox-panel {
    width: 100px;
    min-height: var(--minToolboxHeight);
    border-right: medium solid var(--vscode-editorWidget-border, #000000);
  }

  .toolbox-panel .title {
    margin-top: 6px;
  }

  .toolbox-panel-svg {
    width: -webkit-fill-available;
    min-height: var(--minToolboxHeight);
    height: 100%;
  }

  .ghost {
    width: var(--minGateWidth);
    height: var(--gateHeight);
    position: absolute;
    z-index: 1;
    pointer-events: none;
    opacity: 0.5;
  }

  .qubit-line-control {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 8px;
  }

  .qubit-line-control .title {
    margin-left: 16px;
  }

  .add-qubit-line,
  .remove-qubit-line {
    border-radius: 4px;
    padding: 8px 16px;
    margin: 4px;
    cursor: pointer;
    font-size: 14px;
    user-select: none;
    background: var(--vscode-button-background, #007acc);
    color: var(--vscode-button-foreground, #ffffff);
    border: 1px solid var(--vscode-button-border, #005a9e);
  }

  .add-qubit-line:hover,
  .remove-qubit-line:hover {
    background: var(--vscode-button-hoverBackground, #005a9e);
  }

  .add-qubit-line:disabled,
  .remove-qubit-line:disabled {
    background: var(--vscode-button-secondaryBackground, #d4d4d4);
    color: var(--vscode-disabledForeground, #a1a1a1);
    border: 1px solid var(--vscode-button-secondaryBackground, #d4d4d4);
    cursor: not-allowed;
  }
}

.context-menu {
  position: absolute;
  background-color: var(--vscode-menu-background, #ffffff);
  border: 1px solid var(--vscode-menu-border, #cccccc);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  padding: 5px 0;
  border-radius: 4px;
}

.context-menu-option {
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--vscode-menu-foreground, #000000);
}

.context-menu-option:hover {
  background-color: var(--vscode-menu-selectionBackground, #f0f0f0);
  color: var(--vscode-menu-selectionForeground, #000000);
}

.prompt-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.prompt-container {
  background: var(--vscode-editor-background, #ffffff);
  color: var(--vscode-editor-foreground, #000000);
  padding: 20px;
  border-radius: 5px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  text-align: center;
  width: 400px;
  max-width: 90%;
}

.prompt-message {
  margin-bottom: 10px;
  color: var(--vscode-editor-foreground, #000000);
  font-size: 1rem;
}

.prompt-input {
  width: 100%;
  padding: 8px;
  margin-bottom: 10px;
  background: var(--vscode-input-background, #ffffff);
  color: var(--vscode-input-foreground, #000000);
  border: 1px solid var(--vscode-input-border, #cccccc);
  font-size: 1rem;
  border-radius: 4px;
  box-sizing: border-box;
}

.prompt-buttons {
  display: flex;
  justify-content: space-between;
}

.prompt-button {
  padding: 8px 16px;
  margin: 0 5px;
  background: var(--vscode-button-background, #007acc);
  color: var(--vscode-button-foreground, #ffffff);
  border: 1px solid var(--vscode-button-border, #005a9e);
  cursor: pointer;
  border-radius: 4px;
}

.prompt-button:hover {
  background: var(--vscode-button-hoverBackground, #005a9e);
}

.prompt-button:disabled {
  background: var(--vscode-button-secondaryBackground, #d4d4d4);
  color: var(--vscode-disabledForeground, #a1a1a1);
  border: 1px solid var(--vscode-button-secondaryBackground, #d4d4d4);
  cursor: not-allowed;
}

.pi-button {
  width: 40px;
  height: 40px;
  padding: 0;
  text-align: center;
  line-height: 40px;
  font-size: 16px;
}
