/*********************
chat.css
- 챗봇 UI 스타일
*********************/

/* 챗봇 래퍼 */
.chat-modal {
    position: fixed;
    bottom: 20px;
    left: 200px; /* nav-bar 오른쪽에 위치 */
    z-index: 9999;
    animation: slideUp 0.3s ease-out;
}

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

.chat-modal.hidden {
    display: none;
}

/* 오버레이는 사용하지 않음 */
.chat-overlay {
    display: none;
}

/* 채팅 컨테이너 */
.chat-container {
    position: relative;
    width: 400px;
    height: 600px;
    background-color: rgba(245, 245, 245, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 2px solid rgba(255, 165, 0, 0.4);
}

/* 헤더 */
.chat-header {
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(224, 224, 224, 0.5);
    min-height: 60px;
}

.chat-logo img {
    height: 35px;
}

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

.chat-menu {
    width: 24px;
    height: 24px;
    cursor: pointer;
    padding: 4px;
}

.chat-menu img {
    height: 24px;
}

.chat-close {
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.chat-close:hover {
    background-color: #f0f0f0;
}

.chat-close span {
    font-size: 20px;
    color: #666;
    font-weight: 300;
}

/* 메시지 영역 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* 스크롤바 스타일 */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* 메시지 버블 */
.message {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
    animation: fadeIn 0.3s ease-in-out;
}

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

/* 사용자 메시지 (오른쪽, 흰색 배경) */
.message.user {
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* AI 메시지 (왼쪽, 노란색 배경) */
.message.ai {
    background-color: #ffc107;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* 메시지 내 마크다운 스타일 */
.message strong {
    font-weight: 700;
}

.message em {
    font-style: italic;
}

.message code {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "Courier New", monospace;
    font-size: 0.9em;
}

.message h1,
.message h2,
.message h3 {
    font-weight: 700;
    margin: 8px 0 4px 0;
}

.message h1 {
    font-size: 1.3em;
}

.message h2 {
    font-size: 1.2em;
}

.message h3 {
    font-size: 1.1em;
}

.message li {
    margin-left: 20px;
    margin-bottom: 4px;
}

.message br {
    display: block;
    content: "";
    margin: 4px 0;
}

/* 로딩 애니메이션 (AI 응답 대기) */
.message.ai.loading {
    color: white;
    font-weight: bold;
}

.loading-dots {
    display: inline-block;
}

.loading-dots span {
    animation: blink 1.4s infinite;
    animation-fill-mode: both;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {
    0%,
    80%,
    100% {
        opacity: 0.3;
    }
    40% {
        opacity: 1;
    }
}

/* 입력 영역 */
.chat-input-container {
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 15px 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    border-top: 1px solid rgba(224, 224, 224, 0.5);
}

.chat-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 25px;
    padding: 12px 18px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    cursor: url("img/chatting/icon_cursor.png"), auto;
}

.chat-input:focus {
    border-color: #ffc107;
}

.chat-input::placeholder {
    color: #999;
}

/* 전송 버튼 */
.send-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.send-button:hover:not(:disabled) {
    transform: scale(1.1);
}

.send-button:disabled {
    cursor: not-allowed;
}

.send-button img {
    width: 32px;
    height: 32px;
}

/* 반응형 디자인 */
@media (max-width: 1024px) {
    .chat-modal {
        left: 20px;
    }

    .chat-container {
        width: 360px;
        height: 550px;
    }
}

@media (max-width: 768px) {
    .chat-modal {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    .chat-container {
        width: calc(100vw - 20px);
        max-width: 400px;
        height: 500px;
    }
}

@media (max-width: 480px) {
    .chat-modal {
        left: 0;
        right: 0;
        bottom: 0;
    }

    .chat-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
}
