/* bookshelf.css */

/* ── ヘッダー ── */
.shelf-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 1.2rem;
  gap: .8rem;
  box-shadow: var(--shadow);
}

/* ── テーマ対応 ── */
body[data-theme="dark"] .shelf-header {
  background: #2d2f3e;
  border-bottom-color: #3d4050;
  color: #fff;
}
body[data-theme="sepia"] .shelf-header {
  background: #e8dcc8;
  border-bottom-color: #d4c5b0;
}
body[data-theme="dark"] .shelf-sidebar {
  background: #2d2f3e;
  border-right-color: #3d4050;
  color: #fff;
}
body[data-theme="sepia"] .shelf-sidebar {
  background: #e8dcc8;
  border-right-color: #d4c5b0;
}

.shelf-header .logo {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--color-primary);
  flex: 1;
}

.shelf-header .user-name {
  font-size: .82rem;
  color: var(--color-muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── メイン：2カラムレイアウト ── */
.shelf-layout {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* ── サイドバー ── */
.shelf-sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem .6rem;
}
.sidebar-header h2 {
  font-size: .85rem;
  font-weight: 700;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.sidebar-add-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  color: var(--color-muted);
  transition: background var(--transition), color var(--transition);
}
.sidebar-add-btn:hover { background: var(--color-bg); color: var(--color-primary); }

.folder-list {
  flex: 1;
  overflow-y: auto;
  padding: .3rem;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .55rem .75rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  font-size: .88rem;
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition);
  text-align: left;
}
.folder-item:hover { background: var(--color-bg); }
.folder-item.active {
  background: var(--color-primary-light, #e8f0fe);
  color: var(--color-primary);
  font-weight: 600;
}
.folder-icon { font-size: 1rem; flex-shrink: 0; }
.folder-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 本棚コンテンツ ── */
.shelf-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem 1.5rem;
}
.stats-main { max-width:900px;margin:auto;padding:1.5rem; }
#chart { width:100%;height:240px;margin-top:1rem;border:1px solid var(--color-border); }

.shelf-content-header {
  margin-bottom: 1.2rem;
}
.shelf-content-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}
.shelf-tools { display:flex;gap:.5rem;flex-wrap:wrap;margin-top:.7rem; }
.shelf-tools input,.shelf-tools select { border:1px solid var(--color-border);border-radius:6px;padding:.45rem; }
#bodySearchResults { display:flex;flex-direction:column;gap:.35rem;margin-top:.5rem;font-size:.8rem; }
.favorite-badge { position:absolute;top:.4rem;left:.4rem;color:#ffd54f;font-size:1.4rem;text-shadow:0 1px 3px #000; }
.offline-badge { position:absolute;bottom:.4rem;left:.4rem;background:#176b3a;color:#fff;border-radius:99px;padding:.15rem .4rem;font-weight:bold; }

/* ── コンテキストメニュー ── */
.context-menu {
  position: fixed;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,.18);
  padding: .4rem 0;
  z-index: 500;
  min-width: 180px;
}
.context-menu-item {
  padding: .5rem 1rem;
  font-size: .85rem;
  cursor: pointer;
  transition: background var(--transition);
}
.context-menu-item:hover { background: var(--color-bg); }
.context-menu-divider { height: 1px; background: var(--color-border); margin: .3rem 0; }

/* ── ローディング ── */
#loading {
  display: flex;
  justify-content: center;
  padding: 3rem;
}

/* ── 空状態 ── */
#emptyState {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--color-muted);
}
#emptyState svg { margin: 0 auto 1rem; opacity: .4; }
#emptyState p { font-size: 1rem; margin-bottom: 1rem; }

/* ── 本棚グリッド ── */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1.2rem;
}

@media (max-width: 480px) {
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .8rem; }
}

/* ── 本カード ── */
.book-card {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}
.book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 24px rgba(0,0,0,.14);
}

.book-cover {
  aspect-ratio: 2/3;
  background: var(--color-border);
  overflow: hidden;
}
.book-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .3s ease;
}
.book-card:hover .book-cover img { transform: scale(1.04); }

.progress-badge {
  position: absolute;
  bottom: .4rem;
  right: .4rem;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 99px;
}

.book-info {
  padding: .6rem .7rem .7rem;
}
.book-title {
  font-size: .85rem;
  font-weight: 700;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-author {
  font-size: .75rem;
  color: var(--color-muted);
  margin-top: .2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-bar {
  height: 3px;
  background: var(--color-border);
  border-radius: 2px;
  margin-top: .5rem;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 2px;
  transition: width .4s ease;
}

/* ── 削除ボタン ── */
.book-delete {
  position: absolute;
  top: .4rem;
  right: .4rem;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
}
.book-card:hover .book-delete { opacity: 1; }

/* ── レスポンブレイク：狭い画面ではサイドバーを折りたたむ ── */
@media (max-width: 768px) {
  .shelf-sidebar {
    width: 56px;
    min-width: 56px;
  }
  .sidebar-header h2 { display: none; }
  .sidebar-add-btn { margin: 0 auto; }
  .folder-item { justify-content: center; padding: .55rem; }
  .folder-name { display: none; }
  .folder-item.active { background: var(--color-bg); }
}
