/* 智能体模式 — 入口登录 / 政府·企业工作台 */
.ag-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--ag-panel, #fff);
  border-radius: 16px;
  border: 1px solid var(--ag-border, rgba(226, 232, 240, 0.9));
  box-shadow: 0 12px 40px rgba(8, 47, 73, 0.12);
  overflow: hidden;
}

html[data-theme="dark"] .ag-panel {
  --ag-panel: rgba(8, 22, 48, 0.96);
  --ag-border: rgba(56, 189, 248, 0.2);
  --ag-text: #e2e8f0;
  --ag-text2: #94a3b8;
  --ag-bot-bg: rgba(15, 40, 72, 0.9);
  --ag-user-bg: linear-gradient(135deg, #238636, #2ea043);
  --ag-input-bg: #0d1117;
}

html[data-theme="light"] .ag-panel,
html:not([data-theme]) .ag-panel {
  --ag-text: #1a3353;
  --ag-text2: #64748b;
  --ag-bot-bg: #f3f4f6;
  --ag-user-bg: linear-gradient(135deg, #10b981, #059669);
  --ag-input-bg: #fff;
}

.ag-chat {
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 18px;
  min-height: 0;
  max-height: 100%;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.ag-chat::-webkit-scrollbar {
  width: 8px;
}

.ag-chat::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 4px;
}

.ag-chat::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.35);
  border-radius: 4px;
}

.ag-chat::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.55);
}

html[data-theme="dark"] .ag-chat::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
}

.ag-msg {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  max-width: 100%;
}

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

.ag-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.ag-bubble {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ag-text);
  max-width: min(520px, calc(100% - 48px));
}

.ag-msg-bot .ag-bubble {
  background: var(--ag-bot-bg);
  border-bottom-left-radius: 4px;
}

.ag-msg-user .ag-bubble {
  background: var(--ag-user-bg);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ag-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.ag-action-btn {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

html[data-theme="dark"] .ag-action-btn {
  color: #3fb950;
  border-color: rgba(63, 185, 80, 0.35);
  background: rgba(63, 185, 80, 0.12);
}

.ag-action-btn:hover {
  filter: brightness(1.05);
}

.ag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 10px;
  justify-content: center;
  flex-shrink: 0;
}

.ag-chip {
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid var(--ag-border, #e5e7eb);
  background: transparent;
  color: var(--ag-text2);
  font-size: 12px;
  cursor: pointer;
}

.ag-chip:hover {
  border-color: #10b981;
  color: #059669;
}

/* 登录页 — 历史对话与快捷提示 */
.ag-history-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 14px;
  color: var(--ag-text2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.ag-history-divider::before,
.ag-history-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--ag-border, #e5e7eb);
}

.ag-history-divider span {
  flex-shrink: 0;
  padding: 2px 10px;
  border-radius: 10px;
  background: rgba(100, 116, 139, 0.08);
}

.ag-history-divider.ag-history-now span {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

html[data-theme="dark"] .ag-history-divider.ag-history-now span {
  color: #3fb950;
}

.ag-msg-history {
  opacity: 0.72;
}

.ag-msg-history .ag-bubble {
  font-size: 13px;
  padding: 10px 14px;
}

.ag-history-time {
  display: block;
  margin-top: 6px;
  font-size: 10px;
  font-weight: 500;
  color: var(--ag-text2);
  opacity: 0.85;
}

.ag-prompt-bar {
  flex-shrink: 0;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--ag-border, #e5e7eb);
  background: rgba(248, 250, 252, 0.6);
}

html[data-theme="dark"] .ag-prompt-bar {
  background: rgba(8, 22, 48, 0.5);
}

.ag-prompt-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ag-text2);
  margin-bottom: 8px;
}

.ag-chips-login {
  padding: 0;
  justify-content: flex-start;
  gap: 6px;
}

.ag-chips-login .ag-chip {
  padding: 5px 11px;
  font-size: 12px;
  background: #fff;
  border-color: rgba(16, 185, 129, 0.25);
  color: #047857;
}

html[data-theme="dark"] .ag-chips-login .ag-chip {
  background: rgba(15, 40, 72, 0.6);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.3);
}

.ag-chips-login .ag-chip:hover {
  background: rgba(16, 185, 129, 0.1);
  border-color: #10b981;
}

.ag-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--ag-border, #e5e7eb);
  background: var(--ag-input-bg);
  flex-shrink: 0;
}

