/* ==========================================================================
   AI 커뮤니티 유사성 검색 챗봇 스타일 (Gemini RAG Assistant)
   - 모던 플로팅 위젯, 다크모드 호환, 애니메이션
   - 사용자 규칙 준수: 버튼에 이모지 일절 미사용 (SVG 및 텍스트 적용)
   ========================================================================== */

/* ---------------------------------- 플로팅 버튼 (FAB) */
.ai-fab-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
}

@media (max-width: 768px) {
    .ai-fab-container {
        bottom: 76px; /* 모바일 하단 GNB와의 겹침 방지 */
        right: 16px;
    }
}

.ai-fab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 18px;
    border: none;
    border-radius: 999px;
    background: var(--btn-bg, #e0245e);
    color: var(--btn-text, #ffffff);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s;
    outline: none;
}

.ai-fab-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
    filter: brightness(1.05);
}

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

.ai-fab-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
    flex-shrink: 0;
}

/* ---------------------------------- 챗봇 메인 패널 */
.ai-chat-panel {
    position: fixed;
    bottom: 84px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 620px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1001;
    border: 1px solid rgba(0, 0, 0, 0.08);
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-chat-panel.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

@media (max-width: 480px) {
    .ai-chat-panel {
        bottom: 70px;
        right: 12px;
        left: 12px;
        width: auto;
        height: calc(100vh - 140px);
    }
}

/* 다크모드 대응 */
.dark .ai-chat-panel {
    background: #1e1e24;
    border-color: #2e2e38;
    color: #e6e6eb;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

/* ---------------------------------- 챗봇 헤더 */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #fbfbfd;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.dark .ai-chat-header {
    background: #18181d;
    border-bottom-color: #282832;
}

.ai-chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-chat-header-title-text {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a24;
    line-height: 1.2;
}

.dark .ai-chat-header-title-text {
    color: #f0f0f5;
}

.ai-chat-header-quota {
    font-size: 11px;
    color: #777788;
    margin-top: 3px;
    line-height: 1;
}

.dark .ai-chat-header-quota {
    color: #a0a0b2;
}

.ai-chat-header-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(224, 36, 94, 0.1);
    color: var(--btn-bg, #e0245e);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.dark .ai-chat-header-badge {
    background: rgba(224, 36, 94, 0.2);
}

.ai-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 헤더 버튼 (이모지 미사용, 순수 텍스트/클래스) */
.ai-chat-btn-ghost {
    background: none;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 6px;
    color: #555566;
    font-size: 12px;
    font-weight: 500;
    padding: 5px 10px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    line-height: 1;
}

.ai-chat-btn-ghost:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #111116;
}

.dark .ai-chat-btn-ghost {
    border-color: #383845;
    color: #a0a0b2;
}

.dark .ai-chat-btn-ghost:hover {
    background: #2a2a35;
    color: #ffffff;
}

.ai-chat-btn-close {
    background: none;
    border: none;
    color: #888899;
    padding: 6px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.ai-chat-btn-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #111116;
}

.dark .ai-chat-btn-close:hover {
    background: #2a2a35;
    color: #ffffff;
}

/* ---------------------------------- 챗봇 메시지 목록 */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #ffffff;
    scroll-behavior: smooth;
}

.dark .ai-chat-messages {
    background: #1e1e24;
}

/* 스크롤바 */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}
.ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}
.dark .ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

/* 메시지 래퍼 */
.ai-msg-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 88%;
}

.ai-msg-user {
    align-self: flex-end;
}

.ai-msg-assistant {
    align-self: flex-start;
    max-width: 94%;
}

