/* =====================================================
   WWP Relational Database Plugin - v2.22.0
   ===================================================== */

/* Scope all rules to avoid theme conflicts */
.pmd-root,
.pmd-root * {
  box-sizing: border-box;
}

/* Main container */
.pmd-root {
  display: flex !important;
  flex-direction: column;
  gap: 8px;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 8px;
  background: #2d2d2d;
  color: #f0f0f0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  width: 100%;
  /* height is set inline via shortcode attribute */
  min-height: 550px;
  overflow: hidden;
}

/* Toolbar */
.pmd-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px solid #444;
  flex-shrink: 0;
}

.pmd-toolbar-spacer {
  margin-left: auto;
}

.pmd-toolbar label {
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #f0f0f0;
  margin: 0;
  padding: 0;
  font-weight: normal;
}
/* `display: inline-flex` above wins over the browser's default
   `[hidden] { display: none }`, so labels stay visible even when their
   `hidden` attribute is set (e.g. the Tree-direction control in radial
   mode). Restore the hide behavior explicitly. */
.pmd-toolbar label[hidden] {
  display: none;
}

.pmd-toolbar select,
.pmd-toolbar input[type="range"] {
  background: #3a3a3a;
  color: #f0f0f0;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 13px;
  margin: 0;
}

/* --- Search combobox (v2.17.0) --- */
.pmd-search-label {
  position: relative;
}
.pmd-node-search-wrapper {
  position: relative;
  display: inline-block;
}
.pmd-node-search-input {
  background: #3a3a3a;
  color: #f0f0f0;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 4px 26px 4px 8px;
  font-size: 13px;
  font-family: inherit;
  min-width: 240px;
  height: 28px;
  box-sizing: border-box;
}
.pmd-node-search-input:focus {
  outline: none;
  border-color: #00aaff;
  background: #444;
}
.pmd-node-search-input::placeholder {
  color: #888;
}
.pmd-node-search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  color: #aaa;
  border: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.pmd-node-search-clear:hover {
  background: #555;
  color: #fff;
}
.pmd-node-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 320px;
  max-width: 480px;
  max-height: 60vh;
  overflow-y: auto;
  background: #2d2d2d;
  border: 1px solid #555;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 60;
  margin: 0;
  padding: 4px;
  list-style: none;
}
.pmd-node-search-item {
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
}
.pmd-node-search-item:hover,
.pmd-node-search-item.is-highlighted {
  background: #404040;
  border-color: #666;
}
.pmd-node-search-empty {
  padding: 10px;
  color: #aaa;
  font-size: 13px;
  font-style: italic;
}
.pmd-search-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}
.pmd-search-name mark {
  background: #ffcc00;
  color: #1a1a1a;
  padding: 0 2px;
  border-radius: 2px;
}
.pmd-search-attach {
  color: #ffcc00;
  font-size: 11px;
  vertical-align: middle;
  margin-left: 4px;
}
.pmd-search-meta {
  font-size: 11px;
  color: #aaa;
  margin-top: 2px;
}
.pmd-search-snippet {
  font-size: 12px;
  color: #cfcfcf;
  margin-top: 4px;
  line-height: 1.4;
}
.pmd-search-snippet mark {
  background: #4a4a00;
  color: #ffd954;
  padding: 0 2px;
  border-radius: 2px;
}

.pmd-checkbox-label {
  cursor: pointer;
}

/* Panel container */
.pmd-panels {
  display: flex;
  gap: 8px;
  flex-grow: 1;
  /* FIX: explicit min-height:0 so flex children can shrink correctly */
  min-height: 0;
}

/* Cytoscape canvas */
.pmd-canvas {
  flex-grow: 1;
  position: relative;
  border: 1px solid #444;
  border-radius: 6px;
  background: #1e1e1e;
  min-width: 0;
  /* FIX: explicit min-height so Cytoscape never gets a 0px container */
  min-height: 400px;
  height: 100%;
}
/* Side panel */
.pmd-sidepanel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 12px;
  background: #3a3a3a;
  width: 30%;
  max-width: 350px;
  min-width: 250px;
  overflow-y: auto;
}

/* ---------------- Mobile / narrow-viewport layout ---------------- */
/* Below ~800px the side-panel doesn't have enough room. Stack it below
   the canvas instead, full-width, with a capped height so the page can
   still scroll past it. */
@media (max-width: 800px) {
  .pmd-panels {
    flex-direction: column;
  }
  .pmd-canvas {
    width: 100%;
    min-height: 60vh;
  }
  .pmd-sidepanel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: 50vh;
  }
}

/* Buttons */
.pmd-fullscreen-btn,
.pmd-toggle-panel,
.pmd-reset-btn {
  background: #4f4f4f;
  color: #f0f0f0;
  border: 1px solid #666;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
}

