/* AI Code Playground - Dark Theme */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    background-color: #0d1117;
    color: #c9d1d9;
    line-height: 1.6;
    font-size: 14px;
}

/* ヘッダー */
.header {
    background: #161b22;
    border-bottom: 1px solid #30363d;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    color: #f0f6fc;
    font-size: 1.5rem;
    font-weight: 600;
}

.header-buttons {
    display: flex;
    gap: 0.5rem;
}

/* ボタン */
.btn {
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.btn:hover {
    background: #30363d;
    border-color: #8b949e;
}

.btn-primary {
    background: #238636;
    border-color: #238636;
    color: #ffffff;
}

.btn-primary:hover {
    background: #2ea043;
    border-color: #2ea043;
}

.btn-secondary {
    background: #0969da;
    border-color: #0969da;
    color: #ffffff;
}

.btn-secondary:hover {
    background: #1f6feb;
    border-color: #1f6feb;
}

/* プロンプトセクション */
.prompt-section {
    padding: 1.5rem;
    background: #161b22;
    border-bottom: 1px solid #30363d;
}

.prompt-container {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

/* モデル選択 */
.model-select {
    background: #0d1117;
    border: 1px solid #30363d;
    color: #c9d1d9;
    padding: 0.75rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    min-width: 160px;
    max-width: 240px;
    appearance: auto;
}

.model-select:focus {
    outline: none;
    border-color: #1f6feb;
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.1);
}

.model-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.prompt-input {
    flex: 1;
    background: #0d1117;
    border: 1px solid #30363d;
    color: #c9d1d9;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
}

.prompt-input:focus {
    outline: none;
    border-color: #1f6feb;
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.1);
}

/* ステータス行 */
.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    min-height: 1.5rem;
}

.generation-status {
    font-size: 0.875rem;
    color: #7d8590;
}

.generation-status.generating {
    color: #1f6feb;
}

.generation-status.error {
    color: #f85149;
}

.generation-status.success {
    color: #3fb950;
}

.generation-stats {
    font-size: 0.8rem;
    color: #7d8590;
    font-variant-numeric: tabular-nums;
}

.generation-stats .stat-highlight {
    color: #d2a8ff;
    font-weight: 600;
}

/* メインコンテンツ */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: calc(100vh - 160px);
    gap: 1px;
    background: #30363d;
}

/* エディタセクション */
.editor-section {
    background: #0d1117;
    display: flex;
    flex-direction: column;
}

.editor-tabs {
    display: flex;
    background: #161b22;
    border-bottom: 1px solid #30363d;
}

.tab-btn {
    background: transparent;
    color: #7d8590;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    color: #c9d1d9;
    background: #21262d;
}

.tab-btn.active {
    color: #f0f6fc;
    background: #0d1117;
    border-bottom-color: #1f6feb;
}

.editor-panels {
    flex: 1;
    position: relative;
}

.editor-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
}

.editor-panel.active {
    display: block;
}

.editor-panel .cm-editor {
    height: 100%;
    font-size: 14px;
}

/* プレビューセクション */
.preview-section {
    background: #0d1117;
    display: flex;
    flex-direction: column;
}

.preview-header {
    background: #161b22;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid #30363d;
}

.preview-header h3 {
    color: #f0f6fc;
    font-size: 0.875rem;
    font-weight: 600;
}

.preview-container {
    flex: 1;
    padding: 1rem;
    background: #ffffff;
}

#previewFrame {
    width: 100%;
    height: 100%;
    border: 1px solid #30363d;
    border-radius: 6px;
    background: #ffffff;
}

.console-section {
    background: #161b22;
    border-top: 1px solid #30363d;
    max-height: 120px;
    overflow-y: auto;
}

.console-header {
    padding: 0.5rem 1rem;
    color: #7d8590;
    font-size: 0.75rem;
    border-bottom: 1px solid #30363d;
}

.console-output {
    padding: 0.5rem 1rem;
    font-family: 'SF Mono', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
    color: #c9d1d9;
    white-space: pre-wrap;
}

/* モーダル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
}

.modal-content h3 {
    color: #f0f6fc;
    margin-bottom: 1rem;
}

.modal-content label {
    display: block;
    color: #c9d1d9;
    margin-bottom: 0.5rem;
}

.modal-content input {
    width: 100%;
    background: #0d1117;
    border: 1px solid #30363d;
    color: #c9d1d9;
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
}

.modal-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .header-buttons {
        justify-content: center;
    }
    
    .prompt-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .model-select {
        max-width: 100%;
    }
    
    .status-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: 50vh 50vh;
        height: calc(100vh - 180px);
    }
    
    .prompt-input {
        margin-bottom: 0.75rem;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1rem;
    }
    
    .header h1 {
        font-size: 1.25rem;
    }
    
    .prompt-section {
        padding: 1rem;
    }
    
    .tab-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
}

/* キューUI */
.queue-status {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
    padding: 0.6rem 1rem;
    background: rgba(31, 111, 235, 0.1);
    border: 1px solid rgba(31, 111, 235, 0.3);
    border-radius: 6px;
    animation: queuePulse 2s ease-in-out infinite;
}

.queue-position {
    color: #58a6ff;
    font-weight: 600;
    font-size: 0.875rem;
}

.queue-estimate {
    color: #7d8590;
    font-size: 0.8rem;
}

.status-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.queue-global {
    font-size: 0.8rem;
    color: #d29922;
    background: rgba(210, 153, 34, 0.1);
    border: 1px solid rgba(210, 153, 34, 0.25);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    white-space: nowrap;
}

@keyframes queuePulse {
    0%, 100% { border-color: rgba(31, 111, 235, 0.3); }
    50% { border-color: rgba(31, 111, 235, 0.6); }
}

/* ローディングアニメーション */
.loading {
    display: inline-block;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* スクロールバー */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #161b22;
}

::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}