/* PyMOL WebGL viewer - stylesheet
 *
 * Kept framework free so the page can be dropped into any site.  The only
 * hard requirement of the PyMOL wasm build is a <canvas id="canvas">
 * element (PyMOL creates its WebGL context on it).
 */

:root {
  --pm-bg: #0b0f14;
  --pm-panel: #121820;
  --pm-panel-2: #1a222c;
  --pm-border: #263141;
  --pm-text: #d7e0ea;
  --pm-muted: #8b9bb0;
  --pm-accent: #2fb8a6;
  --pm-accent-dark: #1f8a7c;
  --pm-warn: #e8b04b;
  --pm-error: #e86a5a;
  --pm-mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas,
    monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--pm-bg);
  color: var(--pm-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

#pymol-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

/* ------------------------------------------------------------------ header */
.pm-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  background: var(--pm-panel);
  border-bottom: 1px solid var(--pm-border);
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.pm-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.pm-brand .pm-brand-main {
  color: var(--pm-accent);
  font-size: 17px;
}

.pm-brand .pm-brand-sub {
  color: var(--pm-muted);
  font-size: 12px;
  font-weight: 400;
}

.pm-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pm-toolbar .pm-sep {
  width: 1px;
  height: 20px;
  background: var(--pm-border);
  margin: 0 4px;
}

.pm-text-input,
.pm-select {
  background: #0b1118;
  color: var(--pm-text);
  border: 1px solid var(--pm-border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  outline: none;
  min-width: 120px;
}

.pm-text-input {
  width: 150px;
  font-family: var(--pm-mono);
}

.pm-text-input:focus,
.pm-select:focus {
  border-color: var(--pm-accent-dark);
}

button.pm-btn,
label.pm-btn {
  appearance: none;
  border: 1px solid var(--pm-border);
  background: var(--pm-panel-2);
  color: var(--pm-text);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s ease, border-color 0.12s ease;
  user-select: none;
  white-space: nowrap;
}

button.pm-btn:hover,
label.pm-btn:hover {
  background: #223040;
  border-color: #33455c;
}

button.pm-btn:disabled,
label.pm-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.pm-btn.pm-primary {
  background: var(--pm-accent-dark);
  border-color: var(--pm-accent);
  color: #04110f;
  font-weight: 600;
}

button.pm-btn.pm-primary:hover {
  background: var(--pm-accent);
}

.pm-spacer {
  flex: 1 1 auto;
}

/* --------------------------------------------------------------- main body */
.pm-main {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  min-width: 0;
}

.pm-viewport {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  background: #000;
  overflow: hidden;
}

.pm-viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  outline: none;
}

/* --------------------------------------------------------------- sidebar */
.pm-sidebar {
  flex: 0 0 340px;
  display: flex;
  flex-direction: column;
  background: var(--pm-panel);
  border-left: 1px solid var(--pm-border);
  min-height: 0;
}

.pm-sidebar.pm-collapsed {
  display: none;
}

.pm-sidebar-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px 0;
  border-bottom: 1px solid var(--pm-border);
  flex: 0 0 auto;
}

.pm-tab {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--pm-muted);
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}

.pm-tab.pm-active {
  color: var(--pm-text);
  border-bottom-color: var(--pm-accent);
}

.pm-tab-panel {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
}

.pm-tab-panel.pm-active {
  display: flex;
  flex-direction: column;
}

/* console / output */
.pm-output {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 12px;
  font-family: var(--pm-mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: #0d131a;
}

.pm-output .pm-line {
  margin: 0 0 2px;
}

.pm-output .pm-line.pm-err {
  color: var(--pm-error);
}

.pm-output .pm-line.pm-sys {
  color: var(--pm-muted);
}

.pm-output .pm-line.pm-ok {
  color: var(--pm-accent);
}

.pm-console {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--pm-border);
  padding: 8px;
  background: var(--pm-panel-2);
}

.pm-console .pm-prompt {
  color: var(--pm-accent);
  font-family: var(--pm-mono);
  font-size: 13px;
}

.pm-console input {
  flex: 1 1 auto;
  min-width: 0;
  background: #0b1118;
  border: 1px solid var(--pm-border);
  border-radius: 5px;
  color: var(--pm-text);
  padding: 7px 9px;
  font-family: var(--pm-mono);
  font-size: 12px;
  outline: none;
}

.pm-console input:focus {
  border-color: var(--pm-accent-dark);
}

/* settings tab */
.pm-settings {
  padding: 12px;
  overflow-y: auto;
  font-size: 13px;
}

.pm-settings h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pm-muted);
  margin: 16px 0 8px;
  font-weight: 600;
}

.pm-settings h3:first-child {
  margin-top: 0;
}

.pm-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0;
}

.pm-field label {
  color: var(--pm-muted);
}