.pmd-reset-btn:hover {
  background-color: #5a5a5a;
}

.pmd-fullscreen-btn svg {
  stroke: #f0f0f0;
  display: block;
}

.pmd-fullscreen-btn:hover,
.pmd-toggle-panel:hover {
  background-color: #5a5a5a;
}

/* Side panel content */
.pmd-title {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.2;
  color: #fff;
}

.pmd-description {
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 12px;
  color: #f0f0f0;
}

.pmd-connections h4 {
  font-size: 14px;
  margin: 16px 0 8px;
  border-bottom: 1px solid #4f4f4f;
  padding-bottom: 4px;
  color: #f0f0f0;
}

.pmd-connections-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.conn-item {
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
  color: #f0f0f0;
}

.conn-item:hover {
  background-color: #4f4f4f;
}

/* Legend */
.pmd-legend {
  margin-top: 16px;
  border-top: 1px solid #4f4f4f;
  padding-top: 12px;
}

.pmd-legend h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #f0f0f0;
}

.pmd-legend h5 {
  margin: 12px 0 8px;
  font-size: 13px;
  font-weight: bold;
  color: #f0f0f0;
}

.pmd-legend ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.pmd-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f0f0f0;
}

.legend-color-box {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Error state */
.pmd-error {
  padding: 20px;
  background-color: #ffebee;
  color: #c62828;
  border: 1px solid #c62828;
  border-radius: 8px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  text-align: center;
}

/* Fullscreen mode */
.pmd-root:fullscreen,
.pmd-root:-webkit-full-screen,
.pmd-root:-moz-full-screen {
  border-radius: 0;
  height: 100vh !important;
  width: 100vw !important;
}

/* Edge hover panel styles */
.pmd-edge-from,
.pmd-edge-to {
    font-weight: bold;
    color: #fff;
}
.pmd-edge-arrow {
    color: #ffcc00;
    font-size: 16px;
    margin: 0 4px;
}

/* --- Side-panel header (v2.17.0): thumbnail + pills --- */
.pmd-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.pmd-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid #555;
  background: #1e1e1e;
  flex-shrink: 0;
}
.pmd-type-pill,
.pmd-date-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  line-height: 1.4;
  white-space: nowrap;
}
.pmd-date-pill {
  background: #555;
  border: 1px solid #666;
}

/* --- Connections list: media indicator dot --- */
.conn-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.conn-attach-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffcc00;
  margin-left: 8px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 204, 0, 0.2);
}

