/**
 * 企业知识库 · OA 门户样式与 PC 端小Q 抽屉入口
 */
:root {
  --portal-orange: #f5a623;
  --portal-orange-dark: #e8940f;
  --portal-orange-bg: #fff7e6;
  --portal-orange-bar: #f5a623;
  --portal-text: #333333;
  --portal-text-secondary: #666666;
  --portal-text-muted: #999999;
  --portal-border: #e8e8e8;
  --portal-bg: #f0f2f5;
  --portal-surface: #ffffff;
  --portal-font: "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif;
  --portal-topbar-h: 50px;
  --kb-drawer-w: 420px;
  --kb-fab-size: 56px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--portal-font);
  font-size: 14px;
  color: var(--portal-text);
  background: var(--portal-bg);
  line-height: 1.5;
}

.portal-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── 顶栏 ── */
.portal-topbar {
  display: flex;
  align-items: center;
  height: var(--portal-topbar-h);
  padding: 0 16px 0 12px;
  background: var(--portal-surface);
  border-bottom: 1px solid var(--portal-border);
  flex-shrink: 0;
  gap: 4px;
}

.portal-home-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--portal-orange);
  flex-shrink: 0;
  text-decoration: none;
}

.portal-home-icon svg { width: 20px; height: 20px; fill: currentColor; }

.portal-modules {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.portal-modules::-webkit-scrollbar { display: none; }

.portal-modules a {
  padding: 14px 14px;
  color: var(--portal-text-secondary);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.15s;
}

.portal-modules a:hover { color: var(--portal-orange); }

.portal-modules a.is-active {
  color: var(--portal-orange);
  border-bottom-color: var(--portal-orange);
  font-weight: 500;
}

.portal-topright {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  color: var(--portal-text-secondary);
}

.portal-icon-btn {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  color: #888;
  padding: 0;
  border-radius: 4px;
}

.portal-icon-btn:hover { background: #f5f5f5; color: #555; }
.portal-icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

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

.portal-divider {
  width: 1px;
  height: 20px;
  background: var(--portal-border);
}

.portal-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--portal-text);
  cursor: default;
}

.portal-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #d9d9d9;
}

/* ── 面包屑行 ── */
.portal-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--portal-surface);
  border-bottom: 1px solid var(--portal-border);
  font-size: 13px;
  color: var(--portal-text-muted);
}

.portal-breadcrumb strong { color: var(--portal-text); font-weight: normal; }

.portal-subbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border: 1px solid var(--portal-border);
  border-radius: 4px;
  background: var(--portal-surface);
  font-size: 12px;
  color: var(--portal-text-secondary);
  cursor: pointer;
  font-family: inherit;
}

.portal-subbar-btn:hover { border-color: var(--portal-orange); color: var(--portal-orange); }

/* ── 主内容 ── */
.portal-main {
  flex: 1;
  padding: 16px 20px 80px;
  overflow: auto;
}

.portal-section {
  background: var(--portal-surface);
  border: 1px solid var(--portal-border);
  margin-bottom: 16px;
}

.portal-section-head {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--portal-border);
  font-size: 15px;
  font-weight: 600;
  color: var(--portal-text);
}

.portal-section-head::before {
  content: "";
  width: 4px;
  height: 16px;
  background: var(--portal-orange-bar);
  margin-right: 10px;
  border-radius: 1px;
  flex-shrink: 0;
}

.portal-section-body { padding: 20px 24px; }

/* 个人信息栏 */
.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.profile-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, #ffd591 0%, #f5a623 100%);
}

.profile-greeting {
  font-size: 16px;
  font-weight: 500;
  margin: 0 0 6px;
  color: var(--portal-text);
}

.profile-dept {
  font-size: 13px;
  color: var(--portal-text-muted);
  margin: 0;
}

.profile-stats {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}

.stat-item {
  text-align: center;
  min-width: 72px;
}

.stat-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  margin: 0 auto 8px;
}

