/* グローバルダークテーマ */
body {
    background-color: #1e1e1e !important;
    color: #e0e0e0 !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* スクリプトエディタのスタイル */
.script-editor {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
    border-right: 1px solid #3e3e42;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #2d2d30;
    border-bottom: 1px solid #3e3e42;
    height: 40px;
}

.editor-header h4 {
    margin: 0;
    font-size: 13px;
    color: #cccccc;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.editor-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

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

.monaco-editor-custom {
    height: 100% !important;
}

/* コンソールパネルのスタイル */
.console-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
}

/* キャンバスパネルのスタイル */
.canvas-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
    border-right: 1px solid #3e3e42;
}

.canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #2d2d30;
    border-bottom: 1px solid #3e3e42;
    height: 40px;
}

.canvas-header h4 {
    margin: 0;
    font-size: 13px;
    color: #cccccc;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.canvas-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.canvas-container {
    flex: 1;
    padding: 16px;
    background: #1e1e1e;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.drawing-canvas {
    border: 1px solid #3e3e42;
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #2d2d30;
    border-bottom: 1px solid #3e3e42;
    height: 40px;
}

.console-header h4 {
    margin: 0;
    font-size: 13px;
    color: #cccccc;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.console-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* アクセシビリティとレスポンシブの改善 */
.log-level-filters {
    display: flex;
    gap: 12px;
    margin-right: 12px;
    flex-wrap: wrap;
}

.log-filter-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    cursor: pointer;
    font-size: 12px;
    color: #d0d0d0;
    padding: 2px;
    border-radius: 3px;
    transition: background-color 0.1s ease;
}

.log-filter-checkbox:focus-within {
    outline: 2px solid #007acc;
    outline-offset: 2px;
}

.log-filter-checkbox input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    accent-color: #0d6efd;
    width: 14px;
    height: 14px;
}

.log-filter-checkbox input[type="checkbox"]:focus {
    outline: 2px solid #007acc;
    outline-offset: 2px;
}

.log-filter-label {
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
    user-select: none;
}

.log-filter-debug {
    background-color: #6f42c1;
    color: white;
}

.log-filter-info {
    background-color: #17a2b8;
    color: white;
}

.log-filter-success {
    background-color: #28a745;
    color: white;
}

.log-filter-warning {
    background-color: #ffc107;
    color: #212529;
}

.log-filter-error {
    background-color: #dc3545;
    color: white;
}

.log-filter-checkbox input[type="checkbox"]:not(:checked)+.log-filter-label {
    opacity: 0.5;
    background-color: #6c757d !important;
    color: white !important;
}

.console-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #1e1e1e;
}

.console-empty {
    color: #6c757d;
    font-style: italic;
    text-align: center;
    padding: 40px 20px;
}

.console-message {
    display: flex;
    margin-bottom: 8px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
}

.console-timestamp {
    color: #6c757d;
    margin-right: 8px;
    flex-shrink: 0;
}

.console-text {
    flex: 1;
    word-break: break-word;
}

.console-info .console-text {
    color: #e1e4e8;
}

.console-debug .console-text {
    color: #6f42c1;
}

.console-success .console-text {
    color: #28a745;
}

.console-warning .console-text {
    color: #ffc107;
}

.console-error .console-text {
    color: #dc3545;
}

/* スクリプトランナーコンテナ */
.script-runner-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
}

.upper-section {
    height: 66.67%;
    /* 上2/3 */
    display: flex;
    flex-direction: row;
    position: relative;
}

.editor-section {
    width: 50%;
    /* 左半分 */
    height: 100%;
    border-right: 1px solid #3e3e42;
}

.canvas-section {
    width: 50%;
    /* 右半分 */
    height: 100%;
}

.console-section {
    height: 33.33%;
    /* 下1/3 */
    border-top: 1px solid #3e3e42;
}

/* リサイズハンドル */
.horizontal-resizer {
    width: 4px;
    height: 100%;
    background-color: #3e3e42;
    cursor: col-resize;
    position: relative;
    z-index: 10;
    transition: background-color 0.2s ease;
}

.horizontal-resizer:hover {
    background-color: #007acc;
}

.vertical-resizer {
    width: 100%;
    height: 4px;
    background-color: #3e3e42;
    cursor: row-resize;
    position: relative;
    z-index: 10;
    transition: background-color 0.2s ease;
}

.vertical-resizer:hover {
    background-color: #007acc;
}

/* リサイズ中のスタイル */
body.resizing {
    user-select: none;
}

body.resizing .horizontal-resizer {
    background-color: #007acc;
}

body.resizing .vertical-resizer {
    background-color: #007acc;
}

/* リサイズハンドルのアクセシビリティ */
.horizontal-resizer::before,
.vertical-resizer::before {
    content: '';
    position: absolute;
    background-color: #007acc;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.horizontal-resizer::before {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 20px;
    border-radius: 1px;
}

.vertical-resizer::before {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 2px;
    border-radius: 1px;
}

.horizontal-resizer:hover::before,
.vertical-resizer:hover::before {
    opacity: 1;
}

/* ボタンのフラットスタイル - 枠からはみ出し防止 */
.btn {
    border-radius: 2px;
    border: none;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-weight: 400;
    padding: 4px 12px;
    transition: background-color 0.1s ease;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.btn-primary {
    background-color: #0e639c;
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #1177bb;
    color: #ffffff;
}

.btn-primary:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.btn-primary:disabled {
    background-color: #4a4a4a;
    color: #888888;
}

.btn-outline-secondary {
    background-color: transparent;
    color: #cccccc;
    border: 1px solid #454545;
}

.btn-outline-secondary:hover {
    background-color: #37373d;
    color: #ffffff;
    border-color: #454545;
}

.btn-outline-secondary:focus {
    outline: 2px solid #007acc;
    outline-offset: 2px;
}

.btn-sm {
    padding: 2px 8px;
    font-size: 12px;
}

/* レスポンシブ対応 */
@media (max-width: 992px) {
    .upper-section {
        flex-direction: column;
        height: 66.67%;
    }

    .editor-section {
        width: 100% !important;
        height: 50% !important;
        border-right: none;
        border-bottom: 1px solid #3e3e42;
    }

    .canvas-section {
        width: 100% !important;
        height: 50% !important;
    }

    /* モバイルではリサイザーを非表示 */
    .horizontal-resizer {
        display: none;
    }

    /* 縦方向のリサイザーは残す */
    .vertical-resizer {
        display: block;
    }
}

@media (max-width: 768px) {
    .upper-section {
        height: 60%;
    }

    .console-section {
        height: 40%;
    }

    .canvas-container {
        padding: 8px;
    }

    .drawing-canvas {
        max-width: 100%;
        height: auto;
    }

    .log-level-filters {
        gap: 8px;
    }

    .log-filter-checkbox {
        font-size: 11px;
    }

    .log-filter-label {
        padding: 1px 4px;
    }

    .console-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .editor-actions {
        flex-wrap: wrap;
        gap: 4px;
    }

    .dropdown {
        margin-bottom: 4px;
    }
}

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

    .script-editor,
    .console-panel {
        background: #1e1e1e;
    }

    .editor-header,
    .console-header {
        background: #2d2d30;
        border-color: #3e3e42;
        color: #cccccc;
    }

    .editor-header h4,
    .console-header h4 {
        color: #cccccc;
    }

    .log-filter-checkbox input[type="checkbox"]:not(:checked)+.log-filter-label {
        background-color: #495057 !important;
    }
}