/* =========================================================
   1) AIチャットボット
   ========================================================= */

/* =========================================
   変数定義（指定色）
   ========================================= */
:root {
    --clinic-navy: #1f3a5f;
    --clinic-greige: #6f6a64;
    --clinic-light-greige: #eaeae8;
    /* グレージュを薄めた色 */
}

/* =========================================
   右下のチャットボタン（コンテナ構成）
   ========================================= */
#chat-button-container {
    position: fixed;
    bottom: 20px;
    right: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    #chat-button-container {
        bottom: 60px;
        right: 5px;
    }
}

/* ホバー時に少し浮き上がる演出 */
#chat-button-container:hover {
    transform: translateY(-5px);
}

/* 円形のアイコン部分 */
.chat-icon-bubble {
    background-color: var(--clinic-navy);
    color: white;
    width: 90px;
    /* 文字を入れるために少し大きく */
    height: 90px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    /* ★ 縦並びに変更 */
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#icon-closed {
    font-size: 28px;
    /* ★ 少し大きくして存在感を出す */
    line-height: 1;
}

/* アイコンの中の「AI相談」テキスト */
.chat-button-text {
    margin-top: 2px;
    /* ★ アイコンとの距離を微調整 */
    font-size: 14px;
    /* ★ 中に入れるため少し小さく */
    font-weight: bold;
    color: #fff;
    /* ★ 文字色を白に変更 */
    letter-spacing: 0.05em;
    /* 背景や影、パディングを削除（丸の中に馴染ませるため） */
}

.hidden {
    display: none !important;
}

/* =========================================
   チャットウィンドウ本体
   ========================================= */
#chat-window {
    position: fixed;
    bottom: 110px;
    /* ボタンとテキストの高さに合わせて調整 */
    right: 25px;
    width: 370px;
    height: 550px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
    transition: all 0.3s ease;
}

@media screen and (max-width: 768px) {
    #chat-window {
        position: fixed !important;
        inset: 0 !important;
        width: 100vw !important;
        height: 100dvh !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        right: auto !important;
        bottom: auto !important;
        left: 0 !important;
        top: 0 !important;
        transform: none !important;
        z-index: 10002 !important;
    }
}

/* ヘッダー */
#chat-header {
    background: rgba(31, 58, 95, 0.9);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
}

.clinic-logo {
    height: 30px;
    width: auto;
    margin-right: 10px;
}

.clinic-name {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.close-button {
    font-size: 24px;
    width: 40px;
    height: 40px;

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
}

/* =========================================
   メッセージエリア
   ========================================= */
#chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    padding: 12px 16px;
    border-radius: 15px;
    max-width: 85%;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.message.user {
    white-space: pre-wrap;
}

/* ユーザーのメッセージ（紺色） */
.message.user {
    background: var(--clinic-navy);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

/* AIのメッセージ（グレージュ系） */
.message.bot {
    background: rgba(234, 234, 232, 0.8);
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

/* 入力中アニメーション（ドット） */
.typing {
    display: flex;
    gap: 4px;
    padding: 10px 15px !important;
}

.dot {
    width: 6px;
    height: 6px;
    background: var(--clinic-navy);
    border-radius: 50%;
    animation: wave 1.3s linear infinite;
}

.dot:nth-child(2) {
    animation-delay: -1.1s;
}

.dot:nth-child(3) {
    animation-delay: -0.9s;
}

@keyframes wave {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-6px);
    }
}

/* =========================================
   入力エリア
   ========================================= */
#chat-input-area {
    padding: 20px;
    background: transparent;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.input-bubble {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 6px;
    border-radius: 30px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

#user-input {
    flex: 1;
    padding: 8px 15px;
    border: none;
    background: transparent;
    font-size: 16px;
    outline: none;
}

/* 送信ボタン（飛行機アイコン） */
.send-icon-button {
    background-color: var(--clinic-greige);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.send-icon-button:hover {
    background-color: var(--clinic-navy);
}

/* 1. ボタンのコンテナ設定（横方向中央配置に） */
.bot-link-container {
    display: flex;
    justify-content: center;
    /* ★横方向中央配置 */
    margin-top: 10px;
    /* メッセージとの間隔を調整 */
    margin-bottom: 15px;
    padding-left: 0;
    /* 左パディングを解除 */
    background: transparent !important;
    padding: 0 !important;
}

/* 2. 「詳細はこちら」ボタンのデザイン（添付画像のネイビー枠デザイン） */
.detail-button {
    display: inline-block;
    padding: 10px 30px;
    /* 横幅を少し広げて、添付画像のサイズ感に */
    background-color: white;
    /* ★白地 */
    color: #001f5b !important;
    /* ★ネイビー文字 */
    border: 2px solid #001f5b;
    /* ★ネイビーの枠線 */
    text-decoration: none !important;
    border-radius: 25px;
    /* ★添付画像のような強い角丸 */
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    /* 影は控えめに */
    transition: all 0.2s ease;
    cursor: pointer;
}

/* 3. ホバー時の動作（添付画像のように、少し色を濃くするか、影を強くする） */
.detail-button:hover {
    background-color: #f0f0f0;
    /* 少しグレーに */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* 4. ★クリック（アクティブ）時の動作（ネイビー反転） */
.detail-button:active {
    background-color: #001f5b !important;
    /* ★ネイビー地に */
    color: white !important;
    /* ★白文字に */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    /* 影を沈める */
    transform: translateY(1px);
    /* ボタンが沈むアニメーション */
}

.message.bot p {
    margin: 0;
}

.message.bot ul {
    padding-left: 18px;
    margin: 4px 0 0 0;
}

.message.bot li {
    margin-bottom: 2px;
}

.message.bot li:last-child {
    margin-bottom: 0;
}

/* =========================================
   チャット内アクションボタン
   ========================================= */
.bot-action-row {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    justify-content: center;
    flex-wrap: nowrap;
}

.action-button {
    min-width: 122px;
    height: 58px;
    padding: 0 18px;
    border-radius: 10px;
    color: #fff;
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.01em;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.action-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.2);
    opacity: 0.97;
}

.action-button-icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 24px;
}

.action-button-icon svg {
    width: 24px;
    height: 24px;
    display: block;
    stroke: #fff;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.action-line .action-button-icon svg {
    fill: #fff;
    stroke: none;
}

.action-line .action-button-icon svg text {
    fill: #49a847;
    font-size: 5px;
    font-weight: 700;
    font-family: Arial, sans-serif;
}

.action-button-label {
    white-space: nowrap;
}

.action-web {
    background: linear-gradient(180deg, #2e5588 0%, #244975 100%);
}

.action-line {
    background: linear-gradient(180deg, #63be58 0%, #4faa48 100%);
}

@media (max-width: 480px) {
    .bot-action-row {
        gap: 12px;
    }

    .action-button {
        min-width: 116px;
        height: 54px;
        padding: 0 16px;
        font-size: 17px;
    }

    .action-button-icon,
    .action-button-icon svg {
        width: 22px;
        height: 22px;
    }
}

.message.bot table {
    width: auto;
    table-layout: auto;
    margin-top: 10px;
    border-collapse: collapse;
}

.message.bot th {
    background: #f7f7f7;
    font-weight: 700;
    padding: 10px 8px;
    border: 1px solid #d9d9d9;
    text-align: center;
    white-space: nowrap;
}

.message.bot td {
    padding: 12px 8px;
    border: 1px solid #d9d9d9;
    text-align: center;
    line-height: 1.5;
    white-space: nowrap;
}

.message.bot td:first-child {
    font-weight: 600;
    white-space: nowrap;
}