/* anywidget-archimate styles */

/* Light mode (matches marimo light) */
.aam-wrapper {
  --aam-bg: #ffffff;
  --aam-text: #0f172a;
  --aam-border: #e2e8f0;
  --aam-toolbar-bg: #f8f9fa;
  --aam-btn-bg: #f1f5f9;
  --aam-btn-hover: #e2e8f0;
  --aam-graph-bg: #ffffff;
  --aam-detail-bg: #f8f9fa;
  --aam-panel-bg: #f8f9fa;
  --aam-panel-width: 220px;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  color: var(--aam-text);
  background: var(--aam-bg);
  border: 1px solid var(--aam-border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Dark mode (matches marimo dark) */
.aam-wrapper.aam-dark {
  --aam-bg: #181c1a;
  --aam-text: #eceeed;
  --aam-border: #3b403e;
  --aam-toolbar-bg: #1f2321;
  --aam-btn-bg: #252927;
  --aam-btn-hover: #3b403e;
  --aam-graph-bg: #181c1a;
  --aam-detail-bg: #252927;
  --aam-panel-bg: #1f2321;
}

/* Toolbar */
.aam-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--aam-toolbar-bg);
  border-bottom: 1px solid var(--aam-border);
  flex-shrink: 0;
}

.aam-title {
  font-weight: 600;
  font-size: 14px;
  margin-right: auto;
}

.aam-legend {
  display: flex;
  gap: 12px;
  font-size: 12px;
}

.aam-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.aam-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1.5px solid;
  display: inline-block;
}

.aam-btn {
  padding: 4px 10px;
  border: 1px solid var(--aam-border);
  border-radius: 4px;
  background: var(--aam-btn-bg);
  color: var(--aam-text);
  cursor: pointer;
  font-size: 12px;
  line-height: 1.4;
}

.aam-btn:hover {
  background: var(--aam-btn-hover);
}

.aam-btn-filter {
  font-size: 16px;
  padding: 2px 8px;
  line-height: 1;
}

/* Content area: sidebar + graph */
.aam-content {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ============================================================================
   Filter Panel (left sidebar)
   ============================================================================ */

.aam-filter-panel {
  width: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--aam-panel-bg);
  border-right: 1px solid var(--aam-border);
  transition: width 0.2s ease, min-width 0.2s ease;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.aam-filter-panel.aam-panel-open {
  width: var(--aam-panel-width);
  min-width: var(--aam-panel-width);
}

.aam-filter-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--aam-border);
  font-size: 13px;
  flex-shrink: 0;
}

.aam-filter-content {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}

.aam-filter-section {
  padding: 4px 0;
  border-bottom: 1px solid var(--aam-border);
}

.aam-filter-section:last-child {
  border-bottom: none;
}

.aam-filter-nest-section {
  padding: 6px 0;
}

.aam-filter-nest-toggle {
  cursor: pointer;
  font-weight: 500;
}

/* Container (parent) nodes */
.aam-container .aam-node-rect {
  stroke-dasharray: 4 2;
}

.aam-filter-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--aam-text);
  opacity: 0.6;
}

.aam-filter-toggles {
  font-size: 10px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.aam-filter-toggles a {
  color: var(--aam-text);
  opacity: 0.5;
  text-decoration: none;
  cursor: pointer;
}

.aam-filter-toggles a:hover {
  opacity: 1;
  text-decoration: underline;
}

.aam-filter-subheader {
  padding: 4px 12px 2px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  opacity: 0.5;
}

.aam-filter-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  font-size: 12px;
  cursor: default;
  transition: opacity 0.15s;
}

.aam-filter-item:hover {
  background: var(--aam-btn-hover);
}

.aam-filter-item.aam-filter-hidden {
  opacity: 0.4;
}

.aam-filter-checkbox {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
  accent-color: #6366f1;
  flex-shrink: 0;
}

.aam-filter-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1.5px solid;
  flex-shrink: 0;
}

.aam-filter-badge {
  font-size: 9px;
  font-weight: 700;
  color: var(--aam-text);
  opacity: 0.5;
  min-width: 16px;
  flex-shrink: 0;
}

.aam-filter-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aam-filter-count {
  font-size: 10px;
  color: var(--aam-text);
  opacity: 0.45;
  padding: 1px 5px;
  background: var(--aam-btn-bg);
  border-radius: 8px;
  flex-shrink: 0;
}

/* ============================================================================
   Graph container
   ============================================================================ */

.aam-graph-container {
  flex: 1;
  min-height: 200px;
  min-width: 0;
  background: var(--aam-graph-bg);
  overflow: hidden;
  position: relative;
}

.aam-svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Nodes */
.aam-node {
  cursor: pointer;
  transition: opacity 0.15s;
}

.aam-node:hover .aam-node-rect {
  stroke-width: 2.5;
  filter: brightness(1.05);
}

.aam-node-label {
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
  user-select: none;
}

.aam-node-type {
  font-size: 8px;
  pointer-events: none;
  user-select: none;
}

.aam-layer-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
  pointer-events: none;
  user-select: none;
}

/* Edges */
.aam-edge {
  pointer-events: stroke;
  cursor: default;
}

.aam-edge:hover {
  stroke-width: 2.5;
  stroke-opacity: 1;
}

/* ============================================================================
   Details panel (bottom)
   ============================================================================ */

.aam-details {
  border-top: 1px solid var(--aam-border);
  background: var(--aam-detail-bg);
  padding: 0;
  max-height: 160px;
  overflow-y: auto;
}

.aam-details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--aam-border);
}

.aam-details-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--aam-text);
  padding: 0 4px;
}

.aam-details-body {
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.aam-detail-label {
  font-weight: 600;
  color: var(--aam-text);
  opacity: 0.7;
}

.aam-detail-doc {
  margin-top: 4px;
  padding: 6px 8px;
  background: var(--aam-bg);
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.4;
  opacity: 0.85;
}

/* Empty state */
.aam-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--aam-text);
  opacity: 0.5;
  font-size: 14px;
  padding: 20px;
}

.aam-empty code {
  background: var(--aam-btn-bg);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
}

/* Hide dark mode button when host provides theme */
.aam-wrapper.aam-auto-theme .aam-btn-dark {
  display: none;
}
