* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Helvetica Neue', Arial, sans-serif;
}

body {
    background-color: #ffffff;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 画面全体のスクロールを防止 */
}

header {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    background-color: white;
    font-weight: bold;
}

/* アプリ全体のレイアウト */
.app-layout {
    display: flex;
    height: calc(100vh - 50px); /* ヘッダーの高さを考慮 */
    width: 100%;
}

/* サイドバー */
.sidebar {
    width: 280px;
    background-color: #f5f5f5;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.new-chat-button {
    width: 100%;
    padding: 10px 15px;
    background-color: #4285f4;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.new-chat-button:hover {
    background-color: #3367d6;
}

/* セッションリスト */
.session-list {
    flex: 1;
    overflow-y: auto;
}

.session-category {
    padding: 10px 15px;
    font-size: 0.8rem;
    color: #666;
    font-weight: 500;
}

.session-item {
    padding: 10px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.session-item:hover {
    background-color: #e9e9e9;
}

.session-item.active {
    background-color: #e1f5fe;
    border-left-color: #4285f4;
}

.session-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

.session-menu {
    color: #999;
    padding: 5px;
    visibility: hidden;
}

.session-item:hover .session-menu {
    visibility: visible;
}

/* メインコンテナの変更 */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-container {
    flex: 1;
    overflow-y: auto; /* 常にスクロール可能に設定 */
    padding: 20px;
    scroll-behavior: smooth; /* スクロールをスムーズに */
    margin-bottom: 10px; /* 入力エリアとの間隔 */
}

.message {
    margin-bottom: 20px;
    width: 100%; /* 幅を100%に変更し、コンテナいっぱいに表示 */
}

.user-message {
    background-color: #e1f5fe;
    border-radius: 10px;
    padding: 12px 18px;
    /* text-align: right; テキスト自体は右寄せにする */
    /* margin-left: auto; を削除して右寄せにならないようにする */
}

.ai-message {
    background-color: #f7f7f7;
    border-radius: 10px;
    padding: 12px 18px;
    /* box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); */
    width: 100%;
}

/* マークダウンスタイリング */
.markdown-content {
    line-height: 1.6;
    color: #333;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.markdown-content h1 {
    font-size: 1.8em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
}

.markdown-content h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
}

.markdown-content h3 {
    font-size: 1.3em;
}

.markdown-content p {
    margin-bottom: 1em;
}

.markdown-content ul, 
.markdown-content ol {
    margin-bottom: 1em;
    padding-left: 2em;
}

.markdown-content blockquote {
    padding: 0 1em;
    color: #6a737d;
    border-left: 0.25em solid #dfe2e5;
    margin: 0 0 1em 0;
}

.markdown-content pre {
    background-color: #ffffff; /* 背景色を白に変更 */
    border-radius: 3px;
    padding: 16px;
    overflow: auto;
    margin-bottom: 1em;
    position: relative;
    border: 1px solid #e0e0e0; /* 枠線を追加して視認性を確保 */
}

.markdown-content code {
    background-color: rgba(27, 31, 35, 0.05);
    border-radius: 3px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 85%;
    padding: 0.2em 0.4em;
}

.markdown-content pre code {
    background-color: transparent;
    padding: 0;
    font-size: 100%;
    display: block;
    counter-reset: line;
}

/* 行番号用のスタイル */
.markdown-content pre code .line {
    display: inline-block;
    width: 100%;
    position: relative;
    padding-left: 2em;
    box-sizing: border-box;
    counter-increment: line;
}

.markdown-content pre code .line:before {
    content: counter(line);
    position: absolute;
    left: 0;
    width: 1.5em;
    text-align: right;
    color: #999;
    padding-right: 0.5em;
    border-right: 1px solid #ddd;
    user-select: none;
}

.markdown-content table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1em;
}

.markdown-content table th,
.markdown-content table td {
    padding: 6px 13px;
    border: 1px solid #dfe2e5;
}

