/* ============================================
   Total Workspace — style.css
   포트폴리오 미션 전용 스타일
============================================ */

:root {
    --bg-dark: #1a1d2e;
    --bg-panel: #242637;
    --bg-sidebar: #1e2033;
    --bg-header: #141526;
    --accent: #7c6cf5;
    --accent-hover: #9b8fff;
    --success: #4caf7d;
    --warning: #f5a623;
    --danger: #e05c7a;
    --text-primary: #e0e0f0;
    --text-secondary: #9090b0;
    --text-muted: #5a5a7a;
    --border: #2e3050;
    --sidebar-width: 220px;
    --header-h: 56px;
    --mission-w: 320px;
}

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

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ===== 헤더 ===== */
.app-header {
    height: var(--header-h);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    justify-content: flex-end;
}

.back-btn {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    white-space: nowrap;
}

.back-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.hamburger-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.hamburger-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.header-title {
    display: flex;
    flex-direction: column;
}

.header-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.header-title h1 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.step-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

/* 진행 바 */
.progress-wrap {
    flex: 1;
    max-width: 300px;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #a78bfa);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ===== 메인 컨테이너 (3패널) ===== */
.app-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) var(--mission-w) 1fr 1fr;
    flex: 1;
    overflow: hidden;
}

/* ===== 사이드바 ===== */
.step-sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s ease, opacity 0.3s ease;
}

.step-sidebar.closed {
    width: 0;
    opacity: 0;
    pointer-events: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}

.toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.2s;
}

.toggle-btn:hover {
    color: var(--text-primary);
}

.step-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding: 8px 0;
}

.step-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.step-list li:hover {
    background: rgba(124, 108, 245, 0.08);
    color: var(--text-primary);
}

.step-list li.active {
    background: rgba(124, 108, 245, 0.15);
    color: var(--accent-hover);
    border-left-color: var(--accent);
    font-weight: 600;
}

.step-list li.done {
    color: var(--success);
}

.step-list li.done .step-check {
    color: var(--success);
}

.step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.step-list li.active .step-num {
    background: var(--accent);
    color: white;
}

.step-list li.done .step-num {
    background: var(--success);
    color: white;
}

/* ===== 패널 공통 ===== */
.panel {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}

/* ===== 미션 패널 ===== */
.mission-panel {
    background: var(--bg-panel);
}

.mission-header {
    padding: 14px 16px 0;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.mission-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.mission-title-row h2 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.hint-btn {
    background: rgba(245, 166, 35, 0.15);
    border: 1px solid rgba(245, 166, 35, 0.3);
    color: var(--warning);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.hint-btn:hover {
    background: rgba(245, 166, 35, 0.25);
}

.hint-box {
    background: rgba(245, 166, 35, 0.1);
    border: 1px solid rgba(245, 166, 35, 0.3);
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #f5d87a;
    line-height: 1.6;
}

.mission-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    font-size: 13px;
    line-height: 1.8;
    color: var(--text-primary);
}

.mission-content h3 {
    font-size: 14px;
    color: var(--accent-hover);
    margin: 12px 0 6px;
}

.mission-content p {
    margin-bottom: 10px;
}

.mission-content ul {
    padding-left: 18px;
    margin-bottom: 10px;
}

.mission-content li {
    margin-bottom: 4px;
}

.mission-content code {
    background: rgba(124, 108, 245, 0.15);
    color: #a78bfa;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.mission-content pre {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    padding: 10px 14px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 12px;
    line-height: 1.6;
}

.mission-content pre code {
    background: none;
    padding: 0;
    color: #c9d1d9;
}

.mission-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    margin-bottom: 12px;
}

.mission-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ===== 버튼 ===== */
.action-btn {
    padding: 7px 14px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    background: var(--border);
    color: var(--text-primary);
}

.action-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

.success-btn {
    background: var(--success);
    color: white;
}

.warning-btn {
    background: rgba(245, 166, 35, 0.2);
    color: var(--warning);
    border: 1px solid rgba(245, 166, 35, 0.4);
}

.goal-btn {
    background: rgba(124, 108, 245, 0.2);
    color: var(--accent-hover);
    border: 1px solid rgba(124, 108, 245, 0.4);
    font-size: 12px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.goal-btn:hover {
    background: rgba(124, 108, 245, 0.35);
    transform: translateY(-1px);
}

/* ===== 에디터 패널 ===== */
.editor-panel {
    overflow: hidden;
}

.editor-actions {
    display: flex;
    gap: 8px;
}

.CodeMirror {
    height: calc(100vh - var(--header-h) - 43px) !important;
    font-size: 13px;
    font-family: 'Fira Code', 'Courier New', monospace;
    line-height: 1.6;
}

/* ===== 미리보기 패널 ===== */
.preview-panel {}

.iframe-container {
    flex: 1;
    overflow: hidden;
}

#previewFrame {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

/* ===== 목표 미리보기 모달 ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 70vw;
    height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 14px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.modal-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.goal-frame {
    flex: 1;
    width: 100%;
    border: none;
    background: white;
}

/* ===== 완료 화면 ===== */
.complete-screen {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(20, 21, 38, 0.97);
    display: flex;
    align-items: center;
    justify-content: center;
}

.complete-box {
    text-align: center;
    max-width: 800px;
    width: 90%;
}

.complete-icon {
    font-size: 80px;
    margin-bottom: 16px;
    animation: bounceIn 0.6s ease;
}

.complete-box h2 {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent-hover);
    margin-bottom: 8px;
}

.complete-box p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.complete-preview {
    width: 100%;
    height: 400px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--accent);
    margin-bottom: 20px;
}

.complete-preview iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.complete-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.complete-actions a.action-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
    }

    60% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* ===== 스크롤바 ===== */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #404060;
}