/* 時空システム用CSS */

/* 時空探索セクション */
.jikuu-explore-section {
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.explore-jikuu-btn {
    background: white;
    color: #1e3c72;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 0.5rem;
}

.explore-jikuu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.explore-description {
    color: white;
    font-size: 0.9rem;
    opacity: 0.9;
    margin: 0;
}

/* タブナビゲーション */
.tab-navigation {
    display: flex;
    border-bottom: 1px solid #e1e5e9;
    margin-bottom: 20px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 24px;
    cursor: pointer;
    font-size: 14px;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.tab-btn.active {
    color: #1f2937;
    border-bottom-color: #3b82f6;
    font-weight: 500;
}

.tab-btn:hover {
    color: #1f2937;
    background-color: #f9fafb;
}

/* 権限変更ダイアログ */
.permission-change-content {
    padding: 1rem 0;
}

.current-jikuu-info {
    background: #f8fafc;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.current-jikuu-info h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.current-permission {
    color: #6b7280;
    margin: 0;
}

.current-permission span {
    font-weight: 500;
    color: #374151;
}

.permission-options h4 {
    font-size: 1.1rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 1rem;
}

.permission-radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.permission-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.permission-option:hover {
    border-color: #d1d5db;
    background: #f9fafb;
}

.permission-option input[type="radio"] {
    margin-top: 0.25rem;
}

.permission-option input[type="radio"]:checked + .permission-info .permission-name {
    color: #1e3c72;
    font-weight: 700;
}

.permission-option:has(input[type="radio"]:checked) {
    border-color: #2a5298;
    background: linear-gradient(135deg, rgba(30, 60, 114, 0.05), rgba(42, 82, 152, 0.05));
}

.permission-info {
    flex: 1;
}

.permission-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: #1f2937; /* 明確な文字色を指定 */
}

.permission-desc {
    font-size: 0.9rem;
    color: #6b7280;
    line-height: 1.4;
}

.permission-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.permission-actions .btn-primary,
.permission-actions .btn-secondary {
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.permission-actions .btn-primary {
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: white;
    border: none;
}

.permission-actions .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 60, 114, 0.3);
}

.permission-actions .btn-secondary {
    background: white;
    color: #6b7280;
    border: 1px solid #d1d5db;
}

.permission-actions .btn-secondary:hover {
    background: #f9fafb;
    color: #374151;
}

/* 時空アイテム */
.jikuu-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 500px;
    overflow-y: auto;
}

.jikuu-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    cursor: pointer;
}

.jikuu-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.jikuu-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.jikuu-visibility {
    background-color: #f3f4f6;
    color: #6b7280;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.jikuu-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 13px;
    color: #6b7280;
}

.jikuu-actions {
    display: flex;
    gap: 8px;
}

.jikuu-actions button {
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    background-color: white;
    color: #374151;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.jikuu-actions .btn-secondary:hover {
    background-color: #f9fafb;
    border-color: #9ca3af;
}

.jikuu-actions .btn-primary {
    background-color: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.jikuu-actions .btn-primary:hover {
    background-color: #2563eb;
    border-color: #2563eb;
}

.jikuu-actions .btn-danger {
    background-color: #ef4444;
    color: white;
    border-color: #ef4444;
}

.jikuu-actions .btn-danger:hover {
    background-color: #dc2626;
    border-color: #dc2626;
}

/* 共有URL入力 */
.shared-url-input {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.shared-url-input h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #1f2937;
}

.input-group {
    display: flex;
    gap: 8px;
}

.input-group input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 14px;
}

.input-group input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input-group button {
    padding: 8px 16px;
    background-color: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}

.input-group button:hover {
    background-color: #2563eb;
}

