@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
  --bg-primary: #0a0c12;
  --bg-secondary: #0f1117;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --bg-input: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.18);
  --accent-1: #6366f1;
  --accent-2: #8b5cf6;
  --accent-3: #a78bfa;
  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.3);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(245, 158, 11, 0.3);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(239, 68, 68, 0.3);
  --info: #06b6d4;
  --info-bg: rgba(6, 182, 212, 0.1);
  --info-border: rgba(6, 182, 212, 0.25);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-elevated: 0 8px 40px rgba(0, 0, 0, 0.5);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 14px;
  overflow-x: hidden;
}

/* Background decoration */
body::before {
  content: '';
  position: fixed;
  top: -30%;
  left: -20%;
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.07) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -20%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.07) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ── */

.app-wrapper {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 48px;
}

/* ── Header ── */

.app-header {
  padding: 36px 0 32px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 36px;
}

.app-header .logo-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-3);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.app-header .logo-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-gradient);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.app-header h1 {
  font-size: 38px;
  font-weight: 800;
  background: linear-gradient(135deg, #f1f5f9 30%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 10px;
}

.app-header p {
  font-size: 15px;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto;
}

/* ── Main Grid ── */

.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 20px;
  align-items: start;
}

.panel-left {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Cards ── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-hover);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ── Form Elements ── */

.input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.input-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

input[type="text"],
select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: var(--transition);
  -webkit-appearance: none;
}

input[type="text"]:focus,
select:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
  background: rgba(99, 102, 241, 0.06);
}

input[type="text"]::placeholder {
  color: var(--text-muted);
}

select option {
  background: #1e2130;
  color: var(--text-primary);
}

/* Custom select arrow */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.12);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: none;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

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

.btn-full {
  width: 100%;
}

.btn-lg {
  padding: 14px 24px;
  font-size: 15px;
  border-radius: var(--radius-md);
}

/* ── People List ── */

.people-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.people-list::-webkit-scrollbar {
  width: 4px;
}

.people-list::-webkit-scrollbar-track {
  background: transparent;
}

.people-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.person-tag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  transition: var(--transition);
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.person-tag:hover {
  border-color: var(--border-hover);
}

.person-tag .person-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.person-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px 0;
  font-style: italic;
}

/* ── Connection List ── */

.connection-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.connection-list::-webkit-scrollbar {
  width: 4px;
}
.connection-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.connection-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  transition: var(--transition);
  animation: slideIn 0.2s ease;
}

.connection-item:hover {
  border-color: var(--border-hover);
}

.connection-item .conn-names {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.conn-from {
  color: var(--accent-3);
  font-weight: 600;
}

.conn-arrow {
  color: var(--text-muted);
  font-size: 11px;
}

.conn-type-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-3);
  border: 1px solid rgba(99, 102, 241, 0.25);
}

/* ── Query Section ── */

.query-select-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.vs-divider {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  text-align: center;
  padding-bottom: 11px;
  letter-spacing: 0.1em;
}

/* ── Results Panel ── */

.result-placeholder {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.result-placeholder .placeholder-icon {
  font-size: 40px;
  margin-bottom: 12px;
  display: block;
  opacity: 0.5;
}

.result-placeholder p {
  font-size: 14px;
}

.result-content {
  display: none;
  animation: fadeUp 0.3s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-content.visible {
  display: block;
}

/* Relationship result block */
.rel-result-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.rel-icon {
  font-size: 28px;
  line-height: 1;
}

.rel-label {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.rel-label small {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Path trace */
.path-trace {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.path-trace-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.path-nodes {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
}

.path-node {
  display: flex;
  align-items: center;
  gap: 0;
}

.path-person {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-hover);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.path-person.highlight {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.5);
  color: var(--accent-3);
}

.path-edge {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 8px;
}

.path-edge-type {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
}

.path-arrow {
  color: var(--accent-1);
  font-size: 14px;
  line-height: 1;
}

/* FVA Status Banner */
.fva-banner {
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 16px;
  border: 1px solid;
}

.fva-banner.fva-yes {
  background: var(--success-bg);
  border-color: var(--success-border);
}

.fva-banner.fva-no {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.fva-banner.fva-unknown {
  background: var(--warning-bg);
  border-color: var(--warning-border);
}

.fva-banner .fva-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.fva-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.fva-yes .fva-badge {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.fva-no .fva-badge {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.fva-unknown .fva-badge {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.fva-title {
  font-size: 14px;
  font-weight: 700;
}

.fva-yes .fva-title { color: var(--success); }
.fva-no .fva-title { color: var(--danger); }
.fva-unknown .fva-title { color: var(--warning); }

.fva-description {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.fva-section-ref {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 6px;
}

.fva-section-ref a {
  color: var(--accent-3);
  text-decoration: none;
}

.fva-section-ref a:hover {
  text-decoration: underline;
}

/* Disclaimer */
.disclaimer {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.disclaimer strong {
  color: var(--info);
}

/* no-result */
.no-result {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 14px;
}

.no-result .no-result-icon {
  font-size: 36px;
  display: block;
  margin-bottom: 10px;
  opacity: 0.5;
}

/* ── Divider ── */

.section-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ── Tooltips ── */

[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e2130;
  color: var(--text-secondary);
  font-size: 11px;
  padding: 5px 9px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  border: 1px solid var(--border);
  z-index: 100;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ── NETWORK MAP ── */
.network-map-container {
  width: 100%;
  height: 480px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  margin-top: 1rem;
  overflow: hidden;
  position: relative;
}

.network-map-container canvas {
  outline: none;
}

/* ── Footer ── */

.app-footer {
  margin-top: 48px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

.app-footer a {
  color: var(--accent-3);
  text-decoration: none;
}

/* ── Responsive ── */

@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .app-header h1 {
    font-size: 28px;
  }
}
