/* 列の定義 (Grid Column) */
.grid-colums2{
    grid-template-columns: 1fr 3fr;
    margin: 2rem auto;
    padding: 0px 10px;
}
.grid-colums2-2{
    grid-template-columns: 7fr 5fr;
    margin: 0px 10px;
    padding: 0px 10px;
}
.grid-colums4{
    /* 4つの列を定義し、それぞれ均等な幅 (1fr) にする fr は「fraction（分数）」の単位で、利用可能なスペースの割合を意味します。 */
    /* (例: 100px 200px 50px auto; のようにピクセルやautoも使えます) */
    grid-template-columns: 1fr 1fr 1fr 1fr;
    margin: 2rem auto;
    padding: 0px 10px;
    width: 80%;
}
.grid-colums4-2{
    grid-template-columns: 1fr 1fr 2fr 1fr;
    margin: 0px;
    padding: 0px;
}
.grid-colums5{
    grid-template-columns: 7fr 1fr 1fr 2fr 1fr;
    margin: 0px 10px;
    padding: 0px 10px;
}
.grid-colums8{
    /* 4つの列を定義し、それぞれ均等な幅 (1fr) にする fr は「fraction（分数）」の単位で、利用可能なスペースの割合を意味します。 */
    /* (例: 100px 200px 50px auto; のようにピクセルやautoも使えます) */
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
    margin: 2rem auto;
    padding: 0px 10px;
    width: 80%;
}
.grid-colums13{
    /* grid-template-columns: repeat(auto-fit, minmax(141px, 1fr)); ← ここがポイント */
    gap: 10px 0; /* 縦に隙間、横は0（必要に応じて調整） */
    grid-template-columns: 4fr 4fr 2fr 4fr 1fr;
    /* grid-template-columns: 4fr 4fr 2fr 4fr 1fr 4fr 1fr 4fr 1fr 4fr 1fr 4fr 1fr; */
    font-size: 0.8rem;
    margin: 0px 10px;
    padding: 0px 10px;
    border-width: 0 0 1px 0;
    border-style: solid;
    border-color: #ff3ae1;
    align-items: center; /* 縦中央揃え（オプションで見た目改善） */
}
.grid-container {
    display: grid;              /* Gridコンテナ化 */
    grid-template-rows: auto;   /* 行の定義 (Grid Row) - 必要に応じて */
    gap: 0px;                   /* 1ピクセルの隙間を空ける */
    width: 98%;
}

/* グリッドアイテムのスタイル */
.grid-item {
    /* display: flex;
    justify-content: center;
    align-items: center; */

    min-width: 0;                  /* Gridアイテムが縮むのを許可（重要！） */
    white-space: normal;
    /* word-break: break-word;        /* 長い単語も強制折り返し */
    /* overflow-wrap: anywhere;       現代的な折り返し */
    border: 1px solid #ccc; /* 境界線を追加して表のように見せる */
    padding: 8px 4px;              /* セルの内余白（読みやすく） */
    /* padding: 10px; */
    box-sizing: border-box;
    /* text-align: center; */
}
.grid-item > input,
.grid-item > select {
    /* text-align: center; */
    width: 100%;
}
/* 見出しのスタイル */
.header {
    text-align: center;
    font-weight: bold;
    background-color: #f0f0f0;
}

.text_align{
    text-align: center;
}

.dflex {
    display: flex; 
    /* align-items: center;     上下で中央*/
    align-items: flex-start;    /* 上下で上揃え*/
}
table { 
    border-collapse: collapse; 
    width: 100%; 
}
table td { 
    border: 1px solid #ccc; 
    padding: 5px; 
}

/* 単位リストのテーブル調整 */
table.unit-table {
    table-layout: fixed; /* テーブル幅を固定し、セル幅を均等に分割 */
    width: 100%;
}
table.unit-table td {
    width: 25%; /* 列数（4）に応じて均等に分割 */
    /* text-align: center; */ /* inputタグがあるので不要かも */
}
table.unit-table input[type="text"] {
    width: 100%; /* inputをセルの幅いっぱいに広げる */
    box-sizing: border-box; /* paddingやborderを幅に含める */
    text-align: center;
    border: none; /* セルに境界線があるため、inputの境界線を消す */
}