/* --- Attachments section --- */
.pmd-attachments {
  border-top: 1px solid #4f4f4f;
  padding-top: 12px;
  margin-top: 8px;
}
.pmd-attachments h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #f0f0f0;
}
.pmd-attachments-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pmd-attach-card {
  background: #2d2d2d;
  border: 1px solid #4f4f4f;
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pmd-attach-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.pmd-attach-desc {
  font-size: 12px;
  color: #cfcfcf;
  line-height: 1.4;
}
.pmd-attach-card audio,
.pmd-attach-card video,
.pmd-attach-card img {
  max-width: 100%;
  border-radius: 4px;
  display: block;
}
.pmd-attach-card audio { width: 100%; }
.pmd-attach-card video { background: #000; }
/* Inline embed iframe (SoundCloud / YouTube / Vimeo / Spotify widgets).
   166px = SoundCloud's compact-mode default height; YouTube/Vimeo widgets
   resize to their own aspect inside this height, which is fine for a
   sidebar preview. The lightbox version (.pmd-lightbox-iframe) gets full
   real estate via its existing rule lower in this file. */
.pmd-attach-card iframe.pmd-attach-embed {
  width: 100%;
  height: 166px;
  border: 0;
  border-radius: 4px;
  display: block;
  background: #2a2a2a;
}
.pmd-attach-link {
  color: #79c0ff;
  text-decoration: none;
  font-size: 13px;
  word-break: break-all;
}
.pmd-attach-link:hover { text-decoration: underline; }
.pmd-attach-pdf::before,
.pmd-attach-link::before {
  /* subtle file-type marker — empty by default, hook for plugin authors */
}

/* --- Layout selector emphasis --- */
.pmd-toolbar select.pmd-layout-select {
  min-width: 160px;
  font-weight: 600;
}

/* --- Randomize-colors button (v2.17.0) --- */
.pmd-palette-btn {
  background: #4f4f4f;
  color: #f0f0f0;
  border: 1px solid #666;
  border-radius: 6px;
  padding: 4px 10px 4px 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 1;
  height: 28px;
}
.pmd-palette-btn:hover  { background-color: #5a5a5a; }
.pmd-palette-btn:active { background-color: #444;    }
.pmd-palette-preview {
  display: inline-flex;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid #666;
  height: 16px;
}
.pmd-palette-preview-swatch {
  display: inline-block;
  width: 8px;
  height: 16px;
}
.pmd-palette-label {
  font-weight: 600;
}

/* --- "View full" button on attachment cards (v2.17.0) --- */
.pmd-attach-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}
.pmd-attach-view-full {
  background: #3a3a3a;
  color: #f0f0f0;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  line-height: 1.2;
}
.pmd-attach-view-full:hover {
  background: #4a4a4a;
  border-color: #777;
}

/* --- Lightbox (v2.17.0) --- */
.pmd-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
}
.pmd-lightbox[hidden] {
  display: none;
}
.pmd-lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  cursor: pointer;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.pmd-lightbox-content {
  position: relative;
  width: min(1400px, 92vw);
  max-height: 92vh;
  background: #2d2d2d;
  border: 1px solid #555;
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pmd-lightbox-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid #444;
  background: #333;
  flex-shrink: 0;
}
.pmd-lightbox-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pmd-lightbox-newtab {
  color: #79c0ff;
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 4px;
}
.pmd-lightbox-newtab:hover {
  text-decoration: underline;
  background: rgba(121, 192, 255, 0.08);
}
.pmd-lightbox-close {
  background: transparent;
  color: #f0f0f0;
  border: 1px solid #666;
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pmd-lightbox-close:hover {
  background: #4a4a4a;
  border-color: #888;
}
.pmd-lightbox-body {
  flex-grow: 1;
  background: #1e1e1e;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}
.pmd-lightbox-iframe {
  width: 100%;
  height: 100%;
  min-height: 75vh;
  border: 0;
  background: #fff;
}
.pmd-lightbox-img {
  max-width: 100%;
  max-height: 84vh;
  display: block;
  object-fit: contain;
}
.pmd-lightbox-video {
  max-width: 100%;
  max-height: 84vh;
  display: block;
  background: #000;
}

/* =====================================================
   Music-aware additions (phyzk Music DB v0.1.0)
   ===================================================== */

/* Color-by / Size-by selectors share a subtle highlight so they read as a
   distinct toolbar group from the generic controls. */
.pmd-music-control {
  position: relative;
}
.pmd-music-control::before {
  content: "";
  position: absolute;
  inset: -2px -4px;
  border-radius: 4px;
  background: rgba(0, 170, 255, 0.06);
  z-index: -1;
}

/* Legend header tells the user which dimension is driving color right now. */
.pmd-legend-header {
  font-size: 12px;
  color: #cfcfcf;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.pmd-legend-palette {
  color: #888;
  font-size: 11px;
}

/* Gradient bar shown when Color-by maps to a sequential / diverging /
   sequential-date palette. We position the min/max labels as flex
   flanks and the mid label (diverging only) absolutely. */
.pmd-legend-grad-wrap {
  margin: 4px 0 8px;
}
.pmd-legend-grad {
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.pmd-legend-grad-labels {
  position: relative;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #cfcfcf;
  margin-top: 4px;
}
.pmd-legend-grad-mid {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  color: #aaa;
  font-style: italic;
}
.pmd-legend-grad-min,
.pmd-legend-grad-max {
  font-variant-numeric: tabular-nums;
}

/* Palette button shows up to 6 swatches now (chromatic wheel has more
   distinct hues than the original categorical palettes — 5 felt sparse). */
.pmd-palette-preview-swatch {
  width: 12px;
  height: 12px;
  display: inline-block;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  margin-right: -3px;
}

/* Bucket-parents toggle group — visually clusters the 5 axis checkboxes
   together (BPM / Energy / Loudness / Duration / Spectral) so they read
   as a single control group, not loose toggles. The trailing label sits
   inside the group's tinted background. */
.pmd-bucket-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 8px 2px 6px;
  border: 1px solid #4a5b6e;
  border-radius: 4px;
  background: rgba(0, 170, 255, 0.05);
}
.pmd-bucket-group-label {
  font-size: 12px;
  color: #aab8c7;
  letter-spacing: 0.02em;
  margin-right: 2px;
}
.pmd-bucket-group .pmd-checkbox-label {
  font-size: 12px;
  gap: 3px;
}

/* The .pmd-canvas wraps Cytoscape's own absolutely-positioned canvases.
   Position the wheel-key labels in the same coordinate system. */
.pmd-canvas {
  position: relative;  /* already implied by upstream, restated for clarity */
}
.pmd-wheel-label {
  position: absolute;
  width: 32px;
  height: 20px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #cfcfcf;
  letter-spacing: 0.02em;
  pointer-events: none;
  text-shadow: 0 0 4px #1e1e1e, 0 0 4px #1e1e1e;
  z-index: 5;
}


