/* NyxTools:Multi AI discussion - Web UI - ダークモード専用ミニマルデザイン */

:root {
    /* ダークモードカラーパレット */
    --bg-primary: #0a0a0f;
    --bg-secondary: #13131a;
    --bg-card: #1a1a24;
    --bg-hover: #22222e;
    --text-primary: #e8e8f0;
    --text-secondary: #9090a8;
    --text-muted: #60607a;
    --accent-primary: #6366f1;
    --accent-hover: #7c3aed;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: #2a2a38;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.6);
}

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

body {
    font-family: 'Inter', 'Noto Sans JP', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 0;
    padding-bottom: 180px; /* 入力欄の高さ分の余白 */
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ヘッダー */
.header {
    text-align: center;
    background: var(--card-bg);
    padding: 40px 20px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1em;
}

/* モード選択 */
.mode-selector {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.mode-selector h2 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.mode-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.mode-card {
    background: var(--card-bg);
    border: 3px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.mode-card.selected {
    border-width: 4px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.mode-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.mode-icon {
    font-size: 2em;
}

.mode-header h3 {
    font-size: 1.3em;
}

.mode-description {
    color: var(--text-secondary);
    margin-bottom: 15px;
    min-height: 60px;
}

.mode-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
}

.stat {
    flex: 1;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-weight: bold;
    color: var(--primary-color);
}

.mode-models {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.model-badge {
    background: var(--bg-color);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    color: var(--text-primary);
}

/* クエリセクション - 下部固定 */
.query-section,
.chat-input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    padding: 20px;
    border-top: 2px solid var(--border);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.6);
    z-index: 1000;
    max-width: 100%;
}

.query-section h2 {
    display: none; /* タイトルを非表示でコンパクトに */
}

/* カスタマイズセクション */
.customize-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.customize-section summary {
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-primary);
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
    user-select: none;
}

.customize-section summary:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

.customize-section[open] summary {
    margin-bottom: 15px;
}

.system-prompt-input {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.95em;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.system-prompt-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.customize-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.preset-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.preset-btn:active,
.preset-btn.active {
    transform: translateY(0);
    background: var(--accent-primary);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

#promptInput,
.prompt-input {
    width: 100%;
    min-height: 60px;
    max-height: 120px;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95em;
    font-family: inherit;
    resize: none; /* 自動リサイズはJSで処理 */
    transition: border-color 0.3s ease;
    background: var(--bg-secondary);
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#promptInput:focus,
.prompt-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.query-actions,
.mode-selection-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-select,
.mode-selection-row select {
    flex: 0 0 auto;
    min-width: 200px;
    padding: 10px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.9em;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
}

.submit-btn,
.enter-key-style {
    flex: 0 0 auto;
    padding: 10px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.submit-btn:hover {
    transform: scale(1.05);
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 結果セクション */
.results-section {
    animation: fadeIn 0.5s ease;
}

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

.summary-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.summary-card h3 {
    margin-bottom: 20px;
    font-size: 1.5em;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.summary-stat {
    text-align: center;
}

.summary-stat-value {
    display: block;
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 5px;
}

.summary-stat-label {
    display: block;
    font-size: 0.9em;
    opacity: 0.9;
}

/* モデル結果 */
.model-results {
    display: grid;
    gap: 20px;
}

.model-result {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    border-left: 5px solid var(--primary-color);
}

.model-result.error {
    border-left-color: var(--danger-color);
}

.model-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.model-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.model-icon {
    font-size: 1.5em;
}

.model-name {
    font-size: 1.2em;
    font-weight: bold;
}

.model-metrics {
    display: flex;
    gap: 20px;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.model-metric {
    display: flex;
    align-items: center;
    gap: 5px;
}

.thinking-section {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 4px;
}

.thinking-section h4 {
    color: #856404;
    margin-bottom: 10px;
}

.thinking-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    color: #856404;
    font-family: monospace;
    font-size: 0.9em;
    max-width: 100%;
}

.content-section {
    background: var(--bg-color);
    padding: 20px;
    border-radius: 8px;
}

.content-section h4 {
    margin-bottom: 10px;
    color: var(--text-primary);
}

.response-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.8;
    max-width: 100%;
}

.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--danger-color);
}
/* テーマ切り替えボタン */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.5em;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* 履歴パネル */
.history-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--card-bg);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
    transition: right 0.3s ease;
    z-index: 999;
    overflow-y: auto;
    padding: 20px;
}

.history-panel.open {
    right: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.history-close {
    cursor: pointer;
    font-size: 1.5em;
    color: var(--text-secondary);
}

.history-item {
    background: var(--bg-color);
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.history-item:hover {
    transform: translateX(-5px);
    box-shadow: var(--shadow);
}

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

.history-item-mode {
    font-weight: bold;
    color: var(--primary-color);
}

.history-item-time {
    font-size: 0.85em;
    color: var(--text-secondary);
}

.history-item-prompt {
    font-size: 0.9em;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* エクスポートボタン */
.export-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.export-btn {
    flex: 1;
    padding: 10px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.export-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ツールバー */
.toolbar {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.toolbar-btn {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.toolbar-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* フッター */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    margin-top: 30px;
    margin-bottom: 20px; /* 下部入力欄の上に配置 */
    opacity: 0.6;
    font-size: 0.9em;
}

.footer a {
    color: var(--primary-color);
    text-decoration: underline;
}   text-decoration: underline;
}

/* WebSocket ストリーミング用スタイル */
.result-card.streaming {
    border-left: 4px solid var(--primary-color);
    animation: pulse 2s ease-in-out infinite;
}

.streaming-content {
    min-height: 100px;
    font-family: 'Inter', 'Noto Sans JP', system-ui;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.typing-cursor {
    display: inline-block;
    width: 8px;
    height: 1em;
    background: var(--primary-color);
    margin-left: 2px;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
    }
    50% {
        box-shadow: 0 2px 16px rgba(33, 150, 243, 0.6);
    }
}

@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;
    }
}

.result-card.success {
    border-left: 4px solid var(--success-color);
}

.result-card.error {
    border-left: 4px solid var(--danger-color);
}

/* チャットメッセージ（吹き出し式） */
.message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.message.user {
    align-self: flex-end;
    align-items: flex-end;
    max-width: 95%; /* AI回答と同じ右端位置 */
}

.message.assistant {
    align-self: flex-start;
    align-items: flex-start;
    max-width: 95%; /* AIの回答は広く表示 */
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.message.user .message-header {
    flex-direction: row-reverse;
}

.message-avatar {
    font-weight: 600;
    color: var(--text-primary);
}

.message-timestamp {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.message-content {
    background: var(--bg-card);
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .message-content {
    background: var(--accent-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    border-bottom-left-radius: 4px;
}

/* AI応答カードのスタイル調整 */
.message.assistant .ai-responses {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 100%; /* 親要素の幅を超えない */
}

.message.assistant .ai-response-card {
    background: var(--bg-card);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    display: inline-block; /* 内容に応じて幅が変わる */
    max-width: 100%;
}

.message.assistant .response-header {
    margin-bottom: 8px;
}

.message.assistant .response-model-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.message.assistant .response-text {
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.8;
    font-size: 0.95rem;
}

/* 段落の余白 */
.message.assistant .response-text p {
    margin: 0.8em 0;
}

.message.assistant .response-text p:first-child {
    margin-top: 0;
}

.message.assistant .response-text p:last-child {
    margin-bottom: 0;
}

/* コードブロック */
.message.assistant .response-text pre {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    margin: 1em 0;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.5;
}

.message.assistant .response-text code {
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

.message.assistant .response-text pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
}

/* 強調表示 */
.message.assistant .response-text strong {
    font-weight: 600;
    color: var(--text-primary);
}

.message.assistant .response-text em {
    font-style: italic;
    color: var(--text-secondary);
}

/* 引用 */
.message.assistant .response-text blockquote {
    border-left: 4px solid var(--border);
    padding-left: 16px;
    margin: 1em 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* 水平線 */
.message.assistant .response-text hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5em 0;
}

/* Markdownリストのスタイル */
.message.assistant .response-text ul,
.message.assistant .response-text ol {
    margin: 0.5em 0;
    padding-left: 2em;
}

.message.assistant .response-text ul {
    list-style-type: disc;
}

.message.assistant .response-text ol {
    list-style-type: decimal;
}

.message.assistant .response-text li {
    margin: 0.25em 0;
}

.message.assistant .response-text ul ul,
.message.assistant .response-text ol ul {
    list-style-type: circle;
    margin: 0.25em 0;
}

.message.assistant .response-text ul ul ul,
.message.assistant .response-text ol ul ul {
    list-style-type: square;
}

/* Markdownテーブルのスタイル */
.message.assistant .response-text table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    margin: 1.5em 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.9em;
}

.message.assistant .response-text thead {
    background: rgba(59, 130, 246, 0.1);
    position: sticky;
    top: 0;
    z-index: 1;
}

.message.assistant .response-text th {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.message.assistant .response-text td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: top;
}

/* Zebra striping for readability */
.message.assistant .response-text tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.message.assistant .response-text tbody tr:hover {
    background: var(--bg-hover);
    transition: background 0.2s ease;
}

/* 最後の行のボーダーを削除 */
.message.assistant .response-text tbody tr:last-child td {
    border-bottom: none;
}

/* テーブルを横スクロール可能に */
.message.assistant .response-text table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}

.message.assistant .response-text table thead,
.message.assistant .response-text table tbody,
.message.assistant .response-text table tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

/* Copyボタンを吹き出しの外に配置 */
.message.assistant .response-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
    padding-right: 0; /* 右端に揃える */
}

.message.assistant .action-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.message.assistant .action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

/* レスポンシブ */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8em;
    }

    .mode-cards {
        grid-template-columns: 1fr;
    }

    .query-actions {
        flex-direction: column;
    }

    .summary-stats {
        grid-template-columns: 1fr;
    }

    .message {
        max-width: 90%;
    }
}
