/**
 * 出走表 × 選手評価 マージビュー スタイル
 * kogisGDP - 競輪AI予想システム
 */

:root {
    --color-primary: #1a73e8;
    --color-secondary: #5f6368;
    --color-success: #34a853;
    --color-warning: #fbbc04;
    --color-error: #ea4335;
    --color-bg: #f8f9fa;
    --color-card: #ffffff;
    --color-border: #dadce0;
    --color-text: #202124;
    --color-text-secondary: #5f6368;

    /* 枠番カラー */
    --frame-1: #f0f0f0;
    --frame-2: #000000;
    --frame-3: #e74c3c;
    --frame-4: #3498db;
    --frame-5: #f1c40f;
    --frame-6: #2ecc71;

    /* 車番カラー */
    --car-1: #f0f0f0;
    --car-2: #1a1a1a;
    --car-3: #e74c3c;
    --car-4: #3498db;
    --car-5: #f1c40f;
    --car-6: #2ecc71;
    --car-7: #e67e22;
    --car-8: #e91e8c;
    --car-9: #9b59b6;

    /* 評価カラー */
    --eval-excellent: #e74c3c;
    --eval-good: #3498db;
    --eval-average: #f39c12;
    --eval-poor: #95a5a6;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ヘッダー */
.header {
    text-align: center;
    margin-bottom: 24px;
}

.header h1 {
    font-size: 1.8rem;
    color: var(--color-primary);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
}

/* レース情報 */
.race-info {
    background: var(--color-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.race-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.race-grade {
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: #fff;
    font-weight: bold;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.race-name {
    font-size: 1.4rem;
    font-weight: bold;
}

.race-details {
    display: flex;
    gap: 20px;
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.race-comment {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    border-left: 4px solid var(--color-primary);
}

/* データパネル */
.data-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.panel-item {
    background: var(--color-card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.panel-item h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--color-text);
}

.file-input-wrapper {
    position: relative;
    margin-bottom: 12px;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-input-wrapper label {
    display: block;
    padding: 12px;
    background: #f1f3f4;
    border: 2px dashed var(--color-border);
    border-radius: 8px;
    text-align: center;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.file-input-wrapper:hover label {
    border-color: var(--color-primary);
    background: #e8f0fe;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-secondary {
    background: #e8f0fe;
    color: var(--color-primary);
}

.btn-secondary:hover {
    background: #d2e3fc;
}

.status {
    display: inline-block;
    margin-left: 12px;
    font-size: 0.85rem;
}

.status.success {
    color: var(--color-success);
}

.status.error {
    color: var(--color-error);
}

/* テーブルセクション */
.merge-table-section {
    background: var(--color-card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 24px;
}

.merge-table-section h2 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--color-text);
}

.table-wrapper {
    overflow-x: auto;
}

.merge-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.merge-table th,
.merge-table td {
    padding: 10px 8px;
    text-align: center;
    border: 1px solid var(--color-border);
}

.merge-table thead th {
    background: #f1f3f4;
    font-weight: 600;
    white-space: nowrap;
}

.th-group {
    background: #e8eaed !important;
}

.th-eval {
    background: #e8f0fe !important;
}

.merge-table tbody tr {
    cursor: pointer;
    transition: background 0.2s;
}

.merge-table tbody tr:hover {
    background: #f8f9fa;
}

/* 予想マーク */
.td-prediction {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--eval-excellent);
}

/* 枠番 */
.td-frame {
    font-weight: bold;
    width: 40px;
}

.td-frame.frame-1 { background: var(--frame-1); color: #333; }
.td-frame.frame-2 { background: var(--frame-2); color: #fff; }
.td-frame.frame-3 { background: var(--frame-3); color: #fff; }
.td-frame.frame-4 { background: var(--frame-4); color: #fff; }
.td-frame.frame-5 { background: var(--frame-5); color: #333; }
.td-frame.frame-6 { background: var(--frame-6); color: #fff; }

/* 車番 */
.td-car {
    font-weight: bold;
    width: 40px;
    border-radius: 4px;
}

.car-1 { background: var(--car-1); color: #333; }
.car-2 { background: var(--car-2); color: #fff; }
.car-3 { background: var(--car-3); color: #fff; }
.car-4 { background: var(--car-4); color: #fff; }
.car-5 { background: var(--car-5); color: #333; }
.car-6 { background: var(--car-6); color: #fff; }
.car-7 { background: var(--car-7); color: #fff; }
.car-8 { background: var(--car-8); color: #fff; }
.car-9 { background: var(--car-9); color: #fff; }

.td-name {
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

.td-rank {
    color: var(--color-primary);
    font-weight: 600;
}

.td-style {
    font-weight: 500;
}

.td-score {
    font-weight: 600;
}

.td-rate {
    color: var(--color-text-secondary);
}

/* 評価セル */
.td-eval {
    background: #fafbfc;
}

.td-comment {
    text-align: left;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.no-eval {
    color: #bbb;
}

.eval-excellent {
    color: var(--eval-excellent) !important;
    font-weight: bold;
}

.eval-good {
    color: var(--eval-good) !important;
}

.eval-average {
    color: var(--eval-average) !important;
}

.eval-poor {
    color: var(--eval-poor) !important;
}

.no-data {
    color: var(--color-text-secondary);
    padding: 40px !important;
    font-style: italic;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--color-card);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: var(--color-text-secondary);
    line-height: 1;
}

.modal-close:hover {
    color: var(--color-text);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
    border-bottom: 1px solid var(--color-border);
}

.modal-car-number {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    border-radius: 8px;
}

.modal-header h2 {
    font-size: 1.5rem;
}

.modal-body {
    padding: 24px;
}

.modal-section {
    margin-bottom: 24px;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-section h3 {
    font-size: 1rem;
    color: var(--color-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--color-primary);
}

.modal-table {
    width: 100%;
    border-collapse: collapse;
}

.modal-table th,
.modal-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.modal-table th {
    background: #f8f9fa;
    font-weight: 500;
    width: 25%;
    color: var(--color-text-secondary);
}

.bank-info {
    margin-top: 12px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.9rem;
}

.comment-box {
    margin-top: 12px;
    padding: 12px;
    background: #fffbeb;
    border-radius: 8px;
    border-left: 4px solid var(--color-warning);
    font-size: 0.9rem;
}

.no-eval-section p {
    color: var(--color-text-secondary);
    font-style: italic;
}

/* フッター */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.footer a {
    color: var(--color-primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

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

    .header h1 {
        font-size: 1.4rem;
    }

    .race-details {
        flex-wrap: wrap;
        gap: 10px;
    }

    .merge-table {
        font-size: 0.8rem;
    }

    .merge-table th,
    .merge-table td {
        padding: 6px 4px;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }
}
