/* 컨테이너 스타일 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.container h1 {
    font-size: 2.5rem;
    font-weight: bold;
    text-align: center;
    margin: 2rem 0 1rem;
    background: linear-gradient(135deg, var(--pink-primary), var(--pink-light));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: fadeIn 0.5s ease-out;
}

.container > p {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2rem;
    animation: fadeIn 0.5s ease-out 0.2s both;
}

/* 채팅 컨테이너 스타일 */
.chat-container {
    max-width: 1000px;
    height: calc(100vh - 250px);
    margin: 0 auto;
    border-radius: 20px;
    box-shadow: 0 4px 20px var(--shadow-color);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.5s ease-out 0.4s both;
}

/* 채팅 헤더 스타일 */
.chat-header {
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--pink-primary), var(--pink-light));
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-title {
    color: #FFFFFF;
    font-size: 1.25rem;
    font-weight: 600;
}

.chat-controls button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #FFFFFF;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.chat-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 채팅 박스 스타일 */
.chat-box {
    flex: 1;
    padding: 1.5rem;
    background: var(--bg-secondary);
    overflow-y: auto;
}

/* 채팅 메시지 컨테이너 스타일 */
.chat-message {
    display: flex;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding: 0 1rem;
    animation: fadeIn 0.3s ease-out;
}

.user-message {
    flex-direction: row-reverse;
    margin-left: auto;
}

.ai-message {
    flex-direction: row;
    margin-right: auto;
}

/* 메시지 내용 스타일 */
.message-content-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 60%;
}

.message-content {
    padding: 1rem;
    border-radius: 16px;
    word-wrap: break-word;
    line-height: 1.5;
}

/* 사용자 메시지 스타일 */
.user-message .message-content {
    background: var(--pink-primary);
    color: white;
    border-bottom-right-radius: 4px;
    margin-right: 8px;
}

/* AI 메시지 스타일 */
.ai-message .message-content {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
    margin-left: 8px;
}

/* 시간 표시 스타일 */
.message-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.user-message .message-time {
    text-align: right;
    margin-right: 8px;
}

.ai-message .message-time {
    text-align: left;
    margin-left: 8px;
}

/* 아바타 스타일 */
.ai-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-image: url('/img/b3faabb5d0d09446.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    flex-shrink: 0;
}

.user-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--pink-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* 모바일 반응형 스타일 */
@media (max-width: 768px) {
    .message-content-wrapper {
        max-width: 75%;
    }

    .ai-avatar,
    .user-avatar {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }
}

/* 코드 블록 스타일 */
.ai-message .message-content pre {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 1rem;
    margin: 0.5rem 0;
    overflow-x: auto;
}

.ai-message .message-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
}

/* 인라인 코드 스타일 */
.ai-message .message-content :not(pre) > code {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.2em 0.4em;
    border-radius: 4px;
}

/* 말풍선 꼬리 스타일 */
.message-content::before {
    content: '';
    position: absolute;
    bottom: 0;
    width: 10px;
    height: 10px;
}

.user-message .message-content::before {
    right: -5px;
    border-left: 10px solid var(--pink-primary);
    border-bottom-left-radius: 10px;
}

.ai-message .message-content::before {
    left: -5px;
    border-right: 10px solid var(--bg-tertiary);
    border-bottom-right-radius: 10px;
}

/* 라이트 모드 메시지 스타일 */
:root {
    .user-message .message-content {
        background: var(--pink-primary);
        color: white;
        border-bottom-right-radius: 4px;
    }

    .ai-message .message-content {
        background: var(--bg-tertiary);
        color: var(--text-primary);
        border-bottom-left-radius: 4px;
        border: 1px solid var(--border-color);
    }

    .message-content pre {
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
    }

    .message-content code {
        background: rgba(0, 0, 0, 0.05);
        color: var(--text-primary);
    }
}

/* 다크 모드 메시지 스타일 */
[data-theme="dark"] {
    .user-message .message-content {
        background: var(--pink-primary);
        color: white;
        border-bottom-right-radius: 4px;
    }

    .ai-message .message-content {
        background: var(--bg-tertiary);
        color: var(--text-primary);
        border-bottom-left-radius: 4px;
        border: 1px solid var(--border-color);
    }

    .message-content pre {
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
    }

    .message-content code {
        background: rgba(255, 255, 255, 0.05);
        color: var(--text-primary);
    }
}

/* 메시지 아바타 스타일 */
.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 8px;
    font-size: 1.2rem;
}

.user-message .message-avatar {
    background: var(--pink-primary);
    color: white;
    order: 1;
}

.ai-message .message-avatar {
    background: var(--mint);
    color: var(--text-primary);
    order: 0;
}

/* 코드 블록 스타일 */
.message-content pre {
    border-radius: 8px;
    padding: 1rem;
    margin: 0.5rem 0;
    overflow-x: auto;
}

.message-content code {
    font-family: 'JetBrains Mono', monospace;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
}

/* 입력 영역 스타일 */
.input-container {
    padding: 1rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--pink-primary);
}

#user-input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.5;
    padding: 0.5rem;
    resize: none;
    min-height: 24px;
    max-height: 150px;
}

#user-input::placeholder {
    color: var(--text-secondary);
}

#user-input:focus {
    outline: none;
}

.send-button {
    background: var(--pink-primary);
    color: #FFFFFF;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.send-button:hover {
    background: var(--pink-dark);
}

/* 스크롤바 스타일 */
:root {
    .chat-box::-webkit-scrollbar {
        width: 8px;
    }

    .chat-box::-webkit-scrollbar-track {
        background: var(--bg-secondary);
    }

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

    .chat-box::-webkit-scrollbar-thumb:hover {
        background: var(--text-secondary);
    }
}

[data-theme="dark"] {
    .chat-box::-webkit-scrollbar {
        width: 8px;
    }

    .chat-box::-webkit-scrollbar-track {
        background: var(--bg-secondary);
    }

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

    .chat-box::-webkit-scrollbar-thumb:hover {
        background: var(--text-secondary);
    }
}

/* 애니메이션 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .container h1 {
        font-size: 2rem;
        margin: 1.5rem 0 0.75rem;
    }

    .chat-container {
        height: calc(100vh - 200px);
        margin: 1rem;
        border-radius: 16px;
    }

    .message-content {
        max-width: 85%;
    }

    .input-wrapper {
        padding: 0.25rem;
    }

    .message-avatar {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }
}

.ai-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-image: url('/img/b3faabb5d0d09446.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    margin: 0 8px;
}

.user-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--pink-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin: 0 8px;
}
/* 메시지 컨테이너 스타일 수정 */
.message-content-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 70%;
}

.message-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    text-align: right;
}

.user-message .message-time {
    text-align: right;
}

.ai-message .message-time {
    text-align: left;
}

/* 아바타 스타일 수정 */
.ai-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-image: url('/img/b3faabb5d0d09446.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    margin: 0 8px;
    order: 0;
}

.user-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--pink-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin: 0 8px;
    order: 1;
}

/* 메시지 정렬 수정 */
.user-message {
    flex-direction: row-reverse;
}

.ai-message {
    flex-direction: row;
}

/* 모바일 반응형 스타일 */
@media (max-width: 768px) {
    .message-content-wrapper {
        max-width: 85%;
    }

    .ai-avatar,
    .user-avatar {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }
}

/* 로딩 애니메이션 */
.loading-dots {
    display: inline-block;
}

.loading-dots::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}