/*
 * ファイル詳細モーダル（プレビュー / ファイル情報）— 20260825 モックアップ準拠
 * index.html と project_detail.html の両方から fileviewer.js とセットで読み込む。
 *
 * プレビューはモックアップの「根拠ワード検索・ページ操作」付きビューア:
 *   ツールバー（サイドメニュー開閉 / ページ / 表示サイズ / 根拠ワード / 文書内検索 / ダウンロード）
 *   本体（左: ページサムネイル、右: ページ）
 */
:root{--fd-teal:#00A3AA;}

/* ---- レイヤー・ウィンドウ ---- */
.file-detail-layer{
  position:fixed;inset:0;z-index:135;display:none;align-items:center;justify-content:center;
  padding:clamp(24px,4vw,56px);background:rgba(22,31,31,.58);
}
.file-detail-layer.open{display:flex;}
.file-detail-window{
  position:relative;
  width:min(800px,calc(100vw - 48px));
  height:min(1240px,calc(100vh - clamp(48px,6vh,80px)));
  background:#fff;color:#242424;border:1px solid #D3E1E0;border-radius:10px;
  box-shadow:0 10px 34px rgba(31,51,51,.18);
  overflow:visible;display:flex;flex-direction:column;
  transition:width .28s cubic-bezier(.22,1,.36,1),height .28s cubic-bezier(.22,1,.36,1);
}
.file-detail-window.preview-mode{width:86vw;height:80vh;max-width:none;max-height:none;}

/* ---- ヘッダー ---- */
.file-detail-head{
  height:86px;min-height:86px;flex:0 0 auto;
  display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;column-gap:24px;
  padding:0 72px 0 30px;border-bottom:1px solid #D3E1E0;background:#fff;border-radius:10px 10px 0 0;
}
.file-detail-title-group{display:flex;flex-direction:column;align-items:flex-start;gap:4px;min-width:0;}
.file-detail-title-line{display:flex;align-items:center;gap:22px;min-width:0;max-width:100%;}
.file-detail-title{
  align-self:flex-start;margin:0;min-width:0;font-size:20px;font-weight:600;line-height:1.25;color:#242424;letter-spacing:.01em;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.file-detail-source-link{
  max-width:min(620px,55vw);overflow:hidden;color:#287FF0;font-size:12px;line-height:1.35;
  text-decoration:none;text-overflow:ellipsis;white-space:nowrap;
}
.file-detail-source-link:hover{text-decoration:underline;}
.file-header-project-wrap{position:relative;flex:0 0 20px;width:20px;height:20px;z-index:45;}
.file-header-project-wrap .file-project-add{
  width:20px;height:20px;min-width:20px;padding:0;margin:0;border:1px solid var(--teal,var(--fd-teal));border-radius:2px;
  background:#fff;color:var(--teal,var(--fd-teal));font-family:inherit;font-size:17px;font-weight:400;line-height:1;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
}
.file-header-project-wrap .file-project-add:hover{background:#EAF8F8;color:#008A90;}
.file-header-project-wrap .file-project-save-menu{top:30px;left:-110px;right:auto;}
.file-detail-head-actions{display:flex;align-items:center;align-self:center;height:34px;gap:14px;margin-right:8px;}
.file-detail-tabs{
  display:inline-grid;grid-template-columns:102px 102px;align-items:center;position:relative;
  overflow:hidden;width:210px;height:34px;padding:3px;border:0;border-radius:5px;background:#E2E2E2;
}
.file-detail-tabs::before{
  content:"";position:absolute;left:3px;top:3px;width:102px;height:28px;background:#fff;
  border-radius:4px;box-shadow:0 1px 3px rgba(0,0,0,.14);transform:translateX(0);
  transition:transform .42s cubic-bezier(.4,0,.2,1),box-shadow .24s ease;will-change:transform;
}
.file-detail-tabs.info-active::before{transform:translateX(102px);}
.file-detail-tab{
  width:102px;height:28px;padding:0;border:none;background:transparent;color:#242424;
  font-family:'Hiragino Sans','Hiragino Kaku Gothic ProN','Noto Sans JP',sans-serif;
  font-size:11px;font-weight:700;line-height:11px;cursor:pointer;
  position:relative;z-index:1;border-radius:4px;box-shadow:none;
  display:flex;align-items:center;justify-content:center;
}
.file-detail-tab.active{background:transparent;color:var(--teal,var(--fd-teal));font-weight:700;}
.file-detail-close{
  position:absolute;right:16px;top:50%;transform:translateY(-50%);width:34px;height:34px;
  border:0;border-radius:50%;background:transparent;color:#242424;cursor:pointer;
  display:flex;align-items:center;justify-content:center;z-index:9;
}
.file-detail-close:hover{background:#F0F4F3;}
.file-detail-close svg{width:19px;height:19px;stroke-width:2;}

/* ---- ペイン共通 ---- */
.file-detail-pane{display:none;flex:1;min-height:0;border-radius:0 0 10px 10px;overflow:hidden;}
.file-detail-pane.active{display:flex;animation:fileDetailPaneSwitch .24s cubic-bezier(.22,1,.36,1) both;}
@keyframes fileDetailPaneSwitch{from{opacity:.45;transform:translateY(4px);}to{opacity:1;transform:translateY(0);}}

/* ---- ファイル情報 ---- */
.file-info-pane{
  display:none;flex-direction:column;background:#fff;
  padding:0 32px 32px;overflow-y:auto;overscroll-behavior:contain;
}
.file-info-pane.active{display:block;}
.file-info-card{width:100%;max-width:920px;margin:0 auto;}
.file-info-row{
  display:grid;grid-template-columns:150px minmax(0,1fr);gap:20px;min-height:46px;align-items:center;
  border-bottom:1px solid #D3E1E0;padding:8px 10px;font-size:14px;line-height:1.55;
}
.file-info-label{font-weight:600;color:#4C5755;}
.file-info-value{min-width:0;overflow-wrap:anywhere;}
.file-box-link{
  display:inline-flex;align-items:center;margin-top:18px;color:var(--teal,var(--fd-teal));
  font-size:14px;font-weight:600;line-height:1.4;text-decoration:none;
}
.file-box-link:hover,.file-box-link:focus-visible{text-decoration:underline;}

/* ---- プレビュー ---- */
.file-preview-pane{background:#F6F8F8;color:#242424;flex-direction:column;overflow:hidden;}
.file-preview-pane [hidden]{display:none !important;}
.fpv-toolbar{
  min-height:66px;height:auto;padding:12px 22px;background:#fff;color:#242424;border-bottom:1px solid #D3E1E0;
  display:grid;grid-template-columns:auto minmax(260px,1fr) auto;gap:20px;align-items:center;flex:0 0 auto;
}
.fpv-control-group,.fpv-page-control,.fpv-zoom-control,.fpv-evidence,.fpv-search-box,.fpv-action-group{display:flex;align-items:center;}
.fpv-control-group{gap:14px;white-space:nowrap;}
.fpv-page-control,.fpv-zoom-control{gap:8px;}
.fpv-tool-button{
  width:32px;height:32px;padding:0;border:1px solid transparent;border-radius:18px;background:#fff;color:#4E5757;
  display:inline-flex;align-items:center;justify-content:center;cursor:pointer;font-family:inherit;font-size:14px;font-weight:500;
}
.fpv-tool-button:hover{border-color:#9BCFD0;background:#F0F9F9;color:var(--teal,var(--fd-teal));}
.fpv-tool-button:disabled{opacity:.4;cursor:default;border-color:transparent;background:#fff;color:#4E5757;}
.fpv-tool-button svg{width:19px;height:19px;stroke:currentColor;fill:none;stroke-width:1.8;}
.fpv-sidebar-toggle{border:0;border-radius:0;background:transparent;color:#008A90;}
.fpv-sidebar-toggle:hover{border-color:transparent;background:transparent;opacity:.72;}
.fpv-sidebar-toggle img{display:block;width:22px;height:22px;transition:transform .2s ease;}
.fpv-sidebar-toggle[aria-expanded="false"] img{transform:rotate(180deg);}
.fpv-page-input,.fpv-zoom-value{
  height:32px;border:0;border-radius:6px;background:#F1F4F4;color:#333;text-align:center;
  font-family:'Roboto','Noto Sans JP',sans-serif;font-size:14px;font-weight:500;
}
.fpv-page-input{width:42px;padding:0 4px;outline:none;-moz-appearance:textfield;}
.fpv-page-input::-webkit-outer-spin-button,.fpv-page-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0;}
.fpv-page-input:focus{box-shadow:0 0 0 2px rgba(0,163,170,.18);}
.fpv-page-total{font-family:'Roboto','Noto Sans JP',sans-serif;font-size:14px;font-weight:500;}
.fpv-zoom-value{min-width:57px;padding:7px 10px;display:inline-block;box-sizing:border-box;}
.fpv-toolbar-middle{min-width:0;display:flex;align-items:center;justify-content:flex-end;gap:14px;}
.fpv-evidence{min-width:0;gap:7px;overflow:hidden;}
.fpv-evidence-label{flex:0 0 auto;font-size:12px;font-weight:600;color:#4E5757;}
.fpv-evidence-tags{min-width:0;display:flex;gap:6px;overflow-x:auto;scrollbar-width:none;}
.fpv-evidence-tags::-webkit-scrollbar{display:none;}
.fpv-evidence-tag{
  height:32px;max-width:240px;padding:0 18px;border:1px solid var(--teal,var(--fd-teal));border-radius:17px;
  background:#fff;color:var(--teal,var(--fd-teal));font-family:inherit;font-size:13px;font-weight:500;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer;flex:0 0 auto;
}
.fpv-evidence-tag:hover{background:#EAF8F8;color:#008A90;}
.fpv-evidence-tag.active{background:var(--teal,var(--fd-teal));color:#fff;box-shadow:none;}
.fpv-search-box{
  height:40px;min-width:300px;padding:0 8px 0 13px;border:1px solid #C7D7D6;border-radius:21px;background:#fff;gap:6px;
}
.fpv-search-box:focus-within{border-color:var(--teal,var(--fd-teal));box-shadow:0 0 0 2px rgba(0,163,170,.10);}
.fpv-search-box svg{width:17px;height:17px;stroke:#9BA6A6;fill:none;stroke-width:2;flex:0 0 auto;}
.fpv-search-input{min-width:70px;flex:1;border:0;outline:none;background:transparent;color:#242424;font-family:inherit;font-size:13px;font-weight:500;}
.fpv-search-input::-webkit-search-cancel-button{-webkit-appearance:none;}
.fpv-search-result{min-width:38px;color:#777;font-family:'Roboto','Noto Sans JP',sans-serif;font-size:12px;font-weight:500;text-align:right;white-space:nowrap;}
.fpv-search-nav{width:25px;height:28px;border:0;background:transparent;color:#7C8787;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;padding:0;}
.fpv-search-nav:hover{color:var(--teal,var(--fd-teal));background:#F0F9F9;border-radius:50%;}
.fpv-search-nav svg{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:2;}
.fpv-action-group{gap:10px;}
.fpv-action-button{
  width:40px;height:40px;border:1px solid var(--teal,var(--fd-teal));border-radius:6px;background:#fff;color:var(--teal,var(--fd-teal));
  display:flex;align-items:center;justify-content:center;cursor:pointer;text-decoration:none;padding:0;
}
.fpv-action-button:hover{background:#EAF8F8;color:#008A90;}
.fpv-action-button svg{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:1.8;}

.fpv-body{flex:1;min-height:0;display:flex;background:#F6F8F8;}
.fpv-thumbs{
  width:232px;flex-shrink:0;padding:22px 0 32px;border-right:1px solid #DDE7E6;background:#fff;overflow:auto;
  transition:width .22s ease,padding .22s ease,opacity .16s ease;
}
.fpv-body.thumbs-collapsed .fpv-thumbs{width:0;padding-left:0;padding-right:0;border-right:0;opacity:0;overflow:hidden;}
.fpv-thumb{display:block;width:210px;margin:0 auto 30px;padding:0;border:0;background:transparent;color:#6D7777;font-family:inherit;font-size:12px;text-align:center;cursor:pointer;}
.fpv-thumb-page{width:210px;min-height:64px;margin-bottom:7px;border:1px solid #DADADA;background:#fff;box-shadow:none;overflow:hidden;box-sizing:border-box;}
.fpv-thumb-page canvas{display:block;width:100%;height:auto;}
.fpv-thumb.active .fpv-thumb-page{box-shadow:0 0 0 3px var(--teal,var(--fd-teal));}
.fpv-canvas{
  flex:1;min-width:0;position:relative;overflow:auto;background:#F6F8F8;padding:30px 24px 80px;
  display:flex;flex-direction:column;align-items:center;scroll-behavior:smooth;
}
.fpv-page{
  position:relative;flex-shrink:0;background:#fff;border:1px solid #DADADA;box-shadow:none;margin:0 auto 44px;
  box-sizing:content-box;transform-origin:top center;
}
.fpv-page canvas{display:block;}
.fpv-page.search-hit{box-shadow:0 0 0 3px rgba(0,163,170,.45);}
.fpv-page-overlay{position:absolute;inset:0;pointer-events:none;overflow:hidden;}
.fpv-hit-rect{position:absolute;background:rgba(0,163,170,.28);border-radius:2px;}
/* Word / Excel / テキストなど、HTML として描画するファイル */
.fpv-page.fpv-page-html{
  width:760px;max-width:100%;min-height:620px;padding:28px 38px 26px;color:#242424;
  font-family:inherit;font-size:13px;line-height:1.8;white-space:normal;overflow-wrap:anywhere;
}
.fpv-page.fpv-page-html .file-modal-text{margin:0;padding:0;background:transparent;font-family:inherit;}
.fpv-page.fpv-page-html pre.file-modal-text{white-space:pre-wrap;}
.fpv-page.fpv-page-html table{border-collapse:collapse;font-size:12px;width:100%;}
.fpv-page.fpv-page-html td,.fpv-page.fpv-page-html th{border:1px solid #ddd;padding:4px 8px;}
mark.fpv-mark{background:#FFF3CD;color:inherit;padding:1px 2px;border-radius:2px;}
mark.fpv-mark.current{background:var(--teal,var(--fd-teal));color:#fff;}
/* PDF.js が使えない場合のフォールバック（ブラウザ内蔵ビューア） */
.file-preview-pane iframe{flex:1;min-height:0;width:100%;border:0;background:#F6F8F8;}
.file-detail-loading,.file-detail-error{
  flex:1;display:grid;place-items:center;padding:40px;color:#6D7777;font-size:14px;text-align:center;
}
.file-detail-error{color:#C0392B;}
.fpv-canvas .file-detail-loading,.fpv-canvas .file-detail-error{width:100%;}

@media (max-width:1180px){
  .fpv-toolbar{grid-template-columns:auto minmax(220px,1fr) auto;gap:10px;padding-left:10px;padding-right:10px;}
  .fpv-control-group{gap:8px;}
  .fpv-evidence-label{display:none;}
  .fpv-search-box{min-width:220px;}
  .fpv-evidence{max-width:260px;}
}
@media (max-width:760px){
  .file-detail-layer{padding:20px;}
  .file-detail-window,.file-detail-window.preview-mode{width:calc(100vw - 40px);height:calc(100vh - 40px);}
  .file-detail-head{height:76px;min-height:76px;padding:0 52px 0 16px;column-gap:8px;}
  .file-detail-source-link{max-width:calc(100vw - 160px);}
  .file-detail-head-actions{gap:6px;margin-right:0;}
  .file-detail-tabs{width:152px;grid-template-columns:74px 74px;}
  .file-detail-tabs::before{width:74px;}
  .file-detail-tabs.info-active::before{transform:translateX(74px);}
  .file-detail-tab{width:74px;font-size:11px;}
  .file-detail-close{right:6px;}
  .file-info-pane{padding:18px 16px;}
  .file-info-row{grid-template-columns:105px 1fr;gap:10px;}
  .fpv-toolbar{grid-template-columns:1fr auto;}
  .fpv-toolbar-middle{grid-column:1/-1;grid-row:2;flex-direction:column;align-items:stretch;gap:8px;}
  .fpv-evidence{max-width:none;}
  .fpv-search-box{min-width:0;width:100%;}
  .fpv-zoom-control{display:none;}
  .fpv-thumbs{width:180px;}
  .fpv-thumb,.fpv-thumb-page{width:140px;}
}
@media (prefers-reduced-motion:reduce){
  .file-detail-tabs::before,.file-detail-window,.fpv-thumbs{transition:none;}
  .file-detail-pane.active{animation:none;}
  .fpv-canvas{scroll-behavior:auto;}
}

/* ファイル詳細の「＋ プロジェクトに保存」メニュー（物件詳細と共通のクラス） */
.file-project-save-wrap{position:relative;width:20px;height:20px;flex:0 0 20px;z-index:20;}
.pd-project-save-menu{
  position:absolute;top:30px;left:-110px;width:280px;padding:20px 0 13px;
  background:#fff;border:1px solid #E2E7E6;border-radius:6px;
  box-shadow:0 4px 13px rgba(0,0,0,.22);display:none;overflow:hidden;z-index:30;
}
.pd-project-save-menu.open{display:block;}
.pd-project-save-label{padding:0 26px 10px;color:#A1A5A4;font-size:12px;font-weight:500;}
.pd-project-save-empty{padding:8px 26px;color:#A1A5A4;font-size:12px;}
.pd-project-save-option,.pd-project-save-link{
  width:100%;height:33px;padding:0 26px;border:0;background:#fff;text-align:left;
  font-family:inherit;font-size:13px;font-weight:600;line-height:1.3;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer;
}
.pd-project-save-option:hover,.pd-project-save-link:hover{background:#F2FBFB;}
.pd-project-save-links{margin-top:8px;padding-top:11px;border-top:1px solid #D3E1E0;background:#fff;}
.pd-project-save-link{height:29px;color:var(--teal,var(--fd-teal));}
