/* ============================================================
   全局布局模块 - 顶部导航 + 侧边栏 + 标签栏 + 主内容区
   嵌套逻辑：侧边栏控制 Tab 容器，Tab 容器控制内容区
   由 layout.js 动态注入 HTML，本文件提供样式
   ============================================================ */

:root {
  --zl-active-menu-bg: #2a4570;
  --zl-sidebar-width: 240px;
  --zl-sidebar-collapsed-width: 64px;
  --zl-header-height: 56px;
  --zl-tabs-height: 44px;
  --zl-sidebar-bg: #001529;
  --zl-content-bg: #f5f7fa;
}

/* ===== 整体壳层 =====
   框架页 body 直接容纳 顶部/侧边/Tab容器，不再使用 zl-shell flex
   （因各区域均为 fixed/sticky，按规范表独立定位） */

/* ===== 顶部导航 =====
   固定吸顶，高度 56px，z-index 1000，高于侧边栏与主内容区 */
.zl-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--zl-header-height);
  background: var(--zl-sidebar-bg);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
  transition: box-shadow 0.2s ease;
}

/* 滚动时阴影（由 JS 在主内容区滚动时加 .zl-header--scrolled 类） */
.zl-header--scrolled {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.zl-header__left {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  line-height: 24px;
  font-weight: 500;
}

/* 汉堡折叠按钮 */
.zl-header__toggle {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.15s ease;
  padding: 0;
  flex-shrink: 0;
}

.zl-header__toggle:hover {
  background: rgba(255, 255, 255, 0.12);
}

.zl-header__toggle svg {
  width: 20px;
  height: 20px;
}

.zl-header__logo-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

/* LOGO 占位符：折叠按钮后面，150×54px；当有真实 LOGO 时（--filled 修饰类）去掉占位虚线框和斜纹 */
.zl-header__logo-placeholder {
  width: 150px;
  height: 54px;
  flex: 0 0 150px;     /* 不被 flex 压缩 */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02)),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.06) 0 8px, rgba(255,255,255,0) 8px 16px);
  border: 1px dashed rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
  padding: 2px 6px;
  overflow: hidden;
  position: relative;
}
.zl-header__logo-placeholder::after {
  content: 'LOGO';      /* src 未填时显示的占位字 */
  letter-spacing: 2px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
}
.zl-header__logo-placeholder .zl-header__logo-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  z-index: 2;
  background: transparent;
}
/* 已填入真实 LOGO：隐藏占位字/斜纹/虚线框，只保留干净的 LOGO 块 */
.zl-header__logo-placeholder--filled {
  background: transparent;
  border: none;
  padding: 0;
}
.zl-header__logo-placeholder--filled::after {
  content: none;
}

/* 品牌图标 + 标题的组合：整体向右移动 180px（LOGO 占位宽度 150 + 左右各 15 的间距） */
.zl-header__title-group {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-left: 40px;
}

.zl-header__right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.zl-header__icon-btn {
  width: 20px;
  height: 20px;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
}

.zl-header__user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 20px;
  color: rgba(255, 255, 255, 0.85);
  cursor: default;
}

.zl-header__user-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
  line-height: 1.15;
  min-width: 0;
}

.zl-header__user-name {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  max-width: none;
  white-space: nowrap;
}

.zl-header__user-type {
  font-size: 12px;
  color: #94a3b8;
  white-space: nowrap;
}

.zl-header__logout {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
  padding: 0;
}

.zl-header__logout:hover {
  background: rgba(239, 68, 68, 0.6);
}

.zl-header__logout svg {
  width: 14px;
  height: 14px;
}

/* 用户区域加载态 - 默认隐藏，待 init() 渲染用户信息后显示 */
.zl-header__user--loading {
  visibility: hidden;
}

.zl-header__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.zl-header__avatar svg {
  width: 18px;
  height: 18px;
  color: #ffffff;
}

/* ===== 侧边导航栏 =====
   fixed 左侧，z-index 900（低于顶部 1000），
   宽度 240/64px 联动 Tab 容器 margin-left */