.ai-bubble-user {
    background: var(--btn-bg, #e0245e);
    color: var(--btn-text, #ffffff);
    padding: 10px 14px;
    border-radius: 14px 14px 2px 14px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ai-bubble-assistant {
    background: #f3f3f6;
    color: #1f2024;
    padding: 12px 15px;
    border-radius: 14px 14px 14px 2px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.dark .ai-bubble-assistant {
    background: #272731;
    color: #ebebf0;
    border-color: #343442;
}

.ai-bubble-assistant p {
    margin: 0 0 8px 0;
}
.ai-bubble-assistant p:last-child {
    margin-bottom: 0;
}
.ai-bubble-assistant strong, .ai-bubble-assistant b {
    color: #0f1015;
    font-weight: 700;
}
.dark .ai-bubble-assistant strong, .dark .ai-bubble-assistant b {
    color: #ffffff;
}

/* ---------------------------------- 검색 결과 게시글 카드 */
.ai-results-container {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-results-title {
    font-size: 11.5px;
    font-weight: 700;
    color: #777788;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 2px;
}

.dark .ai-results-title {
    color: #9999aa;
}

.ai-post-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.09);
    border-radius: 10px;
    padding: 10px 12px;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.ai-post-card:hover {
    transform: translateY(-1px);
    border-color: var(--btn-bg, #e0245e);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06);
}

.dark .ai-post-card {
    background: #1c1c22;
    border-color: #343442;
}

.dark .ai-post-card:hover {
    border-color: var(--btn-bg, #e0245e);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.ai-post-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    gap: 8px;
}

.ai-post-card-meta {
    font-size: 11px;
    color: #888899;
}

.ai-similarity-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    background: #edf7ed;
    color: #2e7d32;
    white-space: nowrap;
}

.ai-similarity-badge.high {
    background: #e8f5e9;
    color: #1b5e20;
}

.ai-similarity-badge.mid {
    background: #fff8e1;
    color: #f57f17;
}

.dark .ai-similarity-badge.high {
    background: rgba(46, 125, 50, 0.25);
    color: #81c784;
}

.dark .ai-similarity-badge.mid {
    background: rgba(245, 127, 23, 0.25);
    color: #ffd54f;
}

.ai-post-card-title {
    font-size: 13px;
    font-weight: 700;
    color: #111116;
    margin-bottom: 4px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dark .ai-post-card-title {
    color: #f0f0f5;
}

.ai-post-card-reason {
    font-size: 11.5px;
    color: #4a4a58;
    line-height: 1.4;
    margin-bottom: 4px;
}

.dark .ai-post-card-reason {
    color: #b0b0c2;
}

.ai-post-card-highlight {
    font-size: 11px;
    color: #666677;
    background: rgba(0, 0, 0, 0.03);
    padding: 4px 8px;
    border-radius: 4px;
    border-left: 2px solid var(--btn-bg, #e0245e);
    line-height: 1.35;
    margin-top: 4px;
    word-break: break-all;
}

.dark .ai-post-card-highlight {
    background: rgba(255, 255, 255, 0.04);
    color: #9898aa;
}

/* ---------------------------------- 추천 질문 칩 (버튼 이모지 미사용) */
.ai-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.ai-chip-btn {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 999px;
    color: #333344;
    font-size: 12px;
    font-weight: 500;
    padding: 5px 12px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    line-height: 1.2;
    text-align: left;
}

.ai-chip-btn:hover {
    background: rgba(224, 36, 94, 0.06);
    border-color: var(--btn-bg, #e0245e);
    color: var(--btn-bg, #e0245e);
}

.dark .ai-chip-btn {
    background: #25252f;
    border-color: #3c3c4b;
    color: #cfcfe0;
}

.dark .ai-chip-btn:hover {
    background: rgba(224, 36, 94, 0.15);
    border-color: var(--btn-bg, #e0245e);
    color: #ffffff;
}

/* ---------------------------------- 로딩 애니메이션 */
.ai-loading-bubble {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: #f3f3f6;
    border-radius: 14px;
    font-size: 12px;
    color: #777788;
}

.dark .ai-loading-bubble {
    background: #272731;
    color: #9999aa;
}

.ai-loading-dots {
    display: inline-flex;
    gap: 4px;
}

.ai-loading-dot {
    width: 6px;
    height: 6px;
    background: var(--btn-bg, #e0245e);
    border-radius: 50%;
    animation: aiPulse 1.2s infinite ease-in-out;
}

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

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

@keyframes aiPulse {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* ---------------------------------- 하단 입력창 (버튼 이모지 미사용) */
.ai-chat-input-container {
    padding: 12px 14px;
    background: #fbfbfd;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.dark .ai-chat-input-container {
    background: #18181d;
    border-top-color: #282832;
}

.ai-chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chat-input {
    flex: 1;
    height: 40px;
    padding: 0 12px;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 10px;
    font-size: 13.5px;
    background: #ffffff;
    color: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ai-chat-input:focus {
    border-color: var(--btn-bg, #e0245e);
    box-shadow: 0 0 0 2px rgba(224, 36, 94, 0.15);
}

.dark .ai-chat-input {
    background: #24242e;
    border-color: #383846;
}

.dark .ai-chat-input:focus {
    border-color: var(--btn-bg, #e0245e);
}

/* 전송 버튼 (이모지 없음, 순수 텍스트/SVG 아이콘 적용) */
.ai-chat-send-btn {
    height: 40px;
    padding: 0 14px;
    border: none;
    border-radius: 10px;
    background: var(--btn-bg, #e0245e);
    color: var(--btn-text, #ffffff);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    transition: filter 0.15s, transform 0.1s;
}

.ai-chat-send-btn:hover {
    filter: brightness(1.06);
}

.ai-chat-send-btn:active {
    transform: scale(0.97);
}

.ai-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: none;
}

/* ---------------------------------- 검색 페이지 연동 배너 (search.php) */
.ai-search-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(224, 36, 94, 0.08) 0%, rgba(150, 40, 200, 0.08) 100%);
    border: 1px solid rgba(224, 36, 94, 0.2);
    border-radius: 12px;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.dark .ai-search-banner {
    background: linear-gradient(135deg, rgba(224, 36, 94, 0.16) 0%, rgba(150, 40, 200, 0.16) 100%);
    border-color: rgba(224, 36, 94, 0.35);
}

.ai-search-banner-text {
    flex: 1;
    min-width: 200px;
}

.ai-search-banner-title {
    font-size: 14px;
    font-weight: 700;
    color: #111116;
    margin-bottom: 2px;
}

.dark .ai-search-banner-title {
    color: #f5f5fa;
}

.ai-search-banner-desc {
    font-size: 12px;
    color: #666677;
    line-height: 1.35;
}

.dark .ai-search-banner-desc {
    color: #a0a0b2;
}

.ai-search-banner-btn {
    background: var(--btn-bg, #e0245e);
    color: var(--btn-text, #ffffff);
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 16px;
    cursor: pointer;
    white-space: nowrap;
    transition: filter 0.15s, transform 0.1s;
}

.ai-search-banner-btn:hover {
    filter: brightness(1.06);
}
