/* リセットCSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ベーススタイル */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: #f8fafc;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* チャットコンテナ */
.chat-container {
    width: 90%;
    max-width: 800px;
    height: 80vh;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.6s ease-out;
}

/* アニメーション */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

@keyframes fadeIn {
    to { opacity: 1; }
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ヘッダー */
.chat-header {
    background: #1e293b;
    color: white;
    padding: 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.05), transparent);
    animation: shimmer 3s infinite;
}

.chat-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 5px;
    position: relative;
    z-index: 1;
}

.chat-header p {
    opacity: 0.9;
    font-size: 14px;
    position: relative;
    z-index: 1;
}

/* メッセージエリア */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
    position: relative;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #64748b;
    border-radius: 3px;
}

/* メッセージ */
.message {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    animation: fadeIn 0.5s ease-out;
    opacity: 0;
    animation-fill-mode: forwards;
}

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

.message-content {
    max-width: 70%;
    padding: 15px 20px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    margin: 0 10px; /* アバター削除に伴い、左右に少しマージンを追加 */
}

.message.user .message-content {
    background: #475569;
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(71, 85, 105, 0.2);
}

.message.bot .message-content {
    background: #f8fafc;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

/* アバター削除に伴い、メッセージコンテンツが直接 .message の子になるため、
   ユーザーメッセージの場合は text-align を使って右寄せにする */
.message.user {
    justify-content: flex-end; /* これは引き続き有効 */
}

/* 入力エリア */
.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.chat-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
    resize: none;
    min-height: 50px;
    max-height: 120px;
    font-family: inherit;
}

.chat-input:focus {
    border-color: #64748b;
    box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.1);
}

/* 送信ボタン */
.send-button {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: #475569;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(71, 85, 105, 0.2);
}

.send-button:hover {
    background: #334155;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(71, 85, 105, 0.3);
}

.send-button:active {
    transform: translateY(0);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* タイピングインジケーター */
.typing-indicator {
    display: none;
    padding: 15px 20px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    margin-bottom: 20px;
    max-width: 70%;
    margin-left: 10px; /* アバター削除に伴い、左マージン調整 */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #64748b;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* ウェルカムメッセージ */
.welcome-message {
    text-align: center;
    color: #64748b;
    padding: 40px 20px;
    font-style: italic;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .chat-container {
        width: 95%;
        height: 90vh;
        border-radius: 12px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .chat-header h1 {
        font-size: 20px;
    }
}

/* --- サンプル質問ボタンのスタイル --- */
.sample-questions-container {
    display: flex;
    flex-wrap: wrap; /* ボタンが多ければ折り返す */
    gap: 8px; /* ボタン間の隙間 */
    margin-bottom: 12px; /* 入力欄との間のマージン */
    padding: 0 5px; /* コンテナ左右の余白 */
}

.sample-question-button {
    background-color: #f0f4f8; /* やや明るい背景色 */
    color: #333; /* テキストの色 */
    border: 1px solid #d0d7de; /* 控えめな境界線 */
    border-radius: 20px; /* 角を丸くしてカプセル型に */
    padding: 8px 16px; /* 内側の余白 */
    font-size: 0.85em; /* 少し小さめのフォントサイズ */
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease; /* ホバー時のアニメーション */
    text-align: center;
}

.sample-question-button:hover {
    background-color: #e6ecf0; /* ホバー時の背景色 */
    border-color: #b0b9c3;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); /* 軽い影 */
}

.sample-question-button:active {
    background-color: #dde3e8; /* クリック時の背景色 */
    box-shadow: none;
}

/* iframeチャットウィジェットの初期非表示 */
.iframe-chat-widget.hidden {
    display: none;
}

/* --- 右下iframeチャットウィジェットのスタイル --- */
.iframe-chat-widget {
    position: fixed;
    bottom: 80px; /* ボタンの高さ分を考慮して調整 */
    right: 20px;
    width: 350px; /* iframeの幅 */
    height: 500px; /* iframeの高さ */
    border: 1px solid #ccc;
    border-radius: 10px; /* iframeコンテナの角丸 */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    overflow: hidden; /* iframeがはみ出ないように */
    z-index: 1000; /* 他の要素より手前に表示 */
}

.iframe-chat-widget iframe {
    width: 100%;
    height: 100%;
    border: none; /* iframe自体の境界線はなし */
}

/* チャットボット表示切り替えボタン */
.chat-toggle-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #007bff; /* ボタンの背景色 (例: 青) */
    color: white; /* ボタンの文字色 */
    border: none;
    border-radius: 50px; /* 丸みを帯びたボタン */
    padding: 12px 20px; /* 内側の余白 */
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* ボタンの影 */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001; /* iframeコンテナより手前に表示 */
    transition: background-color 0.3s ease;
}

.chat-toggle-button .icon {
    margin-right: 8px;
    font-size: 1.5em; /* アイコンのサイズ */
    line-height: 1; /* アイコンの縦位置調整 */
    transition: transform 0.3s ease-in-out; /* アニメーションのトランジション効果 */
}

/* 閉じるアイコン(✕)がアクティブで、ボタンにホバーした時のアイコンのスタイル */
.chat-toggle-button:hover .icon.close-icon-active {
    transform: rotate(90deg); /* アイコンを90度回転させる */
}