/* =========================================================================
   レスポンシブ対応 (スマホ縦 375px〜 / タブレット / ノートPC)
   既存の 1920px 表示に影響を与えないよう、すべて max-width メディアクエリで
   上書きする。ページ側のインライン style を上書きする箇所のみ !important を使用。
   ========================================================================= */

/* --- 全体の文字サイズ縮小 ---
   ページ内の font-size はほぼ rem 指定のため、ルート(html)を縮小するだけで
   ボタン・フォーム・テーブル・サイドバー含む全体が連動して小さくなる。
   大画面（フルHD等）もブラウザ既定の 16px から 15px へ一段下げる。 */
html {
    font-size: 15px;
}

@media (max-width: 991.98px) {
    html {
        font-size: 14px;
    }
}

@media (max-width: 767.98px) {
    html {
        font-size: 13px;
    }
}

@media (max-width: 575.98px) {
    html {
        font-size: 12px;
    }
}

/* --- タブレット以下 (〜991px): 余白圧縮・テーブルは横スクロールで表示 --- */
@media (max-width: 991.98px) {
    .dashboard-main {
        padding: 1rem;
    }

    /* テーブルは列を潰さず横スクロールで見せる
       (コンテナのインライン overflow:hidden を解除するため !important) */
    .dashboard-content .table-responsive,
    .dashboard-content .modern-table-container,
    .table-scroll-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* 一覧系テーブルは最低幅を確保して横スクロールさせる。
       採点画面(.scoring-page)内の小さな補助テーブルは対象外 */
    .dashboard-content:not(.scoring-page) .table-responsive > .table,
    .dashboard-content:not(.scoring-page) .modern-table-container > .table,
    .table-scroll-container > .table {
        min-width: 720px;
    }
}

/* --- スマホ (〜767px): 検索フォームの折返し調整 --- */
@media (max-width: 767.98px) {
    /* 検索フォーム2項目目以降のインデント(ms-3)は折返し時に不揃いになるため解除 */
    .dashboard-content .row > .col-auto {
        margin-left: 0 !important;
    }

    /* 日時レンジ・チェックボックス群は折返しを許可 */
    .dashboard-content .col-auto.d-flex {
        flex-wrap: wrap;
    }

    /* インラインで固定幅指定された入力・選択・入力グループは画面幅を超えない */
    .dashboard-content .form-control,
    .dashboard-content .form-select,
    .dashboard-content .input-group {
        max-width: 100%;
    }
}

/* =========================================================================
   未採点一覧 (NotScoredList) / 採点履歴一覧 (HistoryList): 旧システム(skiw02001)準拠
   横スクロールさせず、文字サイズを極小化して全列を画面幅に収める。
   ========================================================================= */
@media (max-width: 991.98px) {
    /* 共通ルールの min-width(横スクロール) を打ち消して画面幅に収める */
    .dashboard-content.notscored-page .table-responsive > .table,
    .dashboard-content.history-page .table-responsive > .table {
        min-width: 0;
        font-size: 0.7rem !important; /* インライン 0.85rem の上書き */
    }

    .notscored-page .table-responsive th,
    .notscored-page .table-responsive td,
    .history-page .table-responsive th,
    .history-page .table-responsive td {
        padding: 0.25rem 0.15rem;
    }

    .notscored-page .table-responsive th,
    .history-page .table-responsive th {
        white-space: nowrap;
        font-size: 0.65rem;
    }

    .notscored-page .table-responsive .badge,
    .history-page .table-responsive .badge {
        font-size: 0.95em !important; /* セル文字サイズに連動 */
        padding: 0.2em 0.45em;
    }

    .notscored-page .table-responsive .form-check-input,
    .history-page .table-responsive .form-check-input {
        width: 1em;
        height: 1em;
        margin-top: 0;
    }
}

@media (max-width: 767.98px) {
    /* 旧システム同等の極小文字 */
    .dashboard-content.notscored-page .table-responsive > .table,
    .dashboard-content.history-page .table-responsive > .table {
        font-size: 0.62rem !important;
    }

    .notscored-page .table-responsive th,
    .notscored-page .table-responsive td,
    .history-page .table-responsive th,
    .history-page .table-responsive td {
        padding: 0.15rem 0.1rem;
    }

    .notscored-page .table-responsive th,
    .history-page .table-responsive th {
        font-size: 0.58rem;
    }

    /* 上部ボタン群も圧縮して縦の占有を抑える */
    .notscored-page > .d-flex.flex-wrap > .btn,
    .history-page > .d-flex.flex-wrap > .btn {
        font-size: 0.72rem;
        padding: 0.3rem 0.5rem !important;
    }
}

