/**
 * 左側選單樣式
 */

/* ==================== 整體佈局 ==================== */
.content-wrapper {
  display: flex;
  gap: 0;
  margin-top: 1rem;
}

/* ==================== 左側欄 ==================== */
.sidebar {
  width: 300px;
  min-width: 300px;
  height: calc(100vh - 100px);
  overflow-y: auto;
  background: var(--bs-body-bg);
  border-right: 1px solid var(--bs-border-color);
  position: sticky;
  top: 20px;
}

/* 滾動條樣式 */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: var(--bs-secondary-bg);
}

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

.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--bs-secondary-color);
}

/* ==================== 主內容區 ==================== */
.main-content {
  flex: 1;
  min-width: 0;
  padding-left: 2rem;
  padding-right: 1rem;
  max-width: calc(100% - 300px);
}

/* ==================== 選單項目 ==================== */
.menu-section {
  border-bottom: 1px solid var(--bs-border-color);
}

.menu-section:last-child {
  border-bottom: none;
}

/* 第一層：Unit */
.menu-unit {
  padding: 0;
  margin: 0;
}

.menu-unit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background: var(--bs-secondary-bg);
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--bs-emphasis-color);
}

.menu-unit-header:hover {
  background: var(--bs-tertiary-bg);
}

.menu-unit-header .order-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--bs-success);
  color: white;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 0.75rem;
  flex-shrink: 0;
}
.admin .menu-unit-header .order-badge{
  background: var(--bs-danger);
}

.menu-unit-header .unit-name {
  flex: 1;
  line-height: 1.4;
}

.menu-unit-header .toggle-icon {
  transition: transform 0.2s ease;
  color: var(--bs-secondary-color);
  font-size: 0.875rem;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.menu-unit-header[aria-expanded="true"] .toggle-icon {
  transform: rotate(180deg);
}

/* 第二層：Topics */
.menu-topics {
  background: var(--bs-body-bg);
  padding: 0;
  margin: 0;
  list-style: none;
}

.menu-topic-item {
  border-top: 1px solid var(--bs-border-color);
}

.menu-topic-link {
  display: block;
  padding: 0.75rem 1rem 0.75rem 3rem;
  color: var(--bs-body-color);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.2s ease;
  position: relative;
}

.menu-topic-link:hover {
  background: var(--bs-secondary-bg);
  color: var(--bs-success);
  padding-left: 3.25rem;
}

.admin .menu-topic-link:hover {
  background: var(--bs-secondary-bg);
  color: var(--bs-danger);
  padding-left: 3.25rem;
}

.menu-topic-link::before {
  content: "·";
  position: absolute;
  left: 2rem;
  color: var(--bs-success);
  font-weight: 700;
}

.admin .menu-topic-link::before {
  content: "·";
  position: absolute;
  left: 2rem;
  color: var(--bs-danger);
  font-weight: 700;
}

.menu-topic-link.active {
  background: var(--bs-success-bg-subtle);
  color: var(--bs-success);
  font-weight: 600;
  border-left: 3px solid var(--bs-success);
}

.admin .menu-topic-link.active {
  background: var(--bs-danger-bg-subtle);
  color: var(--bs-danger);
  font-weight: 600;
  border-left: 3px solid var(--bs-danger);
}

/* ==================== 響應式設計 ==================== */
@media (max-width: 992px) {
  .content-wrapper {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--bs-border-color);
    margin-bottom: 1rem;
  }

  .main-content {
    padding-left: 0;
    padding-right: 0;
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .menu-unit-header {
    font-size: 0.875rem;
    padding: 0.75rem 0.875rem;
  }

  .menu-unit-header .order-badge {
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    margin-right: 0.5rem;
  }

  .menu-topic-link {
    padding: 0.625rem 0.875rem 0.625rem 2.5rem;
    font-size: 0.8rem;
  }

  .menu-topic-link::before {
    left: 1.5rem;
  }

  .menu-topic-link:hover {
    padding-left: 2.75rem;
  }
}

/* ==================== Dark Mode 優化 ==================== */
[data-bs-theme="dark"] .sidebar {
  border-right-color: #3a3a3a;
}

[data-bs-theme="dark"] .menu-unit-header {
  background: #2a2a2a;
}

[data-bs-theme="dark"] .menu-unit-header:hover {
  background: #333;
}

[data-bs-theme="dark"] .menu-topic-link:hover {
  background: #2a2a2a;
}

/* ==================== 動畫效果 ==================== */
.menu-topics {
  transition: height 0.3s ease;
}

.collapsing {
  transition: height 0.3s ease;
}
