/* ═══════════════════════════════════════════════════════
   Ligand Workspace — Full Overlay for Ligand Management
   ═══════════════════════════════════════════════════════ */

/* Overlay backdrop */
.lw-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.lw-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Workspace container */
.lw-workspace {
  width: min(95vw, 1400px);
  height: min(92vh, 850px);
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header bar */
.lw-header {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--primary), #1B5E20);
  color: #fff;
  gap: 12px;
  flex-shrink: 0;
}
.lw-header h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.3px;
}
.lw-header .lw-breadcrumb {
  font-size: 11px;
  opacity: 0.8;
  flex: 1;
}
.lw-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.15s;
}
.lw-close:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

/* 3-panel body */
.lw-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Panel 1: Library (left) */
.lw-panel-library {
  width: 280px;
  min-width: 240px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background: var(--surface-alt);
}

.lw-panel-library .lw-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.lw-panel-library .lw-search input {
  width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.lw-panel-library .lw-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.1);
}

.lw-library-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}

.lw-library-section {
  padding: 6px 8px 2px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.lw-library-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.lw-library-item:hover {
  background: rgba(46, 125, 50, 0.06);
}
.lw-library-item.active {
  background: rgba(46, 125, 50, 0.12);
  border-color: var(--primary);
}
.lw-library-item .lw-item-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.lw-library-item .lw-item-info {
  flex: 1;
  min-width: 0;
}
.lw-library-item .lw-item-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lw-library-item .lw-item-meta {
  font-size: 10px;
  color: var(--text-muted);
}
.lw-library-item .lw-item-status {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}
.lw-status-ready { background: var(--success-light); color: var(--success); }
.lw-status-pending { background: var(--warning-light); color: var(--warning); }

/* Panel 2: Editor/Preview (center) */
.lw-panel-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.lw-editor-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 12px;
  flex-shrink: 0;
}
.lw-editor-tab {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.lw-editor-tab:hover { color: var(--text); }
.lw-editor-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.lw-editor-content {
  flex: 1;
  overflow: auto;
  padding: 16px;
}

/* 2D structure placeholder */
.lw-2d-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 280px;
  background: var(--surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
}
.lw-2d-placeholder canvas,
.lw-2d-placeholder svg {
  max-width: 100%;
  max-height: 100%;
}

/* 3D viewer placeholder */
.lw-3d-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 320px;
  background: var(--surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Panzoom toolbar */
.lw-panzoom-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.lw-panzoom-toolbar button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-light);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}
.lw-panzoom-toolbar button:hover {
  background: var(--surface-alt);
}

/* Panel 3: Properties & Preparation (right) */
.lw-panel-props {
  width: 320px;
  min-width: 280px;
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background: var(--surface-alt);
}

.lw-props-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.lw-props-section h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.lw-prop-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 2px 0;
}
.lw-prop-row .lw-prop-label {
  color: var(--text-muted);
}
.lw-prop-row .lw-prop-value {
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Preparation checklist */
.lw-checklist {
  padding: 12px 16px;
}
.lw-checklist h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 0 0 10px;
}
.lw-checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 12px;
}
.lw-checklist-item .lw-check-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}
.lw-check-pass { background: var(--success-light); color: var(--success); }
.lw-check-fail { background: #FFEBEE; color: var(--danger); }
.lw-check-pending { background: var(--surface); border: 1px solid var(--border-light); color: var(--text-muted); }

/* Readiness Gate */
.lw-readiness-gate {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}
.lw-gate-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}
.lw-gate-ready {
  background: var(--success-light);
  color: var(--success);
}
.lw-gate-not-ready {
  background: #FFF3E0;
  color: var(--warning);
}
.lw-use-for-docking {
  width: 100%;
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.lw-use-for-docking.enabled {
  background: var(--primary);
  color: #fff;
}
.lw-use-for-docking.enabled:hover {
  background: #1B5E20;
}
.lw-use-for-docking.disabled {
  background: var(--border-light);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* Draw tab SMILES textarea */
.lw-draw-smiles-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font-mono);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  margin-bottom: 8px;
}
.lw-draw-smiles-input:focus {
  border-color: var(--primary);
  outline: none;
}

/* ── Ketcher iframe integration ── */
#ketcherContainer {
  position: relative;
  background: #fff;
}
#ketcherLoading {
  transition: opacity 0.3s ease;
}
#ketcherIframe {
  opacity: 0;
  transition: opacity 0.5s ease;
}
#ketcherIframe.loaded {
  opacity: 1;
}
