/* ===== ヨコハマラボ チャットウィジェット ===== */

#yl-chat-wrapper { position: fixed; bottom: 160px; right: 24px; z-index: 99999; font-family: 'Noto Sans JP', sans-serif; }

#yl-chat-toggle {
    width: 56px; height: 56px; border-radius: 50%;
    background: #1a3a5c; border: none; cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; transition: transform 0.2s, background 0.2s; margin-left: auto;
}
#yl-chat-toggle:hover { background: #3b9eff; transform: scale(1.08); }
.yl-chat-icon-close { display: none; font-style: normal; font-size: 18px; color: #fff; }
.yl-chat-icon-open  { color: #fff; }
#yl-chat-wrapper.open .yl-chat-icon-open  { display: none; }
#yl-chat-wrapper.open .yl-chat-icon-close { display: block; }

#yl-chat-window {
    display: none; flex-direction: column;
    width: 320px; height: 440px;
    background: #fff; border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    margin-bottom: 10px; overflow: hidden;
}
#yl-chat-wrapper.open #yl-chat-window { display: flex; }

#yl-chat-header { background: #1a3a5c; color: #fff; padding: 14px 16px; font-size: 14px; font-weight: 700; flex-shrink: 0; }

#yl-chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.yl-bubble { max-width: 85%; padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.6; word-break: break-word; }
.yl-bubble-bot  { background: #f0f4f8; color: #222; align-self: flex-start; border-bottom-left-radius: 2px; }
.yl-bubble-user { background: #1a3a5c; color: #fff; align-self: flex-end; border-bottom-right-radius: 2px; }
.yl-bubble-loading { color: #888; font-style: italic; }
.yl-dots::after { content: '...'; animation: yl-dot 1.2s infinite; }
@keyframes yl-dot { 0% { content: '.'; } 33% { content: '..'; } 66% { content: '...'; } }

#yl-chat-input-area { display: flex; gap: 8px; padding: 12px; border-top: 1px solid #eee; flex-shrink: 0; background: #fff; }
#yl-chat-input { flex: 1; border: 1px solid #ccc; border-radius: 8px; padding: 8px 10px; font-size: 13px; resize: none; font-family: inherit; line-height: 1.4; }
#yl-chat-input:focus { outline: none; border-color: #3b9eff; }
#yl-chat-send { background: #ff8c00; color: #fff; border: none; border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 700; cursor: pointer; align-self: flex-end; transition: background 0.2s; white-space: nowrap; }
#yl-chat-send:hover    { background: #e07800; }
#yl-chat-send:disabled { background: #ccc; cursor: not-allowed; }

/* フッター：フォームへの誘導リンク */
#yl-chat-footer {
    padding: 8px 14px;
    font-size: 11px;
    color: #888;
    text-align: center;
    border-top: 1px solid #eee;
    background: #fafafa;
    line-height: 1.6;
    flex-shrink: 0;
}
#yl-chat-footer a {
    color: #3b9eff;
    text-decoration: underline;
}
#yl-chat-footer a:hover { color: #1a6fcc; }
#yl-chat-send:disabled { background: #ccc; cursor: not-allowed; }

/* ===== 吹き出し：ページ表示3秒後に出現→8秒後に消滅 ===== */
#yl-chat-balloon {
    position: absolute;
    bottom: 64px;      /* ボタンの上 */
    right: 0;
    background: #1a3a5c;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    padding: 8px 14px;
    border-radius: 12px 12px 2px 12px;
    white-space: nowrap;
    pointer-events: none;  /* クリック透過 */
    /* 初期状態：非表示 */
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}
/* 表示状態 */
#yl-chat-balloon.yl-balloon-show {
    opacity: 1;
    transform: translateY(0);
}
/* しっぽ（右下向き三角） */
#yl-chat-balloon::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 14px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-top: 6px solid #1a3a5c;
}

@media (max-width: 600px) {
    /* ===== スマホ用レイアウト ===== */

    /* 開閉ボタン：ページトップボタン(〜148px)の上に配置 */
    #yl-chat-wrapper {
        bottom: 160px;  /* ページトップボタン上端148px + 余白12px */
        right: 16px;
    }

    /* チャット窓：ボタンの上から画面上端まで使う */
    #yl-chat-window {
        position: fixed;
        /* ボタン bottom:160px + height:56px + 余白8px = 224px */
        bottom: 224px;
        right: 8px;
        left: 8px;
        width: auto;
        max-height: 400px;
        /* 100dvh：iOSでキーボード表示時も正しく追従する動的ビューポート高さ */
        /* 100vh ：dvh非対応ブラウザ向けフォールバック（先に書く） */
        height: calc(100vh - 240px);   /* フォールバック */
        height: calc(100dvh - 240px);  /* dvh対応ブラウザ優先 */
        margin-bottom: 0;
    }

    /* 入力エリア：縦並びレイアウトに変更 */
    #yl-chat-input-area {
        flex-direction: column;  /* 横並び → 縦並び */
        gap: 8px;
        padding: 10px 12px;
    }

    /* 入力欄：横幅いっぱいに拡張・iOSズーム防止のためfont-size 16px */
    #yl-chat-input {
        width: 100%;
        font-size: 16px;  /* 16px未満だとiOSが自動ズームする */
        rows: 2;
    }

    /* 送信ボタン：横幅いっぱいに拡張 */
    #yl-chat-send {
        width: 100%;
        padding: 10px;
        align-self: stretch;
    }
}