/* --- 未採点一覧/採点履歴: スマホでは検索フォームも圧縮する --- */
@media (max-width: 767.98px) {
    /* フォーム外枠 (p-3/mb-4) の余白圧縮 */
    .notscored-page .dashboard-section > .border.rounded-3,
    .history-page .dashboard-section > .border.rounded-3 {
        padding: 0.5rem !important;
        margin-bottom: 0.75rem !important;
    }

    /* 行間・列間ガターの圧縮 */
    .notscored-page .dashboard-section > .border.rounded-3 .row,
    .history-page .dashboard-section > .border.rounded-3 .row {
        --bs-gutter-x: 0.4rem;
        --bs-gutter-y: 0.2rem;
        margin-bottom: 0.3rem !important; /* mb-2 の圧縮 */
    }

    /* 項目ラベル(バッジ): インライン固定幅(90/110px)を解除して小型化 */
    .notscored-page .dashboard-section > .border.rounded-3 .badge,
    .history-page .dashboard-section > .border.rounded-3 .badge {
        width: auto !important;
        min-width: 4.5em;
        font-size: 0.62rem;
        padding: 0.3rem 0.4rem !important;
    }

    /* 入力・選択・入力グループの文字と余白を縮小 */
    .notscored-page .dashboard-section > .border.rounded-3 .form-control,
    .notscored-page .dashboard-section > .border.rounded-3 .form-select,
    .notscored-page .dashboard-section > .border.rounded-3 .input-group-text,
    .notscored-page .dashboard-section > .border.rounded-3 .btn,
    .history-page .dashboard-section > .border.rounded-3 .form-control,
    .history-page .dashboard-section > .border.rounded-3 .form-select,
    .history-page .dashboard-section > .border.rounded-3 .input-group-text,
    .history-page .dashboard-section > .border.rounded-3 .btn {
        font-size: 0.68rem;
        padding: 0.2rem 0.35rem;
        min-height: 0;
    }

    /* チェックボックスとそのラベル */
    .notscored-page .dashboard-section > .border.rounded-3 .form-check-label,
    .history-page .dashboard-section > .border.rounded-3 .form-check-label {
        font-size: 0.68rem;
    }

    .notscored-page .dashboard-section > .border.rounded-3 .form-check-input,
    .history-page .dashboard-section > .border.rounded-3 .form-check-input {
        width: 0.95em;
        height: 0.95em;
        margin-top: 0.1em;
    }

    /* チェックボックス群・入力グループの間隔圧縮 */
    .notscored-page .dashboard-section > .border.rounded-3 .d-flex.gap-3,
    .history-page .dashboard-section > .border.rounded-3 .d-flex.gap-3 {
        gap: 0.5rem !important;
    }

    /* 広い固定幅入力(250px等)は画面幅に応じて縮める */
    .notscored-page .dashboard-section > .border.rounded-3 .form-control,
    .notscored-page .dashboard-section > .border.rounded-3 .form-select,
    .notscored-page .dashboard-section > .border.rounded-3 .input-group,
    .history-page .dashboard-section > .border.rounded-3 .form-control,
    .history-page .dashboard-section > .border.rounded-3 .form-select,
    .history-page .dashboard-section > .border.rounded-3 .input-group {
        max-width: calc(100vw - 7rem);
    }
}

@media (max-width: 575.98px) {
    /* スマホ縦: ヘッダは折返しを許可して列を最小幅まで縮める */
    .notscored-page .table-responsive th,
    .history-page .table-responsive th {
        white-space: normal;
        font-size: 0.55rem;
    }

    .dashboard-content.notscored-page .table-responsive > .table,
    .dashboard-content.history-page .table-responsive > .table {
        font-size: 0.6rem !important;
    }
}

/* --- スマホ縦 (〜575px): 余白の圧縮 --- */
@media (max-width: 575.98px) {
    .dashboard-main {
        padding: 0.75rem 0.5rem;
    }

    .dashboard-header {
        padding: 0 0.75rem;
    }

    .dashboard-section {
        padding: 1rem 0.75rem;
    }
}
