/* SOAM AI Chatbot Stylesheet */
/* Premium UI: Apple Style + Material Design 3 */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-window: rgba(255, 255, 255, 0.95);
    --bg-header: #ffffff;
    --bg-bubble-assistant: #f3f4f6;
    --color-text-assistant: #1f2937;
    --bg-bubble-user: #2563eb;
    --color-text-user: #ffffff;
    --bg-input: #f9fafb;
    --color-text-main: #1f2937;
    --border-color: rgba(16, 185, 129, 0.35);
    --shadow-main: 0 24px 48px -8px rgba(0, 0, 0, 0.16), 0 8px 24px -6px rgba(16, 185, 129, 0.12), inset 0 1px 1px rgba(255, 255, 255, 0.9);
    --blur-effect: blur(12px);
    --font-family: 'Inter', 'Noto Sans KR', sans-serif;
    --banner-bg: #eff6ff;
    --banner-text: #1d4ed8;
}

/* Dark Mode Theme overrides */
body.dark-theme {
    --bg-window: rgba(20, 24, 33, 0.96);
    --bg-header: #1e293b;
    --bg-bubble-assistant: #334155;
    --color-text-assistant: #f1f5f9;
    --bg-bubble-user: #3b82f6;
    --color-text-user: #ffffff;
    --bg-input: #1e293b;
    --color-text-main: #f1f5f9;
    --border-color: rgba(16, 185, 129, 0.5);
    --shadow-main: 0 30px 60px -10px rgba(0, 0, 0, 0.5), 0 12px 30px -8px rgba(16, 185, 129, 0.25), inset 0 1px 0px rgba(255, 255, 255, 0.15);
    --banner-bg: #1e293b;
    --banner-text: #60a5fa;
}

body {
    font-family: var(--font-family);
    transition: background-color 0.3s ease;
}

/* Floating Chatbot Toggle Button */
.soam-chatbot-btn-floating {
    position: fixed;
    top: 50%;
    right: 30px;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
    border: none;
    outline: none;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.4);
    cursor: pointer;
    z-index: 1050;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.soam-chatbot-btn-floating:hover {
    transform: translateY(-50%) scale(1.08);
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.5);
}

.soam-chatbot-btn-floating:active {
    transform: translateY(-50%) scale(0.95);
}

.soam-chatbot-btn-floating .btn-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 24px;
}

/* Pulse animation ring around the button */
.pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
    top: 0;
    left: 0;
    animation: chatbot-pulse 2s infinite ease-out;
    opacity: 0;
    pointer-events: none;
}

@keyframes chatbot-pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Chatbot Card/Window (Apple Glassmorphism + Material 3) */
.soam-chatbot-card {
    position: fixed;
    top: 50%;
    right: 100px;
    transform: translateY(-50%);
    width: 420px;
    height: 620px;
    border-radius: 24px;
    background: var(--bg-window);
    backdrop-filter: var(--blur-effect);
    -webkit-backdrop-filter: var(--blur-effect);
    border: 2.5px solid var(--border-color);
    box-shadow: var(--shadow-main);
    z-index: 1040;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    transition: width 0.3s ease, height 0.3s ease, top 0.3s ease, right 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(30px) translateY(-50%) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateX(0) translateY(-50%) scale(1);
        opacity: 1;
    }
}

/* Chat Header */
.soam-chatbot-header {
    padding: 16px 20px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    color: var(--color-text-main);
}

.avatar-container {
    width: 40px;
    height: 40px;
}

.avatar-icon {
    font-size: 20px;
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.avatar-glow {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--primary-color);
    opacity: 0.15;
    filter: blur(6px);
    border-radius: 12px;
}

.status-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    background-color: #10b981;
    border: 2px solid var(--bg-header);
    border-radius: 50%;
    z-index: 3;
}

.header-title {
    font-size: 15px;
}

.status-text {
    font-size: 11px;
}

.text-muted-custom {
    color: #6b7280;
}
body.dark-theme .text-muted-custom {
    color: #94a3b8;
}

.header-btn {
    border: none;
    background: transparent;
    color: var(--color-text-main);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    opacity: 0.8;
}

.header-btn:hover {
    background-color: rgba(120, 120, 120, 0.15);
    opacity: 1;
}

/* Banner */
.chatbot-banner-info {
    font-size: 11px;
    padding: 8px 16px;
    background-color: var(--banner-bg);
    color: var(--banner-text);
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

/* Chat Body / Messages */
.soam-chatbot-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: bubbleAppear 0.35s cubic-bezier(0.1, 1, 0.1, 1) forwards;
}

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

.message-wrapper.assistant {
    align-self: flex-start;
}

.message-wrapper.user {
    align-self: flex-end;
}

/* Bubble Styling */
.chat-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-break: break-word;
}

.message-wrapper.assistant .chat-bubble {
    background-color: var(--bg-bubble-assistant);
    color: var(--color-text-assistant);
    border-top-left-radius: 4px;
}

