/* ======================================================
   챗봇 위젯 (홈 화면 전용)
====================================================== */
:root {
    --chat-accent: var(--brown);     /* #4a6350; 수정*/
    --chat-accent-tint: rgba(155, 104, 69, .10)  /*(74, 99, 80, .10); 수정*/
}

.chat-toggle {
    position: fixed;
    overflow: visible;
    right: 48px;
    bottom: 42px;
    z-index: 90;

    width: 56px;
    height: 56px;
    border: 1px solid rgba(155, 104, 69, .35);
    border-radius: 50%;

    background: #efe3cf;    /* 수정var(--chat-accent); */
    color: var(--brown); /* #fff; 수정 */


    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(39, 33, 27, .20);


    transition: transform .25s ease, box-shadow .25s ease;
}
.chat-toggle::before,
.chat-toggle::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1.5px solid var(--chat-accent);
    opacity: 0;
    pointer-events: none;
    animation: chat-toggle-ripple 3.2s ease-out infinite;
}
.chat-toggle::after {
    animation-delay: 1.1s;   /* 두 번째 파장이 살짝 늦게 시작 */
}
@keyframes chat-toggle-ripple {
    0% {
        transform: scale(1);
        opacity: .5;
    }
    100% {
        transform: scale(1.7);
        opacity: 0;
    }
}
@media (prefers-reduced-motion: reduce) {
    .chat-toggle::before,
    .chat-toggle::after {
        animation: none;
        opacity: 0;
    }
}
.chat-toggle:hover::before,
.chat-toggle:hover::after {
    animation-play-state: paused;
}

.chat-toggle.open::before,
.chat-toggle.open::after {
    animation: none;
    opacity: 0;
}

/* 호버 중엔 자동 애니메이션 멈추고 기존 hover 효과만 */
.chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 0 5px rgba(253, 250, 246, .9),
                0 10px 22px rgba(39, 33, 27, .24);
}
/* 애니메이션 어지러움 느끼는 사용자를 위한 배려 */
@media (prefers-reduced-motion: reduce) {
    .chat-toggle { animation: none; }
}
.chat-toggle__icon-close {
    display: none;
}
/* path가 채울 영역 없는 선(line)만으로 된 X라, stroke 없이 기본 fill만으로는 안 보임 */
.chat-toggle__icon-close svg {
    width: 24px;
    height: 24px;
}
.chat-toggle__icon-close svg path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}
.chat-toggle__tooltip {
    position: absolute;
    right: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%) translateX(4px);

    white-space: nowrap;
    background: rgba(39, 33, 27, .92);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(39, 33, 27, .22);

    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
}

.chat-toggle__tooltip::after {
    content: "";
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: rgba(39, 33, 27, .92);
}

/* 패널이 열려있을 땐(.open) 안내 문구를 띄우지 않음 */
.chat-toggle:not(.open):hover .chat-toggle__tooltip,
.chat-toggle:not(.open):focus-visible .chat-toggle__tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

@media (prefers-reduced-motion: reduce) {
    .chat-toggle__tooltip { transition: none; }
}
.chat-toggle.open .chat-toggle__icon-open {
    display: none;
}

/* 이모지 톤 맞추기 */
.chat-toggle__icon-open,
.chat-message--bot::before {
    filter: grayscale(1) sepia(.8) saturate(1.4) brightness(.85);
}

.chat-toggle.open .chat-toggle__icon-close {
    display: inline;
}
/* back-to-top 버튼과 겹치지 않도록 위로 살짝 올려둠 */
.back-to-top {
    right: 51px;
    bottom: 120px;
}

.chat-panel {
    position: fixed;
    right: 48px;
    bottom: 110px;
    z-index: 89;

    width: 340px;
    max-width: calc(100vw - 32px);
    height: 460px;
    max-height: calc(100vh - 160px);

    display: flex;
    flex-direction: column;

    background: #fff;
    border: 1px solid rgba(39, 33, 27, .13);
    border-radius: 16px;
    box-shadow: 0 14px 40px rgba(39, 33, 27, .22);

    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);

    transition: opacity .25s ease, visibility .25s ease, transform .25s ease;
}

.chat-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.chat-panel__header {
    padding: 16px 18px;
    border-bottom: 1px solid rgba(39, 33, 27, .10);
    background: var(--chat-accent-tint);   /* var(--muted-bg) → 이걸로 */
    border-radius: 16px 16px 0 0;
}

.chat-panel__header strong {
    display: block;
    color: var(--text-primary);
    font-size: 15px;
}

.chat-panel__subtitle {
    display: block;
    margin-top: 2px;
    color: var(--text-tertiary);
    font-size: 12px;
}

.chat-panel__messages {
    flex: 1;
    overflow-y: auto;

    padding: 14px 16px 14px 26px;

    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    max-width: 85%;
    padding: 9px 13px;
    border-radius: 14px;

    font-size: 13.5px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-message--bot {
    align-self: flex-start;
    background: #f1e8df;    /* 수정 #e2ebe1; */
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    position: relative;
}
.chat-message--bot::before {
    content: "🪷";
    position: absolute;
    left: -20px;
    top: 6px;
    font-size: 14px;
    line-height: 1;
}
.chat-message--user {
    align-self: flex-end;
    background: var(--chat-accent);   /* var(--brown) → 이걸로 */
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-message--pending {
    color: var(--text-tertiary);
    font-style: italic;
}

.chat-panel__form {
    display: flex;
    gap: 8px;

    padding: 12px 14px;
    border-top: 1px solid rgba(39, 33, 27, .10);
}

.chat-panel__input {
    flex: 1;

    padding: 9px 12px;
    border: 1px solid rgba(39, 33, 27, .16);
    border-radius: 999px;

    font: inherit;
    font-size: 13.5px;
    color: var(--text-primary);
}

.chat-panel__input:focus {
    outline: none;
    border-color: var(--chat-accent);
}

.chat-panel__send {
    width: 36px;
    height: 36px;
    flex-shrink: 0;

    border: none;
    border-radius: 50%;

    background: var(--chat-accent);
    color: #fff;

    font-size: 16px;
    cursor: pointer;
}

.chat-panel__send:disabled {
    opacity: .5;
    cursor: not-allowed;
}

@media (max-width: 480px) {
    .chat-toggle {
        right: 24px;
        bottom: 24px;
    }

    .chat-toggle__tooltip {
         display: none;
    }

    .back-to-top {
        right: 24px;
        bottom: 92px;
    }

    .chat-panel {
        right: 16px;
        left: 16px;
        bottom: 92px;
        width: auto;
    }
}


