/* ===== CSS Variables & Reset ===== */
:root {
  /* Light Theme */
  --bg-primary: #fafbfc;
  --bg-secondary: #f0f2f5;
  --bg-tertiary: #e4e6eb;
  --bg-card: rgba(255, 255, 255, 0.94);
  --bg-hover: rgba(0, 122, 255, 0.06);
  --bg-active: rgba(0, 122, 255, 0.12);

  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #aeaeb2;
  --text-link: #3498db;

  --border-color: rgba(0, 0, 0, 0.08);
  --border-light: rgba(0, 0, 0, 0.04);

  --accent: #3498db;
  --accent-hover: #2980b9;
  --green: #5eb95e;
  --orange: #f37b1d;
  --red: #dd514c;
  --purple: #8e44ad;
  --pink: #e7556c;
  --teal: #1abc9c;
  --indigo: #34495e;
  --yellow: #f1c40f;

  /* Solid flat accent colors (no gradients) */
  --c-blue: #3498db;
  --c-green: #5eb95e;
  --c-orange: #f37b1d;
  --c-red: #dd514c;
  --c-purple: #8e44ad;
  --c-pink: #e7556c;
  --c-teal: #1abc9c;
  --c-indigo: #34495e;
  --c-yellow: #f1c40f;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 1px 4px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);

  --radius-sm: 4px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 8px;

  --sidebar-width: 64px;
  --sidebar-expanded: 240px;
  --topbar-height: 52px;

  --transition: 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition-fast: 0.15s ease-out;

  --font-sans: -apple-system, 'SF Pro Display', 'PingFang SC', 'Noto Sans CJK SC', 'Source Han Sans SC', 'Microsoft YaHei', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', 'Source Code Pro', monospace;
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: #1a1c1e;
  --bg-secondary: #222427;
  --bg-tertiary: #2e3033;
  --bg-card: rgba(34, 36, 39, 0.94);
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-active: rgba(0, 122, 255, 0.18);

  --text-primary: #e8e8ed;
  --text-secondary: #9a9ba0;
  --text-tertiary: #5e5f64;

  --border-color: rgba(255, 255, 255, 0.07);
  --border-light: rgba(255, 255, 255, 0.04);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

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

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

body {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Clickable username links */
.msg-sender a, .cli-name a, .post-author a, .contact-name a, .pcm-meta a, .act-text a {
  color: inherit;
  text-decoration: none;
}
.msg-sender a:hover, .cli-name a:hover, .post-author a:hover, .contact-name a:hover, .pcm-meta a:hover, .act-text a:hover {
  text-decoration: underline;
  color: var(--accent);
}

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

input, textarea {
  font-family: inherit;
  font-size: inherit;
  border: none;
  outline: none;
  color: inherit;
  background: none;
}

ul, ol { list-style: none; }

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

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ===== Utility ===== */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
  color: #fff;
  letter-spacing: 0;
  user-select: none;
}

.avatar-lg {
  width: 52px;
  height: 52px;
  font-size: 20px;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 13px;
}

.avatar-xs {
  width: 24px;
  height: 24px;
  font-size: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.badge-pin { background: rgba(255, 149, 0, 0.15); color: var(--orange); }
.badge-lock { background: rgba(255, 59, 48, 0.15); color: var(--red); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.btn-secondary:hover { background: var(--border-color); }

.input {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  transition: border var(--transition-fast);
  width: 100%;
  font-size: 13px;
}
.input:focus { border-color: var(--accent); background: var(--bg-primary); }
.input::placeholder { color: var(--text-tertiary); }

.fade-in {
  animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

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