/* =====================================================
   LIVE配信研究所 - AIチャットボットCSS
   ===================================================== */

/* AIチャットボット - 右上小型チャット */
.chatbot-float-btn {
    position: fixed;
    top: 80px;
    right: 2rem;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--tiktok-pink), var(--tiktok-blue));
    border-radius: 50%;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--tiktok-glow-mixed), 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1003;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    contain: layout style paint;
}

.chatbot-float-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--tiktok-glow-mixed), 0 6px 25px rgba(0, 0, 0, 0.4);
}

/* PC版でのフローティングチャットボットボタン非表示 */
@media (min-width: 769px) {
    .chatbot-float-btn {
        display: none !important;
    }
}

.ai-chatbot {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: none;
    border-radius: 0;
    box-shadow: var(--tiktok-glow-pink), 0 0 30px rgba(254, 44, 85, 0.2);
    z-index: 1002;
    transform: translateY(-20px) scale(0.8);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* PC版でのチャットボットウィンドウ */
@media (min-width: 769px) {
    .ai-chatbot {
        top: auto;
        left: auto;
        bottom: 2rem;
        right: 2rem;
        width: 400px;
        height: 600px;
        border-radius: 20px;
        border: 2px solid var(--tiktok-pink);
        box-shadow: var(--tiktok-glow-pink), 0 10px 40px rgba(0, 0, 0, 0.3);
        transform: translateY(20px) scale(0.9);
    }
    
    .ai-chatbot.active {
        transform: translateY(0) scale(1);
    }
}

.ai-chatbot.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

.chatbot-header {
    padding: 1rem;
    border-bottom: 1px solid var(--tiktok-pink);
    display: flex;
    align-items: center;
    gap: 1rem;
    background: linear-gradient(135deg, rgba(254, 44, 85, 0.1), rgba(37, 244, 238, 0.1));
    flex-shrink: 0; /* 縮まないようにする */
}

/* PC版でのチャットボットヘッダー */
@media (min-width: 769px) {
    .chatbot-header {
        padding: 1.2rem;
        border-radius: 18px 18px 0 0;
    }
}

.ai-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--tiktok-pink), var(--tiktok-blue));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: var(--tiktok-glow-mixed);
}

.chatbot-title h3 {
    font-size: 1rem;
    margin-bottom: 0.2rem;
    color: var(--tiktok-pink);
    text-shadow: var(--tiktok-glow-pink);
}

.status-indicator {
    font-size: 0.8rem;
    color: var(--tiktok-blue);
    text-shadow: var(--tiktok-glow-blue);
}

.chatbot-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--tiktok-pink);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.chatbot-close:hover {
    text-shadow: var(--tiktok-glow-pink);
    transform: scale(1.1);
}

.chatbot-messages {
    flex: 1; /* 残りのスペースをすべて埋める */
    overflow-y: auto;
    padding: 1rem;
    background: rgba(10, 10, 26, 0.3);
    min-height: 0; /* Flexboxでの縮小を許可 */
    -webkit-overflow-scrolling: touch; /* iOSのスムーズスクロール */
}

.message {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.ai-message .message-content {
    background: rgba(37, 244, 238, 0.1);
    border: 1px solid var(--tiktok-blue);
    box-shadow: 0 0 10px rgba(37, 244, 238, 0.2);
}

.user-message {
    justify-content: flex-end;
}

.user-message .message-content {
    background: rgba(254, 44, 85, 0.1);
    border: 1px solid var(--tiktok-pink);
    box-shadow: 0 0 10px rgba(254, 44, 85, 0.2);
}

.message-content {
    padding: 0.8rem;
    border-radius: 15px;
    max-width: 250px;
    word-wrap: break-word;
    color: var(--text-primary);
}

/* PC版でのメッセージサイズ */
@media (min-width: 769px) {
    .message-content {
        max-width: 320px;
        padding: 1rem;
    }
}

.chatbot-input-container {
    border-top: 1px solid var(--tiktok-pink);
    background: rgba(10, 10, 26, 0.5);
    flex-shrink: 0; /* 縮まないようにする */
}

.chatbot-input {
    padding: 1rem;
    display: flex;
    gap: 0.5rem;
    position: sticky;
    bottom: 0;
    background: rgba(10, 10, 26, 0.95);
    backdrop-filter: blur(15px);
    border-top: 1px solid rgba(254, 44, 85, 0.3);
}

/* PC版でのチャットボット入力エリア */
@media (min-width: 769px) {
    .chatbot-input {
        padding: 1.2rem;
        border-radius: 0 0 18px 18px;
        border-top: 1px solid rgba(254, 44, 85, 0.3);
    }
}

.chatbot-input input,
.chatbot-input textarea {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--tiktok-blue);
    border-radius: 10px;
    padding: 0.5rem;
    color: var(--text-primary);
    transition: var(--transition);
    font-size: 16px; /* Safariの自動ズームを防ぐ */
    -webkit-appearance: none;
    font-family: inherit;
}

