/* ========================================
   公式記録入力画面 CSS
   移植元: tmp/redesign-discussion/mocks/official_record_input.html (行8-350)
   ======================================== */

/* 基本フォント */
body.official-record-body {
    font-family: 'BIZ UDPGothic', 'Meiryo', 'MS PGothic', sans-serif;
    font-size: 11px;
    margin: 0;
    padding: 10px;
    padding-bottom: 50vh;
    background: #f5f5f5;
}

/* テーブル共通 */
.official-record-body table { border-collapse: collapse; }
.official-record-body td,
.official-record-body th {
    border: 1px solid #333;
    padding: 2px 3px;
    white-space: nowrap;
    overflow: hidden;
    text-align: center;
    vertical-align: middle;
}

/* ラベルセル（背景なし） */
.official-record-body .label-cell {
    font-weight: normal;
    background: #f0f0f0;
}

/* 入力セル */
.official-record-body .input-cell {
    background: #fff;
}

/* ヘッダー用 */
.header-title {
    font-size: 16px;
    font-weight: bold;
}

/* 大会名 */
.tournament-name {
    font-size: 13px;
    font-weight: bold;
}

/* 小さいフォント */
.small-font { font-size: 9px; }
.mid-font { font-size: 10px; }

/* 選手行 */
.player-row td { height: 22px; }

/* 罫線なしセル（.official-record-body td/th より詳細度を高く保つ） */
.official-record-body .no-border { border: none; }
.official-record-body .border-top-thick { border-top: 2px solid #333; }
.official-record-body .border-bottom-thick { border-bottom: 2px solid #333; }

/* 印刷設定 */
/* A4縦(210mm) - 左右余白(3mm×2) = 204mm ≒ 771px @96dpi。
   print-area=1100px なので scale ≦ 771/1100 ≒ 0.70 が必要。安全マージン込みで 68%。 */
@page {
    size: A4 portrait;
    margin: 3mm;
}
@media print {
    body.official-record-body {
        background: white;
        padding: 0;
        margin: 0;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .print-area-wrapper {
        overflow: visible;
    }
    .print-area {
        zoom: 68%;
        box-shadow: none !important;
    }
    .no-print { display: none !important; }
    /* GCS-274: 「先?」placeholder は入力時の操作ヒントなので印刷物には出さない */
    .pk-first-marker.placeholder { color: transparent !important; }
}

/* 用紙コンテナ */
.print-area-wrapper {
    overflow-x: auto;
    max-width: 100%;
}
.print-area {
    background: white;
    width: 1100px;
    min-width: 1100px;
    margin: 0 auto;
    padding: 10px 15px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

/* スコアボード中央 */
.score-board td {
    height: 20px;
}

/* === 入力UI用スタイル === */

/* 編集可能セル：未入力状態 */
.editable {
    cursor: pointer;
    transition: background 0.15s;
    background: #fff9e6 !important;
}
.editable:hover {
    background: #e8f0fe !important;
}
/* 入力済み */
.editable.has-value {
    background: #fff !important;
    color: #1a1a1a;
}
/* カウンターセル押下時 */
.editable[data-type="counter"]:active {
    background: #dbeafe !important;
}
.editable[data-type="counter"] {
    user-select: none;
    -webkit-user-select: none;
}

/* 小モーダル */
.cell-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    background: #fff;
    border: 2px solid #2563eb;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    padding: 10px;
    min-width: 180px;
    max-width: 320px;
    font-size: 13px;
}
/* 得点経過モーダルなど、ボタンが多くて 320px では収まらないものに付与する */
.cell-modal.wide-modal {
    min-width: 480px;
    max-width: 560px;
}
.cell-modal.active {
    display: block;
}
.cell-modal .modal-title {
    font-size: 11px;
    color: #666;
    margin-bottom: 6px;
    font-weight: bold;
    /* ドラッグハンドル: タイトル行をつかむとモーダル全体を移動できる */
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
    /* タッチ時のスクロールを抑制 (pointermove を確実に受け取るため) */
    touch-action: none;
}
.cell-modal input[type="text"],
.cell-modal input[type="number"] {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    outline: none;
}
.cell-modal input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.2);
}
.cell-modal select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    outline: none;
    background: #fff;
}
.cell-modal select:focus {
    border-color: #2563eb;
}
.cell-modal .modal-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    justify-content: flex-end;
}
.cell-modal .btn {
    padding: 4px 14px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}