.ag-voice {
  width: 36px;
  height: 36px;
  border: 1px solid var(--ag-border, #e5e7eb);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}

.ag-voice.listening {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  animation: ag-pulse 1s infinite;
}

@keyframes ag-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.ag-input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-size: 14px;
  line-height: 1.5;
  max-height: 100px;
  min-height: 24px;
  background: transparent;
  color: var(--ag-text);
  font-family: inherit;
}

.ag-send {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #10b981;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

/* —— 入口页模式切换 —— */
.portal-topbar {
  position: absolute;
  top: 20px;
  right: 24px;
  z-index: 10;
  pointer-events: none;
}
.portal-topbar .portal-mode-bar {
  pointer-events: auto;
}
.portal-mode-bar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 0;
  margin-top: 0;
  margin-bottom: 0;
  padding: 5px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.portal-mode-bar button {
  padding: 10px 32px;
  border: none;
  border-radius: 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  transition: background 0.2s, color 0.2s;
}

.portal-mode-bar button.active {
  background: rgba(255, 255, 255, 0.95);
  color: #0369a1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.portal-agent-wrap {
  position: relative;
  z-index: 1;
  width: var(--portal-content-width, min(1080px, calc(100vw - 48px)));
  height: var(--portal-content-height, 520px);
  min-height: var(--portal-content-height, 520px);
  max-height: var(--portal-content-height, 520px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.portal-agent-mount {
  flex: 1;
  min-height: 0;
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.portal-agent-wrap .ag-panel {
  flex: 1;
  min-height: 0;
  height: 100%;
  border-radius: 20px;
  box-shadow: var(--portal-shadow, 0 24px 64px rgba(8, 47, 73, 0.28));
}

/* 智能体模式：保持与传统模式相同的居中布局，仅切换下方内容区 */
.portal-page.portal-agent-layout {
  justify-content: center;
  padding: 40px 32px 48px;
  min-height: 100vh;
  height: auto;
  max-height: none;
  overflow: hidden;
}

.portal-page.portal-agent-layout .portal-mode-bar {
  margin-bottom: 32px;
}

.portal-view-hidden {
  display: none !important;
}

/* —— 政府/企业智能体工作台 —— */
.agent-console-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--shell-bg, #f0f7ff);
  overflow: hidden;
}

html[data-theme="dark"] .agent-console-page {
  background: #020810;
}

.agent-console-header {
  height: 52px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--shell-header);
  color: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.agent-console-header h1 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.agent-console-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-console-header a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.agent-console-header a:hover {
  background: rgba(255, 255, 255, 0.12);
}

.agent-console-body {
  flex: 1;
  min-height: 0;
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
}

.agent-console-body #govAgentMount,
.agent-console-body #entAgentMount {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.agent-mode-hint {
  text-align: center;
  font-size: 12px;
  color: var(--portal-muted, #64748b);
  padding: 8px 0 0;
  flex-shrink: 0;
}

.login-mode-bar {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-bottom: 20px;
  padding: 3px;
  border-radius: 20px;
  background: var(--shell-bg, #f0f7ff);
  border: 1px solid var(--shell-border);
}

.login-mode-bar button {
  flex: 1;
  padding: 8px 14px;
  border: none;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--portal-muted);
}

.login-mode-bar button.active {
  background: var(--portal-card);
  color: var(--portal-accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.login-agent-shell {
  width: var(--portal-content-width, min(1080px, calc(100vw - 48px)));
  max-width: var(--portal-content-width, min(1080px, calc(100vw - 48px)));
  padding: 28px 32px 32px;
  background: transparent;
  border: none;
  box-shadow: none;
}

.login-agent-shell .login-back {
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: 16px;
}

.login-agent-shell .login-back:hover {
  color: #fff;
}

.login-agent-shell h1,
.login-agent-shell .sub {
  color: #fff;
  text-align: center;
}

.login-agent-shell .sub {
  opacity: 0.88;
  margin-bottom: 20px;
}

.login-agent-shell h1 {
  margin-bottom: 8px;
}

.login-agent-wrap {
  width: 100%;
  height: var(--portal-content-height, 520px);
  min-height: var(--portal-content-height, 520px);
  max-height: var(--portal-content-height, 520px);
  margin-top: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.login-agent-wrap .ag-panel {
  flex: 1;
  min-height: 0;
  height: 100%;
  box-shadow: var(--portal-shadow);
  border: 1px solid var(--shell-border);
  border-radius: 20px;
}

@media (max-width: 680px) {
  :root {
    --portal-content-height: 560px;
  }
  .portal-agent-wrap {
    width: calc(100vw - 24px);
  }
}