.chatbot-input input:focus {
    outline: none;
    border-color: var(--tiktok-pink);
    box-shadow: var(--tiktok-glow-pink);
}

.chatbot-input button {
    background: linear-gradient(135deg, var(--tiktok-pink), var(--tiktok-blue));
    border: none;
    border-radius: 10px;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 600;
    box-shadow: var(--tiktok-glow-mixed);
    transition: var(--transition);
}

.chatbot-input button:hover {
    transform: translateY(-2px);
    box-shadow: var(--tiktok-glow-mixed), 0 5px 15px rgba(37, 244, 238, 0.3);
}

/* チャットボットの選択肢スタイル */
.chatbot-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    width: 100%;
}

.chatbot-option-btn {
    background: rgba(37, 244, 238, 0.1);
    border: 1px solid var(--tiktok-blue);
    box-shadow: 0 0 10px rgba(37, 244, 238, 0.2);
    color: var(--text-primary);
    padding: 0.6rem 0.8rem; /* サイズを小さく */
    border-radius: 15px;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem; /* サイズを小さく */
    font-family: inherit;
}

/* PC版でのチャットボット選択肢ボタン */
@media (min-width: 769px) {
    .chatbot-option-btn {
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
        border-radius: 12px;
    }
}

.chatbot-option-btn:hover {
    background: rgba(37, 244, 238, 0.2);
    border-color: var(--tiktok-pink);
    transform: translateY(-2px);
    box-shadow: var(--tiktok-glow-pink);
}

/* レスポンシブ対応 - チャットボット */
@media (max-width: 768px) {
    .chatbot-float-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
        right: 1rem;
        top: 70px;
        pointer-events: auto;
        contain: layout style paint;
        z-index: 9999;
    }
    
    .ai-chatbot {
        width: 90vw;
        top: 90px;
        left: 50%;
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
        transform: translateX(-50%) scale(0.9);
        right: auto;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    .ai-chatbot.active {
        transform: translateX(-50%) scale(1);
    }
    
    /* トップページでの位置ずれを強制的に修正 */
    body.home .ai-chatbot {
        transform: translateX(-50%) scale(0.9) !important;
        top: 90px !important;
        left: 50% !important;
        right: auto !important;
        bottom: auto !important;
        width: 90vw !important;
    }
    
    body.home .ai-chatbot.active {
        transform: translateX(-50%) scale(1) !important;
    }
    
    .chatbot-messages {
        height: auto !important;
        max-height: calc(100vh - 180px) !important;
    }
    
    .message-content {
        max-width: 220px !important;
        font-size: 0.9rem !important;
        padding: 0.6rem !important;
    }
    
    .chatbot-input {
        padding: 0.8rem !important;
        position: sticky !important;
        bottom: 0 !important;
        background: rgba(10, 10, 26, 0.95) !important;
        backdrop-filter: blur(10px) !important;
    }
    
    .chatbot-input input {
        font-size: 0.9rem !important;
        padding: 0.6rem !important;
        border-radius: 8px !important;
        min-height: 44px !important;
        touch-action: manipulation !important;
    }
    
    .chatbot-input button {
        padding: 0.6rem 1rem !important;
        font-size: 0.9rem !important;
        min-height: 44px !important;
        touch-action: manipulation !important;
    }
}

/* キーボード表示時の調整 */
@media (max-height: 600px) {
    .ai-chatbot {
        height: 100vh;
        width: 100vw;
    }
    
    .chatbot-messages {
        flex: 1;
        min-height: 0;
        -webkit-overflow-scrolling: touch;
    }
    
    .chatbot-input {
        position: sticky;
        bottom: 0;
        background: rgba(10, 10, 26, 0.98);
        backdrop-filter: blur(20px);
        border-top: 1px solid rgba(254, 44, 85, 0.5);
    }
    
    .chatbot-input input,
    .chatbot-input textarea {
        font-size: 16px;
        -webkit-appearance: none;
        font-family: inherit;
    }
}

/* 記事ページでAIチャットボットを非表示 */
body.single .ai-chatbot,
body.single .chatbot-float-btn {
    display: none !important;
    visibility: hidden !important;
}

/* モーダル中はフローティングAIボタンを隠す */
body.modal-open .chatbot-float-btn { 
    opacity: 0; 
    pointer-events: none; 
}
