/* ============================================================
 * 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 #d4d4d8;
  border-radius: 6px;
  background: #ffffff;
  color: #18181b;
  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: #f4f4f5;
  border-color: #a1a1aa;
}

#shareHeaderRoot .sh-btn:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 1px;
}

#shareHeaderRoot .sh-btn[aria-expanded="true"] {
  background: #f4f4f5;
  border-color: #71717a;
}

/* Login button: accent 色で目立たせる (= 未ログイン状態の主要 CTA) */
#shareHeaderRoot .sh-login {
  background: #4f46e5;
  color: #ffffff;
  border-color: #4f46e5;
}
#shareHeaderRoot .sh-login:hover {
  background: #4338ca;
  border-color: #4338ca;
}

#shareHeaderRoot .sh-create-branch {
  background: #f4f4f5;
  border-color: #a1a1aa;
}

#shareHeaderRoot .sh-icon {
  display: inline-flex;
  align-items: center;
  color: #52525b;
}
/* master 仕様 (2026-05-10): branch icon は TORIAI indigo */
#shareHeaderRoot .sh-branch .sh-icon { color: #4f46e5; }
#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: #4f46e5;
  margin-right: 4px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.18);
}

#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: #71717a;
}

/* ── dropdown ────────────────────────────────────────────── */

.sh-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 220px;
  background: #ffffff;
  border: 1px solid #d4d4d8;
  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; }

.sh-dropdown-title {
  padding: 8px 14px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #71717a;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sh-dropdown-header {
  padding: 10px 14px;
  border-bottom: 1px solid #e4e4e7;
}
.sh-user-name {
  font-weight: 600;
  color: #18181b;
  font-size: 14px;
}
.sh-user-meta {
  font-size: 11px;
  color: #71717a;
  margin-top: 2px;
}

.sh-menu-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}

.sh-menu-list .sh-menu-divider {
  height: 1px;
  background: #e4e4e7;
  margin: 4px 0;
}

.sh-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: #18181b;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}
.sh-menu-item:hover {
  background: #f4f4f5;
}
.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: #71717a;
}
.sh-menu-item.is-active .sh-radio {
  color: #4f46e5;
}

/* ── スマホ (≤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;
  }
}
