/* ===== 公告/通知系统样式 =====
 * 三处展示位：
 * 1. 顶部横幅 .ann-banner（type=banner）
 * 2. 首页弹窗 .ann-popup-overlay（type=popup, once=true）
 * 3. 通知中心 .ann-bell + .ann-panel（type=notice）
 */

/* ===== 1. 工具条内嵌横幅 =====
 * 占位在「重置」和「清空工作区」之间：
 * 左边不超过重置，右边贴清空工作区，中间从右往左滚。
 */
.ann-banner-slot {
  flex: 1 1 0;
  min-width: 0;
  max-width: 100%;
  height: 28px;
  display: flex;
  align-items: center;
  overflow: hidden;
}
.ann-banner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 0 6px 0 10px;
  font-size: 12px;
  line-height: 1.3;
  border: 1px solid transparent;
  border-radius: 6px;
  overflow: hidden;
}
.ann-banner.ann-level-info { background: linear-gradient(90deg, rgba(88,166,255,0.18), rgba(88,166,255,0.08)); color: var(--text); border-color: rgba(88,166,255,0.22); }
.ann-banner.ann-level-success { background: linear-gradient(90deg, rgba(35,134,54,0.22), rgba(35,134,54,0.08)); color: var(--text); border-color: rgba(35,134,54,0.24); }
.ann-banner.ann-level-warning { background: linear-gradient(90deg, rgba(210,153,34,0.22), rgba(210,153,34,0.08)); color: var(--text); border-color: rgba(210,153,34,0.24); }
.ann-banner.ann-level-danger { background: linear-gradient(90deg, rgba(248,81,73,0.22), rgba(248,81,73,0.08)); color: var(--text); border-color: rgba(248,81,73,0.24); }
.ann-banner-icon {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}
.ann-banner-marquee {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  position: relative;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
}
.ann-banner-track {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: none;
  white-space: nowrap;
  animation: annBannerMarquee 22s linear infinite;
}
.ann-banner-track:hover { animation-play-state: paused; }
.ann-banner-title {
  font-weight: 600;
  flex-shrink: 0;
}
.ann-banner-content {
  color: var(--text-muted);
  flex-shrink: 0;
}
.ann-banner-content * { display: inline; }
.ann-banner-link {
  flex-shrink: 0;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--blue);
  border: 1px solid var(--blue);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.ann-banner-link:hover { background: var(--blue); color: #fff; }
.ann-banner-close {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
}
.ann-banner-close:hover { background: var(--bg-hover); color: var(--text); }

@keyframes annBannerMarquee {
  from { left: 100%; transform: translateX(0); }
  to { left: 0; transform: translateX(-100%); }
}

/* ===== 2. 首页弹窗 / 通知详情（v2，无遮罩） ===== */
.ann-popup-overlay,
.ann-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  pointer-events: none;
  animation: annFadeIn 0.2s ease;
}
.ann-popup,
.ann-detail {
  pointer-events: auto;
  position: relative;
  width: 100%;
  max-width: 540px;
  max-height: min(80vh, calc(100dvh - 40px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: auto;
  color: #e2e8f0;
  background: linear-gradient(160deg, #131836 0%, #0d1228 50%, #0a0f1f 100%);
  border-radius: 16px;
  border: 1px solid rgba(139, 92, 246, 0.3);
  box-shadow:
    0 0 0 1px rgba(139, 92, 246, 0.35),
    0 0 50px rgba(139, 92, 246, 0.28),
    0 0 100px rgba(99, 102, 241, 0.16),
    0 25px 50px rgba(0, 0, 0, 0.5);
  animation: annPopupIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ann-popup-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid rgba(139, 92, 246, 0.16);
  font-size: 15px;
  font-weight: 600;
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.12), transparent);
}
.ann-popup-header .ann-theme-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.28), rgba(99, 102, 241, 0.22));
  border: 1px solid rgba(167, 139, 250, 0.35);
  color: #c4b5fd;
}
.ann-popup-header .ann-theme-icon svg {
  width: 20px !important;
  height: 20px !important;
  stroke: currentColor;
  fill: none;
}
.ann-popup-header .ann-level-bar {
  display: none;
}
.ann-popup-header.ann-level-info .ann-theme-icon {
  color: #93c5fd;
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.28), rgba(59, 130, 246, 0.18));
  border-color: rgba(96, 165, 250, 0.35);
}
.ann-popup-header.ann-level-success .ann-theme-icon {
  color: #86efac;
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.28), rgba(16, 185, 129, 0.18));
  border-color: rgba(52, 211, 153, 0.35);
}
.ann-popup-header.ann-level-warning .ann-theme-icon {
  color: #fcd34d;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.28), rgba(245, 158, 11, 0.18));
  border-color: rgba(251, 191, 36, 0.35);
}
.ann-popup-header.ann-level-danger .ann-theme-icon {
  color: #fda4af;
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.28), rgba(239, 68, 68, 0.18));
  border-color: rgba(248, 113, 113, 0.35);
}
.ann-popup-title-wrap {
  flex: 1;
  min-width: 0;
}
.ann-popup-title {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f1f5f9;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}
.ann-popup-sub {
  margin-top: 2px;
  font-size: 12px;
  color: #94a3b8;
  font-weight: 400;
}
.ann-popup-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  flex-shrink: 0;
}
.ann-popup-close:hover {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fda4af;
}
.ann-popup-body {
  padding: 16px 18px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
  color: #e2e8f0;
  word-break: break-word;
  min-height: 0;
  flex: 1;
}
.ann-popup-body p { margin: 0 0 10px; }
.ann-popup-body p:last-child { margin-bottom: 0; }
.ann-popup-body a { color: #93c5fd; text-decoration: underline; }
.ann-popup-body img { max-width: 100%; height: auto; border-radius: 8px; }
.ann-popup-body ul, .ann-popup-body ol { margin: 6px 0 10px; padding-left: 24px; }
.ann-popup-body h3, .ann-popup-body h4 { margin: 12px 0 6px; color: #f1f5f9; }
.ann-popup-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px 16px;
  border-top: 1px solid rgba(139, 92, 246, 0.14);
  background: rgba(15, 23, 42, 0.35);
}
.ann-btn {
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #e2e8f0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ann-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}
.ann-btn-primary {
  background: linear-gradient(135deg, #a78bfa, #818cf8);
  border-color: transparent;
  color: #0f172a;
}
.ann-btn-primary:hover {
  filter: brightness(1.08);
  background: linear-gradient(135deg, #a78bfa, #818cf8);
}

@keyframes annFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes annPopupIn {
  from { opacity: 0; transform: scale(0.94) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===== 3. 通知中心（铃铛 + 抽屉） ===== */
.ann-bell {
  position: relative;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}
.ann-bell:hover { background: var(--bg-hover); color: var(--text); }
.ann-bell-dot {
  position: absolute;
  top: -1px;
  right: -1px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 14px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--bg-deep);
  box-sizing: border-box;
}
.ann-bell-dot.ann-hide { display: none; }

@keyframes annDotPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.ann-panel {
  position: fixed;
  top: 56px;
  right: 16px;
  width: 360px;
  max-height: calc(100vh - 80px);
  background: linear-gradient(160deg, #131836 0%, #0d1228 55%, #0a0f1f 100%);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 14px;
  box-shadow:
    0 0 0 1px rgba(139, 92, 246, 0.25),
    0 0 40px rgba(139, 92, 246, 0.18),
    0 20px 40px rgba(0, 0, 0, 0.45);
  z-index: var(--z-drawer, 500);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #e2e8f0;
  animation: annPanelIn 0.2s ease;
}
.ann-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(139, 92, 246, 0.16);
  font-size: 14px;
  font-weight: 700;
  color: #f1f5f9;
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.12), transparent);
}
.ann-panel-markall {
  font-size: 12px;
  color: #93c5fd;
  background: rgba(96, 165, 250, 0.1);
  border: 1px solid rgba(96, 165, 250, 0.22);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 8px;
  transition: all .15s;
}
.ann-panel-markall:hover {
  background: rgba(96, 165, 250, 0.18);
  color: #bfdbfe;
}
.ann-panel-markall.ann-hide { display: none; }
.ann-panel-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 10px 0;
  border-bottom: 1px solid rgba(139, 92, 246, 0.12);
}
.ann-panel-tab {
  flex: 1;
  position: relative;
  height: 32px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
}
.ann-panel-tab.active {
  color: #f1f5f9;
  background: rgba(99, 102, 241, 0.12);
}
.ann-tab-badge {
  display: inline-flex;
  min-width: 14px;
  height: 14px;
  margin-left: 6px;
  padding: 0 4px;
  border-radius: 7px;
  background: var(--red, #f85149);
  color: #fff;
  font-size: 10px;
  line-height: 14px;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}
.ann-tab-badge.ann-hide { display: none; }
.ann-panel-list,
.ann-panel-feedback {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  min-height: 180px;
}
.ann-panel-feedback[hidden],
.ann-panel-list[hidden] { display: none; }
.ann-panel-empty {
  padding: 40px 16px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
}
.ann-item {
  padding: 12px 12px 12px 14px;
  margin-bottom: 6px;
  border: 1px solid rgba(139, 92, 246, 0.12);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.12s, border-color .12s;
  position: relative;
  background:
    linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(15, 23, 42, 0.45)),
    rgba(30, 41, 59, 0.4);
}
.ann-item:hover {
  background:
    linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(15, 23, 42, 0.55)),
    rgba(30, 41, 59, 0.5);
  border-color: rgba(167, 139, 250, 0.28);
}
.ann-item.ann-unread::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 18px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #60a5fa;
  box-shadow: 0 0 8px rgba(96, 165, 250, 0.55);
}
.ann-item-title {
  font-size: 13px;
  font-weight: 600;
  color: #f1f5f9;
  margin-bottom: 4px;
  padding-left: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ann-item-time {
  font-size: 11px;
  color: #64748b;
  padding-left: 10px;
}
.ann-item-preview {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 4px;
  padding-left: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes annPanelIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.tk-list { display: flex; flex-direction: column; }
.tk-item .ann-item-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tk-status {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 8px;
  flex-shrink: 0;
}
.tk-status-open { background: rgba(210,153,34,0.18); color: #fbbf24; }
.tk-status-replied { background: rgba(88,166,255,0.18); color: #93c5fd; }
.tk-status-closed { background: rgba(35,134,54,0.18); color: #86efac; }
.tk-footer {
  padding: 8px 6px 10px;
  border-top: 1px solid rgba(139, 92, 246, 0.12);
}
.tk-footer .ann-btn { width: 100%; }
.tk-login-hint { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.tk-compose, .tk-thread { padding: 6px 8px 12px; display: flex; flex-direction: column; gap: 8px; }
.tk-compose-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
}
.tk-back {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: #cbd5e1;
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
}
.tk-label { font-size: 12px; color: #94a3b8; }
.tk-select, .tk-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(139, 92, 246, 0.22);
  background: rgba(15, 23, 42, 0.55);
  color: #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
}
.tk-textarea { min-height: 96px; resize: vertical; }
.tk-count { font-size: 11px; color: #64748b; text-align: right; }
.tk-upload-row { display: flex; align-items: center; gap: 8px; }
.tk-file-name { font-size: 12px; color: #94a3b8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-error { min-height: 16px; font-size: 12px; color: #fda4af; }
.tk-msg {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(139, 92, 246, 0.12);
}
.tk-msg-admin {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.22);
}
.tk-msg-meta { font-size: 11px; color: #64748b; margin-bottom: 4px; }
.tk-msg-text { font-size: 13px; color: #e2e8f0; white-space: pre-wrap; word-break: break-word; }
.tk-msg-img img { max-width: 100%; border-radius: 8px; margin-top: 8px; }
.tk-closed-hint { text-align: center; font-size: 12px; color: #94a3b8; padding: 8px 0; }
.tk-reply-box { display: flex; flex-direction: column; gap: 8px; }

/* ===== 后台富文本编辑器 ===== */
.rte-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
}
.rte-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.12s;
}
.rte-btn:hover { background: var(--bg-hover); border-color: var(--border-light); }
.rte-btn.ann-divider { background: transparent; border: none; color: var(--text-dim); cursor: default; }
.rte-editor {
  min-height: 160px;
  max-height: 360px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  outline: none;
}
.rte-editor:focus { border-color: var(--blue); }
.rte-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-dim);
  pointer-events: none;
}
.rte-editor p { margin: 0 0 8px; }
.rte-editor ul, .rte-editor ol { padding-left: 24px; margin: 6px 0; }
.rte-editor a { color: var(--blue); }

.ann-admin-head { margin-bottom: 12px; }
.ann-admin-head h3 { margin: 0 0 4px; }
.ann-admin-head p,
.ann-admin-desc {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}
.ann-admin-toolbar { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
.ann-rotate-label {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-right: 8px;
}
.ann-sub-panel { display: none; margin-top: 14px; }
.ann-sub-panel.active { display: block; }

/* 后台公告列表 */
.ann-admin-list { display: flex; flex-direction: column; gap: 8px; }
.ann-admin-item {
  display: grid;
  grid-template-columns: 72px 1fr 70px minmax(150px, 220px) 120px;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.ann-admin-live {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 3px;
  background: rgba(35,134,54,0.18);
  color: var(--green);
}
.ann-admin-item.ann-disabled { opacity: 0.55; }
.ann-admin-type-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  text-align: center;
}
.ann-admin-type-tag.ann-type-banner { background: rgba(88,166,255,0.18); color: var(--blue); }
.ann-admin-type-tag.ann-type-popup { background: rgba(163,113,247,0.18); color: var(--purple); }
.ann-admin-type-tag.ann-type-notice { background: rgba(210,153,34,0.18); color: var(--warn); }
.ann-admin-actions { display: flex; gap: 4px; }
.ann-admin-level-pill {
  display: inline-block;
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 3px;
  background: var(--bg-deep);
  color: var(--text-muted);
}
.ann-admin-level-pill.ann-level-warning { color: var(--warn); }
.ann-admin-level-pill.ann-level-danger { color: var(--red); }
.ann-admin-level-pill.ann-level-success { color: var(--green); }

/* 移动端适配 */
@media (max-width: 768px) {
  .ann-banner-slot { display: none !important; }
  .ann-popup { max-width: calc(100vw - 32px); }
  .ann-panel { right: 8px; left: 8px; width: auto; }
  .ann-admin-item {
    grid-template-columns: 72px 1fr;
    grid-template-rows: auto auto auto;
  }
  .ann-admin-item > * { grid-column: span 2; }
  .ann-admin-item .ann-admin-type-tag { grid-column: 1; }
  .ann-admin-item .ann-admin-actions { grid-column: 2; justify-content: flex-end; }
}
