/* ==========================================================================
   AI Chatbot UI Styles
   - 대화창 스타일 AI 챗봇 시스템
   - 기존 레이어 아키텍처와 독립적 운영
   - modal-system.js 및 form-layout.css와 호환
   ========================================================================== */

/* AI 챗봇 메인 컨테이너 */
#ai-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 3999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* HENEX 책갈피 스타일 버튼 - 왼쪽 배치 */
#henex-bookmark {
    position: fixed;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    z-index: 3999;
    background: #FFFFFF;
    color: #8500d3;
    padding: 15px 10px;
    width: 65px;
    height: 80vh;
    min-height: 800px;
    border: 2px solid #8500d3;
    border-left: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    font-weight: 900;
    font-size: 28px;
    transition: all 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    overflow: hidden; /* 빛 효과가 밖으로 안 나가게 */
}

/* 빛이 지나가는 효과 - 위에서 아래로 */
#henex-bookmark::before {
    content: '';
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 80%;
    background: linear-gradient(180deg,
        transparent,
        rgba(255, 255, 255, 0.6),
        rgba(255, 255, 255, 0.8),
        rgba(255, 255, 255, 0.6),
        transparent
    );
    pointer-events: none;
    animation: shine 3s ease-in-out infinite;
}

@keyframes shine {
    0% {
        top: 100%;
    }
    50% {
        top: -100%;
    }
    100% {
        top: -100%;
    }
}

#henex-bookmark span {
    color: #8500d3;
    text-align: center;
    width: 100%;
}

/* 인쇄상담 한글 텍스트 */
#henex-bookmark .henex-text {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 2px;
    text-align: center;
    width: 100%;
}

/* AI 텍스트 */
#henex-bookmark .henex-subtitle {
    font-size: 22px;
    font-weight: 800;
    line-height: 0.3;
    margin-top: 15px;
    text-align: center;
    width: 100%;
}

/* 구분선 */
#henex-bookmark .henex-divider {
    width: 40px;
    height: 2px;
    background: #8500d3;
    margin: 15px 0;
}

#henex-bookmark:hover {
    padding-left: 14px;
    background: #8500d3;
    color: #FFFFFF;
    border-width: 3px;
}

#henex-bookmark:hover span {
    color: #FFFFFF;
}

#henex-bookmark:hover .henex-divider {
    background: #FFFFFF;
}

#henex-bookmark.active {
    background: #8500d3;
    color: #FFFFFF;
}

#henex-bookmark.active .henex-divider {
    background: #FFFFFF;
}

#henex-bookmark.active span {
    color: #FFFFFF;
}

/* HENEX 버튼 내부 텍스트 스타일링 */
#henex-bookmark span {
    display: block;
    line-height: 1;
    font-size: inherit;
    font-weight: inherit;
}

/* 백드롭 오버레이 */
#ai-chat-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#ai-chat-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

/* 챗봇 버튼 (최소화 상태) */
.ai-chat-button {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 123, 255, 0.4);
}

.ai-chat-button.active {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
}

/* 챗봇 창 - 왼쪽에서 슬라이드 */
.ai-chat-window {
    position: fixed;
    top: 50%;
    left: -500px;
    transform: translateY(-50%);
    width: 500px;
    height: 80vh;
    min-height: 800px;
    background: white;
    border-radius: 0 12px 12px 0;
    overflow: hidden;
    border: 1px solid #e9ecef;
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 3999;
    display: flex;
    flex-direction: column;
}

.ai-chat-window.open {
    left: 0;
}

@keyframes slideInLeft {
    from {
        left: -500px;
    }
    to {
        left: 0;
    }
}

/* 헤더 */
.ai-chat-header {
    background: linear-gradient(135deg, #5c009e 0%, #8500d3 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.ai-chat-title {
    font-weight: 700;
    font-size: 19px;
    color: white;
}

.ai-chat-close {
    position: absolute;
    right: 24px;
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: #f1f3f4;
}

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

/* 메시지 말풍선 */
.ai-message, .user-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: messageSlide 0.3s ease-out;
}

/* 첫 메시지는 중앙 정렬 */
.ai-chat-messages .ai-message:first-child {
    max-width: 90%;
    align-self: center;
    text-align: center;
}

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

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message {
    align-self: flex-start;
    background: white;
    color: #333;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* AI 응답 타이핑 애니메이션 */
.ai-typing {
    align-self: flex-start;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #6c757d;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* 제품 선택 버튼 영역 */
.ai-product-buttons {
    margin-top: 16px;
    padding: 0 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-product-category {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-product-category-title {
    font-size: 13px;
    font-weight: 600;
    color: #495057;
    padding-left: 4px;
}

.ai-product-button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ai-product-btn {
    padding: 8px 14px;
    background: white;
    color: #007bff;
    border: 1.5px solid #007bff;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ai-product-btn:hover {
    background: #007bff;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.ai-product-btn:active {
    transform: translateY(0);
}

/* 입력 영역 */
.ai-chat-input-container {
    padding: 20px 24px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.ai-chat-input-group {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ai-chat-input {
    flex: 1;
    border: 2px solid #8500d3;
    border-radius: 20px;
    padding: 14px 20px;
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 100px;
    min-height: 44px;
    line-height: 22px;
    transition: border-color 0.2s;
    font-family: inherit;
    overflow-y: hidden;
}

.ai-chat-input.scrollable {
    overflow-y: auto;
}

.ai-chat-input:focus {
    border-color: #8500d3;
}

.ai-chat-send {
    width: 40px;
    height: 40px;
    background: #8500d3;
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-chat-send:hover:not(:disabled) {
    transform: scale(1.05);
    background: #5c009e;
}

.ai-chat-send:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

/* 빠른 응답 버튼들 - 중앙 정렬 */
.ai-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    justify-content: center;
}

.ai-quick-reply {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 16px;
    padding: 8px 16px;
    font-size: 13px;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-quick-reply:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

/* 개인정보 입력 금지 안내 */
.ai-privacy-notice {
    padding: 8px 12px;
    margin-bottom: 8px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.5;
    color: #856404;
    text-align: center;
}

/* 반응형 처리 - 모바일 */
@media (max-width: 768px) {
    /* 책갈피 작게 */
    #henex-bookmark {
        font-size: 14px;
        padding: 12px 8px;
        gap: 4px;
    }

    /* 챗창 전체 화면 */
    .ai-chat-window {
        width: 100vw;
        height: 100vh;
        left: -100vw;
        top: 0;
        transform: none;
        border-radius: 0;
    }

    .ai-chat-window.open {
        left: 0;
    }
}

/* 태블릿 */
@media (min-width: 769px) and (max-width: 1024px) {
    .ai-chat-window {
        width: 400px;
        height: 700px;
    }
}