/* =============================
   クロト AIチャットボット UI
   ============================= */

/* --- ランチャー吹き出し --- */
#clotho-chat-callout {
    position: fixed;
    bottom: 96px;
    right: 20px;
    z-index: 9997;
    background: #fff;
    color: #333;
    font-size: 12.5px;
    font-weight: bold;
    line-height: 1.4;
    padding: 8px 12px;
    border-radius: 12px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.15);
    white-space: nowrap;
    pointer-events: none;
    animation: clotho-callout-pop 0.4s ease both;
}
/* 吹き出しの三角 */
#clotho-chat-callout::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 22px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 8px solid #fff;
}
#clotho-chat-callout.hidden {
    display: none;
}
@keyframes clotho-callout-pop {
    0%   { opacity: 0; transform: translateY(6px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- ランチャーボタン（右下に浮く） --- */
#clotho-chat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #1a9a6c;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}
#clotho-chat-launcher:hover {
    background: #157a55;
    transform: scale(1.08);
}
#clotho-chat-launcher svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}
#clotho-chat-launcher .chat-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #e74c3c;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}
#clotho-chat-launcher.has-new .chat-badge {
    display: block;
}

/* --- チャットウィンドウ --- */
#clotho-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 9999;
    width: 360px;
    max-height: 560px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.25s, transform 0.25s;
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
}
#clotho-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ヘッダー */
#clotho-chat-header {
    background: #1a9a6c;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
#clotho-chat-header .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}
#clotho-chat-header .title {
    flex: 1;
    font-size: 14px;
    font-weight: bold;
    line-height: 1.3;
}
#clotho-chat-header .subtitle {
    font-size: 11px;
    opacity: 0.85;
    font-weight: normal;
}
#clotho-chat-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    font-size: 20px;
    line-height: 1;
}
#clotho-chat-close:hover { opacity: 1; }

/* メッセージエリア */
#clotho-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f5f7f6;
}

/* バブル共通 */
.clotho-bubble {
    max-width: 82%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.6;
    word-break: break-word;
}
.clotho-bubble.bot {
    background: #fff;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.clotho-bubble.user {
    background: #1a9a6c;
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}
.clotho-bubble.system {
    background: #eaf6f1;
    color: #555;
    font-size: 12px;
    text-align: center;
    align-self: center;
    border-radius: 8px;
    padding: 6px 12px;
}

/* タイピングインジケーター */
.clotho-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 14px;
    background: #fff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.clotho-typing span {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: clotho-bounce 1.2s infinite;
}
.clotho-typing span:nth-child(2) { animation-delay: 0.2s; }
.clotho-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes clotho-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-6px); }
}

/* 入力エリア */
#clotho-chat-input-area {
    border-top: 1px solid #e8e8e8;
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #fff;
    flex-shrink: 0;
}
#clotho-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13.5px;
    resize: none;
    outline: none;
    max-height: 100px;
    font-family: inherit;
    line-height: 1.5;
    transition: border-color 0.2s;
}
#clotho-chat-input:focus {
    border-color: #1a9a6c;
}
#clotho-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #1a9a6c;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
#clotho-chat-send:hover { background: #157a55; }
#clotho-chat-send:disabled { background: #aaa; cursor: default; }
#clotho-chat-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* スマホ対応 */
@media (max-width: 480px) {
    /* 既存の下部固定メニューバー（約70px）の上に出るよう調整 */
    #clotho-chat-launcher {
        bottom: 86px; /* 70px(メニュー) + 16px(余白) */
        right: 16px;
    }
    #clotho-chat-callout {
        bottom: 158px; /* ランチャーの上に出るよう調整 */
        right: 12px;
    }
    #clotho-chat-window {
        right: 0;
        bottom: 70px; /* メニューバーの高さ分上に */
        width: 100%;
        max-height: calc(80vh - 70px);
        border-radius: 16px 16px 0 0;
    }
}
