/* 基本スタイル */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #f8f9fa;
}

main {
    flex: 1;
}

/* ログインフォーム */
.card {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid rgba(0,0,0,0.125);
}

/* ボタンスタイル */
.btn-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

/* アラートメッセージ */
.alert {
    margin-bottom: 1.5rem;
}

/* 通知領域 */
.notifications-container {
    height: 60px; /* 固定高さを設定 */
    position: relative;
    overflow: hidden; /* はみ出た内容を隠す */
}

.notifications-container .alert {
    position: absolute;
    width: 100%;
    margin: 0;
    transition: opacity 0.5s;
}

/* ナビゲーション */
.navbar {
    margin-bottom: 1rem;
}

/* フッター */
footer {
    margin-top: auto;
}

/* レスポンシブテーブル対応 */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ユーザーカードスタイル */
.user-card {
    transition: all 0.2s ease;
}

.user-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}

.user-card .card-header {
    padding: 0.75rem 1rem;
}

.user-card .card-body {
    padding: 1rem;
}

.user-card .text-muted {
    font-size: 0.85rem;
}

/* スマホ表示時のボタン調整 */
@media (max-width: 576px) {
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .d-flex.flex-wrap.gap-1 {
        gap: 0.25rem !important;
    }

    .table > :not(caption) > * > * {
        padding: 0.5rem 0.25rem;
    }
}

/* チャットインターフェース - 新規追加 */
.chat-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px 15px;
}

.chat-interface-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 500px;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.chat-title {
    font-size: 1.5rem;
    margin: 0;
    color: #212529;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #f8f9fa;
    scrollbar-width: thin;
    scroll-behavior: smooth;
}

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

.chat-history::-webkit-scrollbar-thumb {
    background-color: #ced4da;
    border-radius: 3px;
}

.welcome-message {
    display: flex;
    margin-bottom: 20px;
    animation: fadeIn 0.5s ease-in-out;
}

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

.message {
    display: flex;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-out;
}

.user-message {
    flex-direction: row-reverse;
    justify-content: flex-end;
    margin-left: auto;
    width: 100%;
    text-align: right;
}

.ai-message, .user-message {
    max-width: 80%;
}

.message-bubble {
    border-radius: 18px;
    padding: 12px 16px;
    max-width: 80%;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.ai-message .message-bubble {
    background-color: #f0f2f5;
    color: #212529;
    border-top-left-radius: 4px;
    margin-left: 12px;
}

.user-message .message-bubble {
    background-color: #0d6efd;
    color: white;
    border-top-right-radius: 4px;
    margin-right: 0;
    margin-left: auto;
}

.ai-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
    background-color: #6c757d;
    color: white;
}

.user-avatar {
    display: none; /* ユーザーアバターを非表示 */
}

.message-content {
    line-height: 1.5;
}

.message-content p {
    margin: 0 0 8px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-timestamp {
    font-size: 0.7rem;
    margin-top: 4px;
    text-align: right;
}

.ai-message .message-timestamp {
    color: #6c757d;
}

.user-message .message-timestamp {
    color: rgba(255, 255, 255, 0.8); /* ユーザーメッセージのタイムスタンプを白色に */
}

.chat-input-container {
    padding: 15px;
    background-color: #fff;
    border-top: 1px solid #e9ecef;
    width: 100%;
    box-sizing: border-box;
}

.message-form {
    display: block;
    width: 100%;
}

/* 入力フォームとボタンのレイアウト改善 - 横並び */
.input-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
}

.chat-input {
    border-radius: 20px;
    padding: 12px 16px;
    resize: none;
    line-height: 1.5;
    min-height: 46px;
    max-height: 120px;
    width: 100%;
    transition: all 0.2s ease;
    box-sizing: border-box;
    margin: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #ced4da transparent;
    font-size: 1rem;
}

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

.chat-input::-webkit-scrollbar-track {
    background: transparent;
}

.chat-input::-webkit-scrollbar-thumb {
    background-color: #ced4da;
    border-radius: 10px;
}

.chat-input:focus {
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    border-color: #86b7fe;
    outline: none;
}

.send-button-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-button {
    border-radius: 50%;
    width: 46px;
    height: 46px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}

.send-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.send-button:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.input-options {
    display: flex;
    justify-content: flex-end; /* 文字カウンタが消えるので右寄せに変更 */
    padding: 5px 5px 0;
}

.char-counter {
    display: none; /* 文字カウンタを非表示 */
}

.typing-indicator {
    display: none; /* 入力中表示を非表示 */
}

.thinking-message {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px 0;
    color: #6c757d;
}

/* レスポンシブ調整 */
@media (max-width: 768px) {
    .chat-container {
        padding: 10px;
    }

    .chat-interface-container {
        height: calc(100vh - 160px);
        min-height: 450px;
    }

    .chat-header {
        padding: 10px 15px;
    }

    .chat-title {
        font-size: 1.2rem;
    }

    .chat-history {
        padding: 15px;
    }

    .message-bubble {
        max-width: 85%;
    }

    .ai-message, .user-message {
        max-width: 85%;
    }
}

@media (max-width: 576px) {
    .chat-interface-container {
        height: calc(100vh - 140px);
        min-height: 400px;
        border-radius: 8px;
    }

    .message-bubble {
        max-width: 90%;
        padding: 10px 12px;
    }

    .ai-message, .user-message {
        max-width: 90%;
    }

    .ai-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
}

/* マークダウン対応のための追加スタイル */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-weight: bold;
    line-height: 1.2;
}

.message-content h1 { font-size: 1.8em; }
.message-content h2 { font-size: 1.6em; }
.message-content h3 { font-size: 1.4em; }
.message-content h4 { font-size: 1.2em; }
.message-content h5 { font-size: 1.1em; }
.message-content h6 { font-size: 1em; }

.message-content a {
    color: #0078d7;
    text-decoration: underline;
}

.message-content a:hover {
    text-decoration: none;
}

.message-content ul,
.message-content ol {
    padding-left: 1.5em;
    margin: 0.5em 0;
}

.message-content li {
    margin-bottom: 0.25em;
}

.message-content code.inline-code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
    white-space: nowrap;
}

.message-content pre.code-block {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 1em;
    border-radius: 5px;
    margin: 1em 0;
    overflow-x: auto;
    position: relative;
}

.message-content pre.code-block code {
    font-family: monospace;
    font-size: 0.9em;
    white-space: pre;
    display: block;
}

/* テーブルのスタイル */
.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

.message-content th,
.message-content td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.message-content th {
    background-color: #f2f2f2;
    font-weight: bold;
}

.message-content tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* 引用のスタイル */
.message-content blockquote {
    padding-left: 1em;
    border-left: 4px solid #ddd;
    color: #666;
    margin: 1em 0;
}
