/* 基本スタイル */
body {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 18px;
    margin: 0;
    padding: 0;
    background-color: #f0f2f5;
    color: #333;
}

/* チャット画面全体のコンテナ */
.chat-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 500px; /* PCでもモバイルのように表示するための最大幅 */
    margin: 0 auto;
    background-color: #f0f2f5; /* チャットの背景色 */
    min-height: 100vh; /* 内容が少なくても画面全体の高さを確保 */
}

/* メッセージが表示されるエリア */
.chat-area {
    max-height: 60vh; /* チャットウィンドウの最大高さを画面の60%に制限 */
    overflow-y: auto; /* 内容が最大高さを超えたらスクロールバーを表示 */
    width: 100%;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-sizing: border-box;
}

.message-wrapper {
    display: flex;
    flex-direction: column; /* 翻訳テキストのためにcolumnに変更 */
    gap: 4px; /* メッセージと翻訳の間のスペース */
}

.message-wrapper.align-right {
    align-items: flex-end; /* 右揃え */
}
.message-wrapper:not(.align-right) {
    align-items: flex-start; /* 左揃え */
}

/* メッセージバブルの共通スタイル */
.message {
    padding: 12px 18px;
    border-radius: 18px;
    max-width: 80%;
    line-height: 1.6;
    font-size: 16px;
    font-weight: 500;
    word-break: break-word; /* 長いテキストの改行 */
}
.message-translation {
    display: block;
    font-size: 14px;
    color: #555;
    font-weight: 500;
    padding: 0 15px;
}

/* AIのメッセージバブル */
.message.assistant {
    background-color: #ffffff;
    border: 1px solid #e9e9eb;
    border-top-left-radius: 4px;
}

/* ユーザーのメッセージバブル */
.message.user {
    background-color: #007bff;
    color: white;
    border-top-right-radius: 4px;
}

.message.summary {
    background-color: #f62394; /* 「あなたの好きな本」ボタンと同じ色 */
    color: white;
    border-top-left-radius: 4px;
}

/* 下部の要素が縮まないように設定 */
.mic-button-container,
.input-area,
.iframe-container,
.chat-footer {
    flex-shrink: 0;
}


/* マイクボタン */
.mic-button-container {
    padding: 10px 0;
    text-align: center;
}
.mic-button {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 30px;
    padding: 10px 25px;
    display: inline-flex;
    align-items: center;
    gap: 15px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3);
}
.mic-button-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.mic-button-text .en {
    font-size: 12px;
    font-weight: normal;
}
.mic-icon {
    width: 28px;
    height: 28px;
}

/* テキスト入力欄 */
.input-area {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background-color: #f0f2f5;
    border-top: 1px solid #e0e0e0;
}
.text-input {
    flex-grow: 1;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 16px;
    margin-right: 10px;
}
.send-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    width: 24px;
    height: 24px;
    color: #007bff;
}

/* --- ▼ [追加] キーワード検索エリアのスタイル ▼ --- */

/* キーワードと検索ボタンのエリア全体 */
.keyword-search-area {
    padding: 15px;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0; /* このエリアが縮まないように設定 */
}

/* キーワードボタンを囲むコンテナ */
.keyword-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

/* キーワードボタンの基本スタイル */
.keyword-button {
    flex:1;
    background-color: #ffffff; /* 基本は白色 */
    color: #333;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* キーワードボタンがクリック（選択）された時のスタイル */
.keyword-button.selected {
    background-color: #007bff; /* 選択時は青色 */
    color: #ffffff;
    border-color: #007bff;
}

/* 図書館検索ボタン（オレンジ色）のスタイル */
.search-library-button {
    width: 100%;
    padding: 12px;
    background-color: #f39c12; /* オレンジ色 */
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.search-library-button:hover {
    background-color: #e68a00; /* マウスオーバー時にも少し濃いオレンジ色に */
}

/* --- ▲ [追加] スタイルここまで ▲ --- */


/* 下部フッターボタンのエリア */
.chat-footer {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 15px 10px;
    background-color: #f0f2f5;
    border-top: 1px solid #e0e0e0;
    gap: 10px; /* ボタン間の最小スペース */
}

/* 下部フッターボタンの個別スタイル */
.footer-button {
    height: 75px;
    flex: 1;
    border: none;
    border-radius: 12px;
    padding: 12px 5px; /* 左右のパディングを減らす */
    font-size: 12px;
    line-height: 1.4;
    cursor: pointer;
    font-weight: 500;
}

.footer-button.exit, .footer-button.info {
    background-color: #e9e9eb;
    color: #333;
    font-weight: 700;
}
.footer-button.favorite {
    background-color: #f62394;
    color: white; /* テキスト色を追加 */
    font-weight: 700;
}

.footer-button.favorite:disabled {
    background-color: #cccccc; /* // ボタンをグレーアウトします */
    cursor: not-allowed;     /* // マウスカーソルを変更してクリック不可を知らせます */
    opacity: 0.7;            /* // ボタンを少し透明にします */
}

/* iframeを囲むコンテナ */
.iframe-container {
    width: 100%;
    height: 600px;
    padding: 10px;
    box-sizing: border-box; /* パディングをサイズに含める */
    background-color: #f0f2f5; /* チャットウィンドウの背景色と統一 */
}

/* iframeの基本スタイル */
.iframe-container iframe {
    width: 100%;
    height: 100%;
    border: 1px solid #ddd; /* 境界線が必要な場合 */
    border-radius: 8px;   /* 角を丸くする */
}

@media (max-width: 450px) {
    .chat-container{
        max-width: 100%;
    }
}

/* --- ▼ [修正] 要約モーダルのためのCSS ▼ --- */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 2000;
}

.modal-overlay.visible {
    visibility: visible;
    opacity: 1;
}

.modal-content {
    position: relative;
    background-color: white;
    padding: 30px;
    border-radius: 24px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 2001;
    max-height: 80vh;
    overflow-y: auto;
}

.summary-modal-content {
    text-align: left;
}
.info-modal-content {
    text-align: center;
}

.modal-close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 30px;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
    background: none;
    border: none;
    padding: 10px;
}
.modal-close-button:hover {
    color: #333;
}

.summary-text-container {
    margin-top: 20px;
    font-size: 16px;
    line-height: 1.7;
    white-space: pre-wrap;
}
.info-text-container {
    margin-top: 20px;
    font-size: 16px;
    line-height: 1.8;
}
.info-text-container p {
    margin: 8px 0;
}

.modal-close-trigger {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    cursor: pointer;
    background: none;
    border: none;
}

/* --- ▼ [追加] 権限案内モーダルのためのCSS ▼ --- */

.permission-modal-content {
    text-align: center;
}

.permission-guide-container {
    margin: 20px 0;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 8px;
    text-align: left;
    font-size: 15px;
    line-height: 1.7;
}
.permission-guide-container ol {
    padding-left: 20px;
}

.permission-modal-button {
    width: 100%;
    padding: 12px;
    background-color: #007bff;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}
/* --- ▲ 追加ここまで ▲ --- */
