/* ============================================================
   印刷スタイル
   ============================================================ */

/* 余白設定 */
@page {
    margin: 10mm 8mm;
}

@page :landscape {
    margin: 8mm 12mm;
}

@media print {

    /* 印刷カラー強制 */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body,
    html {
        height: auto !important;
        overflow: visible !important;
    }

    /* ===== ヘッダー: ロゴのみ表示 ===== */
    #header {
        position: static !important;
        height: auto !important;
        background: white !important;
        box-shadow: none !important;
        border-bottom: 1px solid #e0e0e0;
        padding: 8px 16px !important;
        margin-bottom: 5mm;
        display: flex !important;
        align-items: center;
    }

    #header nav,
    #header .is_sp,
    #header .h_menu {
        display: none !important;
    }

    .h_logo {
        display: block !important;
    }

    /* ===== フッター非表示 ===== */
    footer,
    #footer,
    #pagetop,
    #gototop {
        display: none !important;
    }

    /* ===== レイアウト調整 ===== */
    #sb-site {
        margin-top: 0 !important;
    }

    #main {
        height: auto !important;
        overflow: visible !important;
        position: static !important;
    }

    /* ===== 検索条件UI: 印刷では非表示 ===== */
    .search-panel {
        display: none !important;
    }

    /* ===== 地図 + 凡例ラッパー ===== */
    /* A4縦: 297mm - 上下余白20mm - ヘッダー25mm - マージン5mm - テーブル90mm = 157mm → 余裕を見て130mm */
    #map-annotation-wrapper {
        position: relative !important;
        width: 100% !important;
        height: 130mm !important;
        page-break-inside: avoid;
    }

    #js-map {
        width: 100% !important;
        height: 130mm !important;
    }

    /* 航空写真切り替え・レイヤーコントロール非表示 */
    #map-type-toggle,
    #layers-trigger,
    #layers-panel {
        display: none !important;
    }

    /* Google Mapsコントロール非表示 */
    .gm-bundled-control,
    .gm-svpc,
    .gmnoprint:not(.gm-style-cc) {
        display: none !important;
        visibility: hidden !important;
    }

    /* ===== 凡例: 地図の右下に重ねて印刷 ===== */
    #annotation {
        display: block !important;
        position: absolute !important;
        bottom: 5mm !important;
        right: 5mm !important;
        left: auto !important;
        width: 180px !important;
        padding: 10px !important;
        background: white !important;
        border: 1px solid #e0e0e0 !important;
        box-shadow: none !important;
    }

    /* ===== 物件詳細カード（JSで表示中のみ印刷）===== */
    #show-info-card {
        position: static !important;
        margin-left: 0 !important;
        width: 100% !important;
        height: auto !important;
        padding-top: 10px !important;
        overflow: visible !important;
        box-shadow: none !important;
        border-top: 2px solid #e0e0e0;
        page-break-before: auto;
    }

    #close-dialog-info,
    .toggle-show-info-btn-panel {
        display: none !important;
    }

    /* ===== 検索結果テーブル（JSで表示中のみ印刷）===== */
    #search-result {
        position: static !important;
        margin-left: 0 !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        box-shadow: none !important;
        border-top: 2px solid #e0e0e0;
        page-break-before: auto;
    }

    #result-content {
        height: auto !important;
        overflow: visible !important;
    }

    .collabse-bnt-panel,
    #collabse-search-result,
    #toggle-result {
        display: none !important;
    }

    /* テーブル: 上から5件のみ表示 */
    .data-panel {
        overflow: visible !important;
        flex: none !important;
        height: auto !important;
    }

    #result-table {
        min-width: 0 !important;
        width: 100% !important;
        font-size: 11px !important;
    }

    #result-table tbody tr:nth-child(n+11) {
        display: none !important;
    }

    /* ソートUI（矢印）非表示 */
    #result-table thead th::after {
        display: none !important;
    }

    /* 省略インジケーター（10件超の時のみ表示）*/
    #search-result.print-truncated .data-panel::after {
        content: "・・・（以下省略）";
        display: block;
        text-align: center;
        color: #888;
        font-size: 11px;
        padding: 5px 0 3px;
        border-top: 1px dashed #ccc;
    }

    /* サマリー（総件数・総面積）は常に表示 */
    .bottom-panel {
        display: flex !important;
        height: 36px !important;
        font-size: 12px;
    }
}

/* ============================================================
   横向き印刷: テーブルと地図を左右に並べて1ページに収める
   A4横: 210mm - 上下余白16mm - ヘッダー25mm - マージン5mm = 164mm 使用可能
   ============================================================ */
@media print and (orientation: landscape) {

    /* #main をグリッドに変更（フィルターUI非表示のため1行のみ）*/
    #main {
        display: grid !important;
        grid-template-columns: 2fr 3fr;  /* 左:テーブル 40% / 右:地図 60% */
        grid-template-areas: "panel map";
        column-gap: 8mm;
        height: auto !important;
    }

    /* テーブル/詳細カード: 左列 */
    #search-result,
    #show-info-card {
        grid-area: panel;
        border-top: none !important;
        border-right: 1px solid #e0e0e0;
        padding-right: 4mm;
    }

    /* 地図ラッパー: 右列 */
    #map-annotation-wrapper {
        grid-area: map;
        height: 160mm !important;
        position: relative !important;
    }

    #js-map {
        height: 160mm !important;
        border-top: none !important;
    }

    /* パネルなし時: 地図を全幅に */
    #main.print-no-panel {
        grid-template-areas: "map map";
        grid-template-columns: 1fr;
    }

    #main.print-no-panel #map-annotation-wrapper {
        height: 162mm !important;
    }

    #main.print-no-panel #js-map {
        height: 162mm !important;
    }

    /* テーブルを列幅に合わせてコンパクトに */
    #result-table {
        font-size: 10px !important;
    }
}
