/* 1:1 실시간 번역 채팅 위젯 - 오른쪽 하단, 스크롤해도 화면에 고정되어 따라다님 */
.sg-chat-widget-wrap {
    position: fixed;
    bottom: 0;
    right: 0;
    left: auto;
    width: auto;
    height: auto;
    pointer-events: none;
    z-index: 9999;
}
.sg-chat-widget {
    position: fixed;
    /* 카카오 채널 버튼과 겹치지 않도록 상단으로 분리 */
    bottom: 78px;
    right: 12px;
    pointer-events: auto;
    font-family: var(--font-main, 'Inter', 'Noto Sans KR', sans-serif);
}

.sg-chat-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #1e2d3d 0%, #2c3e50 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(30, 45, 61, 0.35);
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}
.sg-chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(30, 45, 61, 0.4);
}
.sg-chat-toggle-icon {
    font-size: 22px;
}

.sg-chat-panel {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 48px);
    max-height: 520px;
    background: #fff;
    color: #2d2d2d;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    border: 1px solid #e8e4df;
    display: none !important;
    flex-direction: column;
    overflow: hidden;
}
.sg-chat-panel * {
    color: inherit;
}
.sg-chat-panel-header,
.sg-chat-panel-header h3,
.sg-chat-close {
    color: #fff;
}
.sg-chat-widget.is-open .sg-chat-panel {
    display: flex !important;
}

.sg-chat-panel-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #1e2d3d 0%, #2c3e50 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sg-chat-panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}
.sg-chat-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.sg-chat-close:hover {
    background: rgba(255,255,255,0.3);
}

/* 언어 선택 단계 */
.sg-chat-lang-step {
    padding: 28px 24px;
    display: none !important;
}
.sg-chat-lang-title {
    margin: 0 0 8px;
    font-size: 1rem;
    font-weight: 600;
    color: #1e2d3d;
}
.sg-chat-lang-detect {
    margin: 0 0 16px;
    font-size: 0.85rem;
    color: #5c5c5c;
}
.sg-chat-lang-select {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid #e8e4df;
    border-radius: 8px;
    font-size: 1rem;
    background: #fff;
    color: #2d2d2d;
}
.sg-chat-lang-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    background: #b8860b;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.sg-chat-lang-btn:hover {
    background: #9a7209;
}

/* 채팅 본문 */
.sg-chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 280px;
}
.sg-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 320px;
    background: #f8f6f3;
}
.sg-chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
}
.sg-chat-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #1e2d3d 0%, #2c3e50 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.sg-chat-msg.admin {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e8e4df;
    color: #2d2d2d;
    border-bottom-left-radius: 4px;
}
.sg-chat-msg-meta {
    font-size: 0.75rem;
    opacity: 0.85;
    margin-top: 4px;
}

.sg-chat-input-wrap {
    padding: 12px 16px;
    border-top: 1px solid #e8e4df;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    background: #fff;
}
.sg-chat-toolbar {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sg-chat-tool-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #e8e4df;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background 0.2s;
}
.sg-chat-tool-btn:hover {
    background: #f8f6f3;
}
.sg-chat-msg-attachments {
    margin-top: 8px;
}
.sg-chat-att-link {
    display: block;
    font-size: 0.85rem;
    color: inherit;
    text-decoration: underline;
    margin-top: 4px;
}
.sg-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e8e4df;
    border-radius: 8px;
    font-size: 0.95rem;
    resize: none;
    min-height: 44px;
    max-height: 100px;
}
.sg-chat-send {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    background: #b8860b;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.sg-chat-send:hover {
    background: #9a7209;
}

@media (max-width: 480px) {
    .sg-chat-widget {
        /* 모바일에서도 카카오 버튼과 간격 유지 */
        bottom: 64px;
        right: 16px;
    }
    .sg-chat-panel {
        width: calc(100vw - 32px);
        right: -8px;
        bottom: 68px;
        max-height: 70vh;
    }
}

/* 카카오 플로팅 버튼 축소 (외부 스크립트 삽입형 대응) */
#kakao-talk-channel-chat-button,
.kakao-talk-channel-chat-button,
#kakao-channel-chat-button,
#kakaoChannelButton,
iframe[src*="kakao.com"][style*="position: fixed"],
iframe[src*="kakao.com"][style*="position:fixed"] {
    transform: scale(0.84) !important;
    transform-origin: bottom right !important;
}
