/* Phylotree Viewer Styles */

.phylotree-container {
  width: 100%;
  overflow: auto;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
}

.phylotree-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.phylotree-toolbar-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.phylotree-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  font-size: 0.875rem;
}

/* Tree container */
.tree-widget {
  padding: 2rem;
  min-height: 400px;
}

/* Phylotree specific styles */
.phylotree-container .node circle {
  fill: #64748b;
  cursor: pointer;
}

.phylotree-container .node text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  fill: #1e293b;
}

.phylotree-container .node.selected circle {
  fill: #3b82f6;
  stroke: #1e40af;
  stroke-width: 2px;
}

.phylotree-container .link {
  fill: none;
  stroke: #94a3b8;
  stroke-width: 1.5px;
}

.phylotree-container .link.branch-multiple {
  stroke-dasharray: 5, 5;
  stroke-width: 2px;
}

.phylotree-container .link.selected {
  stroke: #3b82f6;
  stroke-width: 2.5px;
}

/* Internal node labels */
.phylotree-container .internal-node text {
  fill: #64748b;
  font-size: 10px;
}

/* Leaf node labels */
.phylotree-container .leaf-node text {
  font-size: 12px;
  fill: #1e293b;
}

/* Collapsed clade */
.phylotree-container .collapsed-clade {
  fill: #cbd5e1;
  stroke: #94a3b8;
  stroke-width: 1px;
}

/* Hover effects */
.phylotree-container .node:hover circle {
  stroke: #2563eb;
  stroke-width: 2px;
}

.phylotree-container .link:hover {
  stroke: #2563eb;
  stroke-width: 3px;
}

/* Selection colors - match d3.schemeCategory10 */
.phylotree-selection-0 { color: #1f77b4; }
.phylotree-selection-1 { color: #ff7f0e; }
.phylotree-selection-2 { color: #2ca02c; }
.phylotree-selection-3 { color: #d62728; }
.phylotree-selection-4 { color: #9467bd; }
.phylotree-selection-5 { color: #8c564b; }
.phylotree-selection-6 { color: #e377c2; }
.phylotree-selection-7 { color: #7f7f7f; }
.phylotree-selection-8 { color: #bcbd22; }
.phylotree-selection-9 { color: #17becf; }

/* Toolbar button styles */
.phylotree-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.375rem;
  border: 1px solid #cbd5e1;
  background: white;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.phylotree-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #1e293b;
}

.phylotree-btn:active,
.phylotree-btn.active {
  background: #3b82f6;
  border-color: #2563eb;
  color: white;
}

.phylotree-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.phylotree-btn svg {
  width: 1rem;
  height: 1rem;
}

.phylotree-btn-icon-only {
  padding: 0.5rem;
}

/* Input styles */
.phylotree-input {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 0.375rem;
  border: 1px solid #cbd5e1;
  background: white;
  color: #1e293b;
}

.phylotree-input:focus {
  outline: none;
  border-color: #3b82f6;
  ring: 2px;
  ring-color: #3b82f680;
}

.phylotree-input:disabled {
  background: #f1f5f9;
  color: #94a3b8;
}

/* Badge styles */
.phylotree-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  background: #e2e8f0;
  color: #475569;
}

.phylotree-badge-primary {
  background: #dbeafe;
  color: #1e40af;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .phylotree-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .phylotree-toolbar-group {
    justify-content: center;
  }

  .phylotree-status-bar {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }

  .tree-widget {
    padding: 1rem;
  }
}

/* Loading state */
.phylotree-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: #64748b;
}

.phylotree-loading::after {
  content: "Loading tree...";
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Error state */
.phylotree-error {
  padding: 2rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 0.5rem;
  color: #991b1b;
}

/* Modal styles for newick input/export */
.phylotree-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.phylotree-modal {
  background: white;
  border-radius: 0.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-width: 42rem;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  margin: 1rem;
}

.phylotree-modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.phylotree-modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
}

.phylotree-modal-body {
  padding: 1.5rem;
}

.phylotree-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.phylotree-modal textarea {
  width: 100%;
  min-height: 20rem;
  padding: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  resize: vertical;
}

.phylotree-modal textarea:focus {
  outline: none;
  border-color: #3b82f6;
  ring: 2px;
  ring-color: #3b82f680;
}

/* Hidden utility */
.phylotree-hidden {
  display: none;
}
