/* リセットとベーススタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* ライトテーマ */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f4;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-tertiary: #80868b;
    --border-color: #dadce0;
    --accent-color: #1a73e8;
    --accent-hover: #1669d6;
    --user-message-bg: #1a73e8;
    --user-message-text: #ffffff;
    --bot-message-bg: #f1f3f4;
    --bot-message-text: #202124;
    --shadow: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
    --suggestion-bg: #ffffff;
    --suggestion-border: #dadce0;
    --suggestion-hover: #f8f9fa;
}

[data-theme="dark"] {
    /* ダークテーマ */
    --bg-primary: #202124;
    --bg-secondary: #303134;
    --bg-tertiary: #3c4043;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-tertiary: #bdc1c6;
    --border-color: #5f6368;
    --accent-color: #8ab4f8;
    --accent-hover: #a8c7fa;
    --user-message-bg: #8ab4f8;
    --user-message-text: #202124;
    --bot-message-bg: #303134;
    --bot-message-text: #e8eaed;
    --shadow: 0 1px 2px 0 rgba(0,0,0,0.3), 0 1px 3px 1px rgba(0,0,0,0.15);
    --suggestion-bg: #303134;
    --suggestion-border: #5f6368;
    --suggestion-hover: #3c4043;
}

body {
    font-family: 'Roboto', 'Noto Sans JP', sans-serif;
    background: transparent;
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease;
}

.chatbot-container {
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ヘッダー */
.chatbot-header {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chatbot-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.chatbot-title h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 500;
}

.chatbot-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.chatbot-header-right {
    display: flex;
    gap: 8px;
}

.chatbot-theme-toggle,
.chatbot-fullscreen-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.chatbot-theme-toggle:hover,
.chatbot-fullscreen-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* メッセージエリア */
.chatbot-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: var(--bg-primary);
    transition: background-color 0.3s ease;
}

.chatbot-message {
    display: flex;
    margin-bottom: 20px;
    gap: 12px;
}

.chatbot-user-message {
    flex-direction: row-reverse;
}

/* ユーザーメッセージのアバターを非表示 */
.chatbot-user-message .chatbot-message-avatar {
    display: none;
}

.chatbot-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.chatbot-message-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chatbot-user-message .chatbot-message-content {
    align-items: flex-end;
}

.chatbot-message-text {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 0.9rem;
    box-shadow: var(--shadow);
}

.chatbot-bot-message .chatbot-message-text {
    background: var(--bot-message-bg);
    color: var(--bot-message-text);
    border-top-left-radius: 4px;
}

.chatbot-user-message .chatbot-message-text {
    background: var(--user-message-bg);
    color: var(--user-message-text);
    border-top-right-radius: 4px;
}

.chatbot-message-time {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    padding: 0 4px;
}