/* ファイル入力フィールド自体を非表示にする */
.file-input-hidden {
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    z-index: -1;
}

/* カスタムボタンのスタイル (label要素に適用) */
.custom-file-upload {
    display: inline-block;
    padding: 8px 12px;
    cursor: pointer;
    border: 1px solid #ccc;
    background-color: #f9f9f9;
    color: #333;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.custom-file-upload:hover {
    background-color: #e9e9e9;
}

/* フォームのレイアウトを調整する場合 */
.grid-item.dflex-seal {
    display: flex;
    align-items: center;
    gap: 10px; /* 要素間のスペース */
    flex-wrap: wrap; /* 必要に応じて折り返しを許可 */
}

button.width30 {
    min-width: 30%;
    max-width: 30%;
}

.flex-container {
    gap: 10px;              /* for scroll */
    margin-bottom: 10px;    /* for scroll */

    display: flex;          /* Flexboxを有効化 */
    width: 100%;            /* 基準となる幅 */
    padding: 10px;
    justify-content: space-between;  /* 両端のスペースはなし(0) 
    /* justify-content: space-around;  両端のスペースは、アイテム間のスペースの1/2。 */
    /* justify-content: space-evenly;  両端のスペースと、アイテム間のスペースが、すべて完全に同じ広さ */
}
fieldset {
    border: 1px solid #333;   /* 太さ3px、実線、赤っぽい色 */
    padding: 15px;                  /* 内側の余白 */
    margin: 10px 5px;                 /* 外側の余白 */
    border-radius: 10px;             /* 角を丸くする */
    width: 47%;
}
legend {
    color: #333;
    font-weight: bold;
    font-size: 1.2em;
    background-color: #fff;     /* 背景色（必須ではありませんが、罫線を隠すために設定されることが多い） */
    padding: 0 10px;                /* タイトルテキストの左右の余白 */
}

li.grid-container{
    margin: 0 10px;
    padding: 0 10px;
}
.list-item-clickable {
    cursor: pointer;
    transition: ease all 0.45s;
}
.list-item-clickable:hover {
    opacity: 1;
    color: #ff3ae1 !important;
}
.search-field-dest{
    width: 100%;
    height: 58px;
    padding-right: 58px;
}
.search-submit-dest{
    width: 58px;
    height: 58px;
}

/**************** 左側の宛先、品名一覧をスクロール ****************/
/* 親コンテナをフレックスボックスにして高さを制限する */
.item__post_product_01 {
    display: flex;
    flex-direction: column;
    max-height: 90vh; /* 画面の高さの90%までに制限（調整可能） */
}

/* タイトルとボタンが入っている上部エリア */
.wp__title_top_01 {
    flex-shrink: 0; /* 上部は縮まないように固定 */
    background: #fff; /* スクロールした時に下が透けないように */
    z-index: 10;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee; /* 境界線を入れると分かりやすい */
}

/* フォーム部分のみをスクロールさせる */
#document-issue-form {
    flex-grow: 1;
    overflow-x: hidden; /* 横スクロール禁止 */
    overflow-y: auto;   /* 縦スクロールを有効にする */
    padding: 20px 5px;  /* スクロールバーと重ならないように微調整 */
}

/**************** 右側の宛先一覧をスクロール ****************/
/* スクロールコンテナ（テーブル全体を包むdiv） */
.destination-list-scroll {
    max-height: 500px;            /* 表示領域の高さを制限 */
    overflow: hidden;              /* 全体のオーバーフロー隠し（tbodyだけスクロールさせるため） */
    /* overflow-y: auto;              縦スクロールのみ有効 */
    /* overflow-x: hidden;            横はみ出し防止（既にtable-layout: fixedで対応済みならOK） */
    border: 1px solid #ddd;        /* 枠線でエリアを明確に（オプション） */
    width: 100%;
    box-sizing: border-box;
    /* overflow-x: auto; /* 横方向のスクロールを許可 */
    /* white-space: nowrap; グリッドアイテムが改行されないようにする */
}

