@charset "UTF-8";

/* ===================================================
   情報I ロジック変換・実行ワークスペース 固有スタイル
   1画面・2カラム（50:50固定）・コピペ不要レイアウト
   =================================================== */

:root {
    --header-height: 64px;
    --pane-bg: #ffffff;
    --pane-border: #e2e8f0;
    --editor-bg: #f8fafc;
    --py-editor-bg: #1e293b;
    --py-editor-text: #f8fafc;
    --gutter-bg: #f1f5f9;
    --gutter-text: #64748b;
    --py-gutter-bg: #0f172a;
    --py-gutter-text: #64748b;
    --console-bg: #090d16;
    --console-text: #e2e8f0;
    --accent-convert: #ea580c;
    --accent-convert-hover: #c2410c;
    --accent-run: #059669;
    --accent-run-hover: #047857;
}

html, body {
    height: 100%;
    overflow: hidden;
    background-color: #f1f5f9;
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ===================================================
   ヘッダーエリア
   =================================================== */
.workspace-header {
    height: var(--header-height);
    background: linear-gradient(90deg, #1e3a8a 0%, #2563eb 100%);
    color: #ffffff;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #1d4ed8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    gap: 1rem;
    z-index: 20;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.workspace-header h1 {
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.pyodide-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.8rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

.pyodide-loading {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.pyodide-ready {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.pyodide-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.pyodide-loading .status-dot {
    background-color: #d97706;
    animation: pulse-dot 1.2s infinite ease-in-out;
}

.pyodide-ready .status-dot {
    background-color: #16a34a;
}

.pyodide-error .status-dot {
    background-color: #dc2626;
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(0.85); opacity: 0.6; }
    50% { transform: scale(1.25); opacity: 1; }
}

/* ===================================================
   メイン2カラム ワークスペース（50:50固定）
   =================================================== */
.workspace-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding: 0.75rem;
    height: calc(100vh - var(--header-height));
    width: 100%;
    max-width: 100%;
    margin: 0;
}

.workspace-pane {
    background: var(--pane-bg);
    border: 1px solid var(--pane-border);
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.pane-header {
    padding: 0.65rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--pane-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-shrink: 0;
}

.pane-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e3a8a;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
}

.pane-step-badge {
    background: #2563eb;
    color: #ffffff;
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    letter-spacing: 0.04em;
}

.pane-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.85rem 1rem;
    gap: 0.75rem;
    overflow-y: auto;
    min-height: 0;
}

/* ===================================================
   左カラム：問題選択・説明・日本語ロジックエディタ
   =================================================== */
.problem-selector-bar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.selector-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

.selector-group.chapter-group {
    flex: 1 1 180px;
}

.selector-group.problem-group {
    flex: 1.6 1 220px;
}

.selector-group label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #334155;
    white-space: nowrap;
}

.problem-select {
    width: 100%;
    padding: 0.45rem 0.65rem;
    font-size: 0.88rem;
    font-weight: 600;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background-color: #ffffff;
    color: #0f172a;
    min-height: 38px;
    cursor: pointer;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

.problem-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.problem-info-card {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 0.7rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    flex-shrink: 0;
}

.problem-desc {
    margin: 0;
    font-size: 0.88rem;
    color: #1e3a8a;
    line-height: 1.5;
}

/* エディタセクション見出し・ツールバー */
.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-shrink: 0;
}

.editor-label {
    font-size: 0.84rem;
    font-weight: 700;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.autosave-indicator {
    font-size: 0.75rem;
    font-weight: 400;
    color: #64748b;
}

.editor-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-tool {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    padding: 0.25rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-tool:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #94a3b8;
}

.btn-tool.copied {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}

.btn-reset {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    padding: 0.25rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-reset:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* 行番号付きエディタ共通構造 */
.code-editor-wrapper {
    position: relative;
    flex: 1;
    min-height: 180px;
    display: flex;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--editor-bg);
}

.code-editor-wrapper:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.line-numbers {
    width: 44px;
    padding: 0.75rem 0.4rem;
    background: var(--gutter-bg);
    border-right: 1px solid #e2e8f0;
    color: var(--gutter-text);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.92rem;
    line-height: 1.6;
    text-align: right;
    user-select: none;
    overflow: hidden;
    flex-shrink: 0;
}

.line-numbers span {
    display: block;
}

/* 日本語エディタ（2層ハイライトレイヤー＆穴埋めプレースホルダー強調） */
.jp-editor-wrapper {
    background: var(--editor-bg);
}

.jp-editor-stage {
    position: relative;
    flex: 1;
    overflow: hidden;
}

.jp-highlight-layer,
.jp-textarea,
.code-textarea {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0.75rem 0.85rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.92rem;
    line-height: 1.6;
    tab-size: 4;
    white-space: pre;
    overflow: auto;
    box-sizing: border-box;
    border: none;
}

.jp-highlight-layer {
    pointer-events: none;
    color: #0f172a;
    z-index: 1;
}

.jp-textarea {
    z-index: 2;
    color: transparent;
    background: transparent;
    caret-color: #2563eb;
    resize: none;
    outline: none;
}

.jp-textarea::placeholder {
    color: #94a3b8;
}

.jp-textarea::selection {
    background: rgba(37, 99, 235, 0.25);
    color: transparent;
}

/* 日本語エディタ構文ハイライト＆プレースホルダー配色 */
.jp-tok-placeholder {
    background-color: #fef08a; /* 鮮やかなイエロー背景 */
    color: #b45309;            /* 濃いアンバーオレンジ文字 */
    box-shadow: 0 0 0 2px #f59e0b; /* くっきりしたオレンジ枠線 */
    border-radius: 3px;
    font-weight: 700;
}

.jp-tok-comment {
    color: #64748b;
    font-style: italic;
}

.jp-tok-str {
    color: #0369a1;
}

/* 変換アクションフッター */
.convert-action-bar {
    display: flex;
     flex-direction: column;
    gap: 0.4rem;
    flex-shrink: 0;
}

.btn-convert {
    width: 100%;
    min-height: 46px;
    background: linear-gradient(135deg, var(--accent-convert) 0%, #f97316 100%);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    box-shadow: 0 4px 12px rgba(234, 88, 12, 0.25);
    transition: all 0.2s ease;
}

.btn-convert:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-convert-hover) 0%, #ea580c 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(234, 88, 12, 0.32);
}

.btn-convert:disabled {
    background: #cbd5e1;
    color: #64748b;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

/* ===================================================
   右カラム：Python構文ハイライトエディタ ＆ 実行環境
   =================================================== */
.python-editor-wrapper {
    background: var(--py-editor-bg);
    border-color: #334155;
    flex: 1.1;
    min-height: 170px;
}

.python-editor-wrapper .line-numbers {
    background: var(--py-gutter-bg);
    border-right-color: #334155;
    color: var(--py-gutter-text);
}

.py-editor-stage {
    position: relative;
    flex: 1;
    overflow: hidden;
}

.py-highlight-layer,
.py-textarea {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0.75rem 0.85rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.92rem;
    line-height: 1.6;
    tab-size: 4;
    white-space: pre;
    overflow: auto;
    box-sizing: border-box;
    border: none;
}

.py-highlight-layer {
    pointer-events: none;
    color: var(--py-editor-text);
    z-index: 1;
}

.py-textarea {
    z-index: 2;
    color: transparent;
    background: transparent;
    caret-color: #38bdf8;
    resize: none;
    outline: none;
}

.py-textarea::selection {
    background: rgba(56, 189, 248, 0.28);
    color: transparent;
}

/* Python シンタックスハイライト配色 */
.tok-kw { color: #ff7b72; font-weight: 600; }
.tok-builtin { color: #d2a8ff; }
.tok-str { color: #a5d6ff; }
.tok-num { color: #79c0ff; }
.tok-comment { color: #8b949e; font-style: italic; }
.tok-op { color: #ffa657; }

/* Python エラー行ハイライト */
.line-numbers span.line-num-error {
    background-color: #ef4444;
    color: #ffffff !important;
    font-weight: 700;
    border-radius: 4px;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.7);
    animation: pulse-error-gutter 1.5s ease-in-out infinite alternate;
}

@keyframes pulse-error-gutter {
    from {
        box-shadow: 0 0 3px rgba(239, 68, 68, 0.5);
    }
    to {
        box-shadow: 0 0 9px rgba(239, 68, 68, 0.95);
    }
}

.py-line-error {
    display: inline-block;
    min-width: 100%;
    background-color: rgba(239, 68, 68, 0.22);
    box-shadow: inset 4px 0 0 #ef4444;
    color: inherit;
    text-decoration: underline wavy #ef4444;
    text-underline-offset: 4px;
    border-radius: 0 4px 4px 0;
    box-sizing: border-box;
}

/* 実行ボタンバー */
.run-action-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.btn-run {
    flex: 1;
    min-height: 46px;
    background: linear-gradient(135deg, var(--accent-run) 0%, #10b981 100%);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
    transition: all 0.2s ease;
}

.btn-run:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-run-hover) 0%, #059669 100%);
    transform: translateY(-1px);
}

.btn-run:disabled {
    background: #cbd5e1;
    color: #64748b;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* コンソール出力エリア */
.console-section {
    flex: 0.9;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.console-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.console-output {
    flex: 1;
    background: var(--console-bg);
    color: var(--console-text);
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 0.75rem 0.9rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.55;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

.console-output .console-placeholder {
    color: #64748b;
}

.console-output .console-stderr {
    color: #f87171;
}

.console-output .console-system {
    color: #38bdf8;
}

/* 狭い画面でのフォールバック */
@media (max-width: 820px) {
    html, body {
        overflow: auto;
        height: auto;
    }
    .workspace-header {
        height: auto;
        padding: 0.65rem 1rem;
        flex-wrap: wrap;
    }
    .workspace-main {
        grid-template-columns: 1fr;
        height: auto;
    }
    .workspace-pane {
        min-height: 520px;
    }
}
