/* ============================================================
 * shareRemnantUI.css — Phase 1.5 共有残材 CRUD UI
 *
 * 配置: index.html の hi-sb-main 内に <div id="shareRemnantHead"> (上) +
 *        <div id="shareRemnantList"> (検索/sort の下) の 2 分割
 * Mode: 1C 状態 (branch 選択中) のみ表示、1A は hidden で個人在庫 UI に戻る
 * ============================================================ */

#shareRemnantHead[hidden], #shareRemnantList[hidden] { display: none !important; }

#shareRemnantHead , #shareRemnantList {
  margin-bottom: 16px;
  padding: 0;
  background: transparent;
}

/* master 指示 (2026-05-09): 「本社 残材在庫 N 件 ── ＋ 残材を追加」 形式
 * 営業所で共有している感じを出す。シェア中ユーザーのみ表示 (= shouldShow gate) */
#shareRemnantHead .srn-head , #shareRemnantList .srn-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 4px 12px;
  margin: 0 0 14px;
}

#shareRemnantHead .srn-head-title , #shareRemnantList .srn-head-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #18181b;
}
#shareRemnantHead .srn-head-title svg , #shareRemnantList .srn-head-title svg {
  color: #4f46e5;
  flex: 0 0 auto;
}
#shareRemnantHead .srn-head-branch , #shareRemnantList .srn-head-branch {
  font-size: 16px;
  font-weight: 700;
}
#shareRemnantHead .srn-head-sep , #shareRemnantList .srn-head-sep {
  font-size: 12px;
  color: #71717a;
  font-weight: 500;
}
#shareRemnantHead .srn-count , #shareRemnantList .srn-count {
  display: inline-block;
  padding: 2px 8px;
  background: #f4f4f5;
  border-radius: 999px;
  font-size: 11px;
  color: #71717a;
  font-weight: 500;
}
#shareRemnantHead .srn-head-actions , #shareRemnantList .srn-head-actions {
  display: inline-flex;
  gap: 6px;
  flex: 0 0 auto;
}

/* ── 移行 banner ───────────────────────────────────────── */

#shareRemnantHead .srn-banner , #shareRemnantList .srn-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  margin: 0 12px 12px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 6px;
  color: #78350f;
  font-size: 13px;
}

#shareRemnantHead .srn-banner strong , #shareRemnantList .srn-banner strong { color: #b45309; }

/* ── empty / loading ──────────────────────────────────── */

#shareRemnantHead .srn-empty , #shareRemnantList .srn-empty {
  text-align: center;
  color: #a1a1aa;
  padding: 48px 16px;
  font-size: 13px;
}

/* ── table (PC) ───────────────────────────────────────── */

#shareRemnantHead .srn-table-wrap , #shareRemnantList .srn-table-wrap {
  overflow-x: auto;
  margin: 0 8px;
}

#shareRemnantHead .srn-table , #shareRemnantList .srn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#shareRemnantHead .srn-table thead th , #shareRemnantList .srn-table thead th {
  background: #fafafa;
  border-bottom: 1px solid #e4e4e7;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: #52525b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

#shareRemnantHead .srn-table tbody td , #shareRemnantList .srn-table tbody td {
  padding: 10px;
  border-bottom: 1px solid #f4f4f5;
  vertical-align: middle;
}

#shareRemnantHead .srn-table tbody tr:hover , #shareRemnantList .srn-table tbody tr:hover {
  background: #fafafa;
}

#shareRemnantHead .srn-c-len, #shareRemnantList .srn-c-len,
#shareRemnantHead .srn-c-qty , #shareRemnantList .srn-c-qty {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#shareRemnantHead .srn-c-time , #shareRemnantList .srn-c-time {
  white-space: nowrap;
  color: #71717a;
  font-size: 12px;
}

#shareRemnantHead .srn-c-creator , #shareRemnantList .srn-c-creator {
  white-space: nowrap;
  color: #52525b;
  font-size: 12px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#shareRemnantHead .srn-c-act , #shareRemnantList .srn-c-act {
  white-space: nowrap;
  text-align: right;
}

#shareRemnantHead .srn-c-note , #shareRemnantList .srn-c-note {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #52525b;
}

/* ── pager ─────────────────────────────────────────────── */

#shareRemnantHead .srn-pager , #shareRemnantList .srn-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
}

#shareRemnantHead .srn-pager-info , #shareRemnantList .srn-pager-info {
  font-size: 13px;
  color: #71717a;
}

/* ── buttons ───────────────────────────────────────────── */

#shareRemnantHead .srn-btn, #shareRemnantList .srn-btn,
.srn-modal .srn-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid #d4d4d8;
  border-radius: 6px;
  background: #ffffff;
  color: #18181b;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .12s, border-color .12s;
}

#shareRemnantHead .srn-btn:hover, #shareRemnantList .srn-btn:hover,
.srn-modal .srn-btn:hover {
  background: #f4f4f5;
}

#shareRemnantHead .srn-btn:disabled, #shareRemnantList .srn-btn:disabled,
.srn-modal .srn-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#shareRemnantHead .srn-btn-primary, #shareRemnantList .srn-btn-primary,
.srn-modal .srn-btn-primary {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #ffffff;
}
#shareRemnantHead .srn-btn-primary:hover, #shareRemnantList .srn-btn-primary:hover,
.srn-modal .srn-btn-primary:hover {
  background: #4338ca;
  border-color: #4338ca;
}

