/* ================================================
   CSS Variables
   ================================================ */
:root {
  --primary: #3370FF;
  --primary-hover: #2860E1;
  --primary-light: #EEF3FF;
  --bg-page: #F5F6F7;
  --bg-white: #FFFFFF;
  --text-primary: #1F2329;
  --text-secondary: #646A73;
  --text-placeholder: #8F959E;
  --border: #DEE0E3;
  --success: #34C724;
  --success-light: #E8FAE6;
  --warning: #FF7D00;
  --warning-light: #FFF4E8;
  --danger: #F53F3F;
  --danger-light: #FEECEC;
  --info: #3370FF;
  --sidebar-bg: #1F2329;
  --sidebar-active: #3370FF;
  --sidebar-hover: #2D3139;
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,.06);
  --shadow: 0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --transition: all .18s ease;
}

/* ================================================
   Reset & Base
   ================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: inherit;
}

ul, ol {
  list-style: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  outline: none;
  border: none;
}

img {
  display: block;
  max-width: 100%;
}

/* ================================================
   App Layout
   ================================================ */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ================================================
   Sidebar
   ================================================ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  line-height: 1.4;
  letter-spacing: 0.2px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-nav::-webkit-scrollbar {
  width: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 2px 8px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.65);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: rgba(255,255,255,.9);
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 500;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .85;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

/* ================================================
   Main Area
   ================================================ */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ================================================
   Topbar
   ================================================ */
.topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: var(--transition);
}

.topbar-user:hover {
  background: var(--bg-page);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-name {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

/* ================================================
   Content Area
   ================================================ */
.content-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-page);
  min-height: 0;
}

.page-container {
  min-height: 100%;
  padding: 24px;
  animation: pageEnter .2s ease;
}

@keyframes pageEnter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ================================================
   Page Placeholder
   ================================================ */
.page-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: calc(100vh - var(--topbar-height) - 48px);
  color: var(--text-secondary);
}

.page-placeholder h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
}

.page-placeholder p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ================================================
   Toast Container
   ================================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  min-width: 240px;
  max-width: 360px;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: var(--text-primary);
  pointer-events: auto;
  animation: toastIn .24s ease;
  border-left: 3px solid var(--primary);
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-danger  { border-left-color: var(--danger); }

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast.toast-success .toast-icon { color: var(--success); }
.toast.toast-warning .toast-icon { color: var(--warning); }
.toast.toast-danger  .toast-icon { color: var(--danger); }
.toast .toast-icon   { color: var(--primary); }

.toast-msg {
  flex: 1;
  line-height: 1.5;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(24px); }
}

/* ================================================
   Scrollbar
   ================================================ */
.content-area::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.content-area::-webkit-scrollbar-track {
  background: transparent;
}

.content-area::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.15);
  border-radius: 3px;
}

.content-area::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,.25);
}

/* ================================================
   Section Title
   ================================================ */
.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  width: 3px;
  height: 16px;
  background: var(--primary);
  border-radius: 2px;
  display: inline-block;
}

/* ================================================
   Utilities
   ================================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-secondary { color: var(--text-secondary); }
.text-primary-color { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* AI对话页：.content-area 自身不滚动，滚动发生在 .chat-messages 内部 */
.content-area:has(#page-chat:not([style*="display:none"]):not([style*="display: none"])) {
  overflow: hidden;
}
