/* src/plotsrv/static/plotsrv.css */

:root {
  --bg: #f5f5f5;
  --border: #ddd;
  --button-bg: #ffffff;
  --button-bg-hover: #f0f0f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: #222;
}

.header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-logo {
  height: 34px;
  width: auto;
  display: block;
}

.header-title {
  font-weight: 600;
  font-size: 1rem;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60vw;
}

.view-select select {
  padding: 0.28rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 0.9rem;
}

/* Custom view selector (with icons) */
.ps-viewselect {
  position: relative;
}

.ps-viewselect__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  color: #222;
}

.ps-viewselect__btn:hover {
  background: var(--button-bg-hover);
}

.ps-viewselect__icon {
  width: 14px;
  height: 14px;
  opacity: 0.75;
  display: block;
}

.ps-viewselect__label {
  white-space: nowrap;
  max-width: 36vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ps-viewselect__chev {
  margin-left: 0.1rem;
  opacity: 0.7;
}

.ps-viewselect__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: min(520px, 80vw);
  max-height: 60vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(0,0,0,0.10);
  padding: 0.35rem;
  z-index: 50;
}

.ps-viewselect__group {
  margin: 0.25rem 0 0.5rem;
}

.ps-viewselect__group-label {
  font-weight: 650;
  font-size: 0.82rem;
  color: #444;
  padding: 0.35rem 0.4rem 0.25rem;
}

.ps-viewselect__item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.92rem;
  color: #222;
}

.ps-viewselect__item:hover {
  background: #f5f5f5;
}

.ps-viewselect__item[aria-selected="true"] {
  background: #efefef;
}

.ps-viewselect__itemicon {
  width: 14px;
  height: 14px;
  opacity: 0.75;
  flex: 0 0 auto;
}

.ps-viewselect__itemlabel {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page {
  max-width: 1100px;
  margin: 1.5rem auto;
  padding: 0 1rem 2rem;
}

.plot-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.plot-frame {
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #eee;
  background: #fafafa;
  padding: 0.5rem;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.plot-frame.empty {
  background: #fcfcfc;
}

.empty-state {
  text-align: center;
  font-size: 0.9rem;
  color: #666;
}

#plot {
  max-width: 100%;
  height: auto;
  display: block;
}

.table-scroll {
  overflow: auto;
  max-height: 600px;
  width: 100%;
}

.table-grid {
  width: 100%;
}

.controls {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.controls button {
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--button-bg);
  cursor: pointer;
  font-size: 0.9rem;
}

.controls button:hover {
  background: var(--button-bg-hover);
}

.controls .danger {
  border-color: #e48b8b;
  color: #792424;
  background: #ffecec;
}

.toggle, .interval {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  font-size: 0.9rem;
}

.toggle input {
  transform: translateY(1px);
}

.note {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #666;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid #e48b8b;
  color: #792424;
  background: #ffecec;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* History */
.ps-history select,
.ps-select {
  padding: 0.22rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  font-size: 0.88rem;
}

.ps-history-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid #ead4a4;
  border-radius: 8px;
  background: #fff8e8;
}

.ps-history-banner__main {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.ps-history-banner__text {
  font-size: 0.9rem;
  color: #5e4d22;
}

.ps-is-history .ps-history-banner {
  display: flex;
}

.ps-history-banner[hidden] {
  display: none !important;
}

.ps-history option[disabled] {
  color: #888;
}

/* Disabled auto-refresh while historical */
.ps-disabled-control {
  opacity: 0.6;
  pointer-events: none;
}

.artifact-toolbar {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.artifact-toolbar-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.artifact-toolbar-label {
  font-size: 0.85rem;
  color: #666;
}

.artifact-btn {
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--button-bg);
  cursor: pointer;
  font-size: 0.85rem;
}

.artifact-btn:hover {
  background: var(--button-bg-hover);
}

.artifact-input {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.85rem;
  min-width: 200px;
}

.artifact-counter {
  font-size: 0.8rem;
  color: #666;
}

/* HTML renderer */
.plotsrv-html-iframe-wrap {
  width: 100%;
  border: 1px solid #eee;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.plotsrv-html-iframe {
  width: 100%;
  height: 600px;
  border: 0;
  display: block;
}

/* Text renderer */
.plotsrv-pre {
  width: 100%;
  margin: 0;
  overflow: auto;
  max-height: 600px;
  padding: 0.5rem;
  border: 1px solid #eee;
  border-radius: 6px;
  background: #fff;
  white-space: pre;
  font-size: 0.85rem;
  line-height: 1.35;
}

.plotsrv-pre--wrap {
  white-space: pre-wrap;
  word-break: break-word;
}

.json-tree {
  width: 100%;
  font-size: 0.9rem;
}

.json-children {
  margin: 0.35rem 0 0.35rem 1.25rem;
  padding: 0;
}

.json-children > li {
  list-style: none;
  margin: 0.15rem 0;
}

.json-summaryline {
  cursor: pointer;
}

.json-key {
  font-weight: 600;
}

.json-val {
  color: #333;
}

.json-summary {
  color: #666;
}

.json-badge {
  margin-right: 0.25rem;
}

.json-hit {
  outline: 2px solid rgba(121, 36, 36, 0.25);
  border-radius: 4px;
}

.json-hit-current {
  outline: 2px solid rgba(121, 36, 36, 0.65);
  background: rgba(255, 236, 236, 0.6);
  border-radius: 4px;
}