/* メインコンテナ */
.ct-container {
    display: flex;
    gap: 30px;
    margin: 20px auto;
    max-width: 1800px;
    position: relative;
}

/* サイドバー */
.ct-sidebar {
    width: 380px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* メインエリア */
.ct-main {
    flex: 1;
    min-width: 0;
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

textarea, .CodeMirror { box-sizing:border-box; }


/* コードブロックグループ */
.ct-block-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

/* 統合済みの背景色 */
.ct-block-group.merged {
    background: #f1f5f9;
}

/* コードブロックセクション */
.ct-block-section {
    background: #fff;
    border-radius: 8px;
}

.ct-block-section h3 {
    margin: 0 0 15px 0;
    color: #1e293b;
    font-size: 16px;
}

/* コード入力エリア */
.ct-input-container {
    position: relative;
}

.ct-input {
    width: 100%;
    min-height: 200px;
    font-family: monospace;
}

/* CodeMirror カスタマイズ */
.ct-block-section .CodeMirror {
    height: auto !important;
    min-height: 200px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
}

/* 統合オプション */
.ct-merge-options {
    background: #f8fafc;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    border: 1px solid #e2e8f0;
}

.ct-merge-options h4 {
    margin: 0 0 12px 0;
    color: #1e293b;
    font-size: 14px;
}

.ct-option-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.ct-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.ct-option:hover {
    background: #e2e8f0;
}

.ct-option input[type="radio"] {
    margin: 0;
}

/* ボタン */
.ct-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.ct-preview-button,
.ct-merge-button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    flex: 1;
}

.ct-preview-button {
    background: #3b82f6;
    color: #fff;
}

.ct-preview-button:hover {
    background: #2563eb;
}

.ct-merge-button {
    background: #10b981;
    color: #fff;
}

.ct-merge-button:hover {
    background: #059669;
}

.ct-merge-button:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

/* メインヘッダー */
.ct-main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 20px;
}

/* ハイライト */
.ct-highlight-red {
    background-color: rgba(239, 68, 68, 0.1) !important;
}

.ct-highlight-blue {
    background-color: rgba(59, 130, 246, 0.1) !important;
}

/* コードエディタ出力エリア */
.ct-output-container {
    position: relative;
    height: calc(100vh - 200px);
}

.ct-output-container .CodeMirror {
    height: 100% !important;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
}

/* レスポンシブ対応 */
@media screen and (max-width: 1200px) {
    .ct-container {
        flex-direction: column;
    }

    .ct-sidebar {
        width: 100%;
        height: auto;
        margin-bottom: 20px;
    }

    .ct-main {
        width: 100%;
    }
}

/* 依存関係可視化のためのスタイル */
.ct-analyze-button {
    padding: 8px 16px;
    background: #8b5cf6;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    margin-left: 10px;
}

.ct-analyze-button:hover {
    background: #7c3aed;
    transform: translateY(-1px);
}

.ct-visualizer-button {
    padding: 8px 16px;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    margin-left: 10px;
}

.ct-visualizer-button:hover {
    background: #4f46e5;
    transform: translateY(-1px);
}

/* 依存関係コンテナ */
.ct-dependency-container {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ct-dependency-container h3 {
    color: #1e293b;
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

/* 依存関係テーブル */
.ct-dependency-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 14px;
}

.ct-dependency-table th,
.ct-dependency-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.ct-dependency-table th {
    background: #f8fafc;
    color: #1e293b;
    font-weight: 600;
}

.ct-dependency-table tr:hover {
    background: #f8fafc;
}

/* 依存関係リスト */
.ct-dependency-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ct-dependency-item {
    padding: 3px 6px;
    background: #f1f5f9;
    border-radius: 4px;
    display: inline-block;
    margin-right: 5px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ct-dependency-item:hover {
    background: #e2e8f0;
}

/* 依存関係グラフ */
.ct-dependency-graph {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    background: #f8fafc;
}

.ct-dependency-graph h4 {
    color: #1e293b;
    margin: 0 0 15px 0;
    font-size: 16px;
}

#ct-dependency-canvas {
    display: block;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

/* 関数と変数のタイプ別ハイライト */
.ct-function-name {
    color: #2563eb;
    font-weight: 600;
}

.ct-class-name {
    color: #059669;
    font-weight: 600;
}

.ct-variable-name {
    color: #d97706;
    font-weight: 600;
}

/* ハイライト */
.ct-highlight-function {
    background-color: rgba(59, 130, 246, 0.1) !important;
}

.ct-highlight-class {
    background-color: rgba(5, 150, 105, 0.1) !important;
}

.ct-highlight-variable {
    background-color: rgba(217, 119, 6, 0.1) !important;
}

/* 依存関係の接続ハイライト */
.ct-highlight-connection-from {
    background-color: rgba(139, 92, 246, 0.2) !important;
    border-left: 3px solid #8b5cf6 !important;
}

.ct-highlight-connection-to {
    background-color: rgba(99, 102, 241, 0.2) !important;
    border-left: 3px solid #6366f1 !important;
}

/* ジャンプボタン */
.ct-jump-button {
    padding: 4px 10px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    color: #475569;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ct-jump-button:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* 検出結果がない場合のメッセージ */
.ct-no-dependencies {
    padding: 15px;
    text-align: center;
    color: #64748b;
    font-style: italic;
}

/* レスポンシブ対応 */
@media screen and (max-width: 1200px) {
    .ct-dependency-table {
        font-size: 12px;
    }
    
    .ct-analyze-button,
    .ct-visualizer-button {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    #ct-dependency-canvas {
        width: 100%;
        height: auto;
    }
}

/* コードエディタのサイズと配置を修正 */
.ct-container {
    max-width: 100%;
    overflow: hidden;
    padding: 0 15px;
}

/* サイドバーの幅を調整 */
.ct-sidebar {
    width: 320px;
    max-width: 100%;
    flex-shrink: 0;
}

/* メインエリアのサイズ調整 */
.ct-main {
    flex: 1;
    min-width: 0; /* これが重要: Flexboxのはみ出し防止 */
    max-width: calc(100% - 350px); /* サイドバー幅+マージン分を引く */
}

/* CodeMirrorエディタのサイズ制限 */
.CodeMirror {
    max-width: 100%;
    width: 100% !important;
    height: auto !important;
    min-height: 200px;
    overflow: hidden;
}

.CodeMirror-scroll {
    max-width: 100%;
    overflow-x: auto !important;
}

/* 出力エリアのサイズ制限 */
.ct-output-container {
    max-width: 100%;
    height: auto !important;
    min-height: 300px;
    max-height: 600px; /* 最大高さを設定 */
}

/* 依存関係可視化コンテナのサイズ制限 */
.ct-dependency-container {
    max-width: 100%;
    overflow-x: auto;
}

#ct-dependency-canvas {
    max-width: 100%;
}

/* レスポンシブ対応を強化 */
@media screen and (max-width: 1200px) {
    .ct-container {
        flex-direction: column;
    }

    .ct-sidebar {
        width: 100%;
        max-width: 100%;
    }

    .ct-main {
        width: 100%;
        max-width: 100%;
    }
    
    /* 依存関係ビジュアライザーをモバイル対応 */
    .ct-dependency-table {
        font-size: 12px;
    }
    
    #ct-dependency-canvas {
        height: 300px;
    }
}

/* ビジュアライザーボタンの位置調整 */
.ct-visualizer-button {
    margin-left: 5px;
}

/* エディタの横幅オーバーフロー修正 */
.ct-input-container {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.ct-block-section .CodeMirror {
    max-width: 100%;
    width: 100% !important;
}