/* ========================================
   WOODWORK サイドバー新デザイン
   カラーパレット：
     #181818  チャコールブラック（メイン背景）
     #281818  黒寄りのダークブラウン（ヘッダー濃色）
     #583828  木目ブラウン（選択中メニュー背景）
     #483828  ダークウッドブラウン（木目の濃い部分）
     #B8A38F  グレージュ（アイコン・補助文字）
     #3A342F  ダークグレー（区切り線）
     #F5F2EE  オフホワイト（メイン文字）
     #A8794F  ライトウッドブラウン（ロゴ木色）
     #D6A66A  ゴールドベージュ（アクセント左線）
   ======================================== */

:root {
  --sb-bg:            #181818;
  --sb-header-bg:     #281818;
  --sb-active-bg:     #583828;
  --sb-wood-dark:     #483828;
  --sb-icon:          #B8A38F;
  --sb-divider:       #3A342F;
  --sb-text:          #F5F2EE;
  --sb-logo-wood:     #A8794F;
  --sb-accent:        #D6A66A;
  --sb-text-muted:    #8A7A6A;
  --sb-hover-bg:      rgba(214, 166, 106, 0.08);
  --sb-width:         240px;
  --sb-width-collapsed: 64px;
}

/* ---- サイドバー本体 ---- */
.sidebar {
  width: var(--sb-width);
  background: var(--sb-bg);
  background-image:
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 3px,
      rgba(255,255,255,0.012) 3px,
      rgba(255,255,255,0.012) 4px
    ),
    repeating-linear-gradient(
      180deg,
      transparent 0px,
      transparent 60px,
      rgba(72,56,40,0.18) 60px,
      rgba(72,56,40,0.18) 61px
    );
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.22s ease, width 0.22s ease;
  box-shadow: 3px 0 16px rgba(0,0,0,0.55);
}

/* ---- サイドバー：折りたたみ状態（PC） ---- */
.sidebar.collapsed {
  width: var(--sb-width-collapsed);
}
.sidebar.collapsed .sidebar-logo-text-wrap,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-group-label,
.sidebar.collapsed .sidebar-footer-text {
  display: none;
}
.sidebar.collapsed .sidebar-logo {
  justify-content: center;
  padding: 20px 0 16px;
}
.sidebar.collapsed .sidebar-collapse-btn {
  right: -12px;
  top: 22px;
  transform: rotate(180deg);
}
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 11px 0;
  border-left: none;
}
.sidebar.collapsed .nav-item.active {
  border-left: none;
  background: var(--sb-active-bg);
}
.sidebar.collapsed .sidebar-footer {
  justify-content: center;
  padding: 14px 0;
}

/* ---- 折りたたみトグルボタン ---- */
.sidebar-collapse-btn {
  position: absolute;
  right: 10px;
  top: 24px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--sb-wood-dark);
  border: 1px solid var(--sb-divider);
  color: var(--sb-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.22s ease;
  flex-shrink: 0;
  z-index: 10;
}
.sidebar-collapse-btn:hover {
  background: var(--sb-active-bg);
}
@media (max-width: 900px) {
  .sidebar-collapse-btn { display: none; }
}

/* ---- ロゴエリア ---- */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 16px;
  background: var(--sb-header-bg);
  border-bottom: 1.5px solid var(--sb-divider);
  position: relative;
  flex-shrink: 0;
}

/* ロゴ画像コンテナ */
.sidebar-logo-icon {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* drop-shadow は img 側の filter に委ねる */
}

.sidebar-logo-icon img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  /* 黒白シルエット → 木目ブラウン (#D6A66A 系) + ドロップシャドウ */
  filter:
    invert(1)
    sepia(0.5)
    saturate(1.8)
    hue-rotate(5deg)
    brightness(0.85)
    drop-shadow(0 2px 6px rgba(0,0,0,0.8));
}

.sidebar-logo-text-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-logo-brand {
  font-size: 20px;
  font-weight: 900;
  color: var(--sb-text);
  letter-spacing: 2px;
  line-height: 1.1;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.sidebar-logo-sub {
  font-size: 10.5px;
  color: var(--sb-icon);
  font-weight: 400;
  letter-spacing: 0.5px;
}

/* ---- ナビ全体 ---- */
.sidebar-nav {
  padding: 10px 0 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ---- グループラベル ---- */
.nav-group-label {
  font-size: 10px;
  color: var(--sb-text-muted);
  padding: 14px 20px 5px;
  text-transform: none;
  letter-spacing: 1px;
  font-weight: 600;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-group-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--sb-divider);
  margin-left: 6px;
}

/* ---- ナビアイテム ---- */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px 11px 20px;
  color: var(--sb-icon);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-left: 3.5px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
}

.nav-item:hover {
  background: var(--sb-hover-bg);
  color: var(--sb-text);
  border-left-color: rgba(214,166,106,0.35);
}

.nav-item.active {
  background: var(--sb-active-bg);
  background-image: linear-gradient(
    90deg,
    rgba(214,166,106,0.12) 0%,
    transparent 100%
  );
  color: var(--sb-text);
  border-left-color: var(--sb-accent);
  font-weight: 600;
}

.nav-item.active::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(214,166,106,0.15);
}

/* ---- アイコン ---- */
.nav-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.85;
}
.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  opacity: 1;
}

/* SVGアイコン用 */
.nav-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- フッター（ユーザー情報） ---- */
.sidebar-footer {
  padding: 14px 18px;
  border-top: 1.5px solid var(--sb-divider);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--sb-header-bg);
  flex-shrink: 0;
}

.sidebar-footer .user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--sb-active-bg);
  border: 1.5px solid var(--sb-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  color: var(--sb-text);
}

.sidebar-footer .user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--sb-text);
  line-height: 1.3;
}

.sidebar-footer .user-role {
  font-size: 11px;
  color: var(--sb-text-muted);
}

/* ---- スクロールバー ---- */
.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: var(--sb-divider);
  border-radius: 2px;
}

/* ---- レスポンシブ ---- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sb-width);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0 !important;
  }
}

/* ---- main-content のマージン上書き ---- */
.main-content {
  margin-left: var(--sb-width) !important;
  transition: margin-left 0.22s ease;
}
body.sb-collapsed .main-content {
  margin-left: var(--sb-width-collapsed) !important;
}
@media (max-width: 900px) {
  body.sb-collapsed .main-content {
    margin-left: 0 !important;
  }
}
