/* Modern Sidebar Template CSS */
/* Created: 2025-08-09 */

/* 사이드바 변수 */
:root {
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 70px;
  --sidebar-bg: #ffffff;
  --sidebar-border: #e3e6f0;
  --sidebar-text: #5a5c69;
  --sidebar-hover: #f8f9fc;
  --sidebar-active: #4e73df;
  --sidebar-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* 다크 테마 사이드바 변수 */
.dark-theme {
  --sidebar-bg: #2d2d2d;
  --sidebar-border: #404040;
  --sidebar-text: #b0b0b0;
  --sidebar-hover: #3a3a3a;
  --sidebar-active: #4a9eff;
  --sidebar-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Offcanvas 사이드바 스타일 */
.sidebar-offcanvas {
  position: fixed;
  top: 0;
  left: -100%;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--cui-sidebar-bg);
  transition: left 0.3s ease-in-out;
  z-index: 1050;
  overflow-y: auto;
  box-shadow: var(--sidebar-shadow);
}

.sidebar-offcanvas.show {
  left: 0;
}

/* 사이드바 오버레이 */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1040;
  display: none;
}

.sidebar-overlay.show {
  display: block;
}

/* 사이드바 헤더 */
.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--bs-border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--cui-sidebar-text);
  font-size: 1.25rem;
  font-weight: 600;
}

.sidebar-brand img {
  height: 32px;
  margin-right: 10px;
}

.sidebar-close {
  background: none;
  border: none;
  color: var(--cui-sidebar-text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 사이드바 검색 */
.sidebar-search {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--bs-border-color);
}

.sidebar-search input {
  width: 100%;
  padding: 0.5rem 1rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 3px;
  background: var(--sidebar-hover);
  color: var(--cui-sidebar-text);
  font-size: 0.875rem;
}

.sidebar-search input:focus {
  outline: none;
  border-color: var(--sidebar-active);
}

/* 사이드바 메뉴 */
.sidebar-menu {
  padding: 1rem 0;
}

.sidebar-menu-title {
  padding: 0.5rem 1.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--cui-sidebar-text);
  opacity: 0.6;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-nav-item {
  position: relative;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  color: var(--cui-sidebar-text);
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
}

.sidebar-nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-active);
}

.sidebar-nav-link.active {
  background: var(--sidebar-hover);
  color: var(--sidebar-active);
  font-weight: 600;
}

.sidebar-nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--sidebar-active);
}

/* 사이드바 아이콘 */
.sidebar-nav-icon {
  width: 20px;
  margin-right: 12px;
  text-align: center;
  font-size: 1rem;
}

/* 사이드바 배지 */
.sidebar-nav-badge {
  margin-left: auto;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 3px;
  background: var(--sidebar-active);
  color: white;
}

/* 서브메뉴 (아코디언) */
.sidebar-submenu {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: var(--sidebar-hover);
}

.sidebar-nav-item.open .sidebar-submenu {
  max-height: 500px;
}

.sidebar-submenu-item {
  padding-left: 3rem;
}

.sidebar-submenu-link {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--cui-sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.sidebar-submenu-link:hover {
  color: var(--sidebar-active);
}

.sidebar-submenu-link.active {
  color: var(--sidebar-active);
  font-weight: 600;
}

/* 드롭다운 화살표 */
.sidebar-nav-arrow {
  margin-left: auto;
  transition: transform 0.3s ease;
}

.sidebar-nav-item.open .sidebar-nav-arrow {
  transform: rotate(90deg);
}

/* 사이드바 푸터 */
.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--bs-border-color);
  margin-top: auto;
}

.sidebar-user {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  background: var(--sidebar-hover);
  border-radius: 3px;
  text-decoration: none;
  color: var(--cui-sidebar-text);
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-right: 12px;
}

.sidebar-user-info {
  flex: 1;
}

.sidebar-user-name {
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0;
}

.sidebar-user-role {
  font-size: 0.75rem;
  opacity: 0.7;
  margin: 0;
}

/* 햄버거 메뉴 버튼 */
.sidebar-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1030;
  background: var(--cui-sidebar-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 3px;
  padding: 0.5rem;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.sidebar-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.sidebar-toggle i {
  font-size: 1.25rem;
  color: var(--cui-sidebar-text);
}

/* 모바일 최적화 */
@media (max-width: 768px) {
  .sidebar-offcanvas {
    width: 85%;
    max-width: var(--sidebar-width);
  }

  .sidebar-toggle {
    top: 10px;
    left: 10px;
  }
}

/* 데스크톱 고정 사이드바 옵션 */
@media (min-width: 1024px) {
  .sidebar-desktop-fixed {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--cui-sidebar-bg);
    border-right: 1px solid var(--bs-border-color);
    overflow-y: auto;
    z-index: 100;
  }

  .sidebar-desktop-fixed ~ .main-content {
    margin-left: var(--sidebar-width);
  }

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

  .sidebar-desktop-collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
  }

  .sidebar-desktop-collapsed .sidebar-nav-link {
    justify-content: center;
    padding: 0.75rem;
  }

  .sidebar-desktop-collapsed .sidebar-nav-icon {
    margin: 0;
  }

  .sidebar-desktop-collapsed .sidebar-nav-text,
  .sidebar-desktop-collapsed .sidebar-nav-badge,
  .sidebar-desktop-collapsed .sidebar-nav-arrow,
  .sidebar-desktop-collapsed .sidebar-header .sidebar-brand span,
  .sidebar-desktop-collapsed .sidebar-search,
  .sidebar-desktop-collapsed .sidebar-menu-title,
  .sidebar-desktop-collapsed .sidebar-user-info {
    display: none;
  }
}

/* 애니메이션 */
@keyframes slideIn {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.sidebar-offcanvas.show {
  animation: slideIn 0.3s ease-out;
}

.sidebar-overlay.show {
  animation: fadeIn 0.3s ease-out;
}

/* 스크롤바 스타일 */
.sidebar-offcanvas::-webkit-scrollbar {
  width: 6px;
}

.sidebar-offcanvas::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-offcanvas::-webkit-scrollbar-thumb {
  background: var(--bs-border-color);
  border-radius: 3px;
}

.sidebar-offcanvas::-webkit-scrollbar-thumb:hover {
  background: var(--cui-sidebar-text);
}
