/* 解剖学検索アプリのスタイル - 縦一列レイアウト版 + ドラッグ機能 */

/* デフォルト背景色を黒に設定 + 全画面表示 */
#network {
    background-color: #000000 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 1 !important;
}

body {
    background-color: #000000 !important;
    /* スマホでのタッチ操作を改善 */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* スマホでのスクロールを滑らかに */
    -webkit-overflow-scrolling: touch;
}

/* スマホ対応のタッチ操作改善 */
.list-group-item {
    /* タッチ操作を改善 */
    -webkit-tap-highlight-color: rgba(33, 150, 243, 0.3);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    
    /* タッチ時の視覚的フィードバック */
    transition: background-color 0.15s ease;
}

.list-group-item:active {
    background-color: #e3f2fd !important;
    transform: scale(0.98);
}

/* UI要素を非表示にしてシンプルな背景に */
.summary {
    display: none !important;
}

.command-bar {
    display: none !important;
}

.home-button {
    display: none !important;
}

.table-browser {
    display: none !important;
}

/* スマホでのタッチ領域を拡大 */
@media (max-width: 768px) {
    .list-group-item {
        min-height: 48px !important; /* 最小タッチ領域 */
        padding: 12px 15px !important;
        font-size: 16px !important; /* iOS Safariのズーム防止 */
        line-height: 1.4 !important;
    }
    
    .badge {
        font-size: 12px !important;
        padding: 4px 8px !important;
    }
}

/* ドラッグ可能なパネル用のスタイル */
#draggable-search-panel {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#draggable-search-panel:active {
    cursor: grabbing !important;
}

/* 入力フィールドとボタンはドラッグ時に選択可能にする */
#draggable-search-panel input,
#draggable-search-panel button {
    user-select: auto;
    -webkit-user-select: auto;
    -moz-user-select: auto;
    -ms-user-select: auto;
    cursor: auto;
}

.search-panel {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 160px; /* さらに小さく */
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px; /* さらに小さく */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1001;
}

.search-panel .search-container {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px;
    margin-bottom: 15px;
    align-items: flex-start !important;
}

.search-input {
    width: 100% !important;
    padding: 6px 10px; /* 小さく */
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px; /* フォントサイズを小さく */
    height: 32px; /* 高さを指定 */
    box-sizing: border-box;
    margin-bottom: 0 !important;
}

.search-btn, .clear-btn {
    padding: 6px 12px; /* 小さく */
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px; /* フォントサイズを小さく */
    height: 32px; /* 高さを統一 */
    min-width: 60px; /* 最小幅を設定 */
    flex: 1 !important; /* 横並び時に均等幅 */
    box-sizing: border-box;
}

.search-btn {
    background-color: #007bff;
    color: white;
}

.search-btn:hover {
    background-color: #0056b3;
}

.clear-btn {
    background-color: #6c757d;
    color: white;
}

.clear-btn:hover {
    background-color: #545b62;
}



.search-results {
    max-height: 300px;
    overflow-y: auto;
    animation: fadeIn 0.3s ease-in;
    /* スクロールを確実に有効化 */
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch;
}

/* スマホ対応：検索結果の高さを画面サイズに応じて調整 */
@media (max-width: 768px) {
    .search-results {
        max-height: calc(100vh - 250px) !important; /* 画面高さから検索欄とマージンを引く */
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important; /* スムーズスクロール */
        touch-action: pan-y !important; /* 縦スクロールを許可 */
    }
    
    .list-group {
        touch-action: pan-y !important; /* リスト内のスクロールを許可 */
    }
    
    .search-panel {
        max-height: calc(100vh - 40px) !important; /* 画面高さからマージンを引く */
        overflow-y: auto !important;
    }
}

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

.search-results h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 16px;
}

.list-group {
    list-style: none;
    padding: 0;
    margin: 0;
}

.list-group-item {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-top: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    position: relative;
}

.list-group-item:first-child {
    border-top: 1px solid #ddd;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

.list-group-item:last-child {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.list-group-item:hover {
    background-color: #e3f2fd;
    border-color: #2196f3;
    cursor: pointer;
    transform: translateX(5px);
    transition: all 0.2s ease;
}

.badge {
    color: white;
    padding: 3px 10px;
    border-radius: 15px;
    font-size: 11px;
    font-weight: bold;
}

/* 解剖学的タイプ別のバッジ色（色盲対応） */
.badge.muscle {
    background-color: #E91E63; /* 筋肉 - ピンク */
}

.badge.artery {
    background-color: #D32F2F; /* 動脈 - 赤 */
}

.badge.nerve {
    background-color: #388E3C; /* 神経 - 緑 */
}

.badge.joint {
    background-color: #1976D2; /* 関節 - 青 */
}

.badge.unknown {
    background-color: #616161; /* その他 - グレー */
}





.list-group-item.selected {
    background-color: #e8f5e8;
    border-color: #4caf50;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.2);
}

.list-group-item:active {
    background-color: #c8e6c9;
    transform: translateX(3px);
}

.list-group-item.clicked {
    background-color: #ffeb3b;
    border-color: #ff9800;
    box-shadow: 0 4px 8px rgba(255, 152, 0, 0.3);
    font-weight: bold;
}

.search-results .selected-item {
    background-color: #e8f5e8;
    border-left: 4px solid #4caf50;
    font-weight: bold;
}

.neighbors-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 250px; /* 小さく */
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px; /* 小さく */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    max-height: 300px; /* 小さく */
    overflow-y: auto;
}

/* スマホ対応：隣接ノードパネルの高さを画面サイズに応じて調整 */
@media (max-width: 768px) {
    .neighbors-panel {
        max-height: calc(100vh - 100px) !important; /* 画面高さからマージンを引く */
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important; /* スムーズスクロール */
    }
}

.neighbors-panel h4 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 16px;
}

