/**
 * WP GFM Renderer - Mermaid図表スタイル
 *
 * Mermaid.jsで生成される図表の表示最適化とレスポンシブ対応
 *
 * @package WpGfmRenderer
 * @since 0.1.0
 */

/* Mermaidコンテナのベーススタイル */
.wp-gfm-mermaid-container {
	margin: 20px 0;
	padding: 15px;
	background: #f8f9fa;
	border-radius: 6px;
	border: 1px solid #e9ecef;
	text-align: center;
	overflow-x: auto;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Mermaid図表の直接スタイル */
.wp-gfm-mermaid {
	display: inline-block;
	max-width: 100%;
	height: auto;
}

/* SVG図表のレスポンシブ対応 */
.wp-gfm-mermaid svg {
	max-width: 100%;
	height: auto;
	display: block;
	margin: 0 auto;
}

/* モバイル環境での調整 */
@media (max-width: 768px) {

	.wp-gfm-mermaid-container {
		margin: 15px 0;
		padding: 10px;
		border-radius: 4px;
	}

	.wp-gfm-mermaid svg {
		font-size: 12px;
	}
}

/* ダークテーマ対応（必要に応じて） */
@media (prefers-color-scheme: dark) {

	.wp-gfm-mermaid-container {
		background: #2d3748;
		border-color: #4a5568;
	}
}

/* エラー表示スタイル（従来版・互換性保持） */
.wp-gfm-mermaid-error {
	color: #dc3545;
	padding: 15px;
	background: #f8d7da;
	border: 1px solid #f5c6cb;
	border-radius: 4px;
	text-align: left;
	font-family: monospace;
	font-size: 14px;
	line-height: 1.4;
}

.wp-gfm-mermaid-error strong {
	color: #721c24;
}

.wp-gfm-mermaid-error pre {
	margin: 10px 0;
	padding: 10px;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 3px;
	font-size: 12px;
	white-space: pre-wrap;
	overflow-x: auto;
}

.wp-gfm-mermaid-error details {
	margin-top: 10px;
}

.wp-gfm-mermaid-error summary {
	cursor: pointer;
	color: #721c24;
	font-weight: 700;
}

/* MD-23: 拡張エラー表示スタイル */
.wp-gfm-mermaid-error-enhanced {
	background: #fff;
	border: 1px solid #e1e5e9;
	border-radius: 8px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	margin: 20px 0;
	max-width: 100%;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: #24292f;
	text-align: left;
}

/* エラーヘッダー */
.mermaid-error-header {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 16px;
	background: #fff2cc;
	border-bottom: 1px solid #e1e5e9;
	border-radius: 8px 8px 0 0;
}

.error-icon {
	font-size: 24px;
	line-height: 1;
	flex-shrink: 0;
}

.error-title h4 {
	margin: 0 0 4px 0;
	font-size: 16px;
	font-weight: 600;
	color: #d73a49;
}

.error-meta {
	margin: 0;
	font-size: 13px;
	color: #656d76;
	font-weight: 400;
}

/* エラー説明 */
.mermaid-error-description {
	padding: 16px;
	background: #f6f8fa;
	border-bottom: 1px solid #e1e5e9;
	font-size: 14px;
	line-height: 1.5;
	color: #24292f;
}

/* 解決策セクション */
.mermaid-error-solutions {
	padding: 16px;
	border-bottom: 1px solid #e1e5e9;
}

.mermaid-error-solutions h5 {
	margin: 0 0 12px 0;
	font-size: 14px;
	font-weight: 600;
	color: #24292f;
}

.solutions-list {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.mermaid-solution-item {
	border: 1px solid #d1d9e0;
	border-radius: 6px;
	padding: 12px;
	background: #f6f8fa;
}

.solution-header {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 6px;
}

.priority-icon {
	font-size: 12px;
	line-height: 1;
}

.solution-header strong {
	font-size: 13px;
	font-weight: 600;
	color: #24292f;
}

.solution-description {
	margin: 0 0 8px 0;
	font-size: 13px;
	color: #656d76;
	line-height: 1.4;
}

.solution-examples-toggle {
	background: #f6f8fa;
	border: 1px solid #d1d9e0;
	border-radius: 4px;
	padding: 6px 12px;
	font-size: 12px;
	color: #24292f;
	cursor: pointer;
	margin-bottom: 8px;
	transition: all 0.2s ease;
}

.solution-examples-toggle:hover {
	background: #e1e5e9;
	border-color: #c4c9d0;
}

.solution-examples-toggle:focus {
	outline: 2px solid #0969da;
	outline-offset: 2px;
}

.solution-examples {
	border-top: 1px solid #d1d9e0;
	padding-top: 8px;
	margin-top: 8px;
}

.example-item {
	margin-bottom: 12px;
}

.example-item:last-child {
	margin-bottom: 0;
}

.example-description {
	font-size: 12px;
	color: #656d76;
	margin-bottom: 4px;
	font-weight: 500;
}

.example-code {
	background: #24292f;
	color: #f0f6fc;
	padding: 8px 12px;
	border-radius: 4px;
	font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
	font-size: 11px;
	line-height: 1.4;
	overflow-x: auto;
	margin: 0;
	white-space: pre;
}

/* 詳細セクション */
.mermaid-error-details {
	padding: 16px;
	border-bottom: 1px solid #e1e5e9;
}

.error-details-toggle,
.original-code-toggle {
	width: 100%;
	margin-bottom: 12px;
}

.error-details-toggle:last-child,
.original-code-toggle:last-child {
	margin-bottom: 0;
}

.error-details-toggle summary,
.original-code-toggle summary {
	cursor: pointer;
	font-size: 13px;
	font-weight: 600;
	color: #24292f;
	padding: 8px 12px;
	background: #f6f8fa;
	border: 1px solid #d1d9e0;
	border-radius: 4px;
	transition: all 0.2s ease;
}

.error-details-toggle summary:hover,
.original-code-toggle summary:hover {
	background: #e1e5e9;
}

.error-details-toggle[open] summary,
.original-code-toggle[open] summary {
	border-radius: 4px 4px 0 0;
	border-bottom-color: transparent;
}

.technical-details,
.original-code-container {
	border: 1px solid #d1d9e0;
	border-top: none;
	border-radius: 0 0 4px 4px;
	padding: 12px;
	background: #fff;
}

.error-message,
.code-issues {
	margin-bottom: 12px;
}

.error-message:last-child,
.code-issues:last-child {
	margin-bottom: 0;
}

.error-message strong,
.code-issues strong {
	font-size: 12px;
	font-weight: 600;
	color: #24292f;
	display: block;
	margin-bottom: 4px;
}

.error-text,
.original-code {
	background: #24292f;
	color: #f0f6fc;
	padding: 12px;
	border-radius: 4px;
	font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
	font-size: 12px;
	line-height: 1.4;
	overflow-x: auto;
	margin: 0;
	white-space: pre-wrap;
	word-break: break-word;
}

.code-issues ul {
	margin: 0;
	padding-left: 20px;
	font-size: 12px;
	color: #656d76;
}

.code-issues li {
	margin-bottom: 4px;
	line-height: 1.4;
}

.original-code-container {
	position: relative;
}

.copy-code-btn {
	position: absolute;
	top: 8px;
	right: 8px;
	background: #f6f8fa;
	border: 1px solid #d1d9e0;
	border-radius: 4px;
	padding: 4px 8px;
	font-size: 11px;
	color: #24292f;
	cursor: pointer;
	transition: all 0.2s ease;
	opacity: 0.8;
}

.copy-code-btn:hover {
	opacity: 1;
	background: #e1e5e9;
}

.copy-code-btn:focus {
	outline: 2px solid #0969da;
	outline-offset: 2px;
}

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

/* ヘルプリンク */
.mermaid-error-help {
	padding: 16px;
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
}

.help-link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: #0969da;
	text-decoration: none;
	font-size: 13px;
	font-weight: 500;
	padding: 6px 12px;
	border: 1px solid #d1d9e0;
	border-radius: 4px;
	background: #f6f8fa;
	transition: all 0.2s ease;
}

.help-link:hover {
	background: #e1e5e9;
	border-color: #c4c9d0;
	text-decoration: none;
}

.help-link:focus {
	outline: 2px solid #0969da;
	outline-offset: 2px;
}

/* モバイル対応 */
@media (max-width: 768px) {

	.wp-gfm-mermaid-error-enhanced {
		margin: 15px 0;
		border-radius: 6px;
	}

	.mermaid-error-header {
		padding: 12px;
		flex-direction: column;
		gap: 8px;
		text-align: center;
	}

	.error-icon {
		align-self: center;
	}

	.mermaid-error-description,
	.mermaid-error-solutions,
	.mermaid-error-details,
	.mermaid-error-help {
		padding: 12px;
	}

	.mermaid-error-help {
		flex-direction: column;
	}

	.help-link {
		justify-content: center;
	}

	.solution-header {
		flex-direction: column;
		align-items: flex-start;
		gap: 4px;
	}

	.copy-code-btn {
		position: static;
		margin-top: 8px;
		width: 100%;
	}
}

/* ダークテーマ対応 */
@media (prefers-color-scheme: dark) {

	.wp-gfm-mermaid-error-enhanced {
		background: #1c2128;
		border-color: #373e47;
		color: #e6edf3;
	}

	.mermaid-error-header {
		background: #2d1b00;
		border-bottom-color: #373e47;
	}

	.error-title h4 {
		color: #ff6b6b;
	}

	.error-meta {
		color: #8d96a0;
	}

	.mermaid-error-description {
		background: #262c36;
		border-bottom-color: #373e47;
		color: #e6edf3;
	}

	.mermaid-solution-item {
		background: #262c36;
		border-color: #373e47;
	}

	.solution-header strong {
		color: #e6edf3;
	}

	.solution-description {
		color: #8d96a0;
	}

	.solution-examples-toggle {
		background: #262c36;
		border-color: #373e47;
		color: #e6edf3;
	}

	.solution-examples-toggle:hover {
		background: #373e47;
		border-color: #4a525a;
	}

	.error-details-toggle summary,
	.original-code-toggle summary {
		background: #262c36;
		border-color: #373e47;
		color: #e6edf3;
	}

	.error-details-toggle summary:hover,
	.original-code-toggle summary:hover {
		background: #373e47;
	}

	.technical-details,
	.original-code-container {
		background: #1c2128;
		border-color: #373e47;
	}

	.error-message strong,
	.code-issues strong {
		color: #e6edf3;
	}

	.code-issues {
		color: #8d96a0;
	}

	.copy-code-btn {
		background: #262c36;
		border-color: #373e47;
		color: #e6edf3;
	}

	.copy-code-btn:hover {
		background: #373e47;
	}

	.help-link {
		background: #262c36;
		border-color: #373e47;
		color: #58a6ff;
	}

	.help-link:hover {
		background: #373e47;
		border-color: #4a525a;
	}
}

/* 読み込み中表示 */
.wp-gfm-mermaid-loading {
	padding: 20px;
	text-align: center;
	color: #6c757d;
	font-style: italic;
}

/* 図表タイプ別の微調整 */

/* フローチャート */
.wp-gfm-mermaid svg.flowchart {

	/* フローチャート特有のスタイル */
}

/* シーケンス図 */
.wp-gfm-mermaid svg.sequence {

	/* シーケンス図特有のスタイル */
}

/* ガントチャート */
.wp-gfm-mermaid svg.gantt {

	/* ガントチャート特有のスタイル */
}

/* クラス図 */
.wp-gfm-mermaid svg.class {

	/* クラス図特有のスタイル */
}

/* 印刷時の調整 */
@media print {

	.wp-gfm-mermaid-container {
		background: transparent;
		border: 1px solid #000;
		box-shadow: none;
		page-break-inside: avoid;
	}

	.wp-gfm-mermaid svg {
		max-width: 100% !important;
		height: auto !important;
	}
}
