/* ── Reset & Base ─────────────────────────────────────────────── */

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

:root {
  --bg-primary: #080c14;
  --bg-secondary: #121620;
  --bg-card: #0f131c;
  --bg-surface: #1a1f2e;
  --accent: #d2f800;
  --accent-dim: rgba(210, 248, 0, 0.15);
  --text-primary: #ffffff;
  --text-secondary: #8a8f98;
  --text-muted: #555b66;
  --border: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(210, 248, 0, 0.4);
  --font-sans: "Geist Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "Geist Mono", "SF Mono", "Fira Code", monospace;
  --panel-width: 380px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ── Layout ───────────────────────────────────────────────────── */

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  flex-shrink: 0;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#workflow-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Logo ─────────────────────────────────────────────────────── */

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 14px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.logo-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 1px;
}

/* ── Buttons ──────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn.active {
  color: var(--bg-primary);
  background: var(--accent);
  border-color: var(--accent);
}

.btn-icon {
  padding: 6px;
  min-width: 28px;
}

.btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-group {
  display: flex;
}

.btn-group .btn {
  border-radius: 0;
  margin-left: -1px;
}

.btn-group .btn:first-child {
  border-radius: 2px 0 0 2px;
  margin-left: 0;
}

.btn-group .btn:last-child {
  border-radius: 0 2px 2px 0;
}

.separator {
  width: 1px;
  height: 20px;
  background: var(--border);
}

/* ── Search ───────────────────────────────────────────────────── */

.search-wrapper {
  position: relative;
}

.search-input {
  width: 240px;
  padding: 6px 10px 6px 30px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 2px;
  outline: none;
  transition: border-color 0.15s ease;
}

.search-input:focus {
  border-color: var(--accent);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  stroke: var(--text-muted);
  stroke-width: 2;
  fill: none;
}

.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 400px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.search-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s ease;
}

.search-result:hover {
  background: var(--bg-surface);
}

.search-result:last-child {
  border-bottom: none;
}

.search-result-type {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
  width: 60px;
}

.search-result-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-name mark {
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 1px;
  padding: 0 2px;
}

.search-result-path {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  flex-shrink: 0;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: none;
}

.search-result-flags {
  font-family: var(--font-mono);
  font-size: 9px;
  color: #f59e0b;
  flex-shrink: 0;
}

.search-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

.search-more {
  padding: 8px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-mono);
}

/* ── Filters ──────────────────────────────────────────────────── */

.filter-select {
  padding: 6px 24px 6px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a8f98' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.filter-select:focus {
  border-color: var(--accent);
}

.filter-select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* ── Detail Panel ─────────────────────────────────────────────── */

#detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--panel-width);
  height: 100%;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  z-index: 20;
}

#detail-panel.open {
  transform: translateX(0);
}

.detail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 1;
}

.detail-panel-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

#detail-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  transition: color 0.15s ease;
}

#detail-close:hover {
  color: var(--text-primary);
}

#detail-close svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

#detail-content {
  padding: 16px;
}

.detail-header {
  margin-bottom: 16px;
}

.detail-badges {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.detail-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 2px;
  text-transform: uppercase;
}

.client-badge {
  background: rgba(249, 115, 22, 0.15);
  color: #f97316;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.server-badge {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.detail-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
  word-break: break-word;
}

.detail-path {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 8px;
  word-break: break-all;
}

.detail-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
}

.detail-meta {
  display: flex;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

/* ── Detail Sections ──────────────────────────────────────────── */

.detail-section {
  margin-bottom: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.detail-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.flags-title {
  color: #f59e0b;
}

.detail-flags {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-flag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 2px;
  line-height: 1.3;
}

.detail-flag.critical {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-left: 3px solid #ef4444;
}

.detail-flag.warning {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border-left: 3px solid #f59e0b;
}

.detail-flag.info {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border-left: 3px solid #3b82f6;
}

.detail-exports {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.detail-export {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-card);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 2px;
}

.detail-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.1s ease;
}

.detail-link:hover {
  background: var(--bg-card);
}

.detail-link-type {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
  width: 50px;
  text-transform: uppercase;
}

.detail-link-name {
  font-size: 11px;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-link-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  flex-shrink: 0;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Minimap ──────────────────────────────────────────────────── */

#minimap {
  position: absolute;
  bottom: 16px;
  left: 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: crosshair;
  z-index: 15;
}

/* ── Stats Bar ────────────────────────────────────────────────── */

.stats-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.stat strong {
  color: var(--text-secondary);
}

/* ── Layout Status ────────────────────────────────────────────── */

#layout-status {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 15;
}

#layout-status.visible {
  opacity: 1;
}

/* ── Legend ────────────────────────────────────────────────────── */

.legend {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(8, 12, 20, 0.85);
  border: 1px solid var(--border);
  border-radius: 4px;
  z-index: 15;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 1px;
}

/* ── Scrollbar ────────────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Responsive ───────────────────────────────────────────────── */

@media (max-width: 768px) {
  .toolbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 8px;
  }

  .toolbar-center {
    order: 3;
    flex-basis: 100%;
    justify-content: flex-start;
  }

  .search-input {
    width: 100%;
  }

  #detail-panel {
    width: 100%;
  }

  .legend {
    display: none;
  }
}
