/* 챗봇 아이콘 */
#chatbot-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.chatbot-button {
    display: flex;
    align-items: center;
    background: #6366f1;
    color: white;
    border-radius: 20px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    transition: all 0.3s ease;
    border: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chatbot-button:hover {
    background: #4f46e5;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.chatbot-text {
    margin-left: 4px;
    margin-right: 4px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

/* 챗봇 캐릭터 */
.chatbot-character {
    width: 32px;
    height: 32px;
    position: relative;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #495057;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.chatbot-face {
    position: relative;
    width: 26px;
    height: 26px;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    overflow: visible;
}

.chatbot-eyes {
    display: flex;
    gap: 6px;
    position: relative;
    margin-top: -1px;
}

.eye {
    width: 4px;
    height: 8px;
    background: #000000;
    border-radius: 50%;
    position: relative;
    transition: transform 0.1s ease;
}

/* 눈 깜빡임 애니메이션 */
.eye.blink {
    animation: blink 0.3s ease-in-out;
}

@keyframes blink {

    0%,
    100% {
        transform: var(--eye-transform, translate(0, 0)) scaleY(1);
    }

    50% {
        transform: var(--eye-transform, translate(0, 0)) scaleY(0.1);
    }
}

/* 표정 변화 */
.chatbot-face.happy .eye {
    transform: scaleX(1.0) scaleY(0.5);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}

.chatbot-face.sleepy .eye {
    transform: scaleY(0.2);
    opacity: 0.8;
}

.chatbot-face.surprised .eye {
    transform: scale(1.4);
}

/* 볼 홍조 효과 */
.chatbot-face::before,
.chatbot-face::after {
    content: '';
    position: absolute;
    width: 5px;
    height: 3px;
    background: rgba(255, 182, 193, 0.8);
    border-radius: 50%;
    top: 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.chatbot-face::before {
    left: 4px;
}

.chatbot-face::after {
    right: 4px;
}

.chatbot-face.happy::before,
.chatbot-face.happy::after {
    opacity: 1;
}

/* 입 표현 */
.chatbot-mouth {
    position: absolute;
    bottom: 11px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 4px;
    background: #495057;
    border-radius: 0 0 8px 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.chatbot-face.happy .chatbot-mouth {
    opacity: 0;
    border-radius: 0 0 8px 8px;
    bottom: 11px;
    width: 9px;
    height: 5px;
}

/* 호버 효과 */
.chatbot-character:hover {
    animation: bounce 0.6s ease-in-out;
}

@keyframes bounce {

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

    25% {
        transform: scale(1.05) rotate(-2deg);
    }

    50% {
        transform: scale(1.1) rotate(0deg);
    }

    75% {
        transform: scale(1.05) rotate(2deg);
    }
}

/* 챗봇 윈도우 */
#chatbot-window {
    position: fixed;
    bottom: 0px;
    right: 20px;
    width: 400px;
    height: calc(100vh - 150px);
    background: white;
    border-radius: 0px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 1001;
    overflow: hidden;
}

#chatbot-window.show {
    display: flex;
}

/* 챗봇 헤더 */
#chatbot-header {
    background: #fff;
    color: #6366f1;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
}

.chatbot-header-left {
    display: flex;
    align-items: center;
}

.chatbot-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: #4f46e5;
}

.chatbot-header-right {
    display: flex;
    gap: 4px;
}

.chatbot-header-btn {
    background: transparent;
    border: none;
    color: #6366f1;
    padding: 6px;
    border-radius: 4px;
    transition: background 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.chatbot-header-btn:hover {
    background: #eef2ff;
    color: #4f46e5;
}

/* 챗봇 메시지 영역 */
#chatbot-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 챗봇 입력 영역 */
#chatbot-input {
    padding: 12px 16px;
    border-top: 1px solid #e0e0e0;
    background: white;
}

#chatbot-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

#user-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

#user-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#chatbot-form button {
    background: #6366f1;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: background 0.2s ease;
}

#chatbot-form button:hover {
    background: #4f46e5;
}

#chatbot-form button:disabled {
    background: #adb5bd;
    cursor: not-allowed;
}

/* 확대된 챗봇 모달 */
.chatbot-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.chatbot-overlay.show {
    display: flex;
}

.chatbot-modal {
    position: fixed;
    width: 90%;
    bottom: 0px;
    max-width: 1000px;
    height: 90%;
    background: white;
    border-radius: 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

#chatbot-modal-header {
    background: #fff;
    color: #6366f1;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
}

#chatbot-modal-header .chatbot-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: #4f46e5;
}

#chatbot-modal-header .chatbot-header-btn {
    background: transparent;
    border: none;
    color: #6366f1;
    padding: 6px;
    border-radius: 4px;
    transition: background 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

#chatbot-modal-header .chatbot-header-btn:hover {
    background: #eef2ff;
    color: #4f46e5;
}

#chatbot-modal-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#chatbot-modal-input {
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
    background: white;
}

#chatbot-modal-form {
    display: flex;
    gap: 12px;
    align-items: center;
}

#modal-user-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 24px;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

#modal-user-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#chatbot-modal-form button {
    background: #6366f1;
    border: none;
    border-radius: 50% !important;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: background 0.2s ease;
}

#chatbot-modal-form button:hover {
    background: #4f46e5;
}

#chatbot-modal-form button:disabled {
    background: #adb5bd;
    cursor: not-allowed;
}

/* 소스 컨테이너 */
.chatbot-sources-container {
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

.chatbot-sources-container .list-group-item {
    background-color: transparent;
    transition: background-color 0.2s ease;
    overflow-wrap: break-word;
    word-break: break-word;
}

.chatbot-sources-container .list-group-item:hover {
    background-color: #e9ecef;
}

.chatbot-sources-container .preview-content {
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    overflow: hidden;
    white-space: pre-wrap;
}

.chatbot-sources-container a {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .chatbot-button {
        padding: 4px 8px 4px 4px;
    }

    .chatbot-character {
        width: 28px;
        height: 28px;
    }

    .chatbot-face {
        width: 22px;
        height: 22px;
    }

    .chatbot-text {
        font-size: 11px;
        margin-left: 4px;
    }

    .chatbot-modal {
        width: 95%;
        height: 90%;
        margin: 20px;
    }

    #chatbot-window {
        width: calc(100% - 40px);
        right: 20px;
        left: 20px;
        height: calc(100vh - 180px);
        max-height: none;
    }

    #chatbot-icon {
        bottom: 15px;
        right: 15px;
    }
}

/* 모바일에서 챗봇 비활성화 */
@media (max-width: 767px) {
    #chatbot-icon,
    #chatbot-window,
    #chatbot-overlay,
    #chatbot-container,
    #chatbot-modal,
    #chatbot-modal-header,
    #chatbot-modal-messages,
    #chatbot-modal-input {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
}