body {
    font-family: sans-serif;
    margin: 20px;
    line-height: 1.6;
    color: #333;
}

/* --- RAGコントロールヘッダーの修正スタイル (レイアウト崩れ対策) --- */
.rag-controls-header {
    display: flex; /* 要素を横並びにする */
    align-items: center; /* 垂直方向の中央揃え */
    gap: 15px; /* 要素間の間隔 */
    margin-top: 20px; /* H1からの間隔を確保 */
    margin-bottom: 20px; /* 次のセクションとの間隔 */
}

/* rag-controls-header内のラベルは、Flexboxで位置を揃えるため、標準のmarginをリセット */
.rag-controls-header label {
    margin-top: 0;
}

/* リセットボタンのスタイルも、Flexbox制御のためにマージンをリセット */
#resetDocsButton {
    background-color: #dc3545; /* 赤色 */
    padding: 8px 15px;
    margin-left: 0; 
    margin-top: 0; 
}
/* ------------------------------------------------------------- */


/* 全体のコンテナ */
.rag-source-container {
    display: flex;
    gap: 20px;
    margin-top: 10px;
}

/* ファイル一覧エリア */
#fileList {
    flex: 0 0 250px;
    border: 1px solid #ccc;
    padding: 10px;
    max-height: 300px;
    overflow-y: auto;
    background: #f8f8f8;
}

#fileList h3 {
    margin-top: 0;
    font-size: 1.1em;
    color: #333;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
}

#fileList ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#fileList li {
    padding: 5px 0;
    cursor: pointer;
    color: #007BFF;
    text-decoration: underline;
    font-size: 0.9em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#fileList li:hover {
    color: #0056b3;
}

/* ファイル内容表示エリア */
#fileContent {
    flex-grow: 1;
    white-space: pre-wrap;
    background: #eef;
    padding: 10px;
    border: 1px solid #ccc;
    min-height: 50px;
    max-height: 300px;
    overflow-y: auto;
}

#fileContent pre {
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
    padding: 5px 0;
}

/* 貼り付けエリア */
#pasteArea {
    height: 100px; /* 高さを調整 */
}

/* 入力系 */
textarea {
    width: 100%;
    height: 50px;
    margin-top: 5px;
    padding: 8px;
    box-sizing: border-box;
    border: 1px solid #ccc;
}

label {
    display: block;
    margin-top: 15px;
    font-weight: bold;
}

select {
    padding: 8px;
    border: 1px solid #ccc;
    margin-right: 10px;
}

button {
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    margin-top: 10px;
    margin-right: 5px;
}

#saveOcrButton {
    background-color: #007BFF;
}

/* 注意: #resetDocsButtonのスタイルは上でrag-controls-headerに対応済み */

button:disabled {
    background-color: #aaa;
    cursor: not-allowed;
}

/* チャットログ */
#chatLog {
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 10px;
}

#chatLog p {
    background: #f0f0f0;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
}

#chatLog strong {
    color: #333;
    font-weight: bold;
}

/* 貼り付けた画像スタイル */
#fileContent img {
    max-width: 100%;
    height: auto;
    border: 2px solid #555;
    margin-top: 5px;
    display: block;
}

/* OCRステータス表示 */
.ocr-status {
    font-weight: bold;
    padding: 5px 0;
    border-bottom: 1px dashed #ccc;
    margin-bottom: 5px;
    color: orange;
    /* ローディングインジケータ（シンプル版） */
    display: flex;
    align-items: center;
    gap: 10px;
}
/* スピナーアニメーション（オプション） */
.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}