/* /graph/graph.css */
:root {
    --primary: #009a44;
    --primary-dark: #0b7d36;
    --accent: #f17c4e;
  
    --bg: #f6f8fb;
    --surface: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border-color: #e2e8f0;
  
    --shadow-soft: 0 10px 30px rgba(0,0,0,.06);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
  
    --header-height: 76px;
  }
  
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    background: radial-gradient(900px 360px at 50% 0%, rgba(0,154,68,.08), transparent 60%), var(--bg);
    color: var(--text);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Main scroll handled by panels if needed */
  }
  
  a { text-decoration: none; color: inherit; }
  ul { list-style: none; }
  
  /* ============ Header (QA Consistent) ============ */
  .site-header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,.05);
    position: relative;
    z-index: 100;
    flex-shrink: 0;
  }
  .header-inner {
    max-width: 100%;
    height: 100%;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  
  /* Brand */
  .brand { display: flex; align-items: center; gap: 12px; }
  .brand-mark { height: 40px; width: auto; }
  .brand-text { display: flex; flex-direction: column; }
  .brand-text img { height: 26px; object-fit: contain; margin-right: auto; }
  .brand-subtitle { font-size: 11px; color: var(--muted); letter-spacing: 0.5px; }
  
  /* Nav */
  /* Nav ——改成和 /qa/qa.css 一样的显示方式 */
.nav{ display:flex; align-items:center; gap: 24px; }
/* Nav (match QA) */
.nav-links{ display:flex; gap: 8px; align-items:center; }

.nav-link,
.dropdown-toggle{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap: 4px;

  padding: 10px 12px;
  border-radius: 10px;
  transition: all .2s ease;

  background: transparent;
  border: none;
  cursor: pointer;
  color: #6b7280;
  font-weight: 700;
}

.nav-label{
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.nav-icon-fa{
  font-size: 17px;
  opacity: .55;
  transition: transform .2s ease, opacity .2s ease;
}

.nav-link:hover,
.nav-link.active,
.dropdown-toggle:hover{
  background: rgba(0,154,68,.08);
  color: var(--primary);
}
.nav-link:hover .nav-icon-fa,
.nav-link.active .nav-icon-fa,
.dropdown-toggle:hover .nav-icon-fa{
  opacity: 1;
  transform: translateY(-1px);
}

/* Country chip */
.country-item{ position: relative; }
.country-toggle{
  flex-direction: row;
  gap: 10px;
  padding: 10px 12px;
}
.country-label{
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: none;
  font-weight: 800;
  color: var(--text);
}
.country-flag{
  width: 22px;
  height: 14px;
  border-radius: 3px;
  object-fit: cover;
  border: 1px solid rgba(15,23,42,.10);
}

/* Dropdown menu (match QA, keep .show) */
.dropdown-menu{
  position:absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  border-radius: 12px;
  padding: 10px;
  display:none;
  min-width: 220px;
  max-height: 320px;
  overflow:auto;
  z-index: 1000;
  border: 1px solid rgba(15,23,42,.06);
}
.dropdown-menu.show{ display:block; }

.dropdown-menu li a{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.dropdown-menu li a:hover{
  background: rgba(0,154,68,.12);
  color: var(--primary-dark);
}
/* 当前国家高亮 */
.dropdown-menu li a.active{
    background: rgba(0,154,68,.16);   /* 比 hover 稍微更深一点 */
    color: var(--primary-dark);
    font-weight: 800;
  }  
/* 悬停打开国家下拉菜单 —— 行为与 QA 一致 */
.country-item:hover .dropdown-menu{
    display: block;
  }
  
  /* 桌面端：给下拉一个“hover 缓冲带”，减少抖动 */
  @media (min-width: 993px){
    .country-item::after{
      content:"";
      position:absolute;
      left:-12px;
      right:-12px;
      top:100%;
      height:12px;
    }
  }  
  
  /* Mobile Toggle */
  .nav-toggle, .nav-toggle-label { display: none; }
  
  /* ============ Main Graph Layout ============ */
  .graph-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 280px 1fr 300px;
    gap: 16px;
    padding: 16px;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
  }
  
  /* Common Panel Styles */
  .panel-left, .panel-center, .panel-right {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.6);
  }
  
  .panel-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(249, 250, 251, 0.5);
  }
  .panel-header h3 { font-size: 15px; font-weight: 700; color: var(--text); }
  
  .panel-body { padding: 16px; overflow-y: auto; flex: 1; }
  
  /* --- Left Panel: Search --- */
  .control-group { margin-bottom: 16px; }
  .control-group label {
    display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px;
  }
  .input-wrapper { position: relative; }
  .input-icon { position: absolute; left: 12px; top: 10px; color: #9ca3af; font-size: 14px; }
  
  input[type="text"], input[type="number"], select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    transition: border-color .2s;
  }
  .input-wrapper input { padding-left: 34px; }
  input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,154,68,.1); }
  
  .row-group { display: flex; gap: 12px; }
  .half { flex: 1; }
  
  .checkbox-list { display: flex; flex-direction: column; gap: 8px; }
  .cb-item { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
  .cb-item input { accent-color: var(--primary); cursor: pointer; }
  
  .btn-primary {
    width: 100%;
    padding: 10px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: background .2s;
    margin-top: 8px;
  }
  .btn-primary:hover { background: var(--primary-dark); }
  
  .stats-card {
    margin: 16px;
    padding: 16px;
    background: #f0fdf4;
    border-radius: var(--radius-md);
    border: 1px solid rgba(0,154,68,.1);
  }
  .stats-card h4 { font-size: 12px; color: var(--primary-dark); margin-bottom: 12px; text-transform: uppercase; }
  .stats-row { display: flex; justify-content: space-between; }
  .stat-item { display: flex; flex-direction: column; align-items: center; }
  .stat-val { font-size: 18px; font-weight: 800; color: var(--primary); }
  .stat-label { font-size: 11px; color: var(--muted); }
  
  /* --- Center Panel: Canvas --- */
  .canvas-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .canvas-header h2 { font-size: 16px; font-weight: 700; color: var(--text); }
  
  .graph-legend { display: flex; gap: 12px; font-size: 12px; }
  .legend-item { display: flex; align-items: center; gap: 6px; }
  .dot { width: 10px; height: 10px; border-radius: 50%; }
  .dot.plant { background: #22c55e; }
  .dot.pest { background: #f97316; }
  .dot.pesticide { background: #3b82f6; }
  
  .canvas-container {
    flex: 1;
    background: #fafafa;
    position: relative;
    min-height: 400px;
  }

  .canvas-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    gap: 16px;
    z-index: 1;
    background: #fafafa;
    pointer-events: none;
  }

  /* ECharts 容器 - 直接使用 canvas-container，不需要额外的 div */
  .graph-chart{
    width: 100%;
    height: 100%;
  }

  /* 简单的显示/隐藏 */
  .is-hidden{
    display: none !important;
  }

  /* ============ Loading Animation ============ */
  .loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(250, 250, 250, 0.95);
    backdrop-filter: blur(4px);
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .loading-overlay.show {
    opacity: 1;
    visibility: visible;
  }

  /* 知识图谱节点动画 */
  .loading-graph {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 20px;
  }

  /* 中心节点 */
  .loading-center-node {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(0, 154, 68, 0.4);
    animation: pulse-center 2s ease-in-out infinite;
  }

  /* 环绕节点 */
  .loading-orbit-node {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
  }

  .loading-orbit-node:nth-child(2) {
    background: #22c55e;
    animation: orbit 3s linear infinite;
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.5);
  }

  .loading-orbit-node:nth-child(3) {
    background: #f97316;
    animation: orbit 3s linear infinite 1s;
    box-shadow: 0 0 15px rgba(249, 115, 22, 0.5);
  }

  .loading-orbit-node:nth-child(4) {
    background: #3b82f6;
    animation: orbit 3s linear infinite 2s;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
  }

  /* 连接线动画 */
  .loading-line {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 50px;
    background: linear-gradient(to bottom, var(--primary), transparent);
    transform-origin: top center;
    opacity: 0.3;
  }

  .loading-line:nth-child(5) {
    animation: rotate-line 3s linear infinite;
  }

  .loading-line:nth-child(6) {
    animation: rotate-line 3s linear infinite 1s;
  }

  .loading-line:nth-child(7) {
    animation: rotate-line 3s linear infinite 2s;
  }

  /* 加载文字 */
  .loading-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 0.5px;
    animation: fade-pulse 1.5s ease-in-out infinite;
  }

  .loading-subtext {
    font-size: 12px;
    color: var(--muted);
    margin-top: 8px;
  }

  /* 动画关键帧 */
  @keyframes pulse-center {
    0%, 100% {
      transform: translate(-50%, -50%) scale(1);
      box-shadow: 0 0 20px rgba(0, 154, 68, 0.4);
    }
    50% {
      transform: translate(-50%, -50%) scale(1.1);
      box-shadow: 0 0 30px rgba(0, 154, 68, 0.6);
    }
  }

  @keyframes orbit {
    0% {
      transform: rotate(0deg) translateX(50px) rotate(0deg);
      opacity: 1;
    }
    50% {
      opacity: 0.6;
    }
    100% {
      transform: rotate(360deg) translateX(50px) rotate(-360deg);
      opacity: 1;
    }
  }

  @keyframes rotate-line {
    0% {
      transform: rotate(0deg);
      opacity: 0.3;
    }
    50% {
      opacity: 0.1;
    }
    100% {
      transform: rotate(360deg);
      opacity: 0.3;
    }
  }

  @keyframes fade-pulse {
    0%, 100% {
      opacity: 1;
    }
    50% {
      opacity: 0.5;
    }
  }
  
  /* --- Right Panel: Details --- */
  .details-body { padding: 0; }
  .detail-placeholder { padding: 24px; text-align: center; font-size: 13px; }
  .detail-row {
    display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid #f1f5f9; text-align: left;
  }
  .detail-row.block { flex-direction: column; gap: 4px; }
  .badge { padding: 2px 8px; border-radius: 4px; font-size: 11px; color: white; font-weight: 600; }
  .badge.pest { background: #f97316; }
  
  /* ============ Responsive ============ */
  @media (max-width: 992px) {
    .graph-layout {
      grid-template-columns: 1fr;
      grid-template-rows: auto 500px auto;
      height: auto;
      overflow-y: auto;
    }
    body { height: auto; overflow-y: auto; }
    .panel-center { min-height: 500px; }
  }
  
  @media (max-width: 768px) {
    .header-inner { padding: 0 16px; }
    .nav { display: none; } /* Use simple toggle logic if needed, or keeping it simple per constraint */
    
    /* Mobile Nav Logic (Simple CSS Toggle) */
    .nav-toggle-label { display: block; font-size: 20px; cursor: pointer; color: var(--text); }
    .nav-toggle:checked ~ .nav {
      display: flex;
      flex-direction: column;
      position: absolute;
      top: 100%; left: 0; right: 0;
      background: white;
      padding: 20px;
      box-shadow: 0 10px 30px rgba(0,0,0,0.1);
      align-items: flex-start;
    }
  }
