/**
 * 侧边栏样式 v2.0
 * 重构版本：简化选择器，统一命名
 */

/* ========================================
   1. 布局模式切换（防闪烁）
   ======================================== */

/* 默认：隐藏侧边栏相关元素（无过渡） */
.cc-sidebar,
.cc-sidebar-overlay,
.cc-mobile-header {
  display: none !important;
  visibility: hidden !important;
}

.cc-horizontal-menu {
  display: block;
  visibility: visible;
}

/* 横版布局模式 */
html.cc-layout-horizontal .cc-sidebar,
html.cc-layout-horizontal .cc-sidebar-overlay,
html.cc-layout-horizontal .cc-mobile-header {
  display: none !important;
}

html.cc-layout-horizontal .cc-horizontal-menu {
  display: block !important;
}

/* 横版布局：宽度限制 */
html.cc-layout-horizontal body {
  max-width: 1280px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

html.cc-layout-horizontal main,
html.cc-layout-horizontal .container,
html.cc-layout-horizontal .cc-wrap,
html.cc-layout-horizontal .cc-main-wrapper,
html.cc-layout-horizontal .user-center-container {
  max-width: 1280px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  width: 100% !important;
}

html.cc-layout-horizontal .cc-layout {
  display: grid !important;
  grid-template-columns: 240px 1fr !important;
  gap: 24px !important;
  max-width: 1280px !important;
}

html.cc-layout-horizontal .cc-aside {
  display: block !important;
}

/* 侧边栏布局模式 */
html.cc-layout-sidebar .cc-sidebar {
  display: flex !important;
  visibility: visible !important;
}

html.cc-layout-sidebar .cc-horizontal-menu {
  display: none !important;
  visibility: hidden !important;
}

html.cc-layout-sidebar .cc-wrap,
html.cc-layout-sidebar .cc-layout {
  max-width: 100% !important;
  width: 100% !important;
}

html.cc-layout-sidebar .cc-aside {
  display: none !important;
}

html.cc-layout-sidebar .cc-layout {
  grid-template-columns: 1fr !important;
}

/* ========================================
   2. 侧边栏主体
   ======================================== */

body.cc-sidebar-layout {
  background: #f7fbff;
  margin: 0 !important;
  padding: 0 !important;
  max-width: 100% !important;
}

body.cc-sidebar-layout .cc-horizontal-menu,
body.cc-sidebar-layout .cc-menu-spacer {
  display: none !important;
}

/* 主内容区域 */
.cc-main-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.cc-sidebar-layout .cc-main-wrapper {
  margin-left: 260px;
  width: calc(100% - 260px);
}

body.cc-sidebar-layout .user-center-container,
body.cc-sidebar-layout .container,
body.cc-sidebar-layout main {
  flex: 1;
  max-width: 100%;
  width: 100%;
  padding: 24px 32px;
}

/* Footer */
body.cc-sidebar-layout .cc-footer {
  margin: 32px 0 24px 0;
  padding: 0 40px;
  width: 100%;
}

/* ========================================
   3. 侧边栏容器
   ======================================== */

.cc-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 260px;
  background: rgba(255, 255, 255, 0.97);
  border-right: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: 4px 0 24px rgba(15, 23, 42, 0.06);
  backdrop-filter: saturate(180%) blur(20px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  /* 桌面端无过渡，移动端在 media query 中添加 */
}

.cc-sidebar::-webkit-scrollbar {
  width: 5px;
}

.cc-sidebar::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 3px;
}

.cc-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.4);
}

/* ========================================
   4. Logo
   ======================================== */

.cc-sidebar-logo {
  display: flex;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
  text-decoration: none;
  color: #0f172a;
  font-weight: 700;
  font-size: 17px;
  gap: 12px;
  transition: color 0.2s;
}

.cc-sidebar-logo:hover {
  color: #2563eb;
  text-decoration: none;
}

.cc-sidebar-logo img {
  width: 38px;
  height: 38px;
  filter: drop-shadow(0 4px 8px rgba(37, 99, 235, 0.2));
}

/* ========================================
   5. 导航菜单
   ======================================== */

.cc-sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.cc-sidebar-link {
  display: flex;
  align-items: center;
  padding: 11px 14px;
  color: #475569;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  border-radius: 10px;
  transition: all 0.2s ease;
  gap: 12px;
}

.cc-sidebar-link i:first-child {
  font-size: 19px;
  min-width: 20px;
  text-align: center;
}

.cc-sidebar-link:hover {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  color: #2563eb;
  text-decoration: none;
  transform: translateX(3px);
}

.cc-sidebar-link.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28);
}

/* ========================================
   6. 下拉菜单
   ======================================== */

.cc-sidebar-dropdown {
  position: relative;
}

.cc-sidebar-dropdown-toggle {
  position: relative;
  padding-right: 36px;
}

.cc-dropdown-arrow {
  position: absolute;
  right: 14px;
  font-size: 18px;
  transition: transform 0.25s ease;
}

.cc-sidebar-dropdown.is-open .cc-dropdown-arrow {
  transform: rotate(180deg);
}

.cc-sidebar-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding-left: 16px;
}

.cc-sidebar-dropdown.is-open .cc-sidebar-submenu {
  max-height: 500px;
}

.cc-submenu-link {
  padding: 9px 14px;
  font-size: 13px;
  margin-left: 16px;
  border-left: 2px solid transparent;
}