.zl-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--zl-sidebar-width);
  height: 100vh;
  background: var(--zl-sidebar-bg);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 900;
  transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 折叠态：仅显示图标，隐藏文字/品牌文字/箭头 */
.zl-sidebar--collapsed {
  width: var(--zl-sidebar-collapsed-width);
}

.zl-sidebar--collapsed .zl-sidebar__brand-text,
.zl-sidebar--collapsed .zl-sidebar__item-name,
.zl-sidebar--collapsed .zl-sidebar__expand,
.zl-sidebar--collapsed .zl-sidebar__submenu {
  display: none;
}

.zl-sidebar--collapsed .zl-sidebar__brand {
  justify-content: center;
  padding: 16px 0;
}

.zl-sidebar--collapsed .zl-sidebar__link,
.zl-sidebar--collapsed .zl-sidebar__link--parent {
  justify-content: center;
  padding: 12px 0;
}

.zl-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  font-size: 18px;
  line-height: 24px;
  font-weight: 500;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
}

.zl-sidebar__brand-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.zl-sidebar__menu {
  list-style: none;
  margin: 0;
  padding: 8px 0 16px;
}

.zl-sidebar__item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.zl-sidebar__item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.zl-sidebar__item--active {
  background: var(--zl-active-menu-bg);
  color: #ffffff;
}

.zl-sidebar__item-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}

.zl-sidebar__item-name {
  white-space: nowrap;
  overflow: hidden;
}

/* 父菜单项 - block 布局避免 flex 容器切换闪烁 */
.zl-sidebar__item--has-submenu {
  display: block;
  padding: 0;
}