/* テーブル本体 */
.destination-table {
    width: 100%;                /* 親幅にぴったり収まる */
    table-layout: fixed;        /* 列幅を均等・固定化し、コンテンツが長くてもセルが広がらない */
    border-collapse: separate;  /* separateに変更（border-spacingでヘッダーとボディの隙間調整） */
    /* border-collapse: collapse; 境界線をきれいに */
    border-spacing: 0;
    min-width: 0;               /* 必要に応じて */
}

/* thead（ヘッダー）固定 */
.destination-table thead {
    display: block;             /* blockにして固定 */
    width: 100%;
}

.destination-table thead th {
    position: sticky;           /* 予備でstickyも（一部ブラウザで効く） */
    top: 0;
    z-index: 10;
}

.destination-table th,
.destination-table td {
    border-top: 0;
    border-right: 0;
    border-left: 0;
    border-bottom: 2px solid #ff3ae1;
    cursor: pointer;
    word-break: break-word;     /* 長いテキスト（例: 長い宛名）を強制的に折り返す */
    overflow-wrap: anywhere;    /* 現代ブラウザ対応の折り返し */
    padding: 8px 4px;           /* 読みやすさのために内余白 */
    box-sizing: border-box;
    font-size: 0.8rem;          /* 既存の小さめフォントを継承 */
    vertical-align: top;        /* 上揃え（必要に応じて） */
}

/* tbodyだけスクロール対象 */
.destination-table tbody {
    display: block;             /* blockにしてスクロール可能に */
    max-height: 1450px;         /* theadの高さを引いた値（例: 全体1500px - thead約50px） */
    overflow-y: auto;           /* 縦スクロールのみ */
    overflow-x: hidden;
    width: 100%;
}

/* trの幅を統一（列揃え必須！） */
.destination-table thead tr,
.destination-table tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

/* 列ごとの幅を明示的に指定（5列の場合） */
.destination-table th:nth-child(1),
.destination-table td:nth-child(1) { width: 20%; } /* 宛名法人/個人名：一番長い可能性が高いので広め */
.destination-table th:nth-child(2),
.destination-table td:nth-child(2) { width: 20%; } /* 部署名 */
.destination-table th:nth-child(3),
.destination-table td:nth-child(3) { width: 10%; } /* 担当者名 */
.destination-table th:nth-child(4),
.destination-table td:nth-child(4) { width: 40%; } /* 品名1 */
.destination-table th:nth-child(5),
.destination-table td:nth-child(5) { width: 10%; } /* 単価1 */

/* ヘッダーの見た目（オプション） */
.destination-table th {
    font-weight: bold;
    background-color: #f0f0f0;
    border-bottom: 2px solid #ff3ae1; /* 既存のボーダー色に合わせ */
}

/* グリッドコンテナは親要素の幅を超えても良い */
.destination-list-scroll .grid-container {
    width: fit-content; /* 内容物の幅に合わせる */
    min-width: 100%;    /* 親要素の幅よりは狭くならないようにする */
}

/* スクロールバーの見た目調整（オプション） */
.destination-table tbody::-webkit-scrollbar {
    width: 8px;
}
.destination-table tbody::-webkit-scrollbar-thumb {
    background-color: #aaa;
    border-radius: 4px;
}

.no-border{
    border: 0px;
}

.width80{
    width: 80%;
}

/* 読み取り専用フィールドのスタイル定義 */
input[readonly] {
    /* background-color: #fcfcfc;     背景色を少し暗くして、入力不可であることを示す */
    color: #808080;     /* 文字色を薄い灰色に変更 (placeholderの色に近い) */
    cursor: default;     /* マウスカーソルをデフォルトに戻す (テキスト入力カーソルを非表示にする) */
}
/* ブラウザによっては、readonly時のテキストシャドウで色が変わるのをリセット */
input[readonly]:focus {
    outline: none;
    box-shadow: none;
}

