/* KoreaFerry FAQ v4.1 - Frontend Styles (Floating Version)
 * v2.3 → v4.1: lang-pill 버튼, 봇 메시지 내 링크 스타일 추가
 */

/* ==================== 플로팅 챗봇 스타일 ==================== */

.kffaq-floating-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 플로팅 버튼 — ★ v4.3: 둥근 사각형 */
.kffaq-floating-btn {
    min-width: 60px;
    height: 56px;
    padding: 0 18px;
    border-radius: 28px;
    background: linear-gradient(135deg, #0066cc 0%, #0052a3 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 102, 204, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s ease;
    position: relative;
    white-space: nowrap;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
}

.kffaq-floating-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(0, 102, 204, 0.5);
}

.kffaq-floating-btn-icon {
    font-size: 22px;
    transition: all 0.3s ease;
    line-height: 1;
}

.kffaq-floating-btn-label {
    transition: all 0.3s ease;
    letter-spacing: -0.5px;
}

.kffaq-floating-btn-close {
    position: absolute;
    font-size: 24px;
    color: #fff;
    opacity: 0;
    transform: rotate(-90deg) scale(0);
    transition: all 0.3s ease;
}

/* 열린 상태: X 표시, 둥근 원형으로 */
.kffaq-floating-btn.active {
    width: 56px;
    min-width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 50%;
}

.kffaq-floating-btn.active .kffaq-floating-btn-icon,
.kffaq-floating-btn.active .kffaq-floating-btn-label {
    opacity: 0;
    transform: scale(0);
    width: 0;
    overflow: hidden;
}

.kffaq-floating-btn.active .kffaq-floating-btn-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* 채팅창 팝업 */
.kffaq-floating-chat {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: kffaq-slide-up 0.3s ease;
}

@keyframes kffaq-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 플로팅 헤더 — ★ v4.6: 2행 (타이틀 + 언어 pill) */
.kffaq-floating-header {
    background: linear-gradient(135deg, #0066cc 0%, #0052a3 100%);
    color: #fff;
    padding: 12px 16px 8px;
    flex-shrink: 0;
}

.kffaq-floating-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.kffaq-floating-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.kffaq-floating-icon {
    font-size: 24px;
}

.kffaq-floating-title {
    font-size: 15px;
    font-weight: 600;
}

.kffaq-floating-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kffaq-floating-lang-select {
    padding: 4px 8px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    outline: none;
}

.kffaq-floating-lang-select option {
    color: #333;
    background: #fff;
}

/* ★ v4.0: 언어 pill 버튼 */
.kffaq-lang-pills {
    display: flex;
    gap: 2px;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 2px;
}

.kffaq-lang-pill {
    padding: 4px 10px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    line-height: 1.4;
}

.kffaq-lang-pill:hover {
    color: #fff;
    background: rgba(255,255,255,0.15);
}

.kffaq-lang-pill.active {
    color: #0052a3;
    background: #fff;
    border-radius: 6px;
}

/* ★ v4.6: 플로팅 헤더 내 언어 pill 버튼 */
.kffaq-floating-lang-pills {
    display: flex;
    gap: 2px;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 2px;
    justify-content: center;
}

.kffaq-floating-lang-pills .kffaq-lang-pill {
    padding: 4px 10px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    line-height: 1.4;
    flex: 1;
    text-align: center;
    white-space: nowrap;
}

.kffaq-floating-lang-pills .kffaq-lang-pill:hover {
    color: #fff;
    background: rgba(255,255,255,0.15);
}

.kffaq-floating-lang-pills .kffaq-lang-pill.active {
    color: #0052a3;
    background: #fff;
}

.kffaq-floating-close-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
}

.kffaq-floating-close-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* ★ v4.6: 채팅 상단 안내 배너 (중앙정렬) */
.kffaq-chat-notice {
    padding: 10px 14px;
    background: #f0f7ff;
    border-bottom: 1px solid #d0e3f7;
    font-size: 12px;
    line-height: 1.7;
    color: #3a5a8c;
    flex-shrink: 0;
    text-align: center;
}
.kffaq-chat-notice .kffaq-notice-title {
    font-weight: 600;
    font-size: 12.5px;
    color: #1a3a6c;
}
.kffaq-chat-notice .kffaq-notice-agent {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed #c0d5ee;
    font-size: 11.5px;
    color: #5a7aaa;
}
/* ★ v4.6: 임베디드 배너 — PC에서는 줄바꿈 없이 한줄 */
.kffaq-embedded .kffaq-notice-title br {
    display: none;
}

.kffaq-chat-notice a {
    color: #2563eb;
    text-decoration: underline;
}

