/* 統一側邊欄樣式 */
:root {
  /* Light theme colors */
  --primary-bg: #f8f9fa;
  --sidebar-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --card-bg: white;
  --text-primary: #495057;
  --text-secondary: #6c757d;
  --text-muted: #adb5bd;
  --border-color: #dee2e6;
  --accent-color: #667eea;
  --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --success-bg: #d4edda;
  --success-border: #28a745;
  --success-text: #155724;
  --warning-bg: #fff3cd;
  --warning-border: #ffc107;
  --warning-text: #856404;
  --danger-bg: #f8d7da;
  --danger-border: #dc3545;
  --danger-text: #721c24;
  --info-bg: #d1edff;
  --info-border: #0d6efd;
  --info-text: #0c5460;
  --nav-link-color: rgba(255, 255, 255, 0.8);
  --nav-link-hover-bg: rgba(255, 255, 255, 0.1);
  --user-info-bg: rgba(255, 255, 255, 0.1);
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark theme colors */
    --primary-bg: #1a1a1a;
    --sidebar-bg: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    --card-bg: #2d3748;
    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --text-muted: #718096;
    --border-color: #4a5568;
    --accent-color: #63b3ed;
    --accent-gradient: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    --success-bg: #22543d;
    --success-border: #38a169;
    --success-text: #9ae6b4;
    --warning-bg: #744210;
    --warning-border: #d69e2e;
    --warning-text: #faf089;
    --danger-bg: #742a2a;
    --danger-border: #e53e3e;
    --danger-text: #fed7d7;
    --info-bg: #2a4365;
    --info-border: #3182ce;
    --info-text: #bee3f8;
    --nav-link-color: rgba(255, 255, 255, 0.7);
    --nav-link-hover-bg: rgba(255, 255, 255, 0.15);
    --user-info-bg: rgba(255, 255, 255, 0.1);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  }
}

/* 側邊欄基本樣式 */
.sidebar {
  min-height: 100vh;
  background: var(--sidebar-bg);
  padding: 0;
  height: 100vh;
  overflow-y: auto;
  transition: all 0.3s ease;
  box-shadow: var(--shadow);
  width: 280px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
}

/* 響應式設計 */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0 !important;
  }
}

@media (min-width: 769px) {
  .main-content {
    margin-left: 280px;
  }
}

/* Logo 區域 */
.sidebar .text-center {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 1rem;
}

.sidebar h4 {
  font-weight: 600;
  font-size: 1.25rem;
}

.sidebar small {
  font-size: 0.75rem;
  opacity: 0.8;
}

/* 用戶資訊區域 */
.user-info {
  padding: 1rem;
  background: var(--user-info-bg);
  border-radius: 10px;
  margin-bottom: 1rem;
  backdrop-filter: blur(10px);
}

.user-info h6 {
  color: white;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.user-info small {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.8rem;
}

/* 用戶詳細資訊樣式 */
.user-details {
  text-align: center;
}

/* 等級徽章樣式 */
.level-badge {
  position: relative;
  width: 40px;
  height: 40px;
  background-image: url('/pic/reward/low_level.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.level-number {
  font-size: 14px;
  font-weight: bold;
  color: #333;
  position: relative;
  z-index: 1;
}

/* 不同等級的背景圖 */
.level-badge.low-level {
  background-image: url('/pic/reward/low_level.png');
}

.level-badge.medium-level {
  background-image: url('/pic/reward/low_level.png');
}

.level-badge.high-level {
  background-image: url('/pic/reward/low_level.png');
}

/* 用戶等級樣式 */
.user-level {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.75rem;
  font-weight: 500;
}

/* 用戶積分顯示樣式 */
.user-points {
  text-align: center;
  margin-top: 8px;
}

.points-number {
  font-size: 1.2rem;
  font-weight: bold;
  color: #ffd700;
  margin-bottom: 0;
}

.points-label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.7rem;
  margin-bottom: 0;
}

/* 導航選單 */
.nav-section {
  margin-bottom: 1.5rem;
}

.nav-section-title {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
  padding: 0 1rem;
}

/* 可縮放區塊樣式 */
.collapsible-section {
  margin-bottom: 1.5rem;
}

.collapsible-title {
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.3s ease;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}

.collapsible-title:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

.section-toggle-icon {
  transition: transform 0.3s ease;
  font-size: 0.7rem;
}

.section-toggle-icon.rotated {
  transform: rotate(180deg);
}

.nav-links-container {
  overflow: hidden;
  transition: all 0.3s ease;
  max-height: 500px;
  opacity: 1;
}

.nav-links-container.collapsed {
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
}

.nav-links-container .nav-link {
  margin-left: 1rem;
  padding-left: 1.5rem;
  border-left: 2px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
}

.nav-links-container .nav-link:hover {
  border-left-color: rgba(255, 255, 255, 0.5);
}

.nav-link {
  color: var(--nav-link-color);
  text-decoration: none;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin: 0.25rem 0.5rem;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  font-weight: 500;
  position: relative;
}

.nav-link:hover {
  color: white;
  background-color: var(--nav-link-hover-bg);
  text-decoration: none;
}

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

.nav-link.active::before {
  content: '';
  position: absolute;
  left: -0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: white;
  border-radius: 2px;
}

.nav-link i {
  width: 20px;
  text-align: center;
  margin-right: 0.5rem;
}

/* 底部區域 */
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer .btn {
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.sidebar-footer .btn:hover {
  transform: scale(1.1);
}

/* 頭像動畫樣式 */
.avatar-container {
  position: relative;
  display: inline-block;
}

.avatar-animation-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
}

.avatar-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.avatar-animation-controls {
  position: absolute;
  bottom: 5px;
  right: 5px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.avatar-animation-controls:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

/* 管理員模式指示器 */
.admin-indicator {
  position: fixed;
  top: 10px;
  right: 10px;
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 1001;
  box-shadow: 0 2px 10px rgba(220, 53, 69, 0.3);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 2px 10px rgba(220, 53, 69, 0.3);
  }
  50% {
    box-shadow: 0 2px 20px rgba(220, 53, 69, 0.6);
  }
  100% {
    box-shadow: 0 2px 10px rgba(220, 53, 69, 0.3);
  }
}

/* 移動端漢堡選單按鈕 */
.mobile-menu-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1002;
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: 8px;
  width: 50px;
  height: 50px;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

.mobile-menu-toggle:hover {
  transform: scale(1.05);
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }
}

/* 主題切換動畫 */
.theme-transition {
  transition: all 0.3s ease;
}

/* 載入動畫 */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 工具提示樣式 */
.tooltip-custom {
  position: relative;
}

.tooltip-custom::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 1000;
}

.tooltip-custom:hover::after {
  opacity: 1;
}
