/* ============================================================
 * shareHeader.css — Phase 1.4 ヘッダー営業所スイッチャー / ログイン / ユーザー
 *
 * 配置: index.html の hdr-right (#guideBtn の前) に <div id="shareHeaderRoot">
 * デザイン: 既存ヘッダー (白 / 黒 / グレー基調) と整合、薄紫アクセント
 * ============================================================ */

#shareHeaderRoot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

#shareHeaderRoot .sh-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #d0d6da;
  border-radius: 6px;
  background: #ffffff;
  color: #171819;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .12s ease, border-color .12s ease;
}

#shareHeaderRoot .sh-btn:hover {
  background: #f5fafc;
  border-color: #9da3a7;
}

#shareHeaderRoot .sh-btn:focus-visible {
  outline: 2px solid #1d1e1f;
  outline-offset: 1px;
}

#shareHeaderRoot .sh-btn[aria-expanded="true"] {
  background: #f5fafc;
  border-color: #6d7277;
}

/* Login button: accent 色で目立たせる (= 未ログイン状態の主要 CTA) */
#shareHeaderRoot .sh-login {
  background: #1d1e1f;
  color: #ffffff;
  border-color: #1d1e1f;
}
#shareHeaderRoot .sh-login:hover {
  background: #3a3d40;
  border-color: #3a3d40;
}

#shareHeaderRoot .sh-create-branch {
  background: #f5fafc;
  border-color: #9da3a7;
}

#shareHeaderRoot .sh-icon {
  display: inline-flex;
  align-items: center;
  color: #4f5457;
}
/* v1.31.0 (master 2026-11-25): 営業所の印も黒 (旧 2026-05-10: TORIAI indigo) */
#shareHeaderRoot .sh-branch .sh-icon { color: #1d1e1f; }
#shareHeaderRoot .sh-login .sh-icon { color: #ffffff; }

/* オンライン indicator dot (= branch button 左、online 感を出す) */
#shareHeaderRoot .sh-online-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #1d1e1f; /* v1.31.0: 名前の印も黒 */
  margin-right: 4px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(29, 30, 31, 0.12);
}

#shareHeaderRoot .sh-label {
  display: inline-block;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#shareHeaderRoot .sh-caret {
  margin-left: 2px;
  font-size: 10px;
  color: #6d7277;
}

/* ── dropdown ────────────────────────────────────────────── */

.sh-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 220px;
  background: #ffffff;
  border: 1px solid #d0d6da;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  padding: 4px 0;
  z-index: 1100;
  font-size: 13px;
}

/* root が relative position にないので、dropdown は body 直下に来てしまう。
 * 親に position 与えるため、JS 側で root の親に relative 付与は避け、
 * root 自身を inline-flex + 子 button を relative にする */
#shareHeaderRoot { position: relative; }

/* ログイン前の鳥 (隠し要素)。左上の TORIAI ロゴの右に出す (master 2026-11-25「TORIAI ロゴの右に」、旧 右下)。
   ロゴ (header .logo-image) は左の縦レール (幅 --toriai-rail-w) の右に幅 264px で固定、文字は左から約 130px まで。
   その右の空き (計算ページでは「鋼材種類・規格」の右、入力欄の上) に収まる位置。 */
.sh-login-bird {
  position: fixed;
  display: block;
  z-index: 900;
  left: calc(var(--toriai-rail-w, 60px) + 154px);
  top: 4px; /* 高さ約 60px。中心をロゴの文字 (y 約 34px) にそろえる */
  width: 68px; /* master 2026-11-25「もうひとまわり小さく」(112 → 88 → 68px) */
  line-height: 1;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-5px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}
.sh-login-bird.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.sh-login-bird img {
  display: block;
  width: 100%;
  height: auto;
  /* GIF は 443x394。読み込み前でもカードの大きさを確保する */
  aspect-ratio: 443 / 394;
  /* 背景・枠なし (master 2026-11-25「背景は消してほしい」)。GIF の透明部分はそのまま画面が見える。
     ダークモードでは colorMode.css で反転を戻さず、マスコットと同じく画面と一緒に反転させる (輪郭が明るくなる) */
  image-rendering: pixelated;
}
.sh-login-bird.is-trio img,
.sh-login-bird.is-torch img {
  aspect-ratio: 1 / 1; /* 3 羽歩き 128x128 / トーチの鳥 313x313 */
}
/* 画像 (src) が無いあいだは描かない。src の無い img は大きさがあると枠と壊れた画像の印 (□) が出る */
.sh-login-bird img:not([src]) { visibility: hidden; }

@media (max-width: 768px), print, (prefers-reduced-motion: reduce) {
  .sh-login-bird { display: none !important; }
}
body.mobile-app .sh-login-bird,
body.mobile-shell .sh-login-bird,
body.page-contact .sh-login-bird { display: none !important; }

.sh-dropdown-title {
  padding: 8px 14px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #6d7277;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sh-dropdown-header {
  padding: 10px 14px;
  border-bottom: 1px solid #e0e6e9;
}
.sh-user-name {
  font-weight: 600;
  color: #171819;
  font-size: 14px;
}
.sh-user-meta {
  font-size: 11px;
  color: #6d7277;
  margin-top: 2px;
}
/* U2 (2026-06-07 master): ドロップダウン内 オーナー(role/org)の下に メールアドレス */
.sh-user-email-meta {
  font-size: 11px;
  color: #6d7277;
  margin-top: 3px;
  word-break: break-all;
}

.sh-menu-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}

.sh-menu-list .sh-menu-divider {
  height: 1px;
  background: #e0e6e9;
  margin: 4px 0;
}

.sh-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: #171819;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}
.sh-menu-item:hover {
  background: #f5fafc;
}
.sh-menu-item.is-active {
  font-weight: 600;
}
.sh-menu-item.sh-menu-danger {
  color: #b91c1c;
}
.sh-menu-item.sh-menu-danger:hover {
  background: #fef2f2;
}

.sh-radio {
  display: inline-block;
  width: 14px;
  text-align: center;
  color: #6d7277;
}
.sh-menu-item.is-active .sh-radio {
  color: #1d1e1f;
}

/* ── スマホ (≤720px): icon-only に縮める ─────────────────── */

@media (max-width: 720px) {
  #shareHeaderRoot .sh-branch .sh-label,
  #shareHeaderRoot .sh-user .sh-label {
    display: none;
  }
  #shareHeaderRoot .sh-branch,
  #shareHeaderRoot .sh-user {
    padding: 0 8px;
  }
  /* ログイン / 営業所を作成 はテキスト残す (短いので) */
}

/* ── スマホ (≤480px): 横スクロール無し、要素詰める ────── */

@media (max-width: 480px) {
  #shareHeaderRoot {
    gap: 4px;
  }
  #shareHeaderRoot .sh-btn {
    padding: 0 6px;
    height: 30px;
    font-size: 12px;
  }
  .sh-dropdown {
    min-width: 200px;
    right: -6px;
  }
}
