/* ==========================================
   z-index優先順位管理CSS
   優先順位: サイドバー > プロフィール・通知ボタン > その他
   ========================================== */

/* ローディング画面のみ最高優先度 */
#instantLoadingScreen {
  z-index: 9999 !important; /* 99999から9999に変更 */
}

/* 最優先: サイドバー関連 (z-index: 2000番台に変更) */
.sidebar,
.mobile-sidebar,
.sidebar-overlay,
nav.sidebar,
aside.sidebar,
[class*="sidebar"] {
  z-index: 2000 !important;
}

.sidebar-toggle,
.menu-toggle,
.hamburger-menu {
  z-index: 2001 !important;
}

/* 第2優先: プロフィール・通知ボタン (z-index: 9000番台) */
.profile-button,
.profile-menu,
.profile-dropdown,
.user-profile-button,
[class*="profile"][class*="button"],
[class*="profile"][class*="menu"] {
  z-index: 1950 !important;
}

.notification-button,
.notification-icon,
.notification-bell,
.notification-badge,
.notification-dropdown,
[class*="notification"][class*="button"],
[class*="notification"][class*="icon"] {
  z-index: 1940 !important;
}

/* 通知ドロップダウン */
.notification-list,
.notification-panel,
.notification-dropdown-content {
  z-index: 1930 !important;
}

/* カレンダー関連 (z-index: 8500番台) */
.fc-popover,
.fc-daygrid-event-harness,
.fc-event,
.fc-daygrid-day-frame,
.fc-more-popover {
  z-index: 1850 !important;
}

/* 第3優先: ヘッダー・ナビゲーション (z-index: 8000番台) */
header,
.header,
.navbar,
.nav-bar,
.top-bar {
  z-index: 1800 !important;
}

/* 第4優先: モーダル・ダイアログ (z-index: 5000番台) */
.modal,
.modal-backdrop,
.modal-overlay,
.dialog {
  z-index: 5000 !important;
}

.modal-content,
.dialog-content {
  z-index: 5100 !important;
}

/* メンバープロフィールモーダル専用 */
#memberProfileModal {
  z-index: 5200 !important;
}

#memberProfileModal .modal-overlay {
  z-index: 5199 !important;
}

#memberProfileModal .modal-content {
  z-index: 5201 !important;
}

/* 第5優先: ドロップダウン・ポップアップ (z-index: 3000番台) */
.dropdown,
.dropdown-menu,
.popover,
.tooltip {
  z-index: 3000 !important;
}

/* 第6優先: カード・パネル (z-index: 1000番台) */
.card:hover,
.panel:hover,
.elevated-card {
  z-index: 1100 !important;
}

/* 基本レイヤー (z-index: 1-100) */
.card,
.panel,
.content-section {
  z-index: 10 !important;
}

/* 特別な調整 */
/* 予約確認モーダル */
.booking-confirmation-modal {
  z-index: 5500 !important;
}

/* イベント詳細モーダル */
#eventDetailModal {
  z-index: 5500 !important;
}

#eventDetailModal .modal-overlay {
  z-index: 5499 !important;
  pointer-events: auto !important;
}

#eventDetailModal .modal-content {
  z-index: 5501 !important;
  pointer-events: auto !important;
}

/* 通知トースト */
.notification-toast,
.toast-notification,
.notification.show {
  z-index: 9999 !important; /* サイドバーの下、ほぼ最前面 */
}

/* モバイル対応 */
@media (max-width: 768px) {
  /* モバイルサイドバーは最優先 */
  .mobile-sidebar,
  .sidebar.mobile-open {
    z-index: 2100 !important;
  }
  
  /* モバイルメニューボタン */
  .mobile-menu-button,
  .mobile-nav-toggle {
    z-index: 2101 !important;
  }
  
  /* モバイル時のプロフィール・通知 */
  .mobile .profile-button,
  .mobile .notification-button {
    z-index: 1960 !important;
  }
}

/* デバッグ用: 開発環境でのみ有効 */
.debug-z-index::after {
  content: attr(data-z-index);
  position: absolute;
  top: 0;
  right: 0;
  background: red;
  color: white;
  padding: 2px 6px;
  font-size: 10px;
  pointer-events: none;
}