﻿/* ============================================
   /ui/assets/css/layout.css（增强版 + 修复版 + 结构补全版）
   企业级后台布局体系（Sidebar + Topbar + Content）
   ============================================ */

/* 1. 布局变量体系 */
:root {
  /* ===== Amazon 官方深色主题 ===== */

  --sidebar-width: 240px;
  --sidebar-collapsed-width: 60px;

  /* 左侧栏：Amazon 二级导航色 #232F3E */
  --sidebar-bg: #232F3E;
  --sidebar-text: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.15);

  /* 顶部栏：Amazon 主导航色 #131921 */
  --topbar-bg: #131921;
  --topbar-border: rgba(255, 255, 255, 0.18);
  --topbar-height: 60px;

  --content-padding-x: 24px;
  --content-padding-y: 20px;
}

/* ===== 玻璃拟态核心效果（Sidebar + Topbar） ===== */

/* Sidebar 玻璃效果 */
.sidebar {
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border-right: none;
  box-shadow: 4px 0 18px rgba(0, 0, 0, 0.15);
}

/* Topbar 玻璃效果 */
.topbar {
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-bottom: none;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
}

/* Hover 更通透 */
.sidebar-item:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* 顶部图标 hover 玻璃化 */
.topbar-icon:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* 2. 整体布局结构 */
.layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background: var(--color-bg-body);
}

/* 3. 左侧菜单（Sidebar） */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  padding-top: 16px;
  transition: width 0.2s ease;
}

/* 修复：恢复 Sidebar 菜单字体为白色 */
.sidebar a,
.sidebar .nav-item a {
    color: var(--sidebar-text) !important;
}

.sidebar .nav-item.active a {
    color: var(--color-primary) !important;
}

/* 顶部 Logo 区域（大厂级标准高度） */
.sidebar-header {
    height: 72px; /* 你要的“比特浏览器级”高度 */
    display: flex;
    align-items: center;  /* 垂直居中 */
    gap: 10px;
    padding-left: 20px;
}

/* Logo 图片 */
.sidebar-logo {
  height: 56px;
  width: auto;
}

/* 网站名称 */
.sidebar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--sidebar-text);
}

/* 菜单：既清掉默认缩进，又给 Logo 留出空间 */
.sidebar-menu {
  padding-left: 0;
  margin-top: 24px; /* ← 给 Logo 区域留空间 */
  list-style: none;
}

/* ======（补全 SidebarItem 结构样式）====== */
.sidebar-item {
  position: relative;     /* tooltip 需要 */
  display: flex;
  align-items: center;
  padding: 12px 20px;     /* 保留原来的 padding */
  cursor: pointer;
  text-decoration: none;
  color: var(--sidebar-text);
  transition: background 0.2s ease;
}

.sidebar-item:hover {
  background: var(--sidebar-hover);
}

/* 链接本身做 flex 容器 */
.sidebar-item .sidebar-link {
  display: flex;
  align-items: center;
  width: 100%;
}

/* Sidebar 文本（正确类名：sidebar-label） */
.sidebar-item .sidebar-label {
  font-size: 14px;
  white-space: nowrap;
}

/* 折叠模式 */
.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

/* 4. 主体区域（Main） */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-body);
  margin-left: var(--sidebar-width);
  transition: margin-left 0.2s ease;
}

/* 折叠时主区域缩进减少 */
.sidebar.collapsed ~ .main {
  margin-left: var(--sidebar-collapsed-width);
}

/* 5. 顶部导航（Topbar） */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
    border-bottom: none;

  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;

  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 1000;
  transition: left 0.2s ease;
}

/* 折叠时 topbar 自动适配 */
.sidebar.collapsed ~ .main .topbar {
  left: var(--sidebar-collapsed-width);
}

/* ======（补全 Topbar 左侧结构）====== */
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ======（补全 Sidebar Toggle 按钮）====== */
.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}

.sidebar-toggle .icon {
  width: 20px;
  height: 20px;
}

/* ⭐ 修复：去掉浏览器默认 focus/active 外框 + 去掉矩形背景 */
.sidebar-toggle {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    outline: none !important;
    box-shadow: none !important;
}
.sidebar-toggle:focus,
.sidebar-toggle:active {
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
}

