/* VDDW — Varroa Drug Design Workbench
   Dark theme matching MAH members area aesthetic */

:root {
  --bg-0: #0a0f16;
  --bg-1: #0f1620;
  --bg-2: #141d29;
  --bg-3: #1a2433;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.15);
  --text-0: #e9eef4;
  --text-1: #b4c0cf;
  --text-2: #7d8b9e;
  --text-mute: #5a6a7d;
  --accent: #18b584;
  --accent-soft: rgba(24,181,132,0.12);
  --accent-border: rgba(24,181,132,0.3);
  --warn: #f4b740;
  --danger: #ef4444;
  --purple: #a78bfa;
  --blue: #60a5fa;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', monospace;
  --font-sans: -apple-system, Inter, 'Segoe UI', sans-serif;
  --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Shell */
.vddw-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.vddw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.2rem;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.vddw-brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.vddw-mark { font-size: 1.8rem; }
.vddw-brand h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.vddw-brand p {
  font-size: 0.72rem;
  color: var(--text-2);
}

.vddw-nav {
  display: flex;
  gap: 0.3rem;
}
.vddw-nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.15s;
}
.vddw-nav-btn:hover {
  color: var(--text-0);
  background: var(--bg-2);
}
.vddw-nav-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

/* Views */
.vddw-view {
  display: none;
  flex: 1;
  overflow: hidden;
}
.vddw-view.active {
  display: flex;
  flex-direction: column;
}

/* Main dock grid */
.vddw-main-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  flex: 1;
  overflow: hidden;
}

/* Left panel */
.vddw-left-panel {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0;
}

.vddw-panel-section {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
}
.vddw-panel-section h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  margin-bottom: 0.6rem;
}

/* Inputs */
select, textarea, input[type="number"], input[type="text"] {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-0);
  padding: 0.5rem 0.7rem;
  font-size: 0.83rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.15s;
}
select:focus, textarea:focus, input:focus {
  border-color: var(--accent);
}
textarea {
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* Target info */
.vddw-target-info {
  margin-top: 0.6rem;
  padding: 0.6rem;
  background: var(--bg-2);
  border-radius: var(--radius);
  font-size: 0.78rem;
}
.vddw-info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.2rem 0;
}
.vddw-info-row span:first-child {
  color: var(--text-2);
}
.vddw-info-row code {
  font-family: var(--font-mono);
  color: var(--blue);
  font-size: 0.75rem;
}

/* SMILES actions */
.vddw-smiles-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.vddw-btn-sm {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-1);
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}
.vddw-btn-sm:hover {
  border-color: var(--border-strong);
  color: var(--text-0);
  background: var(--bg-3);
}

/* 2D depiction */
.vddw-2d-depiction {
  margin-top: 0.6rem;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vddw-2d-depiction canvas { max-width: 100%; height: auto; }
.vddw-2d-depiction:empty { display: none; }

.vddw-warn {
  margin-top: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: rgba(244,183,64,0.1);
  border: 1px solid rgba(244,183,64,0.25);
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--warn);
}

/* Properties grid */
.vddw-prop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}
.vddw-prop-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.5rem;
  background: var(--bg-2);
  border-radius: 4px;
  font-size: 0.78rem;
}
.vddw-prop-row span:first-child { color: var(--text-2); }
.vddw-prop-row code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-0);
}

.vddw-badge {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-weight: 600;
}
.vddw-badge.pass { background: rgba(24,181,132,0.15); color: var(--accent); }
.vddw-badge.fail { background: rgba(239,68,68,0.15); color: var(--danger); }

.vddw-calc-badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: rgba(96,165,250,0.15);
  color: var(--blue);
  margin-left: 0.3rem;
}

/* Docking params */
.vddw-param-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.vddw-param-row label {
  font-size: 0.78rem;
  color: var(--text-2);
}
.vddw-box-inputs {
  display: flex;
  gap: 0.3rem;
}
.vddw-box-inputs input {
  width: 55px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.3rem;
}

.vddw-btn-primary {
  width: 100%;
  margin-top: 0.5rem;
  background: var(--accent);
  color: #0a0f16;
  border: none;
  border-radius: var(--radius);
  padding: 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.vddw-btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 12px rgba(24,181,132,0.3);
}
.vddw-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Right panel */
.vddw-right-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 3D viewer */
.vddw-viewer-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.vddw-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.8rem;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
}
.vddw-viewer-header h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
}
.vddw-viewer-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.vddw-viewer-label {
  font-size: 0.72rem;
  color: var(--text-mute);
  margin-left: 0.5rem;
}

.vddw-3d-viewer {
  flex: 1;
  background: #050a0f;
  position: relative;
  min-height: 300px;
}

