/**
 * 用户中心布局样式
 * 提取自: src/layouts/user-base.html.j2
 * 提取日期: 2026-01-12
 */

:root {
  --user-primary: var(--color-indigo-500);
  --user-primary-soft: var(--color-indigo-50);
  --user-bg: var(--color-gray-50);
  --user-sidebar-width: 15rem;
  --user-header-height: 4rem;
}

/* 确保主导航在用户中心元素之上 */
.main-nav {
  z-index: 1400;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--user-bg);
  color: var(--color-gray-900);
  padding-top: var(--nav-height-desktop, 4.375rem);
}

a {
  color: inherit;
  text-decoration: none;
}

/* 锚点高亮动画 */
@keyframes cardHighlight {
  0% { box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.5); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.card-highlight {
  animation: cardHighlight 2s ease-out;
}

.user-header {
  height: var(--user-header-height);
  background: var(--white);
  border-bottom: 1px solid var(--color-gray-200);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  position: fixed;
  top: var(--nav-height-desktop, 4.375rem);
  left: 0;
  right: 0;
  z-index: 1100;
  gap: 1rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.brand {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--user-primary);
  text-decoration: none;
}

.mobile-toggle {
  display: none;
  border: 1px solid var(--color-gray-200);
  background: var(--white);
  border-radius: 0.5rem;
  padding: 0.5rem 0.625rem;
  cursor: pointer;
}

.user-sidebar {
  width: var(--user-sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--color-gray-200);
  position: fixed;
  top: calc(var(--nav-height-desktop, 4.375rem) + var(--user-header-height));
  left: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 0.75rem 0 1.5rem;
  transition: transform 0.3s ease;
  z-index: 1050;
}

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1.25rem;
  color: var(--color-gray-800);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
  border-left: 3px solid transparent;
  font-size: 0.875rem;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--user-primary-soft);
  color: var(--user-primary);
  border-left-color: var(--user-primary);
}

.sidebar-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--color-gray-200);
}

.sidebar-section-title {
  padding: 0 1.25rem 0.5rem;
  font-size: 0.75rem;
  color: var(--color-gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* 子菜单样式 */
.has-submenu {
  position: relative;
}

.has-submenu > .submenu-toggle::after {
  content: '▸';
  margin-left: auto;
  font-size: 0.625rem;
  transition: transform 0.2s;
}

.has-submenu.expanded > .submenu-toggle::after {
  transform: rotate(90deg);
}

.sidebar-submenu {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: var(--color-gray-50);
}

.has-submenu.expanded > .sidebar-submenu {
  max-height: 75rem;
}

.sidebar-submenu a {
  padding: 0.625rem 1.25rem 0.625rem 2.75rem;
  font-size: 0.8125rem;
  border-left: none;
}

.sidebar-submenu a:hover {
  background: var(--user-primary-soft);
  color: var(--user-primary);
}

.header-user-info {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--color-gray-600);
}

.header-user-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-indigo-500) 0%, var(--color-violet-500) 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-weight: 700;
}

.header-link {
  color: var(--color-gray-500);
  font-size: 0.8125rem;
}

.header-link:hover {
  color: var(--user-primary);
}

.user-main {
  margin-left: var(--user-sidebar-width);
  margin-top: var(--user-header-height);
  padding: 0;
  min-height: calc(100vh - var(--user-header-height));
  overflow-x: auto;
}

.user-content {
  padding: 1.5rem;
  max-width: 75rem;
  margin: 0 auto;
}

@media (max-width: 60rem) {
  body {
    padding-top: var(--nav-height-mobile, 3.75rem);
  }

  .user-header {
    top: var(--nav-height-mobile, 3.75rem);
  }

  .user-sidebar {
    transform: translateX(-100%);
    z-index: 1200;
    top: calc(var(--nav-height-mobile, 3.75rem) + var(--user-header-height));
  }

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

  .user-main {
    margin-left: 0;
  }

  .mobile-toggle {
    display: inline-flex;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1150;
  }

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