/* docs/style.css --- DARK THEME VERSION --- */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: #121212;
    color: #e9ecef;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* 布局: 标题, 时间控制器, 图例 */

.header {
    text-align: center;
    padding: 0.8em;
    background-color: #1c1c1c;
    border-bottom: 1px solid #343a40;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
    position: relative;
    z-index: 1010; /* Header should be on top */
}
.header h1 {
    flex-grow: 1;
    text-align: center;
    margin: 0 60px;
    font-size: 1.5em;
}

.controls {
    text-align: center;
    padding: 0.5em;
    background-color: #1c1c1c;
    border-bottom: 1px solid #343a40;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
    position: relative;
    z-index: 1000;
}

#legend-container {
    text-align: center;
    padding: 0.5em;
    background-color: #1c1c1c;
    border-bottom: 1px solid #343a40;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.controls {
    flex-wrap: wrap;
}

.controls label {
    font-size: 0.9em;
    margin-bottom: 4px;
}

#legend-container {
    overflow: hidden;
    transition: max-height 0.35s ease-in-out, padding 0.35s ease-in-out;
    max-height: 500px;
    padding: 10px;
}
#legend-container.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    border: 1px solid #495057;
    padding: 4px 8px;
    border-radius: 4px;
    background-color: #2a2a2a;
    transition: background-color 0.2s;
}
.legend-item:hover {
    background-color: #383838;
}
.legend-item input[type="checkbox"] {
    margin: 0;
}
.legend-item .color-box {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid #555;
}
.legend-item input[type="color"] {
    width: 20px;
    height: 20px;
    border: none;
    padding: 0;
    background: none;
    cursor: pointer;
}

.legend-wrapper {
    position: relative;
    background-color: #1c1c1c;
    border-bottom: 1px solid #343a40;
    z-index: 1000;
}

.legend-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}
.legend-toggle {
    position: absolute;
    bottom: -6px;
    left: 0;
    transform: none;
    width: 100%;
    height: 12px;
    background-color: #1c1c1c;
    border: 1px solid #343a40;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}
.toggle-lines {
    width: 20px;
    height: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.toggle-line {
    width: 100%;
    height: 1px;
    background-color: #888;
    transition: all 0.3s ease;
}
#legend-container.collapsed + .legend-toggle .toggle-line:first-child {
    transform: translateY(2px);
}
#legend-container.collapsed + .legend-toggle .toggle-line:last-child {
    transform: translateY(-2px);
}
.legend-toggle:hover .toggle-line {
    background-color: #fff;
}
.legend-toggle:hover .toggle-line:first-child {
    transform: translateY(1px);
}
.legend-toggle:hover .toggle-line:last-child {
    transform: translateY(-1px);
}

/* --- 搜索组件样式 --- */
#search-trigger-container {
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    z-index: 1020;
    display: flex;
    align-items: center;
}
#search-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #495057;
    background-color: #2a2a2a;
    color: #f8f9fa;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: all 0.3s ease-in-out;
}
#search-toggle-btn.active {
    border-radius: 8px;
}
#search-toggle-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}
#search-toggle-btn:hover {
    background-color: #383838;
}

#search-mode-selector {
    position: relative;
    margin-left: 8px;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateX(-10px);
    width: 0;
    visibility: hidden;
}
#search-trigger-container.active #search-mode-selector {
    opacity: 1;
    transform: translateX(0);
    width: auto;
    visibility: visible;
}
#search-mode-current {
    display: flex;
    align-items: center;
    background-color: #343a40;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid #6c757d;
}
#search-mode-current .chevron-down {
    width: 20px;
    height: 20px;
    fill: currentColor;
    transition: transform 0.2s;
}
#search-mode-current.open .chevron-down {
    transform: rotate(180deg);
}
#search-mode-options {
    position: absolute;
    top: 110%;
    left: 0;
    background-color: #2a2a2a;
    border: 1px solid #6c757d;
    border-radius: 4px;
    list-style: none;
    padding: 5px 0;
    margin: 0;
    width: 100%;
    transition: all 0.2s;
    transform-origin: top;
}
#search-mode-options.collapsed {
    transform: scaleY(0);
    opacity: 0;
    visibility: hidden;
}
#search-mode-options li {
    padding: 8px 12px;
    cursor: pointer;
}
#search-mode-options li:hover {
    background-color: #495057;
}

