/* サン・ウインド Q&Aチャットボット スタイルシート */

/* チャットボット要素の横スクロール防止 */
#chatbot-button,
#chatbot-window {
    max-width: 100vw !important;
}

:root {
    --primary-color: #009688;
    --primary-dark: #00796B;
    --primary-light: #26A69A;
    --bg-color: #f8fafc;
    --text-color: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 150, 136, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 150, 136, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 150, 136, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 150, 136, 0.1);
}

/* チャットボタン(右側タブ型) - 全ブラウザ統一 */
#chatbot-button {
    position: fixed !important;
    bottom: 50% !important;
    right: 0 !important;
    left: auto !important;
    top: auto !important;
    transform: translateY(50%) !important;
    width: auto !important;
    height: auto !important;
    min-width: 48px !important;
    max-width: 60px !important;
    padding: 16px 12px !important;
    margin: 0 !important;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light)) !important;
    border: none !important;
    border-radius: 8px 0 0 8px !important;
    cursor: pointer !important;
    box-shadow: none !important;
    z-index: 99999 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    font-family: 'M PLUS Rounded 1c', sans-serif !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    line-height: 1 !important;
    color: white !important;
    text-align: center !important;
    overflow: hidden !important;
}

#chatbot-button span {
    display: block !important;
    writing-mode: horizontal-tb !important;
    line-height: 1.2 !important;
    text-align: center !important;
    white-space: nowrap !important;
    font-size: 14px !important;
    color: white !important;
    margin: 0 !important;
    padding: 0 !important;
}

#chatbot-button:hover {
    padding-right: 16px !important;
    box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.4) !important;
    transform: translateY(50%) !important;
}

#chatbot-button svg {
    display: block !important;
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    fill: white !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
}

/* スマホ・タブレット共通 */
@media screen and (max-width: 1024px) {
    #chatbot-button {
        bottom: 50% !important;
        right: 0 !important;
        left: auto !important;
        padding: 14px 10px !important;
        min-width: 44px !important;
        max-width: 52px !important;
        font-size: 13px !important;
    }
    
    #chatbot-button span {
        font-size: 13px !important;
        line-height: 1.15 !important;
    }
    
    #chatbot-button svg {
        width: 22px !important;
        height: 22px !important;
        min-width: 22px !important;
        min-height: 22px !important;
    }
}

/* スマホ専用 */
@media screen and (max-width: 480px) {
    body {
        overflow-x: hidden !important;
         /* max-width: 100vw !important; */  /* ←削除 or コメントアウト */
    }
    
    #chatbot-button {
        padding: 12px 6px !important;
        min-width: 36px !important;
        max-width: 42px !important;
        font-size: 11px !important;
        right: 0 !important;
    }
    
    #chatbot-button span {
        font-size: 11px !important;
        line-height: 1.1 !important;
    }
    
    #chatbot-button svg {
        width: 18px !important;
        height: 18px !important;
        min-width: 18px !important;
        min-height: 18px !important;
    }
}

/* チャットウィンドウ */
#chatbot-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 420px;
    max-width: calc(100vw - 40px); /* 画面幅-余白 */
    height: 600px;
    max-height: calc(100vh - 40px); /* 画面高さ-余白 */
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    display: none;
    flex-direction: column;
    z-index: 100000; /* 99999より上にする */
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#chatbot-window.open {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ヘッダー */
.chatbot-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-header h3 {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-size: 18px;
    font-weight: 700;
}

.close-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.close-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.close-button svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* チャットボディ */
.chatbot-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-color);
    font-family: 'Noto Sans JP', sans-serif;
}

.chatbot-body::-webkit-scrollbar {
    width: 6px;
}

.chatbot-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* メッセージ */
.message {
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-bot {
    display: flex;
    gap: 12px;
}

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

.bot-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bot-avatar svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 75%;
    box-shadow: var(--shadow-sm);
    line-height: 1.6;
}

.message-user .message-content {
    background: var(--primary-color);
    color: white;
}

/* Q&A候補リスト */
.qa-results {
    margin-top: 12px;
}

.results-header {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 12px;
    font-weight: 500;
}

.qa-result-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.qa-result-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateX(2px);
}

.qa-result-number {
    display: inline-block;
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    font-size: 12px;
    font-weight: 700;
    margin-right: 8px;
}

.qa-result-question {
    font-weight: 500;
    color: var(--text-color);
    font-size: 14px;
}

.qa-result-preview {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
    line-height: 1.4;
}

/* カテゴリーリンク(クリッカブル) */
.category-links {
    margin-top: 12px;
}

.category-links strong {
    display: block;
    margin-top: 16px;
    margin-bottom: 8px;
    font-size: 15px;
    color: var(--text-color);
}

.category-links strong:first-child {
    margin-top: 8px;
}

.qa-link {
    padding: 8px 12px;
    margin: 4px 0;
    background: #f8f9fa;
    border-left: 3px solid var(--primary-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    line-height: 1.5;
}

.qa-link:hover {
    background: #E0F2F1;
    border-left-color: var(--primary-dark);
    transform: translateX(4px);
}

/* Q&A詳細 */
.qa-detail {
    margin-top: 12px;
}

.qa-detail-question {
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 15px;
}

.qa-detail-answer {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-color);
    white-space: pre-line;
}

.qa-detail-link {
    display: inline-block;
    margin-top: 12px;
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.qa-detail-link:hover {
    background: var(--primary-dark);
}

/* 入力エリア */
.chatbot-input {
    padding: 12px 16px 8px 16px;
    background: white;
    border-top: 1px solid var(--border-color);
}

.input-container {
    display: flex;
    gap: 8px;
}

#user-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    font-size: 14px;
    font-family: 'Noto Sans JP', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

#user-input:focus {
    border-color: var(--primary-color);
}

#send-button {
    width: 44px;
    height: 44px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

#send-button:hover {
    background: var(--primary-dark);
}

#send-button svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* レスポンシブ */
@media (max-width: 768px) {
    #chatbot-window {
        right: 10px !important;
        left: auto !important;
        bottom: 20px !important;
        top: auto !important;
        width: 70vw !important;
        height: 55vh !important;
        max-height: 550px !important;
        max-width: 70vw !important;
        border-radius: 16px !important;
        overflow-x: hidden !important;
    }
    
    .chatbot-header {
        padding: 14px 16px !important;
        flex-shrink: 0 !important;
    }
    
    .chatbot-body {
        flex: 1 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding: 12px !important;
    }
    
    .chatbot-input {
        flex-shrink: 0 !important;
        padding: 10px 12px !important;
        box-sizing: border-box !important;
    }
    
    .input-container {
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    #user-input {
        flex: 1 !important;
        min-width: 0 !important;
    }
    
    #send-button {
        flex-shrink: 0 !important;
    }

    #chatbot-button {
        right: 10px;
        bottom: 10px;
    }
}
