/*
 * 阔种云应用统一外壳（Header）。
 * 所有接入的应用页面只要引入本文件 + app-shell.js，并放一个 <header id="app-header"></header>，
 * 再调用 AppShell.mount({...}) 即可获得一致的顶栏。
 */

:root {
  --as-brand: #3370ff;
  --as-text: #1f2329;
  --as-muted: #8f959e;
  --as-border: #e5e6eb;
  --as-bg: #f4f5f7;
  --as-hover: #f2f3f5;
  --as-shadow: 0 8px 24px rgba(31, 35, 41, 0.12);
}

.as-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--as-border);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--as-text);
}

/* ---- 左侧：LOGO | 标题 ---- */
.as-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.as-logo {
  height: 30px;
  width: auto;
  flex: none;
  display: block;
}

.as-divider {
  width: 1px;
  height: 18px;
  flex: none;
  background: var(--as-border);
}

.as-title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- 右侧：应用切换 + 账号 ---- */
.as-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.as-launcher {
  position: relative;
}

/* 悬停时用这条透明带把按钮和面板连起来，鼠标从按钮移到面板不会中断 hover */
.as-launcher::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 10px;
}

.as-launcher-btn {
  display: grid;
  grid-template-columns: repeat(3, 4px);
  grid-template-rows: repeat(3, 4px);
  gap: 3px;
  place-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.as-launcher-btn:hover,
.as-launcher.open .as-launcher-btn {
  background: var(--as-hover);
}

.as-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #4e5460;
}

/* ---- 应用列表面板 ---- */
.as-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 200;
  width: 300px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--as-border);
  border-radius: 10px;
  box-shadow: var(--as-shadow);
  display: none;
}

.as-launcher:hover .as-panel,
.as-launcher.open .as-panel {
  display: block;
}

.as-panel-title {
  padding: 2px 6px 10px;
  font-size: 12px;
  color: var(--as-muted);
}

.as-app-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}

.as-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  border-radius: 8px;
  color: var(--as-text);
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  word-break: break-word;
}

.as-app:hover {
  background: var(--as-hover);
}

.as-app.active {
  background: #e8f3ff;
}

.as-app.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.as-app .as-app-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

/* ---- 账号区 ---- */
.as-account {
  position: relative;
}

.as-account-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px 3px 3px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--as-text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.as-account-btn:hover,
.as-account.open .as-account-btn {
  background: var(--as-hover);
}

.as-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: var(--as-brand);
  color: #fff;
  font-size: 12px;
  overflow: hidden;
}

.as-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.as-account-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.as-account-name {
  font-size: 13px;
  font-weight: 500;
  max-width: 132px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.as-account-sub {
  font-size: 11px;
  color: var(--as-muted);
}

.as-caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--as-muted);
}

.as-login-btn {
  height: 32px;
  padding: 0 16px;
  border: none;
  border-radius: 6px;
  background: var(--as-brand);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.as-login-btn:hover {
  background: #2860e1;
}

.as-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 200;
  min-width: 176px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--as-border);
  border-radius: 10px;
  box-shadow: var(--as-shadow);
  display: none;
}

.as-account.open .as-menu {
  display: block;
}

.as-menu-item {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--as-text);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.as-menu-item:hover {
  background: var(--as-hover);
}

.as-menu-sep {
  height: 1px;
  margin: 6px 4px;
  background: var(--as-border);
}

.as-menu-head {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--as-muted);
}
