/* ========================================
   グローバルスタイルス
   ======================================== */

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

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --bg-color: #ecf0f1;
    --text-color: #2c3e50;
    --border-color: #bdc3c7;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* ========================================
   レイアウト
   ======================================== */

.container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #fff;
}

header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 20px;
    box-shadow: var(--shadow);
    z-index: 10;
}

header h1 {
    font-size: 28px;
    margin-bottom: 5px;
}

header .subtitle {
    opacity: 0.9;
    font-size: 14px;
}

.control-panel {
    padding: 15px 20px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.search-box {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 300px;
}

.search-box input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background: #f8f9fa;
    transition: border-color 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--secondary-color);
    background: white;
}

.search-box button {
    padding: 10px 20px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

.search-box button:hover {
    background: #2980b9;
}

.stats-panel {
    display: flex;
    gap: 20px;
}

.stat-item {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 14px;
}

.stat-label {
    color: #7f8c8d;
    font-weight: 600;
}

.stat-value {
    color: var(--secondary-color);
    font-weight: bold;
    font-size: 16px;
}

main {
    flex: 1;
    overflow: hidden;
}

.layout {
    display: flex;
    height: 100%;
    gap: 0;
}

/* ========================================
   グラフコンテナ
   ======================================== */

.graph-container {
    flex: 1;
    position: relative;
    background: linear-gradient(to bottom, #f5f7fa 0%, #e8eef5 100%);
    overflow: hidden;
    box-shadow: inset 1px 0 3px rgba(0, 0, 0, 0.05);
}

#graphSvg {
    width: 100%;
    height: 100%;
}

/* D3 ノードスタイル */
.node {
    stroke: #fff;
    stroke-width: 2px;
    cursor: pointer;
    filter: drop-shadow(1px 1px 3px rgba(0, 0, 0, 0.1));
    transition: filter 0.3s;
}

.node:hover {
    filter: drop-shadow(3px 3px 8px rgba(0, 0, 0, 0.2));
    stroke-width: 3px;
}

.node.active {
    stroke: var(--accent-color);
    stroke-width: 4px;
}

/* ノード色分け */
.node.person { fill: #3498db; }
.node.event { fill: #e74c3c; }
.node.place { fill: #27ae60; }
.node.other { fill: #95a5a6; }

/* リンク */
.link {
    stroke: #bdc3c7;
    stroke-width: 1.5px;
    opacity: 0.6;
    transition: all 0.3s;
}

.link:hover {
    stroke: var(--secondary-color);
    stroke-width: 3px;
    opacity: 1;
}

.link-label {
    font-size: 11px;
    fill: var(--text-color);
    pointer-events: none;
    text-anchor: middle;
    background: white;
    padding: 2px 4px;
}

/* ノードテキスト */
.node-label {
    font-size: 12px;
    font-weight: 600;
    text-anchor: middle;
    fill: white;
    pointer-events: none;
}

/* ツールチップ */
.tooltip {
    position: absolute;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
}

/* ========================================
   サイドバー
   ======================================== */

.sidebar {
    width: 320px;
    background: white;
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    box-shadow: inset 1px 0 3px rgba(0, 0, 0, 0.05);
}

.panel {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.panel h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 8px;
}

.panel h4 {
    font-size: 13px;
    margin-top: 12px;
    margin-bottom: 8px;
    color: #555;
}

.panel p {
    font-size: 13px;
    line-height: 1.6;
    color: #666;
}

.panel ul {
    list-style: none;
    margin-left: 0;
}

.panel ul li {
    font-size: 13px;
    margin-bottom: 6px;
    color: #666;
}

/* ========================================
   検索結果
   ======================================== */

.result-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-item {
    padding: 10px;
    background: #f8f9fa;
    border-left: 3px solid var(--secondary-color);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.3s;
}

.result-item:hover {
    background: #e8f4f8;
    transform: translateX(2px);
}

.result-item-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--primary-color);
}

.result-item-type {
    font-size: 12px;
    color: #7f8c8d;
    margin-top: 3px;
}

/* ========================================
   ノード詳細
   ======================================== */

.node-info {
    margin-bottom: 15px;
}

.node-info-title {
    font-size: 16px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.node-info-type {
    display: inline-block;
    padding: 4px 8px;
    background: var(--secondary-color);
    color: white;
    border-radius: 4px;
    font-size: 11px;
    margin-bottom: 8px;
}

.node-info-description {
    font-size: 13px;
    color: #555;
    line-height: 1.6;
    margin-bottom: 10px;
}

.relations-list {
    margin-top: 15px;
}

.relations-list h4 {
    margin-bottom: 8px;
}

.relation-item {
    padding: 8px;
    background: #f0f3f4;
    border-radius: 3px;
    margin-bottom: 6px;
    font-size: 12px;
}

.relation-type {
    color: var(--accent-color);
    font-weight: 600;
}

.relation-target {
    color: var(--secondary-color);
    cursor: pointer;
    text-decoration: underline;
}

.relation-target:hover {
    text-decoration: none;
}

/* ========================================
   レスポンシブ
   ======================================== */

@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 35%;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .control-panel {
        flex-direction: column;
    }

    .search-box {
        width: 100%;
        min-width: auto;
    }

    .stats-panel {
        width: 100%;
        justify-content: space-around;
    }

    header h1 {
        font-size: 20px;
    }

    header .subtitle {
        font-size: 12px;
    }
}

/* ========================================
   アニメーション
   ======================================== */

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

.panel {
    animation: fadeIn 0.3s ease-out;
}

.result-item {
    animation: fadeIn 0.2s ease-out;
}

/* ========================================
   スクロールバー
   ======================================== */

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

.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #555;
}