a:hover {
    font-weight: bold;
    color: #ff3ae1 !important;
}

.scroll-full-container{
    max-height: 60vh;             /* ← 高さ制限（お好みで調整、例: 500px または 60vh） */
    overflow-y: auto;              /* 縦スクロール有効 */
    overflow-x: hidden;            /* 横はみ出し防止 */
    border: 1px solid #ddd;        /* 枠線でエリア明確（オプション） */
    margin: 2rem auto;
    position: relative;            /* stickyの基準になる */
    font-size: 0.8rem;
}

/* ヘッダー全体（最初のdisplay:flexのブロック）を固定 */
.scroll-full-container > div:first-child {       /* 最初のヘッダー行（番号 + メイン項目） */
    position: sticky;
    top: 0;
    background: #ffffff;           /* スクロール時も背景白（重ねて見えにくくならないように） */
    z-index: 10;
    border-bottom: 2px solid #ff3ae1; /* 既存のボーダー色に合わせ（オプション） */
}

/* サブヘッダー（品名などの行）も固定 */
.scroll-full-container > div:first-child > div:nth-child(2) > div:nth-child(2) {
    position: sticky;
    top: 50px;                     /* メイン項目の高さに合わせ（約50px、実際の高さで調整） */
    background: #ffffff;
    z-index: 9;
}

/* データ行の共通スタイル（読みやすく） */
.scroll-full-container > div:not(:first-child) {
    border-bottom: 1px solid #eee; /* 行区切り（オプション） */
}

/* 明細行の背景色（既存に合わせ） */
.scroll-full-container > div[style*="background-color"] {
    background-color: #f4b8eb !important; /* 既存の明細背景を優先 */
}

/* 長いテキストの折り返し対策（全セル共通） */
.scroll-full-container span {
    word-break: break-word;        /* 長い文字列を折り返す */
    display: block;                /* spanをブロック化で折り返しやすく */
}


/********************************************************/
/* ツールチップを包む親要素（grid-item）を相対パスに設定 */
.admin-tooltip-container {
    position: relative;
    display: inline-flex; /* 吹き出しの基準にするため必要 */
    align-items: center;
    justify-content: center; /* 中のinputを中央に寄せる */
    width: 100%;            /* grid-itemの幅いっぱいに広げる */
    height: 100%;           /* 高さも合わせる */
}
/* マウスオーバー時に表示される吹き出し本体 （非表示状態） */
.admin-tooltip-container::before {
    content: attr(data-tooltip); /* data-tooltip属性の文字を表示 */
    position: absolute;
    bottom: 120%; /* 入力欄の上に表示 */
    left: 50%;
    transform: translateX(-50%) translateY(10px); /* 少し下に配置しておく */
    padding: 8px 12px;
    background-color: #e4314e; /* 背景色 */
    color: #fff; /* 文字色 */
    font-size: 0.8rem;
    border-radius: 6px;
    white-space: pre-wrap; /* 改行コードを有効にする */
    z-index: 100;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    pointer-events: none; /* マウスイベントを邪魔しない */
    opacity: 0; /* 最初は透明 */
    transition: all 0.3s ease; /* アニメーション設定 */

    /* text-align: center;    改行した時に文字を中央揃えにする */
    width: 300px;         /* 必要に応じて横幅を指定（自動改行しやすくなる） */
}

/* 吹き出しの三角形部分（非表示状態） */
.admin-tooltip-container::after {
    content: "";
    position: absolute;
    bottom: 100%; /* 本体のすぐ下 */
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #e4314e; /* 本体と同じ色で三角形を作る */
    z-index: 100;
    opacity: 0;
    transition: all 0.3s ease;
}

/* ホバー時に表示 */
.admin-tooltip-container:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0); /* 定位置にスライドアップ */
}
.admin-tooltip-container:hover::after {
    opacity: 1;
}
