/* ベーススタイル（修正） */
body {
    font-family: "Helvetica Neue", Arial, sans-serif;
    background-color: #f4f7f6;
    margin: 0;
    /* 中央揃えのスタイルを削除し、通常のページスタイルに戻す */
    min-height: 100vh;
}

/* --- ここからチャットウィジェット用のスタイル --- */

/* チャットアイコン */
#chat_icon {
    width: 80px;
    height: 100px;
    object-fit: cover;
    display: block;
}

/* チャットを開くトグルボタン */
.chat-toggle-btn {
    position: fixed;
    /*bottom: 20px;*/
	bottom: 100px;
    right: 20px;
    width: 100px;
    height: 100px;
    background-color: transparent; /* 背景を透明に（画像を見せるため） */
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
    z-index: 1000;
    padding: 0;         /* 余計な余白を削除 */
    overflow: hidden;   /* 画像をボタンの丸みに合わせて切り抜く */
}

.chat-toggle-btn:hover {
    /* 背景色が変わる代わりに少し大きくする演出 */
    transform: scale(1.1);
}

/* チャットコンテナ（修正：右下固定・初期非表示） */
.chat-container {
    position: fixed;
    bottom: 220px; /* ボタンの上に配置 */
    right: 20px;
    width: 380px; /* 少し幅を狭く */
    max-width: 90vw; /* モバイル対応 */
    height: 450px;
    max-height: 70vh;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: visible;
    z-index: 1001;

    /* 初期状態（非表示アニメーション用） */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none; /* 非表示時はクリックなどを無効化 */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* 吹き出しの「しっぽ」部分 */
.chat-container::after {
    content: "";
    position: absolute;
    bottom: -15px; /* コンテナの真下に配置 */
    right: 35px;   /* アイコンの中央付近に来るよう調整 */
    width: 0;
    height: 0;
    /* 三角形を作成 */
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-top: 15px solid #fff; /* コンテナの背景色（入力エリアの色）と合わせる */
    filter: drop-shadow(0 5px 5px rgba(0,0,0,0.1)); /* しっぽにも影をつける */
}

/* チャットコンテナが表示状態のクラス */
.chat-container.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ヘッダー（修正） */
.chat-header {
    background-color: #4285f4;
    color: white;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h1 {
    margin: 0;
    font-size: 1.1rem;
}

/* 閉じるボタン */
#close-chat-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: flex;
    border-radius: 50%;
    transition: background 0.2s;
}
#close-chat-btn:hover {
    background: rgba(255,255,255,0.2);
}


/* --- 以下、前回のCSSと同じ（メッセージエリアなど） --- */

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background-color: #ddd; border-radius: 3px; }

.message { display: flex; max-width: 85%; }
.message.user { align-self: flex-end; }
.message.bot { align-self: flex-start; }

.bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.user .bubble {
    background-color: #4285f4;
    color: white;
    border-bottom-right-radius: 4px;
}
.message.bot .bubble {
    background-color: #e9ecef;
    color: #333;
    border-bottom-left-radius: 4px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: #e9ecef;
    border-radius: 16px;
    width: fit-content;
}
.typing-dot {
    width: 6px; height: 6px; background: #999; border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

.chat-input-area {
    padding: 12px;
    background: white;
    border-top: 1px solid #eee;
}
#chat-form { display: flex; gap: 8px; }
#user-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 0.9rem;
    transition: border-color 0.3s;
}
#user-input:focus { border-color: #4285f4; }
#send-btn {
    background: #4285f4; color: white; border: none;
    width: 38px; height: 38px; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center;
    justify-content: center; transition: background 0.3s;
}
#send-btn:hover { background: #3367d6; }
#send-btn:disabled { background: #ccc; cursor: not-allowed; }

/* モバイル向け調整 */
@media (max-width: 480px) {
    .chat-container {
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    .chat-container::after {
        display: none;
    }
}