/* ====================================
   Q&A チャットボット
   ==================================== */
.c-faqChat {
    --faqChat-main: var(--color_main, #04384c);
    position: fixed;
    right: 16px;
    /* 959px以下では、下部固定メニューの上に「ページトップへ戻る」ボタン（bottom: 64px・高さ52px）が出るため、その上に置く */
    bottom: 128px;
    z-index: 9990;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    font-size: 14px;
    line-height: 1.6;
}

.c-faqChat__toggle {
    padding: 10px 18px;
    border: none;
    border-radius: 999px;
    background: var(--faqChat-main);
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.c-faqChat__toggle:focus-visible,
.c-faqChat__close:focus-visible,
.c-faqChat__send:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -4px;
}

.c-faqChat__panel {
    display: flex;
    flex-direction: column;
    width: 340px;
    max-width: calc(100vw - 32px);
    height: 460px;
    max-height: calc(100vh - 200px);
    border-radius: 10px;
    background: #fff;
    color: #333;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.c-faqChat__panel[hidden] {
    display: none;
}

.c-faqChat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--faqChat-main);
    color: #fff;
}

.c-faqChat__title {
    font-weight: bold;
}

.c-faqChat__close {
    padding: 0 6px;
    border: none;
    background: none;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.c-faqChat__log {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: #f5f6f7;
    overflow-y: auto;
}

.c-faqChat__msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 10px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.c-faqChat__msg--bot {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e2e4e7;
}

.c-faqChat__msg--user {
    align-self: flex-end;
    background: var(--faqChat-main);
    color: #fff;
}

.c-faqChat__link {
    color: var(--faqChat-main);
    text-decoration: underline;
}

.c-faqChat__msg.is-pending {
    color: #777;
}

.c-faqChat__msg.is-error {
    border-color: #d9534f;
    color: #b52b27;
}

.c-faqChat__form {
    display: flex;
    gap: 8px;
    padding: 10px 12px 6px;
    border-top: 1px solid #e2e4e7;
}

.c-faqChat__input {
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 16px; /* iOSで入力時に画面が拡大されないサイズ */
    line-height: 1.4;
    resize: none;
}

.c-faqChat__send {
    padding: 0 14px;
    border: none;
    border-radius: 6px;
    background: var(--faqChat-main);
    color: #fff;
    font-weight: bold;
    cursor: pointer;
}

.c-faqChat__send:disabled {
    opacity: 0.5;
    cursor: default;
}

.c-faqChat__note {
    margin: 0;
    padding: 0 12px 8px;
    color: #777;
    font-size: 11px;
    line-height: 1.4;
}

/* PCでは右端に「申込手順」ボタン（functions.php の .pc-btn-manual）が出るため、
   同じ大きさ（幅48px・高さ120px）の縦長ボタンにして、「ページトップへ戻る」と「申込手順」の間に並べる。
   3つのボタンの中心がそろうよう right を合わせ、パネルはボタンの列の左側に開く */
@media screen and (min-width: 769px) {
    .c-faqChat {
        right: 42px;
        bottom: 108px;
        z-index: 9991;
    }
    .c-faqChat__toggle {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        width: 48px;
        height: 120px;
        padding: 0 17px; /* 文字1つ分の幅だけ残し、1文字ずつ折り返して縦に並べる */
        border-radius: 6px;
        line-height: 1.3;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    }
    .c-faqChat__toggle::before {
        content: "💬";
        margin-bottom: 6px;
        font-size: 22px;
        font-weight: normal;
        line-height: 1;
        white-space: nowrap;
    }
    .c-faqChat__panel {
        position: absolute;
        right: calc(100% + 12px);
        bottom: 0;
        max-height: calc(100vh - 230px);
    }
}

/* 769〜959px では「ページトップへ戻る」が右16px・下64pxに出るため、縦長ボタンの列をその真上に合わせる
   （「申込手順」側の位置は functions.php の .pc-btn-manual で同じ幅に合わせている） */
@media screen and (min-width: 769px) and (max-width: 959px) {
    .c-faqChat {
        right: 18px;
        bottom: 128px;
    }
    .c-faqChat__panel {
        max-height: calc(100vh - 250px);
    }
}

/* スマホ（768px以下）では左下に置く。高さは右下の「ページトップへ戻る」（下部固定メニューの上）にそろえる */
@media screen and (max-width: 768px) {
    .c-faqChat {
        right: auto;
        left: 16px;
        bottom: calc(64px + env(safe-area-inset-bottom) * 0.5);
        align-items: flex-start;
    }
    .c-faqChat__panel {
        max-height: calc(100vh - 140px);
    }
}
