/* チャットボット全体のコンテナ */
#my-chatbot {
    position: fixed;
    z-index: 1000;
    font-family: Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    pointer-events: none; /* コンテナ全体のポインターイベントを無効化 */
}

/* チャットアイコン（バナー）の基本スタイル */
#my-chatbot #chat-icon {
    position: fixed;
    cursor: pointer;
    z-index: 1001; /* チャットボットより前面に表示 */
    border-radius: 10px;
    overflow: hidden;
    background-color: transparent; /* 背景色を透明に設定 */
    transition: all 0.3s ease;
    bottom: 20px; /* バナーの上に表示 */
    right: 20px;
    display: block; /* 明示的に表示を設定 */
    pointer-events: auto;
}

/* PC向けのスタイル */
@media screen and (min-width: 769px) {
    #my-chatbot #chat-icon {
        width: auto; /* 最小幅を解除 */
        height: auto; /* 最小高さを解除 */
        min-width: 100px; /* 最小幅を設定 */
        min-height: 40px; /* 最小高さを設定 */
    }

    #my-chatbot #chat-icon img {
        max-width: none; /* max-widthの制限を解除 */
        max-height: none; /* max-heightの制限を解除 */
        width: auto; /* 画像の幅を自動に設定 */
        height: auto; /* 画像の高さを自動に設定 */
        display: block; /* 画像をブロック要素として扱う */
    }
}

/* スマートフォン向けのスタイル */
@media screen and (max-width: 767px) {
    #my-chatbot #chat-icon {
        width: 50vw; /* スマホ横幅の50%に変更 */
        height: auto;
        max-height: 25vw; /* 最大高さも調整（必要に応じて） */
        right: 5vw;
        bottom: 20px;
        overflow: hidden;
    }

    #my-chatbot #chat-icon img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        object-position: center;
    }

    #my-chatbot {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }

    #my-chatbot #chat-container {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }

    #my-chatbot #chat-messages-wrapper {
        height: calc(100% - 120px); /* ヘッダーとフッターの高さを考慮 */
        overflow-y: auto;
    }

    #my-chatbot #chat-input-container {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 10px;
        background-color: #fff;
        box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
    }
}

#my-chatbot #chat-icon img,
#my-chatbot .chat-icon-placeholder {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

/* デバッグ用 */
#my-chatbot #chat-icon::after {
    content: 'Icon should be visible';
    color: red;
    font-size: 12px;
    position: absolute;
    top: 100%;
    left: 0;
}

/* チャットコンテナ */
#my-chatbot #chat-container {
    position: fixed;
    width: 420px;
    height: 680px;
    border-radius: 10px;
    background: white;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    pointer-events: auto;
}

#my-chatbot #chat-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

#my-chatbot #chat-messages-container {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column-reverse;
}

/* チャットヘッダー */
#my-chatbot #chat-header {
    background-color: var(--chat-header-color, #cc0000);
    color: white;
    padding: 10px 15px;
    font-weight: bold;
    font-size: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#my-chatbot #chat-title {
    font-weight: bold;
    color: white;
    flex-grow: 1;
}

#my-chatbot #close-chat {
    cursor: pointer;
    font-size: 20px;
    color: #333;
}

/* 免責事項 */
#my-chatbot #chat-disclaimer {
    color: #000000;
    background-color: #f8f8f8;
    padding: 5px 10px;
    font-size: 10px;
    text-align: center;
    border-bottom: 1px solid #eee;
}

#my-chatbot #chat-messages-wrapper {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* メッセージエリア */
#my-chatbot #chat-messages {
    display: flex;
    flex-direction: column;
    padding: 10px;
    min-height: min-content;
}

#my-chatbot #chat-messages .message:first-child {
    margin-top: auto;
}

/* メッセージ共通スタイル */
#my-chatbot .message {
    display: flex;
    margin-bottom: 10px;
    max-width: 80%;
    background: none !important; /* 他のCSSを上書き */
}

#my-chatbot .user-message {
    justify-content: flex-end;
    align-self: flex-end;
}

#my-chatbot .user-message .message-bubble {
    background-color: #4CAF50 !important; /* 他のCSSを上書き */
    color: white;
    border-bottom-right-radius: 0;
}

/* ボットメッセージ */
#my-chatbot .bot-message {
    display: flex;
    margin-bottom: 10px;
}

#my-chatbot .bot-message .message-content {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    flex-grow: 1;
    min-width: 0;
}

#my-chatbot .bot-message .message-bubble {
    background-color: #f0f0f0 !important; /* 他のCSSを上書き */
    color: black;
    border-radius: 18px;
    padding: 8px 12px;
    font-size: 16px;
    line-height: 1.3;
    word-wrap: break-word;
    max-width: calc(100% - 50px); /* アイコンの幅を考慮 */
}

