/* ============================================
   AI Data Agent Platform — 公共样式
   ============================================ */

/* === Reset & Base === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  border: none;
  outline: none;
  cursor: pointer;
  background: none;
}

input, textarea {
  font-family: inherit;
  border: none;
  outline: none;
}

ul, ol {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
}

/* === 主题切换过渡 === */
body.theme-transitioning,
body.theme-transitioning * {
  transition: background-color 0.3s var(--ease-standard),
              color 0.3s var(--ease-standard),
              border-color 0.3s var(--ease-standard),
              box-shadow 0.3s var(--ease-standard) !important;
}

/* === 滚动条 === */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* === 导航栏 === */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--nav-bg);
  backdrop-filter: var(--nav-blur);
  -webkit-backdrop-filter: var(--nav-blur);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 40px;
  border-bottom: 1px solid var(--border-subtle);
}

.navbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.navbar__logo {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  color: var(--color-accent);
}

[data-theme="dark"] .navbar__logo {
  background: var(--bg-tertiary);
}

.navbar__title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.navbar__center {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 40px;
}

.navbar__right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* === 搜索框 === */
.search-box {
  position: relative;
  width: 100%;
  max-width: 360px;
}

.search-box__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-box__input {
  width: 100%;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--input-bg);
  box-shadow: var(--input-shadow);
  padding: 0 16px 0 42px;
  font-size: 14px;
  color: var(--text-primary);
  transition: box-shadow 0.2s var(--ease-standard);
}

.search-box__input::placeholder {
  color: var(--text-tertiary);
}

.search-box__input:focus {
  box-shadow: var(--input-shadow), 0 0 0 2px rgba(26, 26, 46, 0.08);
}

[data-theme="dark"] .search-box__input:focus {
  box-shadow: var(--input-shadow), 0 0 0 2px rgba(212, 184, 122, 0.15);
}

/* === 按钮 === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s var(--ease-standard);
  white-space: nowrap;
  user-select: none;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-accent);
}

[data-theme="dark"] .btn-primary {
  background: var(--bg-tertiary);
  color: var(--color-accent);
  border: 1px solid var(--border-default);
}

.btn-primary:hover {
  filter: brightness(1.15);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
  min-height: auto;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.btn-icon {
  width: 40px;
  height: 40px;
  min-height: auto;
  padding: 0;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s var(--ease-standard);
}

.btn-icon:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* === 标签 === */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* === 状态指示灯 === */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}

.status-dot--online {
  background: var(--status-online);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.status-dot--offline {
  background: var(--status-offline);
}

.status-dot--maintenance {
  background: var(--status-maintenance);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.status-dot--thinking {
  background: var(--color-accent);
  box-shadow: 0 0 8px rgba(201, 169, 110, 0.4);
  animation: thinking-pulse 1.5s ease-in-out infinite;
}

@keyframes thinking-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* === 主题切换开关 === */
.theme-toggle {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  position: relative;
  cursor: pointer;
  transition: all 0.3s var(--ease-standard);
}

.theme-toggle::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-primary);
  top: 2px;
  left: 2px;
  transition: transform 0.3s var(--ease-standard);
}

[data-theme="dark"] .theme-toggle::after {
  transform: translateX(20px);
}

/* === Toast 提示 === */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s var(--ease-standard);
  z-index: 9999;
}

[data-theme="dark"] .toast {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* === 动画 === */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes pulse-attention {
  0%, 100% { box-shadow: 0 0 0 0 rgba(26, 26, 46, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(26, 26, 46, 0); }
}

[data-theme="dark"] .new-message-btn--attention {
  animation-name: pulse-attention-dark;
}

@keyframes pulse-attention-dark {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 184, 122, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(212, 184, 122, 0); }
}

/* === 响应式 === */
@media (max-width: 1199px) {
  .navbar {
    padding: 0 24px;
  }
}

@media (max-width: 767px) {
  .navbar {
    padding: 0 16px;
  }
  .navbar__center {
    display: none;
  }
}