.stat-ring--blue { border-color: #1890ff; color: #1890ff; }
.stat-ring--navy { border-color: #2f54eb; color: #2f54eb; }
.stat-ring--teal { border-color: #13c2c2; color: #13c2c2; }
.stat-ring--green { border-color: #52c41a; color: #52c41a; }

.stat-label {
  font-size: 12px;
  color: var(--portal-text-muted);
}

/* 待办表格 */
.portal-table-wrap { overflow-x: auto; }

.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.portal-table th,
.portal-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--portal-border);
}

.portal-table th {
  background: #fafafa;
  font-weight: 500;
  color: var(--portal-text-secondary);
  white-space: nowrap;
}

.portal-table tbody tr:hover td { background: #fafafa; }

.portal-table td:first-child { color: var(--portal-text-muted); width: 48px; text-align: center; }

.portal-table a {
  color: var(--portal-text);
  text-decoration: none;
}

.portal-table a:hover { color: var(--portal-orange); }

/* ── FAB（强化版：胶囊 + 涟漪 + 引导气泡）── */
.kb-fab-wrap {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.kb-fab-wrap.is-drawer-open .kb-fab-hint,
.kb-fab-wrap.is-drawer-open .kb-fab-ripples {
  opacity: 0;
  pointer-events: none;
}

/* 引导气泡 */
.kb-fab-hint {
  position: relative;
  padding: 10px 16px;
  background: var(--portal-surface);
  border: 1px solid #ffe7ba;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--portal-text);
  box-shadow: 0 6px 20px rgba(245, 166, 35, 0.22);
  white-space: nowrap;
  animation: hint-float 3s ease-in-out infinite, hint-enter 0.6s ease-out;
  transform-origin: right bottom;
}

.kb-fab-hint::after {
  content: "";
  position: absolute;
  right: 28px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: var(--portal-surface);
  border-right: 1px solid #ffe7ba;
  border-bottom: 1px solid #ffe7ba;
  transform: rotate(45deg);
}

.kb-fab-hint strong {
  color: var(--portal-orange-dark);
  font-weight: 600;
}

.kb-fab-hint-close {
  margin-left: 10px;
  padding: 0 4px;
  border: none;
  background: none;
  color: #bbb;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  vertical-align: middle;
}

.kb-fab-hint-close:hover { color: #666; }

.kb-fab-hint.is-dismissed {
  display: none;
}

/* 涟漪环 */
.kb-fab-ripples {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 200px;
  height: 64px;
  pointer-events: none;
}

.kb-fab-ripples span {
  position: absolute;
  right: 20px;
  bottom: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(245, 166, 35, 0.45);
  animation: fab-ripple 2.4s ease-out infinite;
}

.kb-fab-ripples span:nth-child(2) { animation-delay: 0.8s; }
.kb-fab-ripples span:nth-child(3) { animation-delay: 1.6s; }

.kb-fab-inner {
  position: relative;
  z-index: 1;
}

.kb-fab {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px 12px 14px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffc53d 0%, #f5a623 45%, #e8940f 100%);
  color: #fff;
  cursor: pointer;
  box-shadow:
    0 6px 24px rgba(245, 166, 35, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.25) inset;
  font-family: inherit;
  overflow: hidden;
  position: relative;
  animation: fab-bounce 2.8s ease-in-out infinite;
  transition: transform 0.2s, box-shadow 0.2s;
}

.kb-fab::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: fab-shine 3.5s ease-in-out infinite;
}

.kb-fab:hover {
  transform: scale(1.04) translateY(-2px);
  box-shadow:
    0 10px 32px rgba(245, 166, 35, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.3) inset;
  animation: none;
}

.kb-fab:active {
  transform: scale(0.98);
}

.kb-fab-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kb-fab-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.kb-fab-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  line-height: 1.25;
}

.kb-fab-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.kb-fab-sub {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.9;
  margin-top: 2px;
}

@keyframes fab-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes fab-shine {
  0%, 70%, 100% { left: -100%; }
  35% { left: 150%; }
}

@keyframes fab-ripple {
  0% {
    transform: scale(0.6);
    opacity: 0.7;
  }
  100% {
    transform: scale(2.8);
    opacity: 0;
  }
}

@keyframes hint-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes hint-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .kb-fab,
  .kb-fab::before,
  .kb-fab-ripples span,
  .kb-fab-hint {
    animation: none !important;
  }
  .kb-fab-hint { opacity: 1; transform: none; }
}

@media (max-width: 480px) {
  .kb-fab-wrap { right: 12px; bottom: 12px; }
  .kb-fab-sub { display: none; }
  .kb-fab { padding: 10px 16px 10px 12px; }
  .kb-fab-hint { font-size: 12px; max-width: 200px; white-space: normal; }
}

/* ── 遮罩 + 抽屉 ── */
.kb-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s, visibility 0.28s;
}

.kb-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.kb-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--kb-drawer-w);
  max-width: 100vw;
  height: 100vh;
  background: #f7f8fa;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.kb-drawer.is-open { transform: translateX(0); }

