/* チャットボックスのメインスタイル */
#chat-box {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    width: 350px !important;
    max-height: 450px !important;
    background-color: #ffffff !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.15) !important;
    z-index: 10000 !important;
    transition: all 0.3s ease !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    display: flex !important;
    flex-direction: column !important;
}

/* 1280px以下の画面サイズ対応 */
@media (max-height: 720px) {
    #chat-box {
        max-height: 400px !important;
    }
}

/* モバイル対応 */
@media (max-width: 768px) {
    #chat-box {
        width: 90% !important;
        right: 5% !important;
        left: 5% !important;
        bottom: 10px !important;
        max-height: 70vh !important;
    }
}

/* チャットヘッダー */
#chat-header {
    background: linear-gradient(135deg, #C8381D 0%, #E85D3D 100%) !important;
    color: white !important;
    padding: 12px 16px !important;
    border-radius: 12px 12px 0 0 !important;
    cursor: pointer !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 14px !important;
    flex-shrink: 0 !important;
}

#chat-title {
    font-weight: 600 !important;
    flex: 1 !important;
}

/* 言語選択ボタン */
.language-selector {
    display: flex !important;
    gap: 8px !important;
    margin-right: 10px !important;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    color: white !important;
    padding: 4px 12px !important;
    border-radius: 16px !important;
    cursor: pointer !important;
    font-size: 12px !important;
    transition: all 0.3s ease !important;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

.lang-btn.active {
    background: white !important;
    color: #C8381D !important;
}

/* トグルアイコン */
.toggle-icon {
    font-size: 12px !important;
    transition: transform 0.3s ease !important;
}

/* 最小化状態 */
#chat-box.minimized {
    max-height: 48px !important;
    overflow: hidden !important;
}

#chat-box.minimized .toggle-icon {
    transform: rotate(180deg) !important;
}

#chat-box.minimized #chat-content-wrapper {
    display: none !important;
}

/* チャットコンテンツラッパー */
#chat-content-wrapper {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-height: 0 !important;
    background: white !important;
    border-radius: 0 0 12px 12px !important;
}

/* 履歴クリアボタン */
.chat-clear-button {
    background-color: #FDB839 !important;
    color: #333 !important;
    border: none !important;
    padding: 8px 16px !important;
    margin: 10px !important;
    border-radius: 20px !important;
    cursor: pointer !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    transition: all 0.3s ease !important;
    flex-shrink: 0 !important;
}

.chat-clear-button:hover {
    background-color: #FFA500 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 8px rgba(253, 184, 57, 0.3) !important;
}

/* チャットコンテンツ */
#chat-content {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 10px 16px !important;
    background-color: #f8f9fa !important;
    font-size: 13px !important;
    min-height: 200px !important;
}

/* メッセージスタイル */
.chat-message {
    margin-bottom: 12px !important;
    animation: fadeIn 0.3s ease !important;
}

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

.message-sender {
    font-size: 11px !important;
    color: #666 !important;
    margin-bottom: 4px !important;
    font-weight: 500 !important;
}

.assistant-container {
    display: flex !important;
    align-items: flex-start !important;
    gap: 10px !important;
}

/* BOTアバター（ロボットアイコン） */
.avatar {
    width: 32px !important;
    height: 32px !important;
    background: linear-gradient(135deg, #C8381D 0%, #E85D3D 100%) !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    overflow: hidden !important;
}

/* ロボットアイコンのSVG */
.avatar::before {
    content: '' !important;
    width: 20px !important;
    height: 20px !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 2C11.5 2 11 2.5 11 3V4H8C6.9 4 6 4.9 6 6V19C6 20.1 6.9 21 8 21H16C17.1 21 18 20.1 18 19V6C18 4.9 17.1 4 16 4H13V3C13 2.5 12.5 2 12 2M8 6H16V19H8V6M9 8V10H11V8H9M13 8V10H15V8H13M9 12V17H15V12H9Z'/%3E%3C/svg%3E") !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
}

.message-content {
    background: white !important;
    padding: 10px 14px !important;
    border-radius: 12px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    max-width: calc(100% - 42px) !important;
    line-height: 1.5 !important;
}

.user-message .message-content {
    background: #E3F2FD !important;
    margin-left: auto !important;
    margin-right: 0 !important;
}

.system-message .message-content {
    background: #FFF3E0 !important;
    text-align: center !important;
    font-size: 12px !important;
    color: #666 !important;
}

/* 入力エリア */
#chat-input-container {
    display: flex !important;
    padding: 12px !important;
    background: white !important;
    border-top: 1px solid #e0e0e0 !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
}

#chat-input {
    flex: 1 !important;
    padding: 8px 12px !important;
    border: 1px solid #ddd !important;
    border-radius: 20px !important;
    font-size: 13px !important;
    outline: none !important;
    transition: border-color 0.3s ease !important;
}

#chat-input:focus {
    border-color: #C8381D !important;
}

#chat-send {
    background: #C8381D !important;
    color: white !important;
    border: none !important;
    padding: 8px 20px !important;
    border-radius: 20px !important;
    cursor: pointer !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    transition: all 0.3s ease !important;
    white-space: nowrap !important;
}

#chat-send:hover {
    background: #A02815 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 8px rgba(200, 56, 29, 0.3) !important;
}

/* ローディングアニメーション */
.loading {
    display: inline-block !important;
    width: 20px !important;
    height: 20px !important;
    margin-left: 10px !important;
}

.loading:after {
    content: " " !important;
    display: block !important;
    width: 16px !important;
    height: 16px !important;
    border-radius: 50% !important;
    border: 2px solid #C8381D !important;
    border-color: #C8381D transparent #C8381D transparent !important;
    animation: loading 1.2s linear infinite !important;
}

@keyframes loading {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* スクロールバーのカスタマイズ */
#chat-content::-webkit-scrollbar {
    width: 6px !important;
}

#chat-content::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
    border-radius: 3px !important;
}

#chat-content::-webkit-scrollbar-thumb {
    background: #C8381D !important;
    border-radius: 3px !important;
}

#chat-content::-webkit-scrollbar-thumb:hover {
    background: #A02815 !important;
}

/* ダウンロードリンク */
.download-link {
    color: #C8381D !important;
    text-decoration: none !important;
    font-weight: 500 !important;
    display: inline-block !important;
    margin-top: 4px !important;
    font-size: 13px !important;
}

.download-link:hover {
    text-decoration: underline !important;
}

/* レスポンシブ調整 */
@media (max-width: 480px) {
    #chat-box {
        width: 95% !important;
        right: 2.5% !important;
        left: 2.5% !important;
    }
    
    #chat-header {
        padding: 10px 12px !important;
    }
    
    .lang-btn {
        padding: 3px 10px !important;
        font-size: 11px !important;
    }
    
    #chat-content {
        font-size: 12px !important;
    }
    
    .message-content {
        padding: 8px 12px !important;
    }
}