/* 恢复右侧图标区域布局 */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
  position: relative;   /* ⭐ 让 Dropdown 相对于整个导航栏定位 */
}

/* 恢复用户区域布局 */
.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 恢复头像圆形样式 */
.topbar-user .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

/* ====== 顶部图标按钮（Topbar Icon）====== */
.topbar-icon {
  border: none;
  background: transparent;
  padding: 8px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.topbar-icon svg {
  width: 22px;
  height: 22px;
  stroke-width: 2 !important; /* ← 关键修复 */
  flex-shrink: 0;
}

.topbar-icon:hover {
  background: rgba(0, 0, 0, 0.06);
}

.topbar-icon:focus {
  outline: none;
  box-shadow: none;
}

/* ⭐ Reset：统一清除 Topbar 所有按钮的默认样式 */
.topbar button {
    background: transparent;
    border: none;
    padding: 0;
    outline: none;
    box-shadow: none;
}
.topbar button:focus,
.topbar button:active {
    outline: none;
    box-shadow: none;
}

/* 6. 内容区域（Content） */
.content {
  flex: 1;
  padding: calc(var(--content-padding-y) + var(--topbar-height)) var(--content-padding-x) var(--content-padding-y);
  overflow-y: auto;
}

/* 7. 响应式规则 */
@media (max-width: 992px) {
  .sidebar {
    width: 200px;
  }
  .main {
    margin-left: 200px;
  }
  .topbar {
    left: 200px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .main {
    margin-left: 0;
  }
  .topbar {
    left: 0;
  }
}

/* ============================================
   玻璃拟态卡片（Card） + 大厂级阴影体系
   ============================================ */

/* 全局卡片玻璃拟态 */
.card {
  background: rgba(255, 255, 255, 0.55); /* 半透明白玻璃 */
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);

  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);

  padding: 20px;
  transition: all 0.25s ease;
  
  /* 大厂级柔光阴影（Linear / Vercel 风） */
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.08),
    0 8px 24px rgba(0, 0, 0, 0.06);
}

/* 卡片 hover 悬浮效果（更高级） */
.card:hover {
  transform: translateY(-3px);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.10),
    0 12px 32px rgba(0, 0, 0, 0.08);
}

/* 卡片标题更大厂 */
.card h3,
.card-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 14px;
  color: #1a1a1a;
}

/* 卡片内容更清晰 */
.card p,
.card-body {
  color: #333;
  font-size: 14px;
  line-height: 1.6;
}

/* ============================================
   玻璃拟态 + 暗黑模式（自动切换）
   ============================================ */

@media (prefers-color-scheme: dark) {
  :root {
    /* 深色模式下的玻璃拟态渐变蓝（更亮、更科技） */
    --sidebar-bg: linear-gradient(
        180deg,
        rgba(30, 40, 120, 0.55) 0%,
        rgba(40, 55, 160, 0.45) 100%
    );
    --sidebar-text: #e8eaff;
    --sidebar-hover: rgba(255, 255, 255, 0.12);

    --topbar-bg: linear-gradient(
        90deg,
        rgba(40, 55, 160, 0.55) 0%,
        rgba(60, 75, 200, 0.45) 100%
    );
    --topbar-border: rgba(255, 255, 255, 0.18);

    /* 内容区背景（深色玻璃） */
    --color-bg-body: rgba(10, 12, 20, 0.85);
  }

  /* Sidebar 深色玻璃效果 */
  .sidebar {
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 4px 0 18px rgba(0, 0, 0, 0.4);
  }

  /* Topbar 深色玻璃效果 */
  .topbar {
    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
      border-bottom: none;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  }

  /* 卡片深色玻璃拟态 */
  .card {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    box-shadow:
      0 4px 12px rgba(0, 0, 0, 0.35),
      0 8px 24px rgba(0, 0, 0, 0.25);
  }

  .card:hover {
    transform: translateY(-3px);
    box-shadow:
      0 6px 18px rgba(0, 0, 0, 0.45),
      0 12px 32px rgba(0, 0, 0, 0.35);
  }

  .card h3,
  .card-title {
    color: #e8eaff;
  }

  .card p,
  .card-body {
    color: #cfd3ff;
  }
}