.markdown-content table th {
    background-color: #f6f8fa;
    font-weight: 600;
}

.markdown-content img {
    max-width: 100%;
    box-sizing: content-box;
    margin: 1em 0;
}

.markdown-content hr {
    height: 0.25em;
    padding: 0;
    margin: 24px 0;
    background-color: #e1e4e8;
    border: 0;
}

.image-container {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.message-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
}

.input-container {
    padding: 15px;
    background-color: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    align-items: flex-start;
    position: sticky; /* 入力エリアを固定 */
    bottom: 0; /* 画面下部に固定 */
    z-index: 10; /* 他の要素より前面に表示 */
}

.input-area {
    flex: 1;
    position: relative;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    background-color: white;
}

.file-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
    width: 100%;
}

#message-input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 1rem;
    resize: none;
    min-height: 24px;
    max-height: 150px; /* 最大高さを指定 */
    overflow-y: auto; /* 基本的なスクロール設定 */
    line-height: 1.5; /* 明示的に行の高さを設定 */
    padding: 5px;
}

/* スクロールバーのスタイル */
#message-input::-webkit-scrollbar {
    width: 6px;
}

#message-input::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#message-input::-webkit-scrollbar-thumb {
    background: #888;
}

#message-input::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.input-buttons {
    display: flex;
    gap: 8px;
    align-self: flex-end;
    margin-top: 8px;
}

.icon-button {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    font-size: 1.2rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.icon-button:hover {
    background-color: #f5f5f5;
}

.send-button {
    background-color: #4285f4;
    color: white;
    border: none;
    margin-left: 8px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    align-self: flex-end;
}

.send-button:hover {
    background-color: #3367d6;
}

.hidden {
    display: none;
}

.preview-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.preview-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
}

.preview-file {
    width: 60px;
    height: 60px;
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    text-align: center;
    padding: 5px;
}

.remove-preview {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
}

.code-block {
    background-color: #f6f8fa;
    border-radius: 5px;
    padding: 12px;
    margin: 10px 0;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', monospace;
}

.text-input-row {
    display: flex;
    width: 100%;
    align-items: center;
}

/* タイピングインジケータのスタイル */
.typing-indicator {
    padding: 12px 18px;
}

.typing-animation {
    display: inline-flex;
    align-items: center;
    height: 24px;
}

.typing-animation span {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 5px;
    background-color: #888;
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite ease-in-out;
}

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

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

.typing-animation span:nth-child(3) {
    animation-delay: 0.4s;
    margin-right: 0;
}

@keyframes typingAnimation {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

/* エラーメッセージのスタイル */
.error-message .markdown-content {
    color: #d32f2f;
}

/* セッションドロップダウンメニュー */
.session-dropdown-menu {
    background-color: white;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    min-width: 150px;
    z-index: 1000;
}

.session-dropdown-item {
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.9rem;
}

.session-dropdown-item:hover {
    background-color: #f5f5f5;
}

.session-dropdown-item:active {
    background-color: #e9e9e9;
}

/* セッションリストの空の状態 */
.session-empty-state {
    padding: 20px 15px;
    color: #999;
    font-size: 0.9rem;
    text-align: center;
    font-style: italic;
}

/* カメラ関連のスタイル */
.camera-preview {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 200px;
    height: 150px;
    background-color: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

#camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-close-button {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
}

.camera-close-button:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

.camera-status {
    position: absolute;
    bottom: 5px;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 12px;
    padding: 4px 8px;
    text-align: center;
}

.camera-status.error {
    background-color: rgba(255, 0, 0, 0.7);
}

/* アクティブなカメラボタンのスタイル */
.icon-button.camera-active {
    color: #4285f4;
    background-color: rgba(66, 133, 244, 0.1);
}

/* カメラアイコンの点滅アニメーション（撮影中表示） */
@keyframes cameraRecording {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.camera-recording {
    animation: cameraRecording 2s infinite;
}