/* Results */
.vddw-results-section {
  max-height: 280px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  background: var(--bg-1);
}
.vddw-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
.vddw-results-header h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
}
.vddw-results-count {
  font-size: 0.72rem;
  color: var(--text-mute);
}
.vddw-results-table {
  padding: 0.5rem 0.8rem;
}
.vddw-empty-state {
  color: var(--text-mute);
  font-size: 0.82rem;
  padding: 1.5rem 0;
  text-align: center;
}

.vddw-result-row {
  display: grid;
  grid-template-columns: 30px 1fr 80px 80px 60px;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.3rem;
  background: var(--bg-2);
  border-radius: 4px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.15s;
  border: 1px solid transparent;
}
.vddw-result-row:hover {
  border-color: var(--border-strong);
}
.vddw-result-row.active {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}
.vddw-result-rank {
  font-family: var(--font-mono);
  color: var(--text-mute);
  text-align: center;
}
.vddw-result-pose { color: var(--text-1); font-size: 0.72rem; }
.vddw-result-affinity {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
}
.vddw-result-rmsd {
  font-family: var(--font-mono);
  color: var(--text-2);
  font-size: 0.72rem;
}
.vddw-result-view {
  font-size: 0.7rem;
  color: var(--blue);
  text-align: right;
}

/* Library view */
.vddw-library-grid {
  padding: 1.5rem;
  overflow-y: auto;
}
.vddw-library-header h2 {
  font-size: 1.1rem;
  margin-bottom: 0.3rem;
}
.vddw-library-header p {
  color: var(--text-2);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.vddw-compound-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.vddw-compound-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}
.vddw-compound-card:hover {
  border-color: var(--accent-border);
  transform: translateY(-2px);
}
.vddw-compound-card h3 {
  font-size: 0.92rem;
  margin-bottom: 0.2rem;
}
.vddw-compound-card .vddw-compound-class {
  font-size: 0.7rem;
  color: var(--purple);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.vddw-compound-card .vddw-compound-smiles {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 0.5rem;
}
.vddw-compound-card .vddw-compound-canvas {
  text-align: center;
  margin: 0.5rem 0;
}
.vddw-compound-card .vddw-compound-canvas canvas { max-width: 100%; }
.vddw-compound-card .vddw-compound-moa {
  font-size: 0.75rem;
  color: var(--text-1);
  line-height: 1.4;
}

/* Targets view */
.vddw-targets-section {
  padding: 1.5rem;
  overflow-y: auto;
  max-width: 1000px;
}
.vddw-targets-section h2 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}
.vddw-targets-intro {
  color: var(--text-2);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.vddw-targets-table {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.vddw-target-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.2rem;
}
.vddw-target-card-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.5rem;
}
.vddw-target-card h3 { font-size: 0.95rem; }
.vddw-target-priority {
  font-size: 0.65rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  text-transform: uppercase;
  font-weight: 600;
}
.vddw-target-priority.high { background: rgba(239,68,68,0.15); color: var(--danger); }
.vddw-target-priority.medium { background: rgba(244,183,64,0.15); color: var(--warn); }

.vddw-target-uniprots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
}
.vddw-uniprot-chip {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  background: var(--bg-2);
  border-radius: 3px;
  color: var(--blue);
}
.vddw-target-moa {
  font-size: 0.8rem;
  color: var(--text-1);
  margin-top: 0.4rem;
}

/* About view */
.vddw-about-section {
  padding: 2rem;
  max-width: 800px;
  overflow-y: auto;
}
.vddw-about-section h2 {
  font-size: 1.3rem;
  margin-bottom: 0.8rem;
}
.vddw-about-section h3 {
  font-size: 1rem;
  margin: 1.2rem 0 0.5rem;
  color: var(--accent);
}
.vddw-about-section p, .vddw-about-section ul, .vddw-about-section ol {
  color: var(--text-1);
  font-size: 0.88rem;
  line-height: 1.7;
  margin-bottom: 0.5rem;
}
.vddw-about-section li { margin-left: 1.5rem; margin-bottom: 0.3rem; }
.vddw-about-section a { color: var(--blue); text-decoration: none; }
.vddw-about-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-mute);
}

/* Loading */
.vddw-loading {
  position: fixed;
  inset: 0;
  background: rgba(10,15,22,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
.vddw-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.vddw-loading-text {
  margin-top: 1rem;
  color: var(--text-1);
  font-size: 0.85rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 760px) {
  .vddw-main-grid {
    grid-template-columns: 1fr;
  }
  .vddw-left-panel {
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .vddw-nav-btn { padding: 0.35rem 0.6rem; font-size: 0.75rem; }
}