/* 
 * 千城忆Store - 响应式 SPA 布局样式
 */

:root {
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 0px;
  --header-height: 60px;
  --transition-speed: 0.3s;
}

/* 基础重置与布局 */
body {
  margin: 0;
  padding: 0;
  overflow: hidden; /* 防止 body 滚动，由内容区处理 */
  background: var(--bg-gradient-start);
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* --- 侧边栏样式 --- */
.app-sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(30px) saturate(160%);
  -webkit-backdrop-filter: blur(30px) saturate(160%);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-speed), width var(--transition-speed), background 0.4s ease;
  z-index: 1001;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

[data-theme="dark"] .app-sidebar {
  background: rgba(28, 28, 30, 0.72);
  backdrop-filter: blur(40px) saturate(150%);
  -webkit-backdrop-filter: blur(40px) saturate(150%);
}

.app-sidebar::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(0, 113, 227, 0.03) 0%, transparent 70%);
  animation: rotate 20s linear infinite;
  pointer-events: none;
}

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

.sidebar-header {
  padding: 2rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
}

.sidebar-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
  white-space: nowrap;
  flex: 1;
}

/* 主题切换按钮 - 标题栏 */
.theme-toggle-header {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  border: 2px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.theme-toggle-header:hover {
  background: var(--primary-color);
  transform: rotate(180deg) scale(1.1);
  box-shadow: 0 4px 12px rgba(67, 56, 202, 0.3);
}

.theme-toggle-header .theme-icon {
  transition: transform 0.3s ease;
}

/* 导航菜单 */
.sidebar-nav {
  flex: 1;
  padding: 0 1rem;
  overflow-y: auto;
}

.nav-group {
  margin-bottom: 1.5rem;
}

.nav-item {
  margin-bottom: 0.5rem;
}

.nav-link, .submenu-item {
  display: flex;
  align-items: center;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.3s ease;
  cursor: pointer;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
}

.nav-link::before, .submenu-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 3px;
  background: var(--primary-color);
  transform: scaleY(0);
  transition: transform 0.3s ease;
}

.nav-link:hover::before, .submenu-item:hover::before {
  transform: scaleY(1);
}

.nav-link:hover, .submenu-item:hover {
  background: var(--primary-light);
  color: var(--primary-color);
}

.nav-item.active > .nav-link {
  background: var(--primary-color);
  color: white;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.2);
}

.nav-icon {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
  transition: all 0.3s ease;
}

.nav-link:hover .nav-icon {
  transform: scale(1.2) rotate(-10deg);
}

.nav-text {
  flex: 1;
  font-weight: 500;
}

.nav-arrow {
  font-size: 0.8rem;
  transition: transform var(--transition-fast);
}

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

/* 二级菜单 */
.submenu {
  margin-top: 0.25rem;
  padding-left: 1.5rem;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item.open .submenu {
  display: flex;
  animation: slideDown 0.3s ease-out;
}

.submenu-item {
  font-size: 0.9rem;
  padding: 0.6rem 1rem;
}

.submenu-item.active {
  color: var(--primary-color);
  background: var(--primary-light);
  font-weight: 600;
  border-left: 3px solid var(--primary-color);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 侧边栏底部 - 用户卡片 */
.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--primary-light);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.user-card::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(67, 56, 202, 0.1);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.user-card:hover::before {
  width: 300px;
  height: 300px;
}

.user-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(67, 56, 202, 0.2);
}

.user-avatar-wrapper {
  position: relative;
}

.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid white;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-card:hover .user-avatar {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 4px 16px rgba(67, 56, 202, 0.4);
  border-color: var(--primary-color);
}

.user-status {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--card-bg);
}

.user-status.online { 
  background: #10b981;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.user-name {
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.3s ease;
  text-shadow: 0 0 10px rgba(67, 56, 202, 0);
}

.user-card:hover .user-name {
  text-shadow: 0 0 10px rgba(67, 56, 202, 0.5);
  color: var(--primary-color);
}

.user-info span {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.3s ease;
  opacity: 0.8;
}

.user-card:hover .user-info span {
  opacity: 1;
  color: var(--text-secondary);
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- 主内容区 --- */
.app-content {
  flex: 1;
  height: 100%;
  overflow: hidden;
  position: relative;
  background: transparent;
  padding: 0;
}

#router-view {
  width: 100%;
  height: 100%;
}

#router-view iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.fade-in {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- 移动端适配 --- */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1002;
  width: 40px;
  height: 40px;
  background: var(--primary-color);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  box-shadow: var(--shadow-sm);
}

.mobile-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: white;
  transition: all 0.3s;
}

@media (max-width: 768px) {
  .mobile-toggle {
    display: flex;
    z-index: 1002; /* 确保切换按钮在最上层 */
    top: 1rem;
    left: auto;
    right: 1rem; /* 将按钮移到右上角，避免与logo重叠 */
  }

  .app-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    box-shadow: 10px 0 30px rgba(0,0,0,0.1);
    z-index: 1001; /* 保持侧边栏在较高层级 */
    width: 280px; /* 明确设置宽度 */
  }

  .sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .sidebar-open .app-content {
    opacity: 0.5;
    pointer-events: none;
  }

  .app-content {
    padding: 3.5rem 0 0 0;
  }
}

/* --- 其他 UI 组件 --- */

.loading-placeholder {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 300px;
  color: var(--text-muted);
  font-size: 1.1rem;
}