#shareRemnantHead .srn-btn-secondary, #shareRemnantList .srn-btn-secondary,
.srn-modal .srn-btn-secondary {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #ffffff;
}
#shareRemnantHead .srn-btn-secondary:hover , #shareRemnantList .srn-btn-secondary:hover {
  background: #d97706;
  border-color: #d97706;
}

#shareRemnantHead .srn-btn-ghost, #shareRemnantList .srn-btn-ghost,
.srn-modal .srn-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: #52525b;
  padding: 4px 8px;
}
#shareRemnantHead .srn-btn-ghost:hover , #shareRemnantList .srn-btn-ghost:hover {
  background: #f4f4f5;
  color: #18181b;
}

#shareRemnantHead .srn-btn-danger , #shareRemnantList .srn-btn-danger {
  color: #b91c1c;
}
#shareRemnantHead .srn-btn-danger:hover , #shareRemnantList .srn-btn-danger:hover {
  background: #fef2f2;
  color: #991b1b;
}

/* ── modal ─────────────────────────────────────────────── */

.srn-modal {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 27, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  padding: 16px;
}

.srn-modal-card {
  background: #ffffff;
  border-radius: 8px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  display: flex;
  flex-direction: column;
}

.srn-modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid #e4e4e7;
  font-weight: 600;
  font-size: 15px;
}

.srn-modal-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
}

.srn-modal-foot {
  padding: 12px 18px;
  border-top: 1px solid #e4e4e7;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.srn-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.srn-field > span {
  font-size: 12px;
  color: #52525b;
  font-weight: 500;
}
.srn-field input,
.srn-field select {
  padding: 8px 10px;
  border: 1px solid #d4d4d8;
  border-radius: 6px;
  font-size: 13px;
  background: #ffffff;
}
.srn-field input:focus,
.srn-field select:focus {
  outline: 2px solid #4f46e5;
  outline-offset: -1px;
  border-color: #4f46e5;
}

.srn-field-readonly > div {
  padding: 8px 10px;
  background: #fafafa;
  border-radius: 6px;
  color: #52525b;
  font-size: 13px;
}

.srn-modal-error {
  padding: 8px 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #b91c1c;
  font-size: 12px;
}

.srn-warn-text {
  font-size: 13px;
  line-height: 1.6;
  color: #18181b;
}

.srn-modal-warn .srn-modal-head {
  color: #b91c1c;
}

/* migrate progress */
.srn-migrate-progress {
  margin-top: 12px;
}
.srn-migrate-bar {
  width: 100%;
  height: 8px;
  background: #f4f4f5;
  border-radius: 4px;
  overflow: hidden;
}
.srn-migrate-bar > span {
  display: block;
  height: 100%;
  background: #4f46e5;
  transition: width .3s ease;
  width: 0%;
}
.srn-migrate-text {
  margin-top: 6px;
  font-size: 12px;
  color: #52525b;
  text-align: right;
}

/* ── スマホ (≤720px): card 化 ───────────────────────── */

@media (max-width: 720px) {
  #shareRemnantHead .srn-table thead , #shareRemnantList .srn-table thead { display: none; }
  #shareRemnantHead .srn-table, #shareRemnantList .srn-table,
  #shareRemnantHead .srn-table tbody, #shareRemnantList .srn-table tbody,
  #shareRemnantHead .srn-table tr, #shareRemnantList .srn-table tr,
  #shareRemnantHead .srn-table td , #shareRemnantList .srn-table td { display: block; width: 100%; }
  #shareRemnantHead .srn-table tr , #shareRemnantList .srn-table tr {
    border: 1px solid #e4e4e7;
    border-radius: 8px;
    margin-bottom: 8px;
    padding: 10px 12px;
  }
  #shareRemnantHead .srn-table td , #shareRemnantList .srn-table td {
    padding: 4px 0;
    border-bottom: none;
  }
  #shareRemnantHead .srn-table td.srn-c-act , #shareRemnantList .srn-table td.srn-c-act {
    text-align: right;
    margin-top: 6px;
  }
  #shareRemnantHead .srn-c-len::before , #shareRemnantList .srn-c-len::before { content: '長さ: '; color: #71717a; font-size: 11px; }
  #shareRemnantHead .srn-c-qty::before , #shareRemnantList .srn-c-qty::before { content: '数量: '; color: #71717a; font-size: 11px; }
  #shareRemnantHead .srn-c-note::before , #shareRemnantList .srn-c-note::before { content: 'メモ: '; color: #71717a; font-size: 11px; }
  #shareRemnantHead .srn-c-creator::before , #shareRemnantList .srn-c-creator::before { content: '登録者: '; color: #71717a; font-size: 11px; }
  #shareRemnantHead .srn-c-time::before , #shareRemnantList .srn-c-time::before { content: '更新: '; color: #71717a; font-size: 11px; }
}

@media (max-width: 480px) {
  #shareRemnantHead .srn-head , #shareRemnantList .srn-head {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .srn-modal-card { max-width: 96vw; }
}

/* ── Phase 1.5 v0.5: 残材バー card 形式 (旧 .inv-card-new 踏襲) ── */

.srn-row {
  position: relative;
}
.srn-row .inv-meta {
  font-size: 11px;
  color: #71717a;
}
.srn-row-edit,
.srn-row-del {
  border: 1px solid transparent;
  background: transparent;
  color: #52525b;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 6px;
  white-space: nowrap;
  transition: background-color .12s, color .12s;
}
.srn-row-edit:hover { background: #f4f4f5; color: #18181b; }
.srn-row-del { color: #b91c1c; }
.srn-row-del:hover { background: #fef2f2; color: #991b1b; }
