/* 統一レイアウトの基礎スタイル。
   新しいツール画面もここで定義した .tool-card / 余白の規約に合わせること。 */

body {
  background-color: #f4f5f7;
}

#app-shell {
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  min-width: 240px;
  background-color: #1f2430;
  color: #dfe3ea;
}

.sidebar .brand {
  color: #ffffff;
}

.sidebar .nav-link {
  color: #b8bfcc;
  border-radius: 8px;
}

.sidebar .nav-link:hover {
  background-color: #2a3040;
  color: #ffffff;
}

.sidebar .nav-link.active {
  background-color: #3b82f6;
  color: #ffffff;
}

.sidebar .user-menu {
  color: #dfe3ea;
}

.content-area {
  min-width: 0;
}

.page-header {
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 1rem;
}

/* 各ツールのダッシュボードカードはこのクラスで統一する */
.tool-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  transition: box-shadow 0.15s ease;
}

.tool-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.empty-state {
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  color: #6b7280;
}

/* ------------------------------------------------------------------
   サイドバーの開閉
   開いている状態は <html> の .sidebar-open で表す（初期表示のちらつきを
   避けるため base.html の head 内インラインスクリプトで先に付与する）。
   - PC (>=992px): サイドバーはコンテンツを押し出す。初期は常に開。
   - スマホ (<992px): コンテンツに重ねて表示。初期は閉。
   ------------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background-color: #ffffff;
  border-bottom: 1px solid #e5e7eb;
}

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  color: #374151;
  background-color: transparent;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.sidebar-toggle:hover {
  background-color: #f3f4f6;
  color: #111827;
}

.topbar-brand {
  font-weight: 600;
  color: #1f2430;
  text-decoration: none;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background-color: rgba(15, 23, 42, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* PC: 閉じるときは左へ引き込んでコンテンツを広げる */
@media (min-width: 992px) {
  .sidebar {
    margin-left: -240px;
    transition: margin-left 0.2s ease;
  }

  .sidebar-open .sidebar {
    margin-left: 0;
  }
}

/* スマホ: コンテンツの上に重ねる */
@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1045;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar-open .sidebar {
    transform: translateX(0);
  }

  /* 重ねて表示している間は背面のスクロールを止める */
  .sidebar-open body {
    overflow: hidden;
  }

  .sidebar-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-backdrop {
    transition: none;
  }
}

/* フレックスの子要素は既定で min-width:auto のため、折り返さない長い文字列(text-truncate)が
   あるとコンテンツ領域ごと横に広がる。縮められるようにして省略表示を効かせる。 */
.content-area {
  min-width: 0;
}