.cell-modal .btn-ok {
    background: #2563eb;
    color: #fff;
}
.cell-modal .btn-ok:hover {
    background: #1d4ed8;
}
.cell-modal .btn-cancel {
    background: #e5e7eb;
    color: #333;
}
.cell-modal .btn-clear {
    background: #fef2f2;
    color: #dc2626;
    margin-right: auto;
}

/* ボタン選択グリッド */
.btn-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.btn-grid .btn-option {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    background: #f9fafb;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.1s;
    min-width: 36px;
    text-align: center;
}
.btn-grid .btn-option:hover {
    background: #e0e7ff;
    border-color: #818cf8;
}
.btn-grid .btn-option.selected {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
/* 警告・退場種別ボタン / 得点経過記号ボタンの説明ラベル (コードや記号の隣に小さく出す) */
.btn-option-desc {
    font-size: 10px;
    color: #555;
    margin-left: 4px;
}
/* selected 時は親 (.btn-option) が白文字になるので、desc も継承させる */
.btn-grid .btn-option.selected .btn-option-desc {
    color: inherit;
}

/* GCS-274: OG (オウンゴール) ボタン専用スタイル。
   背番号選択モーダルの選手ボタン群末尾に並び、誤選択防止のため
   破線枠 + 薄黄色背景でひと目で区別できるようにする。 */
.btn-grid .btn-option-og {
    min-width: 42px;
    background: #fef3c7;
    border: 1px dashed #d97706;
}

/* GCS-274: 「先」(PK 戦先攻チーム) マーカーセルの未選択時の placeholder スタイル。
   editable 状態のときだけ薄い「先?」を出して操作可能と分かるようにする。
   選択済 (テキスト「先」) のときは通常スタイルに戻る。 */
.pk-first-marker.placeholder {
    color: #9ca3af;
    font-size: 11px;
}

/* 選手選択リスト */
.player-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
}
.player-list .player-item {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.1s;
}
.player-list .player-item:last-child {
    border-bottom: none;
}
.player-list .player-item:hover {
    background: #e0e7ff;
}
.player-list .player-item.selected {
    background: #2563eb;
    color: #fff;
}

/* 時間入力UI */
.time-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.time-input-group .btn-grid {
    margin-bottom: 2px;
}
.time-input-group input {
    width: 80px !important;
    flex: 0 0 80px;
}

/* 署名キャンバス */
.sig-modal {
    min-width: auto;
}
.sig-modal canvas {
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: crosshair;
    display: block;
    background: #fff;
}

/* 署名モード切替 */
.sig-mode-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}
.sig-mode-tab {
    flex: 1;
    padding: 6px 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #f5f5f5;
    color: #555;
    font-size: 13px;
    cursor: pointer;
    text-align: center;
}
.sig-mode-tab.active {
    background: #1a73e8;
    color: #fff;
    border-color: #1a73e8;
    font-weight: bold;
}
.sig-text-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 8px;
    font-size: 20px;
    background: #fff;
}

/* 署名画像 */
.sig-img {
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain;
}

/* オーバーレイ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 999;
}
.modal-overlay.active {
    display: block;
}
/* 備考欄: 入力済み (has-value) なら罫線なしで本文だけ見せる。未入力時は罫線を残してクリック余地を示す。 */
.official-record-body #remark.has-value { border: none; }

/* 印刷時：未入力セルの背景色を消す */
@media print {
    .print-area .editable,
    .print-area .editable:hover,
    .print-area .editable[data-type="counter"]:active {
        cursor: default !important;
        background: white !important;
    }
    /* 備考欄は印刷時に罫線を消す (枠線なしのメモ欄として扱う) */
    .print-area #remark,
    .print-area td.no-border { border: none !important; }
}