.zl-sidebar__link--parent {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  /* 一级菜单缩进 16px（规范表） */
  padding: 12px 16px 12px 16px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.zl-sidebar__item--has-submenu:hover > .zl-sidebar__link--parent {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.zl-sidebar__expand {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-left: auto;
  transition: transform 0.2s ease;
}

.zl-sidebar__item--open .zl-sidebar__expand {
  transform: rotate(90deg);
}

.zl-sidebar__submenu {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  width: 100%;
}

.zl-sidebar__submenu--open {
  max-height: 9999px;
  overflow: visible;
}

.zl-sidebar__submenu .zl-sidebar__item {
  padding: 0;
}

/* 二级菜单缩进 32px（规范表） */
.zl-sidebar__submenu .zl-sidebar__link {
  padding: 12px 16px 12px 32px;
}

.zl-sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  /* 一级菜单缩进 16px（规范表） */
  padding: 12px 16px 12px 16px;
  color: inherit;
  text-decoration: none;
}

/* ===== Tab 容器 =====
   包裹标签栏 + 主内容区，由侧边栏宽度联动 margin-left */
.zl-tab-container {
  margin-left: var(--zl-sidebar-width);
  margin-top: var(--zl-header-height);
  min-height: calc(100vh - var(--zl-header-height));
  transition: margin-left 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.zl-sidebar--collapsed ~ .zl-tab-container {
  margin-left: var(--zl-sidebar-collapsed-width);
}

/* ===== 标签栏 (Tab Bar) =====
   高度 44px，z-index 800，sticky 跟随主内容区滚动定位 */
.zl-tabs {
  position: sticky;
  top: var(--zl-header-height);
  height: var(--zl-tabs-height);
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  z-index: 800;
  flex-shrink: 0;
  white-space: nowrap;
}

/* 隐藏滚动条但保留滚动 */
.zl-tabs::-webkit-scrollbar {
  height: 4px;
}

.zl-tabs::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 2px;
}

.zl-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #ffffff;
  color: #4b5563;
  font-size: 13px;
  line-height: 20px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.zl-tab:hover {
  background: #f3f4f6;
  color: #1f2937;
}

.zl-tab--active {
  background: var(--zl-sidebar-bg);
  color: #ffffff;
  border-color: var(--zl-sidebar-bg);
}

.zl-tab--active:hover {
  background: var(--zl-sidebar-bg);
  color: #ffffff;
}

.zl-tab__name {
  white-space: nowrap;
}

.zl-tab__close {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  color: inherit;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.zl-tab:hover .zl-tab__close,
.zl-tab--active .zl-tab__close {
  opacity: 0.85;
}

.zl-tab__close:hover {
  background: rgba(239, 68, 68, 0.8);
  color: #ffffff;
  opacity: 1;
}

/* ===== iframe 容器 =====
   每个 Tab 对应一个 iframe，切换时显示/隐藏 */
.zl-iframe-container {
  flex: 1;
  position: relative;
  background: var(--zl-content-bg);
  overflow: hidden;
}

.zl-iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: var(--zl-content-bg);
  display: none;
}

.zl-iframe--active {
  display: block;
}

/* ===== 主内容区 =====
   子页面在 iframe 内渲染，由 iframe 容器控制高度；
   .zl-main 仅负责内边距、最小宽度、背景色，高度自动撑开，由 iframe 内滚动 */
.zl-main {
  padding: 24px;
  min-width: 1200px;
  min-height: calc(100vh - 48px); /* 留出底部呼吸空间，保证背景填满 */
  background: var(--zl-content-bg);
  box-sizing: border-box;
}

/* ===== 修改密码弹窗补充样式 ===== */
.zl-modal-overlay{position:fixed;inset:0;background:rgba(15,23,42,0.45);z-index:99998;display:none;align-items:center;justify-content:center}
.zl-modal-overlay--open{display:flex}
.zl-modal{background:#fff;border-radius:10px;box-shadow:0 20px 60px rgba(15,23,42,0.2);width:480px;max-width:calc(100vw - 32px);max-height:85vh;overflow:hidden;display:flex;flex-direction:column;animation:zlModalIn .18s ease-out}
@keyframes zlModalIn{from{transform:translateY(-8px);opacity:0}to{transform:none;opacity:1}}
.zl-modal__header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid #eef2f7}
.zl-modal__title{margin:0;font-size:16px;font-weight:600;color:#111827}
.zl-modal__close{border:none;background:transparent;color:#6b7280;cursor:pointer;font-size:22px;line-height:1;padding:0 4px;border-radius:4px}
.zl-modal__close:hover{color:#111827;background:#f3f4f6}
.zl-modal__body{padding:20px}
.zl-modal__footer{display:flex;justify-content:flex-end;gap:10px;padding:14px 20px;border-top:1px solid #eef2f7;background:#fafbfc}
.zl-form-group{margin-bottom:16px}
.zl-form-group:last-of-type{margin-bottom:0}
.zl-modal__label{display:block;margin-bottom:6px;font-size:13px;color:#666}
.zl-modal__required{color:red}
.zl-modal__input{width:100%;padding:8px 12px;border:1px solid #d0d0d0;border-radius:4px;font-size:14px;box-sizing:border-box}
.zl-modal__input:focus{outline:none;border-color:#2563eb;box-shadow:0 0 0 3px rgba(37,99,235,0.12)}
.zl-modal__hint{font-size:12px;color:#999;margin-top:4px}
.zl-modal__error{color:red;font-size:13px;min-height:18px;margin-bottom:8px}
.zl-modal__btn--cancel{padding:8px 16px;border:1px solid #d0d0d0;background:#fff;border-radius:4px;cursor:pointer;font-size:14px}
.zl-modal__btn--cancel:hover{background:#f9fafb}
.zl-modal__btn--submit{padding:8px 16px;background:#2563eb;color:#fff;border:none;border-radius:4px;cursor:pointer;font-size:14px}
.zl-modal__btn--submit:hover{background:#1d4ed8}
.zl-modal__btn--submit:disabled{background:#9ca3af;cursor:not-allowed}

/* ===== 侧边栏防闪烁（layout.js 早期注入的样式合并到此处统一管理） ===== */
.zl-header__user--loading{visibility:hidden!important}
.zl-header__logout--hidden{display:none!important}
.zl-sidebar__submenu{max-height:0!important;overflow:hidden!important;transition:none!important}
.zl-sidebar__submenu--open{max-height:9999px!important;overflow:visible!important}