.pm-field select,
.pm-field input[type="range"] {
  flex: 0 0 auto;
  width: 150px;
  background: #0b1118;
  color: var(--pm-text);
  border: 1px solid var(--pm-border);
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 12px;
}

.pm-field input[type="range"] {
  padding: 0;
}

.pm-hint {
  color: var(--pm-muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 10px 0 0;
}

.pm-hint kbd {
  background: #0b1118;
  border: 1px solid var(--pm-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--pm-mono);
  font-size: 11px;
}

/* --------------------------------------------------------------- overlays */
.pm-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(6, 10, 14, 0.86);
  backdrop-filter: blur(2px);
  z-index: 10;
  padding: 24px;
  text-align: center;
}

.pm-overlay.pm-hidden {
  display: none;
}

.pm-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(47, 184, 166, 0.25);
  border-top-color: var(--pm-accent);
  animation: pm-spin 0.9s linear infinite;
}

@keyframes pm-spin {
  to {
    transform: rotate(360deg);
  }
}

.pm-progress {
  width: min(420px, 80%);
  height: 6px;
  border-radius: 3px;
  background: #1b2634;
  overflow: hidden;
}

.pm-progress > div {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--pm-accent-dark), var(--pm-accent));
  transition: width 0.2s ease;
}

.pm-loading-title {
  font-size: 15px;
  font-weight: 600;
}

.pm-loading-detail {
  color: var(--pm-muted);
  font-size: 12px;
  max-width: 520px;
  line-height: 1.5;
}

/* long-running job (ray tracing / PNG export), see #pm-job in index.html */
.pm-job-title {
  font-size: 16px;
  font-weight: 600;
}

.pm-job-detail {
  color: var(--pm-muted);
  font-size: 12px;
  max-width: 460px;
  line-height: 1.6;
}

.pm-job-elapsed {
  font-family: var(--pm-mono);
  font-size: 12px;
  color: var(--pm-accent);
}

body.pm-job-running .pm-viewport {
  cursor: progress;
}

/* drag & drop highlight */
.pm-viewport.pm-dragover::after {
  content: "Drop a structure file to load it";
  position: absolute;
  inset: 12px;
  border: 2px dashed var(--pm-accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--pm-accent);
  background: rgba(47, 184, 166, 0.06);
  pointer-events: none;
  z-index: 5;
}

/* toast */
.pm-toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(18, 24, 32, 0.95);
  border: 1px solid var(--pm-border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--pm-text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 20;
  max-width: 80%;
  text-align: center;
}

.pm-toast.pm-show {
  opacity: 1;
}

.pm-toast.pm-error {
  border-color: var(--pm-error);
  color: #ffd9d3;
}

/* ----------------------------------------------------------- small screens */
@media (max-width: 900px) {
  .pm-sidebar {
    flex-basis: 280px;
  }
  .pm-brand .pm-brand-sub {
    display: none;
  }
}

@media (max-width: 700px) {
  .pm-main {
    flex-direction: column;
  }
  .pm-sidebar {
    flex: 0 0 40%;
    border-left: none;
    border-top: 1px solid var(--pm-border);
  }
}

/* ------------------------------------------------------------- attribution */
/* License / trademark notices (see the "Help" tab and the page footer).  The
 * license requires the copyright + permission notice to appear in all copies
 * and in supporting documentation, so this block is deliberately visible and
 * not collapsed behind a tooltip. */
.pm-footer {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 14px;
  padding: 4px 12px;
  background: var(--pm-panel);
  border-top: 1px solid var(--pm-border);
  color: var(--pm-muted);
  font-size: 11px;
  line-height: 1.4;
}

.pm-footer-mark {
  font-family: var(--pm-mono);
  font-size: 10.5px;
  opacity: 0.85;
}

.pm-license {
  margin: 10px 0 0;
  padding: 10px 12px;
  max-height: 320px;
  overflow: auto;
  background: #0b1118;
  border: 1px solid var(--pm-border);
  border-radius: 6px;
  color: var(--pm-muted);
  font-family: var(--pm-mono);
  font-size: 10.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.pm-link {
  color: var(--pm-accent);
  text-decoration: none;
}

.pm-link:hover {
  text-decoration: underline;
}

/* ------------------------------------------------------------- files panel */
.pm-files {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 10px 0;
}

.pm-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  background: #0b1118;
  border: 1px solid var(--pm-border);
  border-radius: 5px;
  font-size: 12px;
}

.pm-file-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--pm-mono);
}

.pm-file-size {
  flex: 0 0 auto;
  color: var(--pm-muted);
  font-family: var(--pm-mono);
  font-size: 11px;
}

.pm-btn-small {
  flex: 0 0 auto;
  padding: 2px 8px;
  font-size: 11px;
}

.pm-files-empty {
  margin: 0;
}