#search-input-panel {
    position: absolute;
    left: 15px;
    width: 260px;
    max-width: calc(100vw - 30px);
    background-color: #2a2a2a;
    border: 1px solid #495057;
    border-top: none;
    padding: 15px;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 999;
    transition: transform 0.35s ease-in-out;
    transform: translateY(-150%);
}
#search-input-panel.collapsed {
    transform: translateY(-150%);
}
#search-input-panel:not(.collapsed) {
    transform: translateY(0);
}
#search-panel-close-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    color: #adb5bd;
    font-size: 20px;
    cursor: pointer;
}
.search-content {
    display: none;
    flex-direction: column;
    gap: 10px;
}
.search-content.active {
    display: flex;
}
.search-content input,
.search-content button {
    width: 100%;
    box-sizing: border-box;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #6c757d;
    background-color: #343a40;
    color: #f8f9fa;
}
.search-content input::placeholder {
    color: #adb5bd;
}
.search-content button {
    cursor: pointer;
    background-color: #495057;
}
.search-content button:hover {
    background-color: #6c757d;
}
.search-content input[type="number"] {
    -moz-appearance: textfield; /* 针对旧版 Firefox */
    appearance: textfield;      /* 标准属性，适用于所有现代浏览器 */
}
.search-content input:-webkit-autofill,
.search-content input:-webkit-autofill:hover,
.search-content input:-webkit-autofill:focus,
.search-content input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #343a40 inset !important;
    -webkit-text-fill-color: #f8f9fa !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* 图，以及SVG */
#graph-container {
    width: 100%;
    flex-grow: 1;
    overflow: hidden;
    background-color: #121212;
}

/* --- 为解决拖拽问题而进行的画布样式修正 --- */
#graph-container, #graph-container canvas {
    cursor: grab;
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none;     /* IE 10+ */
    user-select: none;         /* Standard syntax */
    touch-action: none;        /* 禁用触摸滚动、缩放等默认行为 */
}
#graph-container canvas:active {
    cursor: grabbing;
}


svg {
    width: 100%;
    height: 100%;
    cursor: grab;
}
svg:active {
    cursor: grabbing;
}
.node circle {
    stroke: #fff;
    stroke-width: 2px;
    transition: opacity 0.3s, stroke 0.3s, stroke-width 0.3s;
}
.node text {
    font-size: 10px;
    text-anchor: middle;
    fill: #fff;
    stroke: #000;
    stroke-width: 0.4px;
    paint-order: stroke;
    pointer-events: none;
    transition: opacity 0.3s;
}
.link {
    fill: none;
    stroke: #fff;
    stroke-opacity: 0.6;
    transition: stroke 0.3s, stroke-opacity 0.3s, stroke-width 0.3s;
}
.link-label {
    font-size: 8px;
    fill: #adb5bd;
    text-anchor: middle;
    pointer-events: none;
    transition: opacity 0.3s;
}
.node.highlight circle {
    stroke: #f00;
    stroke-width: 3px;
}

/* 节点和关系线的黯淡效果 */
.node.faded,
.link.faded {
    opacity: 0.1 !important;
    pointer-events: none;
}

/* 关系文字的黯淡效果 */
/* 这条规则的意思是：当父元素 <g class="link-label-unit faded"> 存在时，
   让它内部的 <text class="link-label"> 元素透明度变为0.1 */
.link-label-unit.faded .link-label {
    opacity: 0.1 !important;
}

/* 确保黯淡的文字标签热区（矩形区域）不再响应鼠标事件 */
.link-label-unit.faded {
    pointer-events: none;
}

.link-label-unit {
    cursor: pointer; /* 在整个标签单元（矩形+文字）上显示手型指针 */
}

.link-label-unit rect {
    fill: transparent; /* 使矩形背景透明 */
    /* 在调试时，可以临时设置一个颜色来查看热区大小，如: fill: rgba(255,0,0,0.2); */
}

/* --- 路径高亮样式 --- */
.link.path-highlight {
    stroke-opacity: 1 !important;
    /* stroke-width 保持不变，仅靠颜色和透明度高亮 */
}
.node.path-highlight circle {
    stroke-width: 3px !important;
}
.node.path-highlight.path-source circle {
    stroke: #ffdd00 !important;
}
.node.path-highlight.path-target circle {
    stroke: #ff6600 !important;
}
.tooltip {
    position: absolute;
    text-align: left;
    padding: 8px;
    font: 12px sans-serif;
    background: rgba(52, 58, 64, 0.9);
    color: white;
    border-radius: 8px;
    pointer-events: none;
    max-width: 300px;
    z-index: 9999; /* 确保tooltip在最上层 */
}

/* 日期输入控制器 */
.date-control-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.date-input-group {
    display: inline-flex;
    align-items: center;
    border: 1px solid #495057;
    border-radius: 4px;
    padding: 2px 6px;
    gap: 4px;
}
.date-input-group span {
    color: #888;
    padding-bottom: 2px;
}
.date-part-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.arrow {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin: 0 4px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    transition: border-color 0.2s;
    font-size: 0;
    line-height: 0;
}
.arrow.up {
    border-bottom: 5px solid #888;
    margin-bottom: 2px;
}
.arrow.up:hover {
    border-bottom-color: #fff;
}
.arrow.down {
    border-top: 5px solid #888;
    margin-top: 2px;
}
.arrow.down:hover {
    border-top-color: #fff;
}
.date-part {
    width: 2.2em;
    border: none;
    text-align: center;
    font-size: 1em;
    background-color: transparent;
    color: inherit;
    padding: 2px 0;
}
.date-part:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.1);
}
.date-part::-webkit-outer-spin-button,
.date-part::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.date-part {
    -moz-appearance: textfield;
    appearance: none;
}
#start-month,
#end-month,
#start-day,
#end-day {
    width: 2em;
}