/* JSONエディタ */
.jikuu-editor {
    display: flex;
    flex-direction: column;
    height: 600px;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.editor-header h3 {
    margin: 0;
    color: #1f2937;
    font-size: 18px;
}

.editor-actions {
    display: flex;
    gap: 8px;
}

.editor-actions button {
    padding: 8px 16px;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.editor-actions .btn-primary {
    background-color: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.editor-actions .btn-secondary {
    background-color: white;
    color: #374151;
}

.json-editor-container {
    flex: 1;
    overflow-y: auto;
}

.json-sections {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.json-section {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.json-section h4 {
    margin: 0;
    padding: 12px 16px;
    background-color: #f9fafb;
    color: #1f2937;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.2s ease;
}

.json-section h4:hover {
    background-color: #f3f4f6;
}

.json-content {
    transition: max-height 0.3s ease;
    overflow: hidden;
}

.json-content.collapsed {
    max-height: 0;
}

.json-content:not(.collapsed) {
    max-height: 300px;
}

.json-textarea {
    width: 100%;
    border: none;
    padding: 16px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.5;
    resize: vertical;
    background-color: #fafafa;
    color: #374151;
}

.json-textarea:focus {
    outline: none;
    background-color: #ffffff;
}

.json-textarea[readonly] {
    background-color: #f5f5f5;
    color: #6b7280;
}

/* メッセージ表示 */
.loading, .error, .info-message {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
    font-style: italic;
}

.error {
    color: #ef4444;
}

.info-message {
    background-color: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    color: #0369a1;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .jikuu-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .jikuu-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .jikuu-actions {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .jikuu-actions button {
        flex: 1;
        min-width: 80px;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .editor-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .editor-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .tab-navigation {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    
    .tab-btn {
        white-space: nowrap;
        min-width: 100px;
    }
}

/* 派生ツリーセクション */
.derivative-tree-section {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.derivative-tree-section h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.derivative-tree-section h3::before {
    content: "🌳";
    font-size: 1.2em;
}

/* ツリー可視化コンテナ */
.tree-visualization {
    background: #fafafa;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    min-height: 400px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.tree-svg {
    width: 100%;
    height: 400px;
    background: white;
}

/* ツリーノードスタイル */
.tree-node {
    cursor: pointer;
    transition: all 0.3s ease;
}

.tree-node-circle {
    fill: #3b82f6;
    stroke: #1e40af;
    stroke-width: 2;
    transition: all 0.2s ease;
}

.tree-node:hover .tree-node-circle {
    fill: #2563eb;
    stroke: #1d4ed8;
    stroke-width: 3;
    r: 8;
}

.tree-node.selected .tree-node-circle {
    fill: #dc2626;
    stroke: #b91c1c;
    stroke-width: 3;
    r: 10;
}

.tree-node.current .tree-node-circle {
    fill: #059669;
    stroke: #047857;
    stroke-width: 3;
}

.tree-node-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 12px;
    fill: #374151;
    text-anchor: middle;
    pointer-events: none;
}

.tree-link {
    fill: none;
    stroke: #6b7280;
    stroke-width: 2;
    stroke-opacity: 0.6;
}

.tree-link.to-selected {
    stroke: #dc2626;
    stroke-width: 3;
    stroke-opacity: 0.8;
}

/* ローディング状態 */
.tree-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-size: 14px;
}

.tree-loading::before {
    content: "🔄";
    font-size: 2rem;
    animation: spin 1s linear infinite;
    margin-bottom: 8px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* エラー状態 */
.tree-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    font-size: 14px;
}

.tree-error::before {
    content: "⚠️";
    font-size: 2rem;
    margin-bottom: 8px;
}

/* 選択されたノード情報パネル */
.selected-node-info {
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    border: 2px solid #cbd5e1;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.selected-node-info.has-selection {
    border-color: #dc2626;
    background: linear-gradient(135deg, #fef2f2, #fecaca);
}

.no-selection {
    text-align: center;
    color: #6b7280;
    font-style: italic;
    margin: 0;
}

.node-details {
    display: none;
}

.node-details.visible {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.node-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 8px 0;
}

.node-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    color: #6b7280;
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.node-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.node-description {
    color: #374151;
    line-height: 1.6;
    margin-bottom: 20px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    border-left: 4px solid #dc2626;
}

/* アクションボタンエリア */
.tree-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.tree-actions button {
    padding: 10px 20px;
    border-radius: 8px;
    border: 2px solid;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-fork {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

.btn-fork:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-view {
    background: white;
    color: #3b82f6;
    border-color: #3b82f6;
}

.btn-view:hover {
    background: #3b82f6;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-generate {
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: white;
    border-color: #1e3c72;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 60, 114, 0.3);
}

/* ツリー凡例 */
.tree-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 24px;
    margin-top: 16px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: #374151;
}

.legend-circle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid;
}

.legend-current .legend-circle {
    background: #059669;
    border-color: #047857;
}

.legend-selected .legend-circle {
    background: #dc2626;
    border-color: #b91c1c;
}

.legend-other .legend-circle {
    background: #3b82f6;
    border-color: #1e40af;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .derivative-tree-section {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .tree-visualization {
        min-height: 300px;
    }
    
    .tree-svg {
        height: 300px;
    }
    
    .selected-node-info {
        padding: 16px;
    }
    
    .node-meta {
        flex-direction: column;
        gap: 8px;
    }
    
    .tree-actions {
        flex-direction: column;
    }
    
    .tree-actions button {
        width: 100%;
        justify-content: center;
    }
    
    .tree-legend {
        flex-direction: column;
        gap: 12px;
    }
}