/* style.css: ダッシュボードのレイアウトと見た目。色はtheme.cssの変数だけを使い、ここに色コードを書かない（コーディング規約v4 8章） */
/* PC（768px以上）：左サイドバー＋メイン（01_dashboard_pc.png）／スマホ：ヘッダー＋ハンバーガーメニュー＋下部タブ（02・10） */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* display指定のある要素でもhidden属性で確実に隠す */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg-color);
  color: var(--text-color);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

button,
input {
  font: inherit;
  color: inherit;
}

h1,
h2 {
  margin: 0;
}

/* ---- 共通部品 ---- */

.button {
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--card-bg-color);
  cursor: pointer;
}

.button:hover:not(:disabled) {
  border-color: var(--accent-color);
}

.button:disabled {
  opacity: 0.6;
  cursor: default;
}

.button-primary {
  border-color: var(--accent-color);
  background: var(--accent-color);
  color: var(--card-bg-color);
}

.button-primary:hover:not(:disabled) {
  opacity: 0.9;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--card-bg-color);
}

.input:focus,
.button:focus-visible,
.icon-button:focus-visible,
.nav-item:focus-visible,
.tab-item:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 1px;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  opacity: 0.75;
}

/* エラー等のお知らせ。専用の色変数は持たず、強調色の枠で目立たせる */
.message {
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--accent-color);
  border-left-width: 4px;
  border-radius: 8px;
  background: var(--card-bg-color);
  font-size: 14px;
}

.soon {
  margin-left: 8px;
  font-size: 11px;
  opacity: 0.8;
}

/* ---- 読み込み中・ログイン画面 ---- */

.view-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  opacity: 0.7;
}

.view-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 32px 24px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--card-bg-color);
}

.login-title {
  margin-bottom: 24px;
  font-size: 22px;
  text-align: center;
}

.login-card .button {
  width: 100%;
  margin-top: 8px;
}

/* ---- ログイン後の画面（スマホが基本、PCはメディアクエリで上書き） ---- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border-color);
  background: var(--card-bg-color);
}

.app-name {
  font-size: 17px;
  font-weight: 600;
}

/* スマホのハンバーガーメニュー（10_hamburgermenu_mobile.png）：左から引き出し、右側の余白を押すと閉じる */
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: min(75vw, 300px);
  padding: 0 16px 16px;
  background: var(--card-bg-color);
  transform: translateX(-100%);
  /* 閉じている間はキーボード操作でもフォーカスされないよう隠す */
  visibility: hidden;
  transition: transform 0.2s ease, visibility 0.2s;
}

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

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--text-color) 40%, transparent);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  margin: 0 -8px 8px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

/* スマホのメニュー順はワイヤーフレームどおり ノート／メモ／新規ノート作成／タグ付け */
.nav-notes { order: 1; }
.nav-memos { order: 2; }
.nav-new-note { order: 3; }
.nav-tagging { order: 4; }

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-color);
  cursor: pointer;
}

.nav-item[aria-current="page"] {
  border-color: var(--accent-color);
  color: var(--accent-color);
  font-weight: 600;
}

.nav-item:disabled,
.tab-item:disabled {
  opacity: 0.45;
  cursor: default;
}

.main {
  padding: 16px 16px calc(72px + env(safe-area-inset-bottom));
}

.page-title {
  margin-bottom: 16px;
  font-size: 20px;
}

/* スマホの下部タブ（ノート／検索／メモ。開発運用上の注意点まとめ4.3.1節） */
.bottom-tabs {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--border-color);
  background: var(--card-bg-color);
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  border: none;
  border-top: 3px solid transparent;
  background: transparent;
  cursor: pointer;
}

.tab-item .soon {
  margin-left: 0;
  font-size: 10px;
}

.tab-item[aria-current="page"] {
  border-top-color: var(--accent-color);
  color: var(--accent-color);
  font-weight: 600;
}

/* ---- ノート一覧 ---- */

.note-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.note-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--card-bg-color);
}

.note-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.note-date {
  font-size: 13px;
  opacity: 0.7;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  padding: 2px 10px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.chip-genre {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.status {
  margin: 24px 0;
  text-align: center;
  opacity: 0.75;
}

.more-area {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.more-area .button {
  min-width: 200px;
}

/* ---- 設定 ---- */

.settings-card {
  max-width: 480px;
  padding: 20px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--card-bg-color);
}

.settings-row {
  margin: 0 0 20px;
}

.settings-value {
  overflow-wrap: anywhere;
}

/* ---- PC ---- */

@media (min-width: 768px) {
  .view-app {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100%;
  }

  .app-header,
  .bottom-tabs,
  .sidebar-overlay,
  #menu-close {
    display: none !important;
  }

  .sidebar {
    position: sticky;
    width: auto;
    height: 100vh;
    padding: 0 16px 16px;
    border-right: 1px solid var(--border-color);
    transform: none;
    visibility: visible;
    transition: none;
  }

  .sidebar-head {
    justify-content: center;
    height: 72px;
    margin: 0 0 8px;
  }

  /* PCのメニュー順は 新規ノート作成／ノート／メモ／タグ付け */
  .nav-new-note { order: 0; }

  .main {
    padding: 24px 32px 40px;
  }

  .note-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }
}
