/* ===== 전역 설정 ===== */
:root {
    --primary-color: #4A90E2;
    --primary-dark: #357ABD;
    --secondary-color: #7B68EE;
    --background-light: #F8F9FA;
    --background-white: #FFFFFF;
    --text-primary: #2C3E50;
    --text-secondary: #546E7A;
    --text-light: #90A4AE;
    --border-color: #E0E0E0;
    --shadow-light: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-medium: 0 4px 16px rgba(0,0,0,0.12);
    --transition: all 0.3s ease;
    
    /* Phase colors */
    --phase-1: #FF6B6B;
    --phase-2: #FFA500;
    --phase-3: #7B68EE;
    --phase-4: #4ECDC4;
    --phase-5: #95E1D3;
}

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

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

/* ===== 사이드바 ===== */
.sidebar {
    width: 320px;
    background: var(--background-white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 100;
}

.sidebar.collapsed {
    margin-left: -320px;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header h2 i {
    color: var(--primary-color);
    font-size: 24px;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

/* 대화 목록 */
.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.conversation-item {
    padding: 14px;
    margin-bottom: 8px;
    background: var(--background-light);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.conversation-item:hover {
    background: #E8F4F8;
    border-left-color: var(--primary-color);
}

.conversation-item.active {
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.1), rgba(123, 104, 238, 0.1));
    border-left-color: var(--primary-color);
}

.conversation-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-light);
}

.conversation-phase {
    display: flex;
    align-items: center;
    gap: 4px;
}

.phase-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: white;
}

.phase-badge[data-phase="1"] { background: var(--phase-1); }
.phase-badge[data-phase="2"] { background: var(--phase-2); }
.phase-badge[data-phase="3"] { background: var(--phase-3); }
.phase-badge[data-phase="4"] { background: var(--phase-4); }
.phase-badge[data-phase="5"] { background: var(--phase-5); }

/* 사이드바 푸터 - 단계 표시 */
.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: var(--background-light);
}

.phase-indicator .phase-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.phase-progress {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.phase-step {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-light);
    transition: var(--transition);
}

.phase-step.active {
    color: var(--text-primary);
    font-weight: 600;
}

.phase-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border-color);
    transition: var(--transition);
    flex-shrink: 0;
}

.phase-step.active .phase-dot {
    width: 14px;
    height: 14px;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

.phase-step[data-phase="1"].active .phase-dot { background: var(--phase-1); }
.phase-step[data-phase="2"].active .phase-dot { background: var(--phase-2); }
.phase-step[data-phase="3"].active .phase-dot { background: var(--phase-3); }
.phase-step[data-phase="4"].active .phase-dot { background: var(--phase-4); }
.phase-step[data-phase="5"].active .phase-dot { background: var(--phase-5); }

/* ===== 메인 컨테이너 ===== */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background-light);
    overflow: hidden;
}

/* 헤더 */
.chat-header {
    background: var(--background-white);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.toggle-sidebar-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-sidebar-btn:hover {
    background: var(--background-light);
    color: var(--primary-color);
}

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

.header-subtitle {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 2px;
}

/* ===== 채팅 영역 ===== */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* 환영 화면 */
.welcome-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100%;
    padding: 40px 20px;
}

.welcome-screen.hidden {
    display: none;
}

.welcome-content {
    max-width: 800px;
    text-align: center;
}

.bot-avatar-large {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    box-shadow: 0 8px 24px rgba(74, 144, 226, 0.3);
}

.bot-avatar-large i {
    font-size: 48px;
    color: white;
}

.welcome-content h2 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.welcome-intro {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.welcome-description {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 40px;
}

.process-overview {
    margin-bottom: 40px;
}

.process-overview h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 24px;
}

.process-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.process-card {
    background: var(--background-white);
    padding: 20px 16px;
    border-radius: 12px;
    box-shadow: var(--shadow-light);
    transition: var(--transition);
}

.process-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
}

.process-number {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin: 0 auto 12px;
}

.process-card h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.process-card p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.welcome-question {
    font-size: 16px;
    color: var(--text-primary);
    padding: 20px;
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.05), rgba(123, 104, 238, 0.05));
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
}

/* 메시지 컨테이너 */
.messages-container {
    max-width: 900px;
    margin: 0 auto;
}

.message {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.message-content {
    flex: 1;
}

.message-role {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.message-text {
    background: var(--background-white);
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    box-shadow: var(--shadow-light);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message.user .message-text {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
}

.message.assistant .message-text {
    background: var(--background-white);
}

.message-time {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 6px;
}

.message-phase {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
    font-weight: 600;
    color: white;
}

.message-phase[data-phase="1"] { background: var(--phase-1); }
.message-phase[data-phase="2"] { background: var(--phase-2); }
.message-phase[data-phase="3"] { background: var(--phase-3); }
.message-phase[data-phase="4"] { background: var(--phase-4); }
.message-phase[data-phase="5"] { background: var(--phase-5); }

/* ===== 입력 영역 ===== */
.input-container {
    background: var(--background-white);
    border-top: 1px solid var(--border-color);
    padding: 20px 24px;
}

.input-wrapper {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#userInput {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    font-family: 'Noto Sans KR', sans-serif;
    color: var(--text-primary);
    resize: none;
    max-height: 150px;
    transition: var(--transition);
}

#userInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.send-btn {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.input-hint {
    max-width: 900px;
    margin: 8px auto 0;
    font-size: 12px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== 로딩 오버레이 ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    background: var(--background-white);
    padding: 40px 60px;
    border-radius: 16px;
    text-align: center;
    box-shadow: var(--shadow-medium);
}

.loading-spinner i {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.loading-spinner p {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}

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

::-webkit-scrollbar-track {
    background: var(--background-light);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* ===== 반응형 디자인 ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        margin-left: -280px;
        box-shadow: var(--shadow-medium);
    }
    
    .sidebar.active {
        margin-left: 0;
    }
    
    .process-steps {
        grid-template-columns: 1fr;
    }
    
    .welcome-content h2 {
        font-size: 24px;
    }
    
    .welcome-intro {
        font-size: 16px;
    }
    
    .chat-container {
        padding: 16px;
    }
    
    .input-container {
        padding: 12px 16px;
    }
}

@media (max-width: 480px) {
    .bot-avatar-large {
        width: 80px;
        height: 80px;
    }
    
    .bot-avatar-large i {
        font-size: 36px;
    }
    
    .process-card {
        padding: 16px 12px;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
    }
}
