/* 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 {
    padding: 6px 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;

    background-color: #1c1c1c;
    border-bottom: 1px solid #343a40;

    gap: 15px;
    flex-shrink: 0;
    z-index: 1010;
}
.header h1 {
    margin: 0;
    padding: 0 10px; /* 给标题左右留一点呼吸空间 */
    font-size: 1.5em;
    text-align: center;
    /* 为防止标题过长时与两侧图标重叠，可以添加最大宽度 */
    max-width: calc(100% - 180px); /* 视口宽度减去两侧图标和间距的大致宽度 */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.controls {
    position: relative; 
    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: 1001;
}

#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);
}

/* --- 左侧控件容器 --- */
#left-controls-container {
    z-index: 1020;
    display: flex;
    flex-direction: column; /* 垂直排列 */
    gap: 8px; /* 搜索和语言按钮之间的间距 */
}

/* --- 搜索组件样式 --- */
#search-trigger-container {
    position: absolute;
    left: 15px; /* 定位在标题栏左侧 */
    top: 50%;
    transform: translateY(-50%);
    
    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: absolute;
    left: calc(100% + 8px); /* 定位在搜索图标的右侧，并留出 8px 间距 */
    top: 50%; /* 垂直居中 */
    transform: translateY(-50%); /* 精确垂直居中 */
    
    /* 隐藏时的初始状态 */
    opacity: 0;
    visibility: hidden;
    width: auto; /* 宽度由内容决定 */
    margin-left: 0; /* 覆盖旧的 margin */
    transition: opacity 0.3s ease, transform 0.3s ease; /* 平滑过渡动画 */
}
#search-trigger-container.active #search-mode-selector {
    opacity: 1;
    transform: translateX(0);
    visibility: visible;
}
#search-mode-current {
    display: flex;
    align-items: center;
    white-space: nowrap; /* 防止文本换行 */
    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;
    z-index: 1022; /* 确保在搜索面板之上 */
}
#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;
}

/* --- 语言选择器样式 --- */
#language-selector-container {
    position: absolute;
    left: 15px; /* 与标题栏的搜索按钮左侧对齐 (因为.header有15px的padding-left) */
    /* top 和 transform 用于垂直居中，但由于父元素是 flex 且 align-items: center，通常这一步可以省略 */
    top: 50%;
    transform: translateY(-50%);
}

#language-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: background-color 0.2s;
}
#language-toggle-btn:hover {
    background-color: #383838;
}
#language-toggle-btn svg.globe-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

#language-options {
    position: absolute;
    top: 0;
    left: 100%;
    margin-left: 8px;

    transform-origin: top left;

    background-color: #2a2a2a;
    border: 1px solid #6c757d;

    border-radius: 4px;
    list-style: none;
    padding: 5px 0;

    margin-top: 0;

    width: max-content;
    min-width: 120px;

    transition: all 0.2s;
    z-index: 1021;
}

#language-options.collapsed {
    transform: scale(0);
    opacity: 0;
    visibility: hidden;
}

#language-options li {
    padding: 8px 12px;
    cursor: pointer;
}

#language-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;
}

/* --- Wiki 链接容器 --- */
#wiki-link-container {
    position: absolute;
    right: 15px;
    width: 260px;
    max-width: calc(100vw - 30px);
    background-color: #2a2a2a;
    border: 1px solid #495057;
    border-top: none;
    padding: 10px;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 998; /* 比搜索框低一级，以免重叠 */
    transition: transform 0.35s ease-in-out, opacity 0.35s ease-in-out;
    opacity: 0;
    transform: translateY(-100%); /* 初始状态，位于其最终位置的上方 */
    pointer-events: none;
    transition: transform 0.35s ease-in-out, opacity 0.35s ease-in-out;
}

#wiki-link-container.visible {
    opacity: 1;
    transform: translateY(0); /* 可见状态，滑入到正常位置 */
    pointer-events: auto;
}

.wiki-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.wiki-icon {
    width: 36px;
    height: auto;
    display: block; /* 确保img标签行为一致 */
    /* fill: #adb5bd; */
}

#wiki-close-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    color: #adb5bd;
    font-size: 20px;
    cursor: pointer;
    transition: color 0.2s;
}

#wiki-close-btn:hover {
    color: #d9534f;
}

#wiki-links-list a {
    display: block;
    color: #e9ecef;
    text-decoration: none;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color 0.2s;
}

#wiki-links-list a:hover {
    background-color: #383838;
}

/* --- 错误提示框样式 --- */
@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;
    }
    #left-controls-container {
        left: 8px;
    }

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

    #search-mode-current .chevron-down, #language-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;
    }
}
