/* 共通サイドバースタイル */

:root {
  --sidebar-width: 240px;
  --sidebar-width-collapsed: 64px;
  --primary: #3b82f6;
}

/* サイドバー */
.sidebar {
  width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  box-shadow: 2px 0 8px rgba(0,0,0,0.05);
  transition: width 0.3s ease, transform 0.3s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .logo-text,
.sidebar.collapsed .sidebar-role {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-toggle i {
  transform: rotate(180deg);
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
  min-height: 56px;
  display: flex;
  align-items: center;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
  white-space: nowrap;
  transition: opacity 0.3s ease;
}

.sidebar-role {
  padding: 6px 16px;
  border-bottom: 1px solid #e5e7eb;
  transition: opacity 0.3s ease;
}

.sidebar-role .role-badge {
  display: inline-block;
  padding: 3px 10px;
  background: #e0e7ff;
  color: #3730a3;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  min-height: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: #6b7280;
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.2s;
  white-space: nowrap;
  font-size: 0.8125rem;
}

.nav-item-button {
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: #f3f4f6;
  color: #111827;
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
}

.nav-item i {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: 0.875rem;
}

.nav-label {
  transition: opacity 0.3s ease;
  white-space: nowrap;
  font-size: 0.8125rem;
}

.nav-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 8px 12px;
}

/* 管理ダッシュボードへのリンク（目立たせる） */
.nav-item.nav-item-admin {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-weight: 600;
}

.nav-item.nav-item-admin:hover {
  background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
  color: #fff;
  transform: translateX(2px);
}

/* マイページへのリンク（目立たせる） */
.nav-item.nav-item-mypage {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  font-weight: 600;
}

.nav-item.nav-item-mypage:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #fff;
  transform: translateX(2px);
}

.sidebar.collapsed .nav-divider {
  margin: 8px 8px;
}

.sidebar-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: 1px solid #e5e7eb;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  transition: all 0.2s;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.sidebar.collapsed .sidebar-toggle {
  right: 18px;
}

.sidebar-toggle:hover {
  background: #f3f4f6;
  border-color: var(--primary);
  color: var(--primary);
}

.sidebar-toggle i {
  transition: transform 0.3s ease;
}

/* メインコンテンツ */
.main-content {
  margin-left: var(--sidebar-width) !important;
  width: calc(100% - var(--sidebar-width)) !important;
  max-width: none !important;
  transition: margin-left 0.3s ease, width 0.3s ease;
  box-sizing: border-box;
}

.sidebar.collapsed ~ .main-content,
.sidebar.collapsed + .main-content {
  margin-left: var(--sidebar-width-collapsed) !important;
  width: calc(100% - var(--sidebar-width-collapsed)) !important;
}

/* メインコンテンツ内のコンテナを全幅に */
.main-content > .container,
.main-content .container {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* サイドバーオーバーレイ（モバイル用） */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* モバイルメニューボタン */
.mobile-menu-button {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 101;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: #111827;
  font-size: 1.2rem;
}

.mobile-menu-button:hover {
  background: #f3f4f6;
}

/* レスポンシブ */
@media (max-width: 768px) {
  .mobile-menu-button {
    display: flex;
  }
  
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }
  
  .sidebar.collapsed {
    transform: translateX(-100%);
  }
  
  .sidebar.open.collapsed {
    transform: translateX(0);
    width: var(--sidebar-width);
  }
  
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }
  
  .sidebar-toggle {
    display: none;
  }
  
  .sidebar.open ~ .main-content,
  .sidebar.open + .main-content {
    margin-left: 0 !important;
  }
  
  /* スライドアニメーションをより滑らかに */
  .sidebar-overlay {
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