#my-chatbot .bot-message .message-bubble p {
    margin: 0.5em 0;
    font-size: 16px; /* 0.9emから16pxに変更 */
}

/* メッセージアイコン */
#my-chatbot .message-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    margin-right: 10px;
    display: inline-block;
}

#my-chatbot .message-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* メッセージバブル */
#my-chatbot .message-bubble {
    padding: 8px 12px;
    border-radius: 18px;
    font-size: 16px;
    line-height: 1.3;
    max-width: 100%;
    background-color: #f0f0f0 !important; /* 他のCSSを上書き */
}

#my-chatbot .message-bubble a {
    color: #0066cc; /* 青色の16進数カラーコード */
    text-decoration: none;
}

#my-chatbot .message-bubble a:hover {
    text-decoration: underline;
}

#my-chatbot .message.loading .message-bubble {
    display: flex;
    align-items: center;
    min-width: 120px;
}

#my-chatbot .message.loading .message-bubble::after {
    content: "";
    display: inline-block;
    width: 1.2em;
    text-align: left;
    animation: ellipsis-dot 1s infinite;
    animation-fill-mode: forwards;
    margin-left: 4px; /* テキストとドットの間隔を調整 */
}

@keyframes ellipsis-dot {
    25% { content: "."; }
    50% { content: ".."; }
    75% { content: "..."; }
    100% { content: ""; }
}

/* 入力エリア */
#my-chatbot #chat-input-container {
    position: relative;
    display: flex;
    align-items: center;
    padding: 10px;
    background-color: #fff;
    border-top: 1px solid #e0e0e0;
    height: auto; /* または適切な固定値、例: 60px */
}

#my-chatbot #user-input {
    flex-grow: 1;
    padding: 0 10px; /* 左右のパディングのみ設定 */
    padding-right: 45px; /* 送信ボタンのスペースを確保 */
    border: 1px solid #ccc;
    font-size: 16px;
    line-height: 1.4; /* 行間を少し広げる */
    min-height: 40px; /* 最小の高さを設定 */
    height: 40px; /* または適切な値 */
    line-height: 40px; /* 高さと同じ値を設定 */
}

/* PC向けイル */
#my-chatbot #send-button {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
}

#my-chatbot #send-button svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: #000;
    stroke-width: 2;
}

#my-chatbot #send-button:hover svg {
    stroke: #555;
}

/* スマートフォン向けスタイル */
@media screen and (max-width: 767px) {
    #my-chatbot #chat-input-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 10px;
        background-color: #fff;
        box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
    }

    #my-chatbot #user-input {
        font-size: 16px;
        padding-right: 45px;
    }

    #my-chatbot #send-button {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        background: transparent !important;
        border: none;
        padding: 0;
        cursor: pointer;
        display: flex;
        justify-content: center;
        align-items: center;
        width: 44px;
        height: 44px;
    }

    #my-chatbot #send-button svg {
        width: 28px;
        height: 28px;
        fill: none;
        stroke: #000;
        stroke-width: 2;
    }

    #my-chatbot #chat-messages-wrapper {
        margin-bottom: 70px;
    }
}

@media screen and (max-width: 767px) {
    #my-chatbot {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }

    #my-chatbot #chat-container {
        display: flex;
        flex-direction: column;
        height: 100%;
        width: 100%;
    }

    #my-chatbot #chat-messages-wrapper {
        flex-grow: 1;
        overflow-y: auto;
    }

    #my-chatbot #chat-input-container {
        position: relative;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 10px;
        background-color: #fff;
    }

    #my-chatbot #chat-icon {
        bottom: 20px;
        right: 20px;
    }
}

/* チャットウィンドウが開いているときスタートアイコンを非表示にする */
#my-chatbot.chat-open #chat-icon {
    display: none !important;
}

/* フッター */
#my-chatbot #chat-footer {
    padding: 10px 10px;
    text-align: center;
    font-size: 10px;
    background-color: white;
    border-top: 1px solid #eee;
}

#my-chatbot #chat-footer a {
    color: #666;
    text-decoration: none;
}

#my-chatbot #chat-footer a:hover {
    text-decoration: underline;
}

:root {
    --chat-header-color: #cc0000;
}

#my-chatbot #chat-header {
    background-color: var(--chat-header-color);
    color: white;
    padding: 10px 15px;
    font-weight: bold;
    font-size: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#my-chatbot #chat-title {
    color: white;
    font-weight: bold;
}

