/* =====================================================================
   fax-responsive.css  (v5.12.40)
   画面サイズ別レイアウト調整。desktop-first の既存CSSに対し、
   最後に読み込んで上書きする。3ティア:
     - タブレット: 901px〜1100px
     - 大きめスマホ/小型タブレット: 601px〜900px
     - スマホ: 〜600px
   既存の構造(HTML)は変更せず、CSSのみで各画面をリフローする。
   ===================================================================== */

/* ------- タッチ操作の最低限のヒット領域を全ティア共通で確保 ------- */
@media (max-width:900px){
  nav button,
  button.act, button.ghost, button.danger,
  .miniBtn, .helpBtn, .folderBtn{
    min-height:40px;               /* 指で押しやすい高さ */
  }
  input, select{ height:40px; }    /* iOSでズームしないよう16px相当 */
  input, select, textarea{ font-size:16px; }
  main{ padding:12px; }
}

/* =====================================================================
   タブレット (901px 〜 1100px)
   3カラム一覧は「フォルダ＋一覧」の2カラムにし、プレビューは畳む。
   ダッシュボードは3列、設定は2列。
   ===================================================================== */
@media (min-width:901px) and (max-width:1100px){
  main{ padding:16px; }
  .dashboard{ grid-template-columns:repeat(3,minmax(120px,1fr)); }
  .settingsGrid{ grid-template-columns:repeat(2,minmax(180px,1fr)); }
  .listWorkspace{
    grid-template-columns:160px minmax(0,1fr);
  }
  /* タブレットではプレビュー枠は一覧の下に回す（列では出さない） */
  .previewPane{ grid-column:1 / -1; }
  .previewBox, .previewEmpty{ height:420px; }
}

/* =====================================================================
   大きめスマホ / 小型タブレット (601px 〜 900px)
   一覧はフォルダを横スクロールのチップ列にし、本体は1カラム。
   フォーム系(grid2)は1カラム、ダッシュボードは2〜3列。
   ===================================================================== */
@media (min-width:601px) and (max-width:900px){
  header{ flex-wrap:wrap; gap:8px 12px; padding:10px 12px; }
  header h1{ font-size:15px; }
  nav{ order:3; width:100%; }
  nav button{ flex:1 1 auto; text-align:center; }

  .dashboard{ grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
  .settingsGrid{ grid-template-columns:repeat(2,minmax(0,1fr)); }
  .grid2{ grid-template-columns:1fr; }

  .listWorkspace{ grid-template-columns:1fr; }
  .folderPane{ position:static; }
  /* フォルダを横スクロールのチップ列に */
  .folderTree{ display:flex; gap:8px; overflow-x:auto; padding:4px 2px; -webkit-overflow-scrolling:touch; }
  .folderTree:before{ display:none; }
  .folderBtn{ width:auto; flex:0 0 auto; margin:0; }
  .folderBtn:before{ display:none; }
  .previewPane{ display:block; }
  .previewBox, .previewEmpty{ height:60vh; }
}

/* =====================================================================
   スマホ (〜600px)
   ・ヘッダーはタイトルを小さく、ナビはスクロール可能な横バー
   ・ダッシュボードは2列
   ・3カラム一覧→1カラム、フォルダは横スクロールチップ
   ・幅広テーブル(送信箱/アドレス帳)はカード型に変形
   ・フォーム・設定・スキャン操作は1カラム＆全幅
   ===================================================================== */
@media (max-width:600px){
  body{ font-size:14px; }
  main{ padding:10px; }
  .panel{ padding:12px; border-radius:10px; margin-bottom:12px; }

  /* ---- ヘッダー / ナビ ---- */
  header{ flex-wrap:wrap; gap:6px 8px; padding:8px 10px; }
  header h1{ font-size:14px; width:100%; }
  header #who{ display:none; }               /* 省スペース優先 */
  nav{
    order:3; width:100%;
    flex-wrap:nowrap; overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    padding-bottom:2px;
  }
  nav button{ flex:0 0 auto; white-space:nowrap; padding:8px 12px; }

  /* ---- ダッシュボード ---- */
  .dashboard{ grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin-bottom:12px; }
  .statCard .num{ font-size:19px; }

  /* ---- 検索行 ---- */
  .row{ gap:8px; }
  .row > input, .row > select{ flex:1 1 100%; min-width:0; }

  /* ---- 一覧ワークスペース ---- */
  .listWorkspace{ grid-template-columns:1fr; gap:10px; }
  .folderPane{ position:static; }
  .folderTitle{ margin:2px 0 6px; }
  .folderTree{ display:flex; gap:8px; overflow-x:auto; padding:2px; -webkit-overflow-scrolling:touch; }
  .folderTree:before{ display:none; }
  .folderBtn{ width:auto; flex:0 0 auto; margin:0; padding:8px 12px; }
  .folderBtn:before{ display:none; }
  .folderBtn .count{ margin-left:6px; }

  /* プレビューはスマホでも見られるように下に表示（高さは画面比） */
  .previewPane{ display:block; }
  .previewBox, .previewEmpty{ height:58vh; }
  .sendPreviewBox{ height:52vh; }

  /* ---- フォーム系 ---- */
  .grid2{ grid-template-columns:1fr; gap:10px; }
  label.fld{ font-size:12px; }

  /* ---- 設定 ---- */
  .settingsGrid{ grid-template-columns:1fr; }

  /* ---- スキャン操作 ---- */
  .scanControls{ gap:6px; }
  .scanControls select{ max-width:none; flex:1 1 44%; }
  .scanPanel{ padding:10px; }

  /* ---- 注釈ビューア ---- */
  #viewerWrap{ flex-direction:column; gap:12px; }
  .side{ min-width:0; width:100%; }
  .toolbar{ gap:5px; }

  /* ---- ボタン群は全幅で押しやすく ---- */
  .rowActions{ flex-wrap:wrap; }

  /* =========================================================
     幅広テーブル → カード型（送信箱・アドレス帳・受信一覧の非コンパクト表）
     thead を隠し、各 tr をカード、各 td を「ラベル: 値」の行にする。
     data-label があればラベル表示、無ければ値のみ。
     ※ #view-list のコンパクト4列表は対象外（別途最適化済み）。
     ========================================================= */
  #view-queue table,
  #view-address table{
    border:0; width:100%;
  }
  #view-queue table thead,
  #view-address table thead{
    position:absolute; width:1px; height:1px;
    overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap;
  }
  #view-queue table tr,
  #view-address table tr{
    display:block;
    border:1px solid var(--line);
    border-radius:10px;
    background:#fff;
    padding:8px 10px;
    margin-bottom:10px;
    box-shadow:0 1px 2px rgba(31,41,51,.05);
  }
  #view-queue table td,
  #view-address table td{
    display:flex;
    justify-content:space-between;
    align-items:baseline;
    gap:12px;
    padding:5px 0;
    border:0;
    border-bottom:1px dashed #eef1f4;
    text-align:right;
    white-space:normal;
    overflow-wrap:anywhere;
  }
  #view-queue table td:last-child,
  #view-address table td:last-child{ border-bottom:0; }
  /* ラベル（data-label 優先） */
  #view-queue table td::before,
  #view-address table td::before{
    content:attr(data-label);
    color:var(--sub);
    font-size:11px;
    font-weight:600;
    text-align:left;
    flex:0 0 auto;
  }
  /* 操作セルはラベル不要・ボタンを全幅寄せ */
  #view-queue table td.rowActions,
  #view-address table td.rowActions{
    justify-content:flex-start;
    flex-wrap:wrap;
    text-align:left;
  }
  #view-queue table td.rowActions::before,
  #view-address table td.rowActions::before{ content:""; }
  #view-queue table td .miniBtn,
  #view-address table td .miniBtn{ flex:1 1 auto; }

  /* テーブルを囲うスクロール枠が別にある場合の保険 */
  .tableScroll{ overflow-x:visible; }
}

