/* ═══════════════════════════════════════════
   Modals - オーバーレイ・ボトムシート・ローダー
   ─── z-index修正: 日付ピッカーが編集モーダルの上に表示 ───
   ═══════════════════════════════════════════ */

/* ─── モーダルオーバーレイ（ベース） ─── */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  justify-content: center;
  align-items: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.show { display: flex; opacity: 1; }

/* ─── z-index 修正：ネストモーダル ─── */
#datePickerOverlay {
  z-index: var(--z-modal-nested);
}

#customPopup {
  z-index: var(--z-modal-nested);
}

#sessionExpiredModal {
  z-index: var(--z-modal-critical);
}

/* ─── モーダルコンテンツ & ポップアップ ─── */
.modal-content,
.popup-box {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  padding: 30px;
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.4s var(--spring);
}

.modal-overlay.show .modal-content,
.modal-overlay.show .popup-box {
  transform: scale(1) translateY(0);
}

/* ─── ボトムシート ─── */
.bottom-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--card-bg-solid);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px 20px calc(env(safe-area-inset-bottom) + 20px);
  box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.1);
  transform: translateY(100%);
  transition: transform 0.4s var(--spring);
}

.modal-overlay.show .bottom-sheet { transform: translateY(0); }

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.sheet-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
}

.sheet-close {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  padding: 8px;
}

.sheet-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 350px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.sheet-item {
  padding: 14px 8px;
  border-radius: var(--radius-lg);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-main);
  text-align: center;
  cursor: pointer;
  transition: all var(--trans-fast);
  background: var(--bg);
}

.sheet-item:hover { background: var(--bg-secondary); }
.sheet-item:active { background: var(--bg-secondary); transform: scale(0.97); }
.sheet-item.selected { background: var(--primary-light); color: var(--primary); }

/* ─── モーダル内パーツ ─── */
.modal-emoji { font-size: 4rem; margin-bottom: 10px; }
.modal-heading { font-size: 1.4rem; font-weight: 800; margin-bottom: 15px; color: var(--text-main); }
.modal-message { text-align: center; color: var(--text-sub); margin-bottom: 24px; line-height: 1.6; font-size: 0.95rem; font-weight: 600; }

.modal-header-bar {
  background: var(--card-bg-solid);
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* ─── ローダー ─── */
#loader {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: var(--z-loader);
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#loader.show { display: flex; opacity: 1; }

.spinner {
  border: 4px solid var(--bg);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
