/**
 * v7/ai/chatbot.css - AI 챗봇 페이지 스타일
 *
 * v7 디자인 원칙: 보더리스, 연한 배경 + 진한 전경, Light Blue 테마.
 * Web Awesome Pro CSS 변수 기반. Bootstrap 미사용. 다크 모드 미적용.
 * Font Awesome Pro Light(fal) 아이콘 사용.
 */

/* ===== 챗봇 컨테이너 ===== */
#v7-ai-chatbot {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 120px); /* JS 로드 전 폴백 */
    min-height: 400px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
}

/* ===== 헤더 ===== */
.chatbot-header {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--wa-color-neutral-95, #f8fafc);
}

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

.chatbot-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--wa-color-brand-95, #e7f5ff);
    color: var(--wa-color-brand-50, #3178c0);
    font-size: 1.15rem;
    flex-shrink: 0;
}

.chatbot-title {
    display: block;
    font-weight: 700;
    font-size: 1rem;
    color: var(--wa-color-neutral-10, #1e293b);
    line-height: 1.3;
}

.chatbot-subtitle {
    display: block;
    font-size: 0.78rem;
    color: var(--wa-color-neutral-60, #64748b);
    line-height: 1.3;
}

/* ===== 메시지 영역 ===== */
.chatbot-messages {
    flex: 1 1 0;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #fff;
    min-height: 0; /* flexbox 내 shrink 허용 필수 */
}

/* ===== 환영 메시지 ===== */
.chatbot-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2.5rem 1.5rem;
    flex: 1;
}

.welcome-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--wa-color-brand-95, #e7f5ff);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.welcome-icon i {
    font-size: 1.5rem;
    color: var(--wa-color-brand-50, #3178c0);
}

.chatbot-welcome h3 {
    margin: 0 0 0.5rem;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--wa-color-neutral-10, #1e293b);
}

.chatbot-welcome p {
    margin: 0 0 1.5rem;
    color: var(--wa-color-neutral-60, #64748b);
    font-size: 0.875rem;
}

.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.suggestion-chip {
    padding: 0.45rem 1rem;
    border: none;
    border-radius: 999px;
    background: var(--wa-color-neutral-95, #f8fafc);
    color: var(--wa-color-neutral-40, #334155);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.suggestion-chip:hover {
    background: var(--wa-color-brand-95, #e7f5ff);
    color: var(--wa-color-brand-50, #3178c0);
}

/* ===== 메시지 공통 ===== */
.chatbot-message {
    display: flex;
    gap: 0.625rem;
    max-width: 82%;
}

.chatbot-message.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chatbot-message.ai-message {
    align-self: flex-start;
}

/* ===== 아바타 ===== */
.message-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.ai-message .message-avatar {
    background: var(--wa-color-brand-95, #e7f5ff);
    color: var(--wa-color-brand-50, #3178c0);
}

.user-message .message-avatar {
    background: #fef9ec;
    color: #b45309;
}

/* ===== 메시지 내용 ===== */
.message-content {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.message-text {
    padding: 0.7rem 1rem;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.6;
    word-break: break-word;
}

.ai-message .message-text {
    background: var(--wa-color-neutral-95, #f8fafc);
    color: var(--wa-color-neutral-20, #1e293b);
    border-top-left-radius: 4px;
}

.user-message .message-text {
    background: #d99a0a;
    color: #fff;
    border-top-right-radius: 4px;
}

.message-time {
    font-size: 0.7rem;
    color: var(--wa-color-neutral-60, #94a3b8);
    padding: 0 0.35rem;
}

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

/* ===== AI 마크다운 스타일 ===== */
.ai-message .message-text p {
    margin: 0.25rem 0;
}

.ai-message .message-text h1,
.ai-message .message-text h2,
.ai-message .message-text h3,
.ai-message .message-text h4 {
    margin: 0.6rem 0 0.3rem;
    font-weight: 600;
    color: var(--wa-color-neutral-10, #1e293b);
}

.ai-message .message-text h1 { font-size: 1.1rem; }
.ai-message .message-text h2 { font-size: 1rem; }
.ai-message .message-text h3 { font-size: 0.925rem; }
.ai-message .message-text h4 { font-size: 0.875rem; }

.ai-message .message-text ul,
.ai-message .message-text ol {
    margin: 0.3rem 0;
    padding-left: 1.25rem;
}

.ai-message .message-text li {
    margin-bottom: 0.2rem;
}

.ai-message .message-text code {
    background: #eef2f7;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--wa-color-neutral-30, #334155);
}

.ai-message .message-text pre {
    background: var(--wa-color-neutral-10, #1e293b);
    color: #e2e8f0;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    overflow-x: auto;
    margin: 0.5rem 0;
    font-size: 0.8rem;
}

.ai-message .message-text pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.ai-message .message-text a {
    color: var(--wa-color-brand-50, #3178c0);
    text-decoration: none;
    font-weight: 500;
}

.ai-message .message-text a:hover {
    text-decoration: underline;
}

.ai-message .message-text strong {
    font-weight: 600;
}

/* ===== AI 생각중 애니메이션 ===== */
.ai-thinking {
    display: flex;
    align-items: center;
    min-height: 24px;
}

.thinking-dots {
    display: flex;
    gap: 5px;
}

.thinking-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--wa-color-brand-70, #5bb5fe);
    animation: thinking-bounce 1.4s ease-in-out infinite;
}

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

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

@keyframes thinking-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* ===== 로딩 ===== */
.chatbot-loading-previous,
.chatbot-loading-initial {
    text-align: center;
    padding: 0.75rem;
    color: var(--wa-color-neutral-60, #94a3b8);
    font-size: 0.8rem;
}

.chatbot-loading-previous i,
.chatbot-loading-initial i {
    color: var(--wa-color-brand-70, #5bb5fe);
}

/* ===== 입력 영역 ===== */
.chatbot-input-area {
    padding: 0.875rem 1.25rem;
    background: var(--wa-color-neutral-95, #f8fafc);
}

.chatbot-input-form {
    display: flex;
    gap: 0.625rem;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    padding: 0.65rem 1rem;
    border: none;
    border-radius: 999px;
    font-size: 0.875rem;
    outline: none;
    background: #fff;
    color: var(--wa-color-neutral-20, #1e293b);
    transition: box-shadow 0.15s;
}

.chatbot-input::placeholder {
    color: var(--wa-color-neutral-60, #94a3b8);
}

.chatbot-input:focus {
    box-shadow: 0 0 0 2px var(--wa-color-brand-90, #ceeaff);
}

.chatbot-input:disabled {
    background: #f1f5f9;
    color: var(--wa-color-neutral-60, #94a3b8);
}

.chatbot-send-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 12px;
    background: var(--wa-color-brand-50, #3178c0);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: background 0.15s;
    flex-shrink: 0;
}

.chatbot-send-btn:hover:not(:disabled) {
    background: var(--wa-color-brand-60, #4a99e4);
}

.chatbot-send-btn:disabled {
    background: var(--wa-color-neutral-80, #c1c8d1);
    cursor: not-allowed;
}

/* ===== 로그인 안내 ===== */
.chatbot-login-notice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    padding: 0.625rem;
    color: var(--wa-color-neutral-60, #64748b);
    font-size: 0.85rem;
}

.chatbot-login-notice i {
    color: var(--wa-color-neutral-60, #94a3b8);
}

.chatbot-login-link {
    color: var(--wa-color-brand-50, #3178c0);
    font-weight: 600;
    text-decoration: none;
}

.chatbot-login-link:hover {
    text-decoration: underline;
}

/* ===== AI 챗봇 페이지에서 푸터 숨김 ===== */
.v7-footer {
    display: none !important;
}

/* ===== 반응형 ===== */
@media (max-width: 991.98px) {
    #v7-ai-chatbot {
        border-radius: 0;
    }

    .chatbot-messages {
        padding: 1rem;
    }

    .chatbot-message {
        max-width: 90%;
    }

    .chatbot-header {
        padding: 0.75rem 1rem;
    }

    .chatbot-input-area {
        padding: 0.75rem 1rem;
    }
}