/* 时间间隔 & GitHub 链接 */
.interval-control-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.date-separator {
    font-size: 1.5em;
    color: #888;
    line-height: 1;
}
.interval-inputs {
    display: flex;
    gap: 5px;
    align-items: center;
    margin-bottom: 4px;
}
.interval-part {
    width: 2em;
    border: 1px solid #495057;
    background-color: transparent;
    color: inherit;
    text-align: center;
    border-radius: 4px;
    padding: 4px;
}
.interval-control-container button,
.interval-control-container a {
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
}
.interval-control-container button {
    border: 1px solid #6c757d;
    background-color: #343a40;
    color: #f8f9fa;
}
.interval-control-container button:hover {
    background-color: #495057;
}
.interval-control-container a {
    color: #7bade0;
}
.interval-control-container a:hover {
    text-decoration: underline;
}
.hidden {
    display: none !important;
}

/* 社交链接容器样式 */
.social-links {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    display: flex; /* 让内部的图标水平排列 */
    align-items: center;
    gap: 12px; /* 设置图标之间的间距 */
}

/* 图标的通用样式 */
.twitter-bird-link,
.twitter-link,
.telegram-link,
.github-link {
    line-height: 0; /* 移除链接的额外高度，确保图标垂直居中 */
    transition: opacity 0.2s; /* 将悬停动画效果应用在整个链接上 */
}

/* 图标的悬停效果 */
.twitter-bird-link:hover,
.twitter-link:hover,
.telegram-link:hover,
.github-link:hover {
    opacity: 0.7; /* 悬停时整个链接（包括图标）变淡 */
}

/* 图标的通用尺寸 */
.twitter-bird-link svg,
.twitter-link svg,
.telegram-link svg,
.github-link svg {
    width: 28px;
    height: 28px;
    display: block;
    stroke: none;
}

/* --- 错误提示框样式 --- */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}
@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #d9534f;
    color: white;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideIn 0.5s forwards;
    z-index: 2000;
}
.toast.closing {
    animation: slideOut 0.5s forwards;
}
#error-toast-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.8;
}
#error-toast-close:hover {
    opacity: 1;
}

/* --- 优化移动端横向布局 --- */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.1em;
        margin: 0 40px;
        flex-grow: 1;
        text-align: center;
    }
    .controls {
        flex-wrap: nowrap;
        gap: 8px;
        padding-left: 8px;
        padding-right: 8px;
    }
    .controls label {
        display: none;
    }
    .date-input-group {
        padding: 2px 4px;
        gap: 2px;
    }
    .date-part {
        font-size: 0.9em;
        width: 2.1em;
    }
    #start-month,
    #end-month,
    #start-day,
    #end-day {
        width: 1.8em;
    }
    .interval-control-container {
        font-size: 0.9em;
    }
    .date-separator {
        display: none;
    }
    .social-links {
        right: 8px; /* 调整右边距 */
        gap: 5px;  /* 调整图标间距 */
    }

    .twitter-bird-link svg,
    .twitter-link svg,
    .telegram-link svg,
    .github-link svg {
        width: 24px;
        height: 24px;
    }
    #search-trigger-container {
        left: 8px;
    }

    /* 1. 缩小“节点/路径”选择器 */
    #search-mode-current {
        padding: 6px 10px; /* 减小内边距 */
        font-size: 0.9em;  /* 减小字体 */
    }

    #search-mode-current .chevron-down {
        width: 16px; /* 减小下拉箭头图标 */
        height: 16px;
    }

    /* 2. 缩小整个搜索面板 */
    #search-input-panel {
        width: 240px; /* 减小面板宽度 */
        padding: 10px; /* 减小面板内边距 */
        left: 8px; /* 与搜索按钮左侧对齐 */
    }

    .search-content {
        gap: 8px; /* 减小内部件间距 */
    }

    /* 3. 缩小面板内的输入框和按钮 */
    .search-content input,
    .search-content button {
        padding: 6px; /* 减小内边距，从而减小高度 */
        font-size: 0.9em; /* 减小字体 */
    }
}

@media (max-width: 400px) {
    .date-part {
        width: 2em;
    }
    #start-month,
    #end-month,
    #start-day,
    #end-day {
        width: 1.5em;
    }
    .controls {
        gap: 5px;
    }
}