/* チャットコンテナのレスポンシブ対応 */
@media screen and (max-width: 480px) {
    #my-chatbot #chat-container {
        width: 100%;
        height: 100%;
        bottom: 0 !important; /* 常に画面下部固定 */
        right: 0 !important; /* 常に画面右端に固定 */
        left: 0 !important; /* 常に画面左端に固定 */
        border-radius: 0;
    }

    #my-chatbot #chat-messages {
        padding: 10px;
    }

    /* 入力エリアの調整 */
    #my-chatbot #chat-input-container {
        padding: 10px;
    }

    #my-chatbot #user-input {
        font-size: 16px; /* モバイルでの入力を容易にする */
    }

    #my-chatbot #send-button {
        width: 44px;
        height: 44px;
        min-width: 44px; /* ボタンが縮まないようにする */
        background: none; /* 背景削除 */
        border: none;
        padding: 0;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    #my-chatbot #send-button svg {
        width: 24px;
        height: 24px;
        fill: none; /* 塗りつぶしを無効化 */
        stroke: #000; /* 線の色を黒に設定 */
        stroke-width: 2; /* 線の太さを設定 */
    }

    /* メッセージの最大幅を調整 */
    #my-chatbot .message {
        max-width: 90%;
    }
}

#my-chatbot #send-button {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

#my-chatbot #send-button svg {
    fill: none !important;
    stroke: #000 !important;
    stroke-width: 2 !important;
}

@media screen and (max-width: 767px) {
    #my-chatbot #send-button,
    #my-chatbot #send-button svg {
        background: transparent !important;
        fill: none !important;
        stroke: #000 !important;
    }
}

/* スタイルを確認 */
#my-chatbot .loading {
    /* スタイルを確認 */
}

#my-chatbot .bot-message {
    /* スタイルを確認 */
}

#my-chatbot .message-bubble {
    /* スタイルを確認 */
}

#my-chatbot .typing-indicator {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

#my-chatbot .typing-indicator .message-bubble {
    color: #888;
    font-style: italic;
}

#my-chatbot .bot-message.loading {
    opacity: 0.7;
}

#my-chatbot .bot-message.loading .message-bubble {
    font-style: italic;
}

#my-chatbot .message.loading {
    opacity: 0.7;
}

#my-chatbot .message.loading .message-bubble {
    font-style: italic;
}

#my-chatbot .message.bot-message.loading {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.7;
    }
}

#my-chatbot .bot-message + .bot-message {
    margin-top: 5px;
}

#my-chatbot .bot-message + .bot-message .message-icon {
    display: none;
}

#my-chatbot .bot-message + .bot-message .message-bubble {
    border-top-left-radius: 18px;
}

/* アイコンの横幅を調整 */
#my-chatbot .bot-message:first-child .message-content {
    width: auto;
}

#my-chatbot #ai-typing {
    display: none;
    margin-bottom: 10px;
    font-style: italic;
    color: #888;
}

/* チャットボット内のメッセージスタイル */
#my-chatbot .message {
    margin: 10px 0;
    padding: 10px;
    border-radius: 5px;
}

/* チャットボット内の見出しスタイル */
#my-chatbot .bot-message .message-bubble strong.chat-heading {
    display: block;
    margin: 0.7em 0 0.3em;
    font-weight: bold;
}

#my-chatbot .bot-message .message-bubble strong.chat-heading.h1 {
    font-size: 1.2em;
}

#my-chatbot .bot-message .message-bubble strong.chat-heading.h2 {
    font-size: 1.1em;
}

#my-chatbot .bot-message .message-bubble strong.chat-heading.h3,
#my-chatbot .bot-message .message-bubble strong.chat-heading.h4,
#my-chatbot .bot-message .message-bubble strong.chat-heading.h5,
#my-chatbot .bot-message .message-bubble strong.chat-heading.h6 {
    font-size: 1em;
}

#my-chatbot .bot-message .message-bubble p {
    margin: 0.5em 0;
    font-size: 0.9em;
}

#my-chatbot .bot-message .message-bubble .chat-list {
    margin: 0.5em 0;
}

#my-chatbot .bot-message .message-bubble .chat-list p {
    margin: 0.2em 0 0.2em 1em;
    position: relative;
    font-size: 0.9em;
}

#my-chatbot .bot-message .message-bubble .chat-list p::before {
    content: '•';
    position: absolute;
    left: -1em;
}

#my-chatbot .bot-message .message-bubble,
#my-chatbot .bot-message .message-bubble p,
#my-chatbot .bot-message .message-bubble span {
    font-size: 16px !important;
    line-height: 1.3;
}

#my-chatbot .bot-message .message-bubble,
#my-chatbot .bot-message .message-bubble * {
    font-size: 16px;
    line-height: 1.3;
}

#my-chatbot {
    position: fixed;
    z-index: 9999999;
    font-family: Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    pointer-events: none; /* コンテナ全体のポインターイベントを無効化 */
}

#my-chatbot #chat-icon,
#my-chatbot #chat-container {
    pointer-events: auto; /* チャットアイコンとチャットウィンドウのポインターイベントを有効化 */
}
