/* ======================================================
   챗봇 위젯 (홈 화면 전용)
====================================================== */

.chat-toggle {
    position: fixed;

    right: 48px;
    bottom: 42px;

    z-index: 90;

    width: 56px;
    height: 56px;

    border: none;
    border-radius: 50%;

    background: var(--brown);
    color: #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, .22);

    transition: transform .25s ease, box-shadow .25s ease;
}

.chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(39, 33, 27, .28);
}

.chat-toggle__icon-close {
    display: none;
}

.chat-toggle.open .chat-toggle__icon-open {
    display: none;
}

.chat-toggle.open .chat-toggle__icon-close {
    display: inline;
}

/* back-to-top 버튼과 겹치지 않도록 위로 살짝 올려둠 */
.back-to-top {
    bottom: 110px;
}

.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(--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;

    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: var(--muted-bg);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-message--user {
    align-self: flex-end;
    background: 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(--brown);
}

.chat-panel__send {
    width: 36px;
    height: 36px;
    flex-shrink: 0;

    border: none;
    border-radius: 50%;

    background: var(--brown);
    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;
    }

    .back-to-top {
        right: 24px;
        bottom: 92px;
    }

    .chat-panel {
        right: 16px;
        left: 16px;
        bottom: 92px;
        width: auto;
    }
}
