/* 基本スタイル */
:root {
    --sire-bg-color: #e0f0ff;
    --dam-bg-color: #ffeeff;
    --border-color: #aaa;
    --header-height: 50px;
    --error-color: #ffdddd; /* エラー背景色 */
    --error-border: #ff4444; /* エラー枠色 */
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    margin: 0;
    background-color: #f4f4f4;
}

/* モーダル共通 */
.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;
    z-index: 1000;
}
.modal {
    background-color: white; padding: 20px 40px; border-radius: 8px; text-align: center;
    max-height: 90vh; overflow-y: auto;
}
.modal-buttons {
    margin-top: 20px; display: flex; gap: 10px; justify-content: center;
}
.modal-buttons button {
    padding: 10px 20px; cursor: pointer;
}
.hidden { display: none !important; }

/* 移行ウィザード用 */
.migration-wizard { text-align: left; max-width: 500px; }
.migration-wizard h3 { text-align: center; margin-top: 0; }
.migration-info-box {
    background-color: #f9f9f9; border: 1px solid #ddd; padding: 15px;
    border-radius: 5px; margin: 15px 0;
}
.migration-info-box h4 { margin: 10px 0 5px; border-bottom: 1px solid #eee; padding-bottom: 5px; }
.migration-info-box ul { padding-left: 20px; margin: 5px 0 15px; }
.migration-info-box li { margin-bottom: 8px; }
.inline-list { padding: 0; list-style: none !important; }
.inline-list li {
    display: inline-block; background-color: #eee; padding: 2px 8px;
    border-radius: 4px; font-size: 0.9em; margin-right: 5px; margin-bottom: 5px !important;
}

/* 保存確認モーダル用 */
.save-confirm-modal { text-align: left; max-width: 600px; width: 90%; }
.save-confirm-list { max-height: 60vh; overflow-y: auto; border: 1px solid #ddd; padding: 10px; }
.confirm-card { background: #f9f9f9; border: 1px solid #ccc; margin-bottom: 15px; padding: 15px; border-radius: 5px; }
.confirm-card h4 { margin: 0 0 10px 0; border-bottom: 1px solid #ddd; padding-bottom: 5px; }
.diff-table { width: 100%; border-collapse: collapse; font-size: 0.9em; margin-bottom: 10px; background: white; }
.diff-table th, .diff-table td { border: 1px solid #ddd; padding: 5px; text-align: left; }
.diff-table th { background: #eee; width: 30%; }
.diff-highlight { color: red; font-weight: bold; }
.confirm-options label { display: block; margin-bottom: 8px; cursor: pointer; }
.confirm-options small { display: block; margin-left: 25px; color: #666; font-size: 0.85em; }

/* ヘッダー */
.main-header {
    background-color: #333; color: white; padding: 0 20px;
    display: flex; justify-content: space-between; align-items: center;
    height: var(--header-height); box-sizing: border-box;
}
.header-group { display: flex; gap: 10px; }
.main-header button { padding: 5px 10px; }

/* スマホ用タブ */
.tab-container { display: none; }

/* メインコンテンツ */
.main-container { display: flex; padding: 20px; gap: 20px; }
.form-container { flex: 0 0 450px; }
.preview-container { flex: 1 1 auto; }
.form-container, .preview-container {
    background-color: white; padding: 20px; border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    height: fit-content; max-height: calc(100vh - var(--header-height) - 40px);
    overflow-y: auto;
}

/* 入力フォーム */
.generation-selector { margin-bottom: 20px; }
.horse-input-group {
    margin-bottom: 15px; border-left: 3px solid var(--border-color); padding-left: 10px;
    background-color: #fff;
}
.horse-input-group h3, .horse-input-group h4, .horse-input-group h5 {
    margin: 0 0 5px 0; font-size: 1em; display: flex; justify-content: space-between; align-items: center;
}
.horse-input-group input[type="text"], .horse-input-group input[type="number"] {
    padding: 5px; margin-right: 5px; margin-bottom: 5px; box-sizing: border-box;
    border: 1px solid #ccc; /* デフォルト枠線 */
}
/* バリデーションエラー時のスタイル */
.input-error {
    background-color: var(--error-color) !important;
    border: 1px solid var(--error-border) !important;
}

.input-row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.fictional-check-label { font-size: 0.85em; font-weight: normal; margin-left: 10px; }

.details-input { margin-top: 5px; }
.details-input summary { cursor: pointer; font-size: 0.85em; color: #666; margin-bottom: 5px; }
.details-input .input-row { margin-top: 5px; background: #f9f9f9; padding: 5px; border-radius: 4px; }

.input-name-ja, .input-name-en { width: 12em; }
.input-year { width: 6em; }
.input-detail { width: 8em; }
.input-lineage { width: 12em; } /* 系統入力欄を拡張 */

/* オートコンプリート */
.autocomplete-wrapper { position: relative; display: inline-block;}
.autocomplete-suggestions {
    position: absolute; top: 100%; left: 0; width: 200px;
    max-height: 150px; overflow-y: auto; background: white;
    border: 1px solid #ccc; z-index: 999; box-sizing: border-box;
}
.autocomplete-suggestion { padding: 8px; cursor: pointer; font-size: 0.9em;}
.autocomplete-suggestion:hover { background-color: #f0f0f0; }

/* 画像生成用クローン */
.clone-container-for-image {
    position: absolute; top: 0; left: -9999px;
    background-color: white; padding: 20px;
    font-family: 'Noto Sans JP', sans-serif;
}
.clone-container-for-image .pedigree-table { font-size: 13px; }

/* 血統表プレビュー */
.pedigree-table-wrapper { overflow-x: auto; }
.pedigree-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 550px; }
.pedigree-cell {
    border: 1px solid var(--border-color); padding: 5px;
    vertical-align: middle; text-align: center;
    width: 13em; box-sizing: border-box;
}
.pedigree-cell span { display: block; min-height: 1.2em; }
.pedigree-cell small { display: block; color: #555; font-size: 0.9em; min-height: 1.1em; }
.sire-cell { background-color: var(--sire-bg-color); }
.dam-cell { background-color: var(--dam-bg-color); }
.pedigree-cell[data-col="5"] span { display: inline; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pedigree-cell[data-col="5"] small { display: none; }

/* レスポンシブ対応 */
@media (max-width: 900px) {
    .main-header { font-size: 0.8em; }
    .tab-container { display: flex; background-color: #f4f4f4; }
    .tab-button { flex: 1; padding: 10px; border: none; background-color: #ddd; border-bottom: 2px solid transparent; }
    .tab-button.active { background-color: white; border-bottom: 2px solid #333; font-weight: bold; }
    .main-container { display: block; padding: 0; }
    .tab-content { display: none; border-radius: 0; max-height: calc(100vh - var(--header-height) - 42px); }
    .tab-content.active { display: block; }
    .form-container, .preview-container { width: auto; padding: 15px; }
    .pedigree-table { font-size: 12px; }
    .clone-container-for-image .pedigree-table { font-size: 13px; }
}