/* 入力エリア */
.chatbot-input-container {
    padding: 16px;
    background: var(--bg-primary);
    flex-shrink: 0;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.chatbot-input {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border-radius: 24px;
    padding: 8px 16px;
    width: 500px;
    margin: 0 auto;
    border: 1px solid transparent;
    transition: all 0.3s ease;
    position: relative; /* 擬似要素の基準点に */
    animation: rainbowShadow 5s ease infinite; /* 速度を調整 */
    box-shadow: 
        0 0 0 1px rgba(26, 115, 232, 0.2),
        0 0 0 2px #ff0000, /* 内側にカラフルなボーダー */
        0 0 0 3px rgba(26, 115, 232, 0.1); /* 外側のソフトな影 */
}

.chatbot-input:focus-within {
    background: var(--bg-primary);
}

@keyframes rainbowShadow {
    0% { box-shadow: 0 0 0 1px #ff0000; }
    8% { box-shadow: 0 0 0 1px #ff8000; }
    16% { box-shadow: 0 0 0 1px #ffff00; }
    24% { box-shadow: 0 0 0 1px #80ff00; }
    32% { box-shadow: 0 0 0 1px #00ff00; }
    40% { box-shadow: 0 0 0 1px #00ff80; }
    48% { box-shadow: 0 0 0 1px #00ffff; }
    56% { box-shadow: 0 0 0 1px #0080ff; }
    64% { box-shadow: 0 0 0 1px #0000ff; }
    72% { box-shadow: 0 0 0 1px #8000ff; }
    80% { box-shadow: 0 0 0 1px #ff00ff; }
    88% { box-shadow: 0 0 0 1px #ff0080; }
    100% { box-shadow: 0 0 0 1px #ff0000; }
}


.chatbot-input input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-primary);
    padding: 8px 0;
}

.chatbot-input input::placeholder {
    color: var(--text-tertiary);
}

.chatbot-send-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
    width: 40px;
    height: 40px;
}

.chatbot-send-btn:hover {
    background: var(--bg-tertiary);
}

.chatbot-send-btn:disabled {
    color: var(--text-tertiary);
    cursor: not-allowed;
}

.chatbot-send-btn:disabled:hover {
    background: transparent;
}

/* フッター */
.chatbot-footer {
    padding: 4px 10px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    text-align: center;
    flex-shrink: 0;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.chatbot-footer small {
    color: var(--text-tertiary);
    font-size: 0.7rem;
}

/* タイピングインジケーター */
.chatbot-typing-indicator {
    display: none;
    margin-bottom: 20px;
    gap: 12px;
}

.chatbot-typing-indicator.active {
    display: flex;
}

.chatbot-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bot-message-bg);
    border-radius: 18px;
    border-top-left-radius: 4px;
    box-shadow: var(--shadow);
}

.chatbot-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    display: block;
    animation: chatbotTypingPulse 1.4s ease-in-out infinite both;
}

.chatbot-typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.chatbot-typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.chatbot-typing-dots span:nth-child(3) {
    animation-delay: 0s;
}

@keyframes chatbotTypingPulse {
    0%, 60%, 100% {
        transform: scale(0.8);
        opacity: 0.7;
    }
    30% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* スクロールバー */
.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* 全画面表示時のスタイル */
.chatbot-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    background: var(--bg-primary);
}

/* 入力候補エリア */
.chatbot-suggestions {
    padding: 0 16px 16px;
    flex-shrink: 0;
}

.chatbot-suggestions-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 500;
}

.chatbot-suggestions-buttons {
    flex-wrap: wrap;
    gap: 8px;
    display: none;
}

.chatbot-suggestion-btn {
    padding: 8px 16px;
    background: var(--suggestion-bg);
    border: 1px solid var(--suggestion-border);
    border-radius: 16px;
    font-size: 0.8rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-family: inherit;
}

.chatbot-suggestion-btn:hover {
    background: var(--suggestion-hover);
}

.chatbot-suggestion-btn:active {
    transform: scale(0.98);
}

.chatbot-suggestion-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.chatbot-suggestion-btn:disabled:hover {
    background: var(--suggestion-bg);
}

/* チャット内リンクスタイル */
.chatbot-link {
    color: var(--accent-color);
    text-decoration: underline;
    word-break: break-all;
    transition: color 0.3s ease;
}

.chatbot-link:hover {
    color: var(--accent-hover);
    text-decoration: none;
}

/* ユーザーメッセージ内のリンクスタイル */
.chatbot-user-message .chatbot-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
}

.chatbot-user-message .chatbot-link:hover {
    color: white;
    text-decoration: none;
}

/* レスポンシブ対応 */
@media (max-width: 480px) {
    .chatbot-header {
        padding: 10px 12px;
    }
    
    .chatbot-messages {
        padding: 12px;
    }
    
    .chatbot-input-container {
        padding: 12px;
    }

    .chatbot-input {
        width: 100%;
        padding: 6px 12px;
    }
    
    .chatbot-suggestions {
        padding: 0 12px 12px;
    }
    
    .chatbot-suggestions-buttons {
        gap: 6px;
        display: flex;
    }
    
    .chatbot-suggestion-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
    
    .chatbot-message-content {
        max-width: 80%;
    }
}
