/* バウンスアニメーション（5秒に1回） */
@keyframes chatbotBounce {
    0% {
        transform: translateY(0);
    }
    4% {
        transform: translateY(-18px);
    }
    8% {
        transform: translateY(0);
    }
    11% {
        transform: translateY(-12px);
    }
    14%, 100% {
        transform: translateY(0);
    }
}

.c-chatbot {
    position: fixed !important;
    right: 2rem !important;
    bottom: 2.4rem !important;
    bottom: calc(env(safe-area-inset-bottom) + 2.4rem) !important;
    top: auto !important;
    left: auto !important;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1.5rem;
}

.c-chatbot__toggle {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    border: none;
    border-radius: 9999px;
    background: #1351B5;
    color: #ffffff;
    font-weight: 600;
    font-size: 1.9rem;
    line-height: 1;
    padding: 1.8rem 2.8rem;
    box-shadow: 0 24px 48px rgba(19, 81, 181, 0.25);
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
    animation: chatbotBounce 5s ease-in-out 2s infinite;
}

.c-chatbot__toggle:focus,
.c-chatbot__toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 30px rgba(19, 81, 181, 0.3);
}

.c-chatbot__toggle:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.75);
    outline-offset: 3px;
}

.c-chatbot__toggleIcon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
}

.c-chatbot__toggleIcon::before {
    content: "\1F4AC";
    font-size: 2rem;
}

.c-chatbot__toggleLabel {
    white-space: nowrap;
}

.c-chatbot__panel {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    position: absolute;
    right: 0;
    bottom: calc(100% + 1.5rem);
    width: min(45rem, calc(100vw - 5rem));
    height: min(68rem, calc(100vh - 10rem));
    border-radius: 3rem;
    background: #ffffff;
    box-shadow: 0 48px 100px rgba(12, 32, 67, 0.35);
    overflow: hidden;
    transform: translateY(2rem);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}

/* チャットボット開いているとき：パネルを上に、ボタンを下に */
.c-chatbot.is-open {
    flex-direction: column-reverse;
}

.c-chatbot.is-open .c-chatbot__panel {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.c-chatbot__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2rem;
    padding: 4rem 3rem 2.5rem;
    background: #1351B5;
    color: #ffffff;
    flex-shrink: 0;
    border-radius: 3rem 3rem 0 0;
    margin: 0;
    position: relative;
    z-index: 1;
}

.c-chatbot__header::before {
    content: none;
}

.c-chatbot__eyebrow {
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}

.c-chatbot__title {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.3;
}

.c-chatbot__close {
    border: none;
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s ease;
    margin-top: 0.5rem;
}

.c-chatbot__close::before,
.c-chatbot__close::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2.2rem;
    height: 4px;
    background: currentColor;
    transform-origin: center;
}

.c-chatbot__close::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.c-chatbot__close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.c-chatbot__close:hover,
.c-chatbot__close:focus-visible {
    background: rgba(255, 255, 255, 0.4);
}

.c-chatbot__body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 2.4rem 2.4rem 2.6rem;
    gap: 1.5rem;
    overflow: hidden;
    background: #ffffff;
    border-radius: 0 0 3rem 3rem;
}

.c-chatbot__messages {
    flex: 1;
    overflow-y: scroll;
    padding-right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

/* スクロールバーのスタイル（Webkit: Chrome, Safari, Edge） */
.c-chatbot__messages::-webkit-scrollbar {
    width: 16px;
}

.c-chatbot__messages::-webkit-scrollbar-track {
    background: #f0f4f8;
    border-radius: 8px;
}

.c-chatbot__messages::-webkit-scrollbar-thumb {
    background: #1351B5;
    border-radius: 8px;
    border: 3px solid #f0f4f8;
}

.c-chatbot__messages::-webkit-scrollbar-thumb:hover {
    background: #0f3f8d;
}

/* スクロールバーのスタイル（Firefox） */
.c-chatbot__messages {
    scrollbar-width: auto;
    scrollbar-color: #1351B5 #f0f4f8;
}

.c-chatbot__message {
    display: flex;
}

.c-chatbot__message--user {
    justify-content: flex-end;
}

.c-chatbot__message--assistant {
    justify-content: flex-start;
}

.c-chatbot__bubble {
    max-width: 90%;
    padding: 1.5rem 1.9rem;
    border-radius: 2.2rem;
    font-size: 1.5rem;
    line-height: 1.6;
    box-shadow: 0 12px 28px rgba(31, 52, 73, 0.1);
    white-space: pre-wrap;
    word-break: break-word;
}

.c-chatbot__message--user .c-chatbot__bubble {
    background: #1351B5;
    color: #ffffff;
    border-bottom-right-radius: 1rem;
}

.c-chatbot__message--assistant .c-chatbot__bubble {
    background: #f5f8fc;
    color: #0b1e39;
    border-bottom-left-radius: 1rem;
}

.c-chatbot__status {
    min-height: 2.5rem;
    font-size: 1.56rem;
    color: #4f627a;
}

.c-chatbot__form {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    flex-shrink: 0;
}

.c-chatbot__label {
    font-size: 1.5rem;
    font-weight: 600;
    color: #4f627a;
}

.c-chatbot__inputGroup {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1.2rem;
    align-items: end;
}

.c-chatbot__input {
    resize: none;
    border-radius: 1.8rem;
    border: 2px solid #c9d7e6;
    padding: 1.4rem 1.8rem;
    font-size: 1.9rem;
    font-family: inherit;
    line-height: 1.5;
    transition: border 0.2s ease, box-shadow 0.2s ease;
    min-height: 6.4rem;
}

.c-chatbot__input:focus {
    border-color: #1351B5;
    box-shadow: 0 0 0 6px rgba(19, 81, 181, 0.2);
    outline: none;
}

.c-chatbot__submit {
    border: none;
    border-radius: 1.8rem;
    background: #1351B5;
    color: #ffffff;
    font-weight: 600;
    font-size: 1.9rem;
    padding: 1.7rem 2.4rem;
    cursor: pointer;
    min-width: 10rem;
    transition: background 0.2s ease, transform 0.2s ease;
}

.c-chatbot__submit:hover,
.c-chatbot__submit:focus-visible {
    background: #0f3f8d;
}

.c-chatbot__submit:disabled {
    background: #9ab9dd;
    cursor: not-allowed;
}

@media (max-width: 767px) {
    .c-chatbot {
        right: 2rem;
        bottom: 2.4rem;
        bottom: calc(env(safe-area-inset-bottom) + 2.4rem);
        width: calc(100% - 4rem);
        align-items: stretch;
    }

    .c-chatbot__toggle {
        justify-content: center;
        width: 100%;
    }

    .c-chatbot__panel {
        width: 100%;
        max-height: calc(100vh - 10rem);
    }
}