.cc-submenu-link:hover {
  border-left-color: #2563eb;
}

.cc-submenu-link.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-left-color: transparent;
}

/* ========================================
   7. 快捷操作区域
   ======================================== */

.cc-sidebar-actions {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(226, 232, 240, 0.6);
}

.cc-sidebar-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(226, 232, 240, 0.8);
  background: #fff;
  color: #475569;
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
}

.cc-sidebar-action-btn:hover {
  color: #2563eb;
  border-color: #2563eb;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  transform: translateY(-2px);
}

.cc-sidebar-action-btn i {
  font-size: 20px;
}

.cc-badge-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ========================================
   8. 用户区域
   ======================================== */

.cc-sidebar-user {
  padding: 12px;
  border-top: 1px solid rgba(226, 232, 240, 0.6);
}

.cc-sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.cc-sidebar-user-info:hover {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
}

.cc-sidebar-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.cc-sidebar-user-details {
  flex: 1;
  min-width: 0;
}

.cc-sidebar-user-name {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cc-sidebar-user-role {
  font-size: 12px;
  color: #64748b;
}

.cc-user-arrow {
  font-size: 18px;
  color: #94a3b8;
  transition: transform 0.25s ease;
}

.cc-sidebar-user.is-open .cc-user-arrow {
  transform: rotate(180deg);
}

.cc-sidebar-user-dropdown {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  margin-top: 8px;
}

.cc-sidebar-user.is-open .cc-sidebar-user-dropdown {
  max-height: 300px;
}

.cc-sidebar-user-dropdown .cc-sidebar-link {
  padding: 10px 14px;
  font-size: 13px;
}

/* ========================================
   9. 移动端顶部导航
   ======================================== */

.cc-mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
  backdrop-filter: saturate(180%) blur(20px);
  z-index: 1001;
  padding: 0 12px;
  align-items: center;
  justify-content: space-between;
}

.cc-mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid rgba(226, 232, 240, 0.8);
  cursor: pointer;
  transition: all 0.2s ease;
}

.cc-mobile-menu-btn:hover,
.cc-mobile-menu-btn:active {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-color: #2563eb;
}

.cc-mobile-menu-btn i {
  font-size: 22px;
  color: #0f172a;
}

.cc-mobile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #0f172a;
  font-weight: 600;
  font-size: 16px;
}

.cc-mobile-brand img {
  width: 30px;
  height: 30px;
}

.cc-mobile-brand:hover {
  text-decoration: none;
  color: #2563eb;
}

.cc-mobile-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cc-mobile-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: transparent;
  color: #475569;
  text-decoration: none;
  position: relative;
  transition: all 0.2s ease;
}

.cc-mobile-action-btn:hover {
  background: #f1f5f9;
  color: #2563eb;
}

.cc-mobile-action-btn i {
  font-size: 20px;
}

.cc-mobile-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.cc-mobile-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: transform 0.2s;
}

.cc-mobile-avatar:hover {
  transform: scale(1.05);
}

/* ========================================
   10. 遮罩层
   ======================================== */

.cc-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(3px);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cc-sidebar-overlay.show {
  display: block;
  opacity: 1;
}

/* ========================================
   11. 响应式设计
   ======================================== */

@media (max-width: 1024px) {
  /* 移动端：侧边栏滑出动画 */
  html.cc-layout-sidebar .cc-sidebar,
  body.cc-sidebar-layout .cc-sidebar {
    display: flex !important;
    visibility: visible !important;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  html.cc-layout-sidebar .cc-sidebar.show,
  body.cc-sidebar-layout .cc-sidebar.show {
    transform: translateX(0);
  }
  
  /* 移动端：显示顶部导航 */
  html.cc-layout-sidebar .cc-mobile-header,
  body.cc-sidebar-layout .cc-mobile-header {
    display: flex !important;
    visibility: visible;
    opacity: 1;
  }
  
  /* 移动端：主内容区域 */
  body.cc-sidebar-layout .cc-main-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
    padding-top: 56px;
  }
  
  body.cc-sidebar-layout .user-center-container,
  body.cc-sidebar-layout .container,
  body.cc-sidebar-layout main {
    padding: 16px 12px 24px;
    width: 100% !important;
  }
  
  body.cc-sidebar-layout .cc-footer {
    margin: 24px 12px;
    padding: 0;
  }
}

@media (max-width: 768px) {
  .cc-sidebar {
    width: 280px;
  }
  
  .cc-mobile-header {
    height: 52px;
  }
  
  .cc-mobile-menu-btn {
    width: 36px;
    height: 36px;
  }
  
  .cc-mobile-menu-btn i {
    font-size: 20px;
  }
  
  .cc-mobile-brand {
    font-size: 15px;
  }
  
  .cc-mobile-brand img {
    width: 28px;
    height: 28px;
  }
  
  body.cc-sidebar-layout .cc-main-wrapper {
    padding-top: 52px;
  }
  
  body.cc-sidebar-layout .user-center-container,
  body.cc-sidebar-layout .container,
  body.cc-sidebar-layout main {
    padding: 12px 10px 20px;
  }
  
  body.cc-sidebar-layout .cc-footer {
    margin: 20px 10px;
  }
}

/* 横版布局响应式 */
@media (max-width: 960px) {
  html.cc-layout-horizontal .cc-layout {
    grid-template-columns: 1fr !important;
  }
  
  html.cc-layout-horizontal .cc-aside {
    position: static !important;
  }
}