.message-wrapper.user .chat-bubble {
    background-color: var(--bg-bubble-user);
    color: var(--color-text-user);
    border-top-right-radius: 4px;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.msg-time {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 4px;
}
.message-wrapper.user .msg-time {
    align-self: flex-end;
}

/* Quick Replies */
.quick-replies-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-reply-btn {
    border: 1px solid var(--border-color);
    background-color: var(--bg-window);
    color: var(--primary-color);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-reply-btn:hover {
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

/* Typing Indicator Animation */
.typing-bubble {
    padding: 14px 20px;
    border-top-left-radius: 4px;
    background-color: var(--bg-bubble-assistant);
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: var(--color-text-assistant);
    opacity: 0.4;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

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

/* Footer / Input Styling */
.soam-chatbot-footer {
    padding: 16px;
    background-color: var(--bg-header);
    border-top: 1px solid var(--border-color);
}

.chat-input {
    border: 1px solid var(--border-color);
    background-color: var(--bg-input);
    color: var(--color-text-main);
    border-radius: 12px !important;
    font-size: 14px;
    padding: 10px 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    background-color: var(--bg-input);
    color: var(--color-text-main);
}

.chat-send-btn {
    border-radius: 12px !important;
    margin-left: 8px;
    padding: 10px 18px;
    background-color: var(--primary-color);
    border: none;
    transition: background-color 0.2s;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.chat-send-btn:hover {
    background-color: var(--primary-hover);
}

.footer-credit {
    font-size: 9px;
    color: #9ca3af;
}

/* Mobile Responsiveness */
@media (max-width: 576px) {
    .soam-chatbot-card {
        width: 100% !important;
        height: 100% !important;
        top: 0 !important;
        bottom: 0 !important;
        right: 0 !important;
        border-radius: 0 !important;
        border: none !important;
        transform: none !important;
        animation: none !important;
    }
    
    .soam-chatbot-btn-floating {
        top: 50% !important;
        bottom: auto !important;
        right: 15px !important;
        transform: translateY(-50%) !important;
    }
    
    .soam-chatbot-btn-floating:hover {
        transform: translateY(-50%) scale(1.08) !important;
    }
    
    .soam-chatbot-btn-floating:active {
        transform: translateY(-50%) scale(0.95) !important;
    }
}

/* ==========================================================================
   그누보드 메인 홈페이지 부트스트랩 클래스 누락 대응용 챗봇 전용 CSS 폴백
   ========================================================================== */
.soam-chatbot-card.d-none,
.soam-chatbot-btn-floating .d-none,
#soam-chatbot-typing.d-none {
    display: none !important;
}

.soam-chatbot-card .d-flex, 
.soam-chatbot-header, 
.soam-chatbot-footer .input-group,
.avatar-container {
    display: flex !important;
}

.soam-chatbot-card .align-items-center, 
.soam-chatbot-header {
    align-items: center !important;
}

.soam-chatbot-card .justify-content-between, 
.soam-chatbot-header {
    justify-content: space-between !important;
}

.soam-chatbot-card .ms-3 {
    margin-left: 1rem !important;
}

.soam-chatbot-card .mt-3 {
    margin-top: 1rem !important;
}

.soam-chatbot-card .mb-0 {
    margin-bottom: 0 !important;
}

.soam-chatbot-card .w-100 {
    width: 100% !important;
}

.soam-chatbot-card .input-group {
    display: flex !important;
    width: 100% !important;
    position: relative !important;
}

.soam-chatbot-card .chat-input {
    flex: 1 !important;
}

/* ==========================================================================
   초기 로딩 시 챗봇 유도 말풍선 & 흔들림(Wobble) 애니메이션
   ========================================================================== */
.welcome-bubble {
    position: absolute;
    right: 80px;
    top: 50%;
    transform: translateY(-50%);
    background-color: #1f2937; /* 시인성이 좋은 짙은 다크그레이 */
    color: #ffffff;
    padding: 10px 18px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    opacity: 0;
    z-index: 1060;
    animation: welcomeBubbleFade 7s ease-in-out forwards;
}

/* 말풍선 오른쪽 꼬리표 화살표 */
.welcome-bubble::after {
    content: "";
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 6px 0 6px 6px;
    border-style: solid;
    border-color: transparent transparent transparent #1f2937;
}

@keyframes welcomeBubbleFade {
    0% { opacity: 0; transform: translateY(-50%) translateX(10px); }
    5% { opacity: 1; transform: translateY(-50%) translateX(0); }
    90% { opacity: 1; transform: translateY(-50%) translateX(0); }
    100% { opacity: 0; transform: translateY(-50%) translateX(-10px); visibility: hidden; }
}

/* 초기 로드 시 버튼 흔들림 모션 */
.soam-chatbot-btn-floating.wobble-on-load {
    animation: chatbot-wobble-anim 2s ease-in-out 3; /* 총 6초 동안 3회 반복 흔들림 */
}

@keyframes chatbot-wobble-anim {
    0%, 100% { transform: translateY(-50%) scale(1); }
    20%, 60% { transform: translateY(-50%) rotate(-8deg) scale(1.05); }
    40%, 80% { transform: translateY(-50%) rotate(8deg) scale(1.05); }
}