/* 플로팅 메시지 영역 */
.kffaq-floating-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 플로팅 입력 영역 */
.kffaq-floating-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.kffaq-floating-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.kffaq-floating-input:focus {
    border-color: #0066cc;
}

.kffaq-floating-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #0066cc;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background 0.2s;
    flex-shrink: 0;
}

.kffaq-floating-send:hover {
    background: #0052a3;
}

.kffaq-floating-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.kffaq-floating-send svg {
    width: 18px;
    height: 18px;
}

/* 플로팅 푸터 */
.kffaq-floating-footer {
    padding: 10px 16px;
    background: #f0f0f0;
    text-align: center;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.kffaq-floating-inquiry {
    color: #666;
    font-size: 13px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.kffaq-floating-inquiry:hover {
    color: #0066cc;
}

/* ==================== 공통 메시지 스타일 ==================== */

.kffaq-message {
    display: flex;
    max-width: 85%;
}

.kffaq-message.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.kffaq-message.bot {
    margin-right: auto;
}

.kffaq-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.kffaq-message.user .kffaq-message-content {
    background: #0066cc;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.kffaq-message.bot .kffaq-message-content {
    background: #fff;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

/* ★ v4.0: 봇 메시지 내 링크 스타일 */
.kffaq-message.bot .kffaq-message-content a {
    color: #0066cc;
    text-decoration: underline;
    word-break: break-all;
}

.kffaq-message.bot .kffaq-message-content a:hover {
    color: #0052a3;
}

/* 타이핑 인디케이터 */
.kffaq-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
}

.kffaq-typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.kffaq-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.kffaq-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.kffaq-typing-dot:nth-child(3) { animation-delay: 0s; }

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

/* ==================== 기존 숏코드 컨테이너 스타일 ==================== */

.kffaq-container {
    max-width: 800px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 언어 선택 */
.kffaq-lang-selector {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    flex-wrap: nowrap;
    justify-content: center;
}

.kffaq-lang-selector button {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.kffaq-lang-selector button:hover {
    border-color: #0066cc;
    color: #0066cc;
}

.kffaq-lang-selector button.active {
    background: #0066cc;
    color: #fff;
    border-color: #0066cc;
}

/* ==================== 임베디드 대화창 스타일 ==================== */

.kffaq-chat-container {
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    background: #fff;
    margin-bottom: 30px;
}

.kffaq-chat-header {
    background: linear-gradient(135deg, #0066cc 0%, #0052a3 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.kffaq-chat-icon {
    font-size: 24px;
}

.kffaq-chat-title {
    font-size: 16px;
    font-weight: 600;
}

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

/* 입력 영역 */
.kffaq-chat-input-area {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
}

.kffaq-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.kffaq-chat-input:focus {
    border-color: #0066cc;
}

.kffaq-chat-send {
    padding: 12px 24px;
    background: #0066cc;
    color: #fff;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.kffaq-chat-send:hover {
    background: #0052a3;
}

.kffaq-chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.kffaq-chat-footer {
    padding: 12px 20px;
    background: #f8f9fa;
    text-align: center;
    border-top: 1px solid #e0e0e0;
}

.kffaq-inquiry-link {
    color: #666;
    font-size: 13px;
    text-decoration: none;
}

.kffaq-inquiry-link:hover {
    color: #0066cc;
    text-decoration: underline;
}

/* ==================== 기존 검색 모드 스타일 ==================== */

.kffaq-search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.kffaq-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.kffaq-input:focus {
    border-color: #0066cc;
}

.kffaq-btn {
    padding: 12px 24px;
    background: #0066cc;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: background 0.2s;
}

.kffaq-btn:hover {
    background: #0052a3;
}

/* 결과 영역 */
.kffaq-result {
    background: #f0f7ff;
    border: 1px solid #0066cc;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.kffaq-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #cce0f5;
}

.kffaq-result-question {
    font-weight: 600;
    color: #0066cc;
}

.kffaq-result-score {
    font-size: 12px;
    color: #666;
    background: #fff;
    padding: 2px 8px;
    border-radius: 10px;
}

.kffaq-result-answer {
    line-height: 1.7;
    color: #333;
    white-space: pre-wrap;
}

.kffaq-result-link {
    margin-top: 12px;
}

.kffaq-result-link a {
    color: #0066cc;
    text-decoration: none;
    font-weight: 500;
}

.kffaq-result-link a:hover {
    text-decoration: underline;
}

/* 매칭 실패 */
.kffaq-no-result {
    background: #fff5f5;
    border: 1px solid #ffcccc;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin-bottom: 20px;
}

.kffaq-no-result-text {
    color: #cc0000;
    margin-bottom: 12px;
}

.kffaq-inquiry-btn {
    display: inline-block;
    padding: 10px 20px;
    background: #0066cc;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
}

.kffaq-inquiry-btn:hover {
    background: #0052a3;
    color: #fff;
}

/* 로딩 */
.kffaq-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: #666;
}

.kffaq-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: #0066cc;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== FAQ 목록 ==================== */

.kffaq-faq-list {
    margin-top: 30px;
}

.kffaq-list-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #333;
}

/* 카테고리 탭 */
.kffaq-category-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.kffaq-tab {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.kffaq-tab:hover {
    border-color: #0066cc;
    color: #0066cc;
}

.kffaq-tab.active {
    background: #0066cc;
    color: #fff;
    border-color: #0066cc;
}

/* 아코디언 */
.kffaq-accordion {
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
}

.kffaq-accordion-item {
    border-bottom: 1px solid #e0e0e0;
}

.kffaq-accordion-item:last-child {
    border-bottom: none;
}

.kffaq-accordion-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #fff;
    border: none;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    transition: background 0.2s;
}

.kffaq-accordion-header:hover {
    background: #f8f9fa;
}

.kffaq-q-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    background: #0066cc;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.kffaq-q-text {
    flex: 1;
    font-weight: 500;
    color: #333;
}

.kffaq-arrow {
    color: #999;
    font-size: 12px;
    transition: transform 0.2s;
}

.kffaq-accordion-item.open .kffaq-arrow {
    transform: rotate(180deg);
}

.kffaq-accordion-content {
    display: none;
    padding: 0 20px 20px 56px;
    background: #f8f9fa;
}

.kffaq-accordion-item.open .kffaq-accordion-content {
    display: block;
}

.kffaq-a-text {
    line-height: 1.7;
    color: #555;
    white-space: pre-wrap;
}

.kffaq-detail-link {
    display: inline-block;
    margin-top: 12px;
    color: #0066cc;
    text-decoration: none;
    font-size: 13px;
}

.kffaq-detail-link:hover {
    text-decoration: underline;
}

.kffaq-empty {
    text-align: center;
    color: #999;
    padding: 40px;
}

/* ==================== 반응형 (모바일) ==================== */

@media (max-width: 600px) {
    /* 플로팅 챗봇 모바일 */
    .kffaq-floating-wrapper {
        bottom: 15px;
        right: 15px;
    }
    
    .kffaq-floating-btn {
        height: 48px;
        padding: 0 14px;
        font-size: 13px;
    }
    .kffaq-floating-btn.active {
        width: 48px;
        min-width: 48px;
        height: 48px;
        padding: 0;
    }
    
    .kffaq-floating-btn-icon {
        font-size: 18px;
    }
    
    .kffaq-floating-chat {
        bottom: 75px;
        right: -5px;
        width: calc(100vw - 20px);
        height: calc(100vh - 180px);
        max-height: none;
        border-radius: 12px;
    }
    
    .kffaq-floating-header {
        padding: 10px 12px 6px;
    }
    
    .kffaq-floating-header-top {
        margin-bottom: 6px;
    }
    
    .kffaq-floating-title {
        font-size: 14px;
    }
    
    .kffaq-floating-lang-pills .kffaq-lang-pill {
        padding: 3px 8px;
        font-size: 11px;
    }
    
    .kffaq-floating-messages {
        padding: 12px;
    }
    
    .kffaq-chat-notice {
        padding: 8px 12px;
        font-size: 11px;
    }
    .kffaq-chat-notice .kffaq-notice-title {
        font-size: 11.5px;
    }
    
    .kffaq-floating-input-area {
        padding: 10px 12px;
    }
    
    .kffaq-floating-input {
        padding: 10px 12px;
        font-size: 16px; /* iOS 줌 방지 */
    }
    
    .kffaq-lang-pill {
        padding: 3px 8px;
        font-size: 11px;
    }
    
    /* 기존 임베디드 */
    .kffaq-chat-messages {
        height: 350px;
    }
    
    .kffaq-message {
        max-width: 90%;
    }
    
    .kffaq-chat-send span {
        display: none;
    }
    
    .kffaq-chat-send svg {
        display: none;
    }
    
    .kffaq-chat-send::after {
        content: '→';
        font-size: 18px;
    }
    
    .kffaq-chat-send {
        padding: 12px 16px;
    }
    
    .kffaq-search-box {
        flex-direction: column;
    }
    
    .kffaq-lang-selector {
        justify-content: center;
        gap: 4px;
    }
    .kffaq-lang-selector button {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    /* ② 임베디드 모바일: 줄바꿈 표시 */
    .kffaq-embedded .kffaq-notice-title br {
        display: inline;
    }
}

/* 태블릿 */
@media (min-width: 601px) and (max-width: 900px) {
    .kffaq-floating-chat {
        width: 360px;
        height: 500px;
    }
}
