/* ============================================================
   画面の部品（部員画面・管理画面の共用）— js/ui.js と対
   色は各画面の --primary / --primary-dark を使う
   ============================================================ */

/* ===== シート ===== */
.ui-sheet {
  position: fixed;
  inset: 0;
  z-index: 1800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.ui-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 24, 18, 0.5);
  animation: uiFade 0.18s ease;
}
.ui-sheet-panel {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
  overflow: hidden;
  animation: uiPop 0.2s ease;
}
.ui-sheet-panel.busy { cursor: progress; }
.ui-sheet-grip { display: none; }
.ui-sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.95rem 1rem 0.7rem;
  border-bottom: 1px solid #efe9e1;
}
.ui-sheet-titles { flex: 1 1 auto; min-width: 0; }
.ui-sheet-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.35;
  color: var(--primary-dark, #6b4f0a);
}
.ui-sheet-sub {
  margin-top: 2px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #8a8a8a;
  line-height: 1.5;
}
.ui-sheet-close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #f4f1ec;
  color: #7a6b5b;
  font-size: 1.35rem;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
}
.ui-sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0.9rem 1rem 1rem;
}
.ui-sheet-foot {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid #efe9e1;
}

.ui-btn {
  flex: 1;
  min-height: 46px;
  padding: 0.6rem 0.8rem;
  border: 1.5px solid #e3dcd2;
  border-radius: 12px;
  background: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  color: #6f6559;
  cursor: pointer;
}
.ui-btn.primary {
  background: var(--primary, #a67c52);
  border-color: var(--primary, #a67c52);
  color: #fff;
}
.ui-btn.danger {
  background: #d64541;
  border-color: #d64541;
  color: #fff;
}
.ui-btn:disabled { opacity: 0.55; cursor: default; }
.ui-btn:active:not(:disabled) { transform: scale(0.98); }

@keyframes uiFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes uiPop {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes uiUp {
  from { transform: translateY(100%); }
  to { transform: none; }
}

@media (max-width: 600px) {
  .ui-sheet { padding: 0; align-items: flex-end; }
  .ui-sheet-panel {
    max-width: none;
    max-height: 88vh;
    border-radius: 20px 20px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: uiUp 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .ui-sheet-grip {
    display: block;
    width: 40px;
    height: 4px;
    margin: 8px auto 0;
    border-radius: 99px;
    background: #ddd5ca;
  }
  .ui-sheet-head { padding-top: 0.6rem; }
}

/* ===== 名前の一覧 ===== */
.ui-names-sec + .ui-names-sec {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px dashed #e8e1d7;
}
.ui-names-head {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin: 0 0 0.45rem;
  font-size: 0.88rem;
  font-weight: 800;
  color: #6f6559;
}
.ui-names-sec.k-present .ui-names-head { color: #2e7d32; }
.ui-names-sec.k-absent .ui-names-head { color: #c62828; }
.ui-names-count { font-size: 0.78rem; font-weight: 700; color: #9a9a9a; }
.ui-names-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ui-name-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 0.9rem;
  font-weight: 700;
  background: #f4f2ef;
  color: #666;
  border: 1px solid #e6e1da;
}
.ui-names-sec.k-present .ui-name-chip { background: #e8f5e9; color: #2e7d32; border-color: #c8e6c9; }
.ui-names-sec.k-absent .ui-name-chip { background: #ffebee; color: #c62828; border-color: #ffcdd2; }
.ui-name-chip em {
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.7);
}
.ui-names-empty { font-size: 0.85rem; color: #b8b8b8; }

/* ===== 保存・送信の状態（画面下の帯） ===== */
.sync-bar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h, 0px) + 14px + env(safe-area-inset-bottom));
  z-index: 95;
  max-width: calc(100% - 32px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.55rem 1.2rem;
  border: none;
  border-radius: 99px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  background: rgba(45, 45, 45, 0.94);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 0.22s ease, transform 0.22s ease, background-color 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sync-bar.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}
.sync-bar[data-state="saving"] { cursor: default; }
.sync-bar[data-state="saved"] { background: #2e8b47; cursor: default; }
.sync-bar[data-state="pending"] { background: var(--primary-dark, #6b4f0a); }
.sync-bar[data-state="error"] { background: #d64541; }
.sync-bar[data-state="offline"] { background: #555; }
