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

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

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

  /* 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
*/

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

  /* Text for qubit labels */
  text {
    fill: var(--main-color);
    dominant-baseline: middle;
    text-anchor: middle;
    user-select: none;
    pointer-events: none;
  }

  /* 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;
  }

  .gate .qs-group-label {
    fill: var(--main-color);
    text-anchor: start;
  }

  .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 */
  .gate-unitary {
    fill: var(--vscode-button-secondaryBackground, #333333);
  }

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

  a.qs-circuit-source-link .qs-qubit-label {
    pointer-events: auto;
  }

  /* Hover effect for clickable gates */
  a.qs-circuit-source-link:hover .gate-unitary {
    fill: var(--vscode-button-secondaryHoverBackground, #4d4d4d);
  }

  a.qs-circuit-source-link:hover .gate-measure,
  a.qs-circuit-source-link:hover .gate-ket {
    fill: var(--vscode-button-hoverBackground, #005a9e);
  }

  a.qs-circuit-source-link:hover .qs-qubit-label {
    fill: var(--vscode-editorLink-activeForeground, #5d5d5d);
  }

  a.qs-circuit-source-link:hover .control-dot,
  a.qs-circuit-source-link:hover .control-line {
    fill: var(--vscode-editorLink-activeForeground, #5d5d5d);
    stroke: var(--vscode-editorLink-activeForeground, #5d5d5d);
  }

  a.qs-circuit-source-link:hover .oplus > line,
  a.qs-circuit-source-link:hover .oplus > circle {
    stroke: var(--vscode-editorLink-activeForeground, #5d5d5d);
  }

  /* Default style for arg-button */
  .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) */
  .arg-button.edit-mode {
    text-decoration: underline;
    cursor: pointer;
    pointer-events: all;
  }

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

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

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

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

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

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

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

  /* Classical wire */
  .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.
*/

  .hidden {
    display: none;
  }

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

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

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

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

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

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

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

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

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

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

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

  .qviz .gate-collapse,
  .qviz .gate-expand {
    opacity: 0;
    transition: opacity 0.2s;
  }

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

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

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

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

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

  .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;
  }

  .ghost-opacity {
    opacity: 0.5;
  }

  .svg-run-button-rect {
    fill: var(--vscode-button-background, #007acc);
    rx: 8;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
    transition:
      fill 0.2s,
      filter 0.2s;
  }

  .svg-run-button:hover .svg-run-button-rect,
  .svg-run-button:focus .svg-run-button-rect {
    fill: var(--vscode-button-hoverBackground, #005a9e);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
  }

  .svg-run-button:focus {
    outline: none;
  }

  .svg-run-button-text {
    fill: var(--vscode-button-foreground, #ffffff);
    font-size: 16px;
    font-family: "Segoe UI", Arial, sans-serif;
    font-weight: bold;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
    letter-spacing: 1px;
    user-select: none;
  }

  .svg-run-button {
    cursor: pointer;
  }
}

.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, transparent);
  cursor: pointer;
  border-radius: 4px;
}

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

.prompt-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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