/* ============================================
   玻璃拟态 + 动画体系（企业级丝滑动效）
   ============================================ */

/* 全局淡入动画（页面加载更丝滑） */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.layout,
.sidebar,
.topbar,
.content,
.card {
  animation: fadeIn 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Sidebar 展开/折叠动画（更大厂） */
.sidebar {
  transition:
    width 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    backdrop-filter 0.3s ease,
    background 0.3s ease;
}

/* Sidebar item hover 动画（更丝滑） */
.sidebar-item {
  transition:
    background 0.25s cubic-bezier(0.16, 1, 0.3, 1),
    padding-left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-item:hover {
  padding-left: 26px; /* 微动效，像比特浏览器 */
}

/* Topbar 动画（轻浮动） */
.topbar {
  transition:
    backdrop-filter 0.3s ease,
    background 0.3s ease,
    border-bottom 0.3s ease;
}

/* 图标按钮 hover 动画（更未来感） */
.topbar-icon {
  transition:
    background 0.25s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.topbar-icon:hover {
  transform: translateY(-2px);
}

/* 卡片悬浮动画（更大厂） */
.card {
  transition:
    transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    backdrop-filter 0.35s ease;
}

.card:hover {
  transform: translateY(-6px);
}

/* 内容区淡入动画（更柔和） */
.content {
  animation: fadeIn 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ===== Amazon 深色主题 · Topbar 文本 & 图标修复（更专业） ===== */

/* Topbar内只控制顶部图标和用户名文字变白，不干扰图标组件菜单 */
.topbar .username,
.topbar .topbar-icon i,
.topbar .topbar-icon svg {
    color: #fff !important;
    stroke: #fff !important;
}

/* 顶部图标（只控制描边，不强制填充） */
.topbar svg {
  stroke: rgba(255, 255, 255, 0.95) !important;
  stroke-width: 2 !important;
  fill: none !important;  /* 强制所有图标保持空心 */
}

/* 搜索框 placeholder 变亮白 */
.topbar input::placeholder {
  color: rgba(255, 255, 255, 0.75) !important;
}

/* 图标和文字的默认布局 */
.sidebar-item .sidebar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-right: 12px;
}

/* 折叠后：只保留图标，图标居中 */
.sidebar.collapsed .sidebar-item .sidebar-link {
  justify-content: center;
  width: auto;   /* ←←← 关键：不再占满整行 */
}

.sidebar.collapsed .sidebar-item .sidebar-icon {
  margin-right: 0;                 /* 去掉右侧间距 */
}

/* ===== Sidebar 折叠模式 · 完整修复 ===== */

/* ⭐ 折叠后 Logo 居中显示 */
.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding-left: 0;
}

/* ⭐ 折叠后隐藏标题，只显示 Logo */
.sidebar.collapsed .sidebar-title {
    display: none;
}

/* 折叠后隐藏文字 */
.sidebar.collapsed .sidebar-item .sidebar-label {
  display: none !important;
}

/* 折叠后图标居中 */
.sidebar.collapsed .sidebar-item {
  justify-content: center !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* 防止文字溢出到内容区 */
.sidebar-item .sidebar-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
}

/* 折叠后禁止竖排显示（关键） */
.sidebar.collapsed .sidebar-item {
  flex-direction: row !important;
}

/* 折叠后：悬停显示 tooltip */
.sidebar.collapsed .sidebar-item:hover::after {
  content: attr(data-title);
  position: absolute;
  left: 100%;                 /* 在侧边栏右侧 */
  top: 50%;
  transform: translateY(-50%);
  margin-left: 8px;

  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 9999;
  pointer-events: none;
}

/* 给 tooltip 一个轻微阴影 */
.sidebar.collapsed .sidebar-item:hover::after {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* ==================================================================
   ⭐ 修复后台页面区域横向滚动（最终版）----这个一直放到最底部
   ================================================================== */

/* 允许页面区域横向滚动 */
.content-wrapper {
    overflow-x: auto;
    overflow-y: visible;
}

/* 让内容区域可以撑开宽度，而不是被 flex 压缩 */
.content {
    min-width: 1200px; /* 你可以改成 1400 / 1600 */
}
