/* AI 채팅 위젯 */
#ai-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37,99,235,0.4);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: transform 0.2s;
}
#ai-chat-btn:hover { transform: scale(1.1); }
#ai-chat-btn .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
}

/* 채팅창 */
#ai-chat-box {
    display: none;
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    z-index: 99999;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Malgun Gothic', sans-serif;
}
#ai-chat-box.open { display: flex; }

/* 모바일 대응 */
@media (max-width: 480px) {
    #ai-chat-box {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    #ai-chat-btn {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
}

/* 헤더 */
#ai-chat-header {
    background: #2563eb;
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
#ai-chat-header .title {
    font-size: 16px;
    font-weight: 700;
}
#ai-chat-header .subtitle {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 2px;
}
#ai-chat-header .close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* 메시지 영역 */
#ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f1f5f9;
}
.ai-msg {
    margin-bottom: 12px;
    display: flex;
}
.ai-msg.user { justify-content: flex-end; }
.ai-msg.bot { justify-content: flex-start; }
.ai-msg .bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}
.ai-msg.user .bubble {
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ai-msg.bot .bubble {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.ai-msg.bot .bubble a {
    color: #2563eb;
    text-decoration: underline;
}

/* 메뉴 버튼 그리드 */
.ai-menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 10px;
}
.ai-menu-btn {
    padding: 10px 8px;
    background: #f0f7ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #1e40af;
    transition: all 0.15s;
    text-align: center;
}
.ai-menu-btn:hover {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* 서브 메뉴 */
.ai-sub-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}
.ai-sub-btn {
    padding: 7px 12px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 16px;
    cursor: pointer;
    font-size: 12px;
    color: #374151;
    transition: all 0.15s;
    white-space: nowrap;
}
.ai-sub-btn:hover {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* 돌아가기 버튼 */
.ai-back-btn {
    padding: 5px 12px;
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    cursor: pointer;
    font-size: 11px;
    color: #6b7280;
    transition: all 0.15s;
}
.ai-back-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.ai-after-btns {
    padding: 6px 10px !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* 로딩 */
.ai-msg.bot .bubble.loading {
    color: #999;
}
.ai-msg.bot .bubble.loading::after {
    content: '';
    animation: dots 1.2s infinite;
}
@keyframes dots {
    0% { content: '.'; }
    33% { content: '..'; }
    66% { content: '...'; }
}

/* 입력 영역 */
#ai-chat-input-wrap {
    display: flex;
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}
#ai-chat-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    resize: none;
    height: 40px;
    line-height: 20px;
    font-family: inherit;
}
#ai-chat-input:focus { border-color: #2563eb; }
#ai-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    border: none;
    cursor: pointer;
    margin-left: 8px;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
#ai-chat-send:disabled { background: #93c5fd; cursor: not-allowed; }
