/* ============================================================
   portal-shell.css — ポータル共通シェルの寸法と状態の正本
   （SPEC_PORTAL_FOUNDATION §7・Z-1042・2026-11-04）

   portal-shell.js の直後、各ページの inline <style> より前に読む。
   旧 portal-sidebar.js が DOMContentLoaded で注入していた CSS をそのまま移設し、
   状態（折畳み・モバイルドロワー）が初回描画の時点で効くようにした。
   色の正本は portal-ui-standard.css（テーマトークン）。ここは寸法・状態・読み込み表示だけ。
   ============================================================ */

/* ---- 読み込み中の地色カバー（html[data-portal-loading] は portal-shell.js が描画前に付け、完了で外す） ---- */
html[data-portal-loading] body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9998; /* ロゴ overlay（.puruth-page-loading = 9999）の直下・ナビ（1000）の上 */
  background: var(--theme-surface, var(--portal-brand-navy, #050a10));
  pointer-events: none;
}

/* ---- 高さ予約（データ到着で伸びる容器に付ける） ---- */
[data-portal-reserve] { min-height: var(--portal-reserve-h, 220px); }
[data-portal-reserve="sm"] { --portal-reserve-h: 120px; }
[data-portal-reserve="lg"] { --portal-reserve-h: 360px; }

/* ---- サイドバーの折畳み（PC のみ。保存状態は html 属性で描画前に、操作後は .layout の class でも同期） ---- */
@media (min-width: 1025px) {
  :is(html[data-sidebar-collapsed] .layout, .layout.sidebar-collapsed) .sidebar {
    width: 0 !important; min-width: 0 !important;
    overflow: hidden !important; padding: 0 !important; border-right: none !important;
  }
  :is(html[data-sidebar-collapsed] .layout, .layout.sidebar-collapsed) .sidebar-collapse-btn svg { transform: scaleX(-1); }
}
/* transition は初回描画が落ち着いた後（html[data-shell-ready]）だけ。読み込み直後に動かさない */
html[data-shell-ready] .sidebar {
  transition: width 0.22s ease, min-width 0.22s ease,
              padding 0.22s ease, border-width 0.22s ease;
}

/* ---- 開閉ボタン・ハンバーガー・ドロワー（旧 portal-sidebar.js 注入分を移設） ---- */
.sidebar-collapse-btn {
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px; padding: 6px; color: rgba(255,255,255,0.45);
  cursor: pointer; transition: all 0.2s; flex-shrink: 0; width: 32px; height: 32px;
}
.sidebar-collapse-btn:hover { color: #fff; border-color: rgba(0,212,255,0.4); background: rgba(0,212,255,0.06); }
.sidebar-collapse-btn svg { transition: transform 0.22s ease; flex-shrink: 0; }
@media (max-width: 1024px) { .sidebar-collapse-btn { display: none !important; } }
.hamburger-btn {
  display: none; background: transparent; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px; padding: 6px; color: rgba(255,255,255,0.6); cursor: pointer;
  width: 32px; height: 32px; align-items: center; justify-content: center; flex-shrink: 0;
}
.hamburger-btn:hover { color: #fff; border-color: rgba(0,212,255,0.3); }
@media (max-width: 1024px) { .hamburger-btn { display: flex; } }
.mobile-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 199; }
.mobile-overlay.open { display: block; }
@media (max-width: 1024px) {
  .sidebar { position: fixed !important; top: 64px; left: 0; z-index: 200;
    width: 280px; min-width: 280px !important; background: rgba(5,10,16,0.98); transform: translateX(-100%);
    height: calc(100vh - 64px); overflow-y: auto; -webkit-overflow-scrolling: touch;
    border-right: 1px solid rgba(255,255,255,0.08) !important; padding: 24px 0 !important; }
  html[data-shell-ready] .sidebar { transition: transform 0.25s ease; }
  .sidebar.mobile-open { transform: translateX(0); }
}
.nav-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.nav-container { display: flex; align-items: center; justify-content: space-between; }

/* ---- サイドバー内のモジュール見出し（旧 render() 注入分を移設） ---- */
.sidebar-module-toggle {
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 0 24px; margin-bottom: 8px;
  font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.02em;
  color: var(--color-text-secondary, #aaa);
  user-select: none; transition: color 0.2s;
}
.sidebar-module-toggle:hover { color: var(--color-text-primary, #fff); }
.sidebar-toggle-icon { transition: transform 0.2s; flex-shrink: 0; opacity: 0.5; }
.sidebar-module.expanded .sidebar-toggle-icon { transform: rotate(90deg); }
.sidebar-module-menu .sidebar-item { padding-left: 48px; }
.sidebar-section > .sidebar-menu > .sidebar-item { font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.02em; }

/* ---- 共通モバイル対応（旧 portal-sidebar.js 注入分を移設・値は変えていない） ---- */
@media (max-width: 768px) {
  html, body { overflow-x: hidden; }
  .nav-container { padding: 0 12px; height: 56px; }
  .nav-logo { font-size: 1rem; white-space: nowrap; }
  .nav-logo img { height: 12px; }
  .nav-left { gap: 8px; }
  .nav-user-info { display: none !important; }
  .nav-user { padding: 6px 10px; gap: 6px; }
  .nav-user-avatar { width: 26px; height: 26px; font-size: 0.75rem; }
  .nav-breadcrumb { display: none; }
  .nav-container .nav-client, .nav-container .nav-user, .nav-container > .nav-right > .nav-logout-btn { display: none !important; }
  .nav-right { gap: 8px; }
  .nav-logout-btn { padding: 6px 10px; font-size: 0.75rem; }
  #navUserName { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; font-size: 0.75rem !important; }
  .sidebar { top: 56px !important; height: calc(100vh - 56px) !important; }
  .main-content { padding: 20px 16px !important; }
  .page-title { font-size: 1.5rem !important; }
  .page-subtitle { font-size: 0.8125rem; }
}
@media (max-width: 480px) {
  .nav-container { padding: 0 8px; height: 48px; }
  .nav-logo { font-size: 0.875rem; gap: 4px; }
  .nav-logo img { height: 10px; }
  .nav-left { gap: 6px; }
  .nav-right { gap: 4px; }
  .nav-logout-btn { padding: 4px 8px; font-size: 0.6875rem; }
  .nav-logout-btn[onclick*="ChangePassword"] { display: none; }
  .nav-user { padding: 4px 6px; gap: 4px; }
  .nav-user-avatar { width: 22px; height: 22px; font-size: 0.625rem; }
  #navUserName { max-width: 80px; font-size: 0.6875rem !important; }
  .sidebar { top: 48px !important; height: calc(100vh - 48px) !important; }
  .main-content { padding: 12px 10px !important; }
  .page-title { font-size: 1.25rem !important; }
  .page-subtitle { font-size: 0.75rem; }
  .hamburger-btn { width: 44px; height: 44px; padding: 10px; }
  .sidebar-collapse-btn { width: 44px; height: 44px; padding: 10px; }
}
@media (max-width: 360px) {
  .nav-logo { font-size: 0.75rem; gap: 0; }
  .nav-logo img { height: 14px; }
  #navUserName { max-width: 60px; }
  .page-title { font-size: 1.125rem !important; }
}
/* テーブル共通: 横スクロール対応 */
@media (max-width: 768px) {
  .route-table, .data-table, table.data-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .section { padding: 16px; }
  .zone { padding: 16px 12px; }
  .modal { width: 95%; padding: 20px; max-height: 90vh; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; justify-content: center; }
  .section-header { flex-direction: column; align-items: flex-start; }
}

/* ---- 動き軽減 ---- */
@media (prefers-reduced-motion: reduce) {
  .sidebar, .sidebar-collapse-btn svg, .sidebar-toggle-icon { transition: none !important; }
}

/* ---- ナビのアカウントメニュー（旧 renderNavUser 注入分を移設・値は変えていない） ---- */
.nav-client { display:flex; align-items:center; gap:8px; padding:6px 12px; background:rgba(0,212,255,0.08); border:1px solid rgba(0,212,255,0.2); border-radius:6px; }
.nav-client-icon { width:20px; height:20px; border-radius:4px; background:linear-gradient(125deg, #e2cf9a 0%, #c5a45b 100%); display:flex; align-items:center; justify-content:center; font-size:0.625rem; font-weight:700; color:var(--color-primary, #050a10); }
.nav-client-info h3 { font-size:0.8125rem; font-weight:600; margin:0; line-height:1.2; }
.nav-client-info p { font-size:0.6875rem; color:var(--color-text-muted, rgba(255,255,255,0.4)); margin:0; line-height:1.2; }
.nav-user { display:flex; align-items:center; gap:8px; padding:6px 12px; background:rgba(255,255,255,0.03); border:1px solid rgba(255,255,255,0.08); border-radius:6px; }
.nav-user-avatar { width:24px; height:24px; border-radius:50%; background:linear-gradient(125deg, #e2cf9a 0%, #c5a45b 100%); display:flex; align-items:center; justify-content:center; font-size:0.6875rem; font-weight:700; color:var(--color-primary, #050a10); }
.nav-user-info h4 { font-size:0.8125rem; font-weight:600; margin:0; line-height:1.2; }
.nav-user-info p { font-size:0.6875rem; color:var(--color-text-muted, rgba(255,255,255,0.4)); margin:0; line-height:1.2; }
.nav-right { display:flex; align-items:center; gap:12px; }
.nav-client-icon.beta, .nav-user-avatar.beta { background: linear-gradient(135deg, #b0b8c4 0%, #8a929e 50%, #c0c8d4 100%); }
.nav-account-menu { display:none; position:relative; }
.nav-account-menu summary { box-sizing:border-box; width:44px; height:44px; display:flex; align-items:center; justify-content:center; list-style:none; cursor:pointer; border:1px solid var(--color-border,currentColor); border-radius:6px; }
.nav-account-menu summary::-webkit-details-marker { display:none; }
.nav-account-panel { position:absolute; top:calc(100% + 6px); right:0; z-index:220; width:min(280px,calc(100vw - 16px)); padding:14px; background:var(--theme-panel,var(--color-primary)); border:1px solid var(--color-border,currentColor); border-radius:8px; box-shadow:var(--portal-shadow,none); }
.nav-account-company, .nav-account-user { overflow-wrap:anywhere; }
.nav-account-company { margin:0 0 4px; font-size:0.875rem; font-weight:600; }
.nav-account-meta { margin:0; color:var(--color-text-muted); font-size:0.75rem; }
.nav-account-user { margin:12px 0 2px; font-size:0.8125rem; }
.nav-account-action { box-sizing:border-box; width:100%; min-height:44px; margin-top:14px; padding:8px 12px; color:var(--color-text-secondary); background:transparent; border:1px solid var(--color-border,currentColor); border-radius:6px; cursor:pointer; }
@media (max-width:768px) { .nav-account-menu { display:block; } }