.kb-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--portal-surface);
  border-bottom: 1px solid var(--portal-border);
  flex-shrink: 0;
}

.kb-drawer-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kb-drawer-title-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #fff7e6, #ffe7ba);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.kb-drawer-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  color: #999;
  font-size: 20px;
  line-height: 1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kb-drawer-close:hover { background: #f5f5f5; color: #333; }

.kb-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.kb-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.kb-msg--user { flex-direction: row-reverse; }

.kb-msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.kb-msg-avatar--bot {
  background: linear-gradient(135deg, #fff7e6, #ffd591);
}

.kb-msg-avatar--user {
  background: #e6f7ff;
  font-size: 12px;
  font-weight: 600;
  color: #1890ff;
}

.kb-msg-bubble {
  max-width: calc(100% - 50px);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.65;
  background: var(--portal-surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.kb-msg--user .kb-msg-bubble {
  background: #1890ff;
  color: #fff;
}

.kb-msg-bubble p { margin: 0 0 8px; }
.kb-msg-bubble p:last-child { margin-bottom: 0; }

.kb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.kb-chip {
  padding: 6px 12px;
  border: 1px solid #d6e4ff;
  border-radius: 16px;
  background: #f0f5ff;
  color: #2f54eb;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
  line-height: 1.4;
}

.kb-chip:hover {
  background: #d6e4ff;
  border-color: #adc6ff;
}

.kb-cite {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--portal-border);
  font-size: 12px;
  color: var(--portal-text-muted);
}

.kb-cite a {
  color: #2f54eb;
  text-decoration: none;
}

.kb-cite a:hover { text-decoration: underline; }

.kb-drawer-foot {
  padding: 12px 16px 16px;
  background: var(--portal-surface);
  border-top: 1px solid var(--portal-border);
  flex-shrink: 0;
}

.kb-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--portal-border);
  border-radius: 12px;
  background: #fafafa;
}

.kb-input-wrap:focus-within {
  border-color: #91d5ff;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
}

.kb-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 22px;
  max-height: 100px;
  line-height: 1.5;
  padding: 4px 0;
}

.kb-input::placeholder { color: #bbb; }

.kb-input-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.kb-attach-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  color: #bbb;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.kb-attach-btn:hover { color: #888; background: #f0f0f0; }

.kb-send-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: #1890ff;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.kb-send-btn:hover { background: #40a9ff; }
.kb-send-btn:disabled { background: #d9d9d9; cursor: not-allowed; }

.kb-send-btn svg { width: 16px; height: 16px; fill: currentColor; }

.kb-typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.kb-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ccc;
  animation: typing 1.2s infinite;
}

.kb-typing span:nth-child(2) { animation-delay: 0.2s; }
.kb-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 480px) {
  .profile-stats { gap: 16px; }
}