/* ------- 極小幅 (〜380px, iPhone SE 等) の微調整 ------- */
@media (max-width:380px){
  nav button{ padding:8px 10px; font-size:12px; }
  .dashboard{ grid-template-columns:repeat(2,minmax(0,1fr)); }
  .statCard .num{ font-size:18px; }
  header h1{ font-size:13px; }
}


/* v5.12.41 UI操作・レスポンシブ補正 */
.scanPanelHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
}

.scanStartControls{
  display:block;
}

#scanStartCamera{
  width:100%;
  min-height:48px;
  font-size:16px;
  font-weight:700;
}

@media (max-width:900px){
  input[type="checkbox"],
  input[type="radio"]{
    width:auto;
    height:auto;
    min-height:0;
    flex:0 0 auto;
  }
}

@media (max-width:600px){
  .row > input[type="checkbox"],
  .row > input[type="radio"]{
    flex:0 0 auto;
    min-width:auto;
  }

  .scanPanelHeader{
    align-items:flex-start;
  }
}

@media (min-width:901px) and (max-width:1100px){
  #view-list .previewPane{
    display:block;
  }
}


/* v5.12.42 アドレス帳並び替えUI */
.abSortDirections{
  display:flex;
  align-items:flex-end;
  gap:5px;
}

.abDirBtn{
  white-space:nowrap;
}

.abDirBtn.is-active{
  background:var(--accent);
  border-color:var(--accent);
  color:#fff;
}

.abSortHeader{
  appearance:none;
  display:inline-flex;
  align-items:center;
  gap:4px;
  border:0;
  background:transparent;
  color:inherit;
  padding:0;
  font:inherit;
  font-weight:700;
  cursor:pointer;
  white-space:nowrap;
}

.abSortHeader:hover,
.abSortHeader:focus-visible{
  color:var(--accent);
  text-decoration:underline;
  text-underline-offset:3px;
}

.abSortHeader.is-active{
  color:var(--accent);
}

.abSortMark{
  display:inline-block;
  min-width:1em;
  text-align:center;
  font-size:11px;
  line-height:1;
}

@media (max-width:600px){
  .abSortDirections{
    flex:1 1 100%;
  }

  .abSortDirections .abDirBtn{
    flex:1 1 0;
  }
}