/* ノードのハイライト - Cytoscape.js用のクラス */
.highlighted-node {
    border-width: 5px !important;
    border-color: #ff6b6b !important;
    background-color: #ffebee !important;
}

.neighbor-node {
    border-width: 3px !important;
    border-color: #4ecdc4 !important;
    background-color: #e0f2f1 !important;
}

/* スマホ対応のレスポンシブデザイン */
@media (max-width: 768px) {
    /* 検索パネルをスマホ用に調整 */
    .search-panel {
        width: calc(100% - 20px) !important;
        left: 10px !important;
        right: 10px !important;
        top: 10px !important;
        position: fixed !important;
        z-index: 1001 !important;
        padding: 10px !important;
        font-size: 16px; /* iOS Safariのズーム防止 */
        max-height: calc(100vh - 40px) !important; /* iPhone画面に収まるように */
        overflow-y: auto !important;
    }
    
    /* フローティング検索ボタンをスマホ用に調整 */
    .floating-search-btn {
        width: 60px !important;
        height: 60px !important;
        font-size: 24px !important;
        top: 20px !important;
        left: 20px !important;
    }
    
    /* フローティング隣接構造ボタンをスマホ用に調整 */
    .floating-neighbors-btn {
        width: 60px !important;
        height: 60px !important;
        font-size: 20px !important;
        bottom: 20px !important;
        right: 20px !important;
    }
    
    /* 検索入力フィールドをスマホ用に調整 */
    .search-input {
        font-size: 16px !important; /* iOS Safariのズーム防止 */
        padding: 12px !important;
        height: 44px !important; /* タッチしやすい高さ */
        box-sizing: border-box !important;
    }
    
    /* ボタンをスマホ用に調整 */
    .search-btn, .clear-btn {
        width: 100% !important;
        height: 44px !important; /* タッチしやすい高さ */
        font-size: 16px !important;
        padding: 12px !important;
        margin: 5px 0 !important;
        box-sizing: border-box !important;
        align-self: stretch !important;
    }
    
    /* 隣接ノードパネルをスマホ用に調整 */
    .neighbors-panel {
        width: calc(100% - 20px) !important;
        left: 10px !important;
        right: 10px !important;
        top: auto !important;
        bottom: 10px !important;
        max-height: 200px !important;
        position: fixed !important;
        z-index: 1001 !important;
        padding: 10px !important;
    }
    
    /* 検索結果をスマホ用に調整 */
    .search-results {
        max-height: 150px !important;
        font-size: 14px !important;
    }
    
    .list-group-item {
        padding: 12px !important;
        font-size: 14px !important;
        min-height: 44px !important; /* タッチしやすい高さ */
    }
    

    
    /* ネットワーク表示エリアの調整 */
    #network {
        padding-top: 80px !important; /* 検索パネル分のスペース（小さく） */
        padding-bottom: 180px !important; /* 隣接パネル分のスペース（小さく） */
    }
}

/* iPhone対応（iPhone 12/13/14等の標準サイズ） */
@media (max-width: 430px) {
    .search-panel {
        width: calc(100% - 16px) !important;
        left: 8px !important;
        right: 8px !important;
        padding: 12px !important;
        max-height: calc(100vh - 100px) !important; /* iPhone画面に確実に収まる */
    }
    
    .neighbors-panel {
        width: calc(100% - 16px) !important;
        left: 8px !important;
        right: 8px !important;
        padding: 12px !important;
        max-height: calc(40vh) !important; /* 画面の40%まで */
    }
    
    .floating-search-btn {
        width: 56px !important;
        height: 56px !important;
        font-size: 22px !important;
    }
    
    .floating-neighbors-btn {
        width: 56px !important;
        height: 56px !important;
        font-size: 18px !important;
        bottom: 20px !important;
        right: 20px !important;
    }
}

/* 極小画面（iPhone SE等）対応 */
@media (max-width: 375px) {
    .search-panel {
        width: calc(100% - 12px) !important;
        left: 6px !important;
        right: 6px !important;
        padding: 10px !important;
        max-height: calc(100vh - 80px) !important;
    }
    
    .neighbors-panel {
        width: calc(100% - 12px) !important;
        left: 6px !important;
        right: 6px !important;
        padding: 10px !important;
        max-height: calc(35vh) !important;
    }
    
    .search-input, .search-btn, .clear-btn {
        font-size: 14px !important;
        height: 40px !important;
        padding: 10px !important;
    }
    
    .list-group-item {
        padding: 10px !important;
        font-size: 13px !important;
        min-height: 40px !important;
    }
    
    .floating-search-btn {
        width: 50px !important;
        height: 50px !important;
        font-size: 20px !important;
    }
    
    .floating-neighbors-btn {
        width: 50px !important;
        height: 50px !important;
        font-size: 16px !important;
        bottom: 20px !important;
        right: 20px !important;
    }
}

/* iPhone Pro Max等の大画面対応 */
@media (max-width: 768px) and (min-height: 800px) {
    .search-panel {
        max-height: calc(60vh) !important; /* 大画面では少し大きく */
    }
    
    .neighbors-panel {
        max-height: calc(45vh) !important;
    }
}