/* CampusLink - Styles */
/* Design: Clean editorial with indigo/violet accent system */

:root {
  --indigo: #4f46e5;
  --indigo-light: #6366f1;
  --indigo-dim: #e0e7ff;
  --violet: #7c3aed;
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9ff;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --text: #111827;
  --text-2: #374151;
  --text-3: #6b7280;
  --text-4: #9ca3af;
  --online: #10b981;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  --shadow-md: 0 4px 24px rgba(79,70,229,.1);
  --nav-h: 64px;
  --font: 'DM Sans', sans-serif;
  --font-display: 'Syne', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: var(--font); }
input, textarea, select { font-family: var(--font); }

/* ===================== */
/* PAGE SYSTEM */
/* ===================== */
.page { width: 100%; min-height: 100vh; }
.page.hidden { display: none !important; }
.main-page { display: none; }
.main-page.active { display: block; }

/* ===================== */
/* AUTH PAGES */
/* ===================== */
.auth-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.auth-brand {
  background: linear-gradient(145deg, #1e1b4b 0%, #312e81 40%, #4338ca 70%, #4f46e5 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
  position: relative;
  overflow: hidden;
  color: white;
}

.brand-content { position: relative; z-index: 2; }

.brand-logo {
  width: 56px;
  height: 56px;
  background: rgba(255,255,255,.15);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.2);
}
.brand-logo svg { width: 32px; height: 32px; color: white; }

.auth-brand h1 {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1;
  margin-bottom: 16px;
  color: white;
}
.auth-brand h1 span { color: #a5b4fc; }

.brand-tagline {
  font-size: 1rem;
  color: rgba(255,255,255,.7);
  max-width: 320px;
  line-height: 1.7;
  margin-bottom: 36px;
}

.brand-features { display: flex; flex-direction: column; gap: 12px; }
.feat {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.85);
  font-size: .92rem;
  font-weight: 500;
}
.feat-icon { font-size: 1.1rem; }

/* Brand orbit animation */
.brand-art {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.orbit {
  position: absolute;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 50%;
  animation: orbit-spin linear infinite;
}
.orbit-1 { width: 300px; height: 300px; right: -80px; top: -80px; animation-duration: 20s; }
.orbit-2 { width: 200px; height: 200px; right: 20px; bottom: 100px; animation-duration: 15s; animation-direction: reverse; }
.orbit-3 { width: 400px; height: 400px; right: -150px; bottom: -150px; animation-duration: 30s; }
.orbit-dot {
  width: 8px; height: 8px;
  background: rgba(255,255,255,.3);
  border-radius: 50%;
  position: absolute;
  top: -4px; left: 50%;
}
@keyframes orbit-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Auth Form Panel */
.auth-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--surface-2);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 24px;
  padding: 40px;
  box-shadow: var(--shadow-md);
}

.auth-card h2 {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
  color: var(--text);
}
.auth-sub { color: var(--text-3); font-size: .92rem; margin-bottom: 28px; }

.field-group { margin-bottom: 18px; }
.field-group label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 7px;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.field-group input,
.field-group textarea,
.field-group select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.field-group input:focus,
.field-group textarea:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
.field-group textarea { resize: vertical; }

.auth-switch {
  margin-top: 20px;
  text-align: center;
  font-size: .88rem;
  color: var(--text-3);
}

/* OTP Inputs */
.verify-icon { font-size: 2.8rem; text-align: center; margin-bottom: 12px; }

.otp-inputs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 24px 0;
}
.otp-digit {
  width: 50px !important;
  height: 58px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  border: 2px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  padding: 0 !important;
  transition: all .2s;
  font-family: var(--font-display) !important;
}
.otp-digit:focus {
  border-color: var(--indigo) !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,.15) !important;
  background: var(--indigo-dim);
}
.otp-digit.filled { border-color: var(--indigo) !important; background: var(--indigo-dim); }

.resend-area { text-align: center; margin-top: 16px; font-size: .88rem; color: var(--text-3); }

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: .2px;
  transition: opacity .2s, transform .1s;
}
.btn-primary:hover { opacity: .9; }
.btn-primary:active { transform: scale(.98); }
.btn-primary.full-width { width: 100%; display: block; text-align: center; }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary-sm {
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  transition: opacity .2s;
}
.btn-primary-sm:hover { opacity: .9; }

.btn-outline-sm {
  background: transparent;
  color: var(--indigo);
  border: 1.5px solid var(--indigo);
  padding: 8px 18px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  transition: all .2s;
}
.btn-outline-sm:hover { background: var(--indigo-dim); }

.btn-danger-sm {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger);
  padding: 8px 18px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
}

.btn-ghost {
  background: transparent;
  color: var(--text-3);
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: .85rem;
  transition: background .2s;
}
.btn-ghost:hover { background: var(--border-light); }

.form-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .85rem;
  margin-bottom: 14px;
}
.form-error.hidden { display: none; }
.hidden { display: none !important; }

/* ===================== */
/* NAVBAR */
/* ===================== */
#navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 20px;
  z-index: 100;
  box-shadow: 0 1px 0 var(--border);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
}
.nav-brand svg { width: 28px; height: 28px; color: var(--indigo); }
.nav-brand span {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.nav-brand strong { color: var(--indigo); }

.nav-search {
  flex: 1;
  max-width: 360px;
  position: relative;
}
.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 8px 16px;
  transition: border-color .2s;
}
.search-wrap:focus-within {
  border-color: var(--indigo);
  background: var(--surface);
}
.search-icon { width: 16px; height: 16px; color: var(--text-4); flex-shrink: 0; }
.search-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: .9rem;
  color: var(--text);
  outline: none;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  z-index: 200;
  max-height: 320px;
  overflow-y: auto;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background .15s;
}
.search-result-item:hover { background: var(--surface-2); }
.search-result-item .sri-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--indigo-dim);
}
.search-result-item .sri-info .sri-name { font-weight: 600; font-size: .9rem; }
.search-result-item .sri-info .sri-email { font-size: .78rem; color: var(--text-3); }

.nav-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  transition: background .15s, color .15s;
  position: relative;
}
.nav-btn:hover, .nav-btn.active { background: var(--indigo-dim); color: var(--indigo); }
.nav-btn svg { width: 20px; height: 20px; }

.nav-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--border);
  transition: border-color .2s;
  margin-left: 6px;
  background: var(--indigo-dim);
}
.nav-avatar:hover { border-color: var(--indigo); }
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; }

.badge {
  position: absolute;
  top: 4px; right: 4px;
  background: var(--danger);
  color: white;
  font-size: .65rem;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--surface);
}

/* Notifications Panel */
.notif-panel {
  position: absolute;
  top: calc(var(--nav-h) + 8px);
  right: 16px;
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  z-index: 300;
  overflow: hidden;
  max-height: 480px;
  display: flex;
  flex-direction: column;
}
.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: .92rem;
}
.notif-header button {
  font-size: .78rem;
  color: var(--indigo);
  background: none;
  border: none;
  font-weight: 600;
}
#notif-list { overflow-y: auto; }

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background .15s;
}
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: #f5f3ff; }
.notif-item.unread:hover { background: #ede9fe; }
.notif-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--indigo-dim);
  flex-shrink: 0;
}
.notif-text { font-size: .88rem; color: var(--text-2); line-height: 1.5; }
.notif-time { font-size: .75rem; color: var(--text-4); margin-top: 2px; }

/* ===================== */
/* MAIN CONTENT */
/* ===================== */
#main-content {
  padding-top: var(--nav-h);
  min-height: 100vh;
}

/* ===================== */
/* FEED PAGE */
/* ===================== */
.feed-layout {
  display: grid;
  grid-template-columns: 280px 1fr 260px;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px;
}

/* Sidebar Profile Card */
.sidebar-profile-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  text-align: center;
  padding-bottom: 20px;
}
.sp-cover {
  height: 70px;
  background: linear-gradient(135deg, var(--indigo), var(--violet));
}
.sp-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--surface);
  margin: -36px auto 12px;
  background: var(--indigo-dim);
}
.sp-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sp-name { font-weight: 700; font-size: .95rem; margin-bottom: 2px; }
.sp-email { font-size: .78rem; color: var(--text-3); margin-bottom: 8px; }
.sp-bio { font-size: .82rem; color: var(--text-3); padding: 0 16px; margin-bottom: 14px; line-height: 1.5; }

/* Create Post Card */
.create-post-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.cp-top { display: flex; gap: 12px; align-items: flex-start; }
.cp-avatar { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; flex-shrink: 0; background: var(--indigo-dim); }
.cp-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cp-input-wrap { flex: 1; }
.cp-input-wrap textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: .9rem;
  resize: none;
  min-height: 44px;
  max-height: 200px;
  outline: none;
  color: var(--text);
  background: var(--surface-2);
  transition: border-color .2s;
  overflow-y: hidden;
}
.cp-input-wrap textarea:focus { border-color: var(--indigo); background: var(--surface); }

.media-preview {
  position: relative;
  margin-top: 12px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
}
.media-preview img, .media-preview video {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 12px;
}
.remove-media {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(0,0,0,.5);
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  backdrop-filter: blur(4px);
}

.cp-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}
.cp-media-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-3);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 7px 12px;
  border-radius: 8px;
  transition: background .15s;
}
.cp-media-btn:hover { background: var(--surface-2); color: var(--indigo); }
.cp-media-btn svg { width: 18px; height: 18px; }

/* Post Cards */
.post-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  animation: fadeSlideIn .3s ease;
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.post-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.post-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--indigo-dim);
  cursor: pointer;
  flex-shrink: 0;
}
.post-user-info .post-user-name {
  font-weight: 700;
  font-size: .92rem;
  cursor: pointer;
  color: var(--text);
}
.post-user-info .post-user-name:hover { color: var(--indigo); }
.post-user-info .post-time { font-size: .75rem; color: var(--text-4); }
.post-delete-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-4);
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color .2s, background .2s;
}
.post-delete-btn:hover { color: var(--danger); background: #fef2f2; }

.post-content {
  font-size: .92rem;
  color: var(--text-2);
  line-height: 1.65;
  margin-bottom: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.post-media {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 8px;
}
.post-media img { width: 100%; object-fit: cover; max-height: 400px; cursor: pointer; }
.post-media video { width: 100%; border-radius: 12px; max-height: 400px; }

/* Right Sidebar */
.sidebar-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.sidebar-card h3 {
  font-size: .88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-3);
  margin-bottom: 14px;
}

.mini-request-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.mini-req-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--indigo-dim);
}
.mini-req-name { font-size: .85rem; font-weight: 600; flex: 1; }
.mini-req-actions { display: flex; gap: 6px; }
.mini-req-actions button {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 600;
  border: none;
}

.load-more { text-align: center; padding: 20px; }
.load-more button { padding: 10px 24px; background: var(--surface); border: 1.5px solid var(--border); border-radius: 24px; font-size: .9rem; font-weight: 600; color: var(--indigo); transition: all .2s; }
.load-more button:hover { border-color: var(--indigo); background: var(--indigo-dim); }

/* ===================== */
/* PROFILE PAGE */
/* ===================== */
.profile-layout {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px;
}

.profile-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.profile-cover {
  height: 140px;
  background: linear-gradient(135deg, var(--indigo) 0%, var(--violet) 100%);
  position: relative;
}
.cover-gradient::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 60%, rgba(0,0,0,.2));
}

.profile-info { padding: 20px 28px 28px; }

.profile-avatar-wrap {
  position: relative;
  display: inline-block;
  margin-top: -60px;
  margin-bottom: 16px;
}
.profile-avatar {
  width: 100px; height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--surface);
  background: var(--indigo-dim);
  display: block;
}
.avatar-upload-btn {
  position: absolute;
  bottom: 4px; right: 4px;
  width: 30px; height: 30px;
  background: var(--indigo);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid var(--surface);
  transition: background .2s;
}
.avatar-upload-btn:hover { background: var(--violet); }
.avatar-upload-btn svg { width: 14px; height: 14px; color: white; }
#avatar-upload-label.hidden { display: none !important; }

.profile-name-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.profile-name-row h2 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; letter-spacing: -0.5px; }
.profile-email-text { color: var(--text-3); font-size: .88rem; }

#profile-actions { display: flex; gap: 8px; }

.profile-bio { color: var(--text-3); font-size: .9rem; line-height: 1.6; margin-bottom: 16px; }

.profile-stats {
  display: flex;
  gap: 32px;
}
.stat { text-align: center; }
.stat span { display: block; font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; color: var(--indigo); }
.stat label { font-size: .75rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }

.edit-profile-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ===================== */
/* CONNECTIONS PAGE */
/* ===================== */
.connections-layout {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.page-header h2 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 800; }
.badge-count {
  background: var(--indigo);
  color: white;
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  min-width: 24px;
  text-align: center;
}

.user-grid { display: flex; flex-direction: column; gap: 12px; }

.user-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: transform .15s;
}
.user-card:hover { transform: translateY(-1px); }
.uc-avatar { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; background: var(--indigo-dim); flex-shrink: 0; }
.uc-info { flex: 1; min-width: 0; }
.uc-name { font-weight: 700; font-size: .9rem; truncate: true; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-email { font-size: .76rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-actions { display: flex; gap: 7px; flex-shrink: 0; }
.uc-actions button { padding: 6px 14px; border-radius: 8px; font-size: .78rem; font-weight: 600; border: none; }

/* ===================== */
/* CHAT PAGE */
/* ===================== */
.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - var(--nav-h));
}

.chat-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
}

#conversation-list { overflow-y: auto; flex: 1; }

.convo-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background .15s;
  border-bottom: 1px solid var(--border-light);
}
.convo-item:hover { background: var(--surface-2); }
.convo-item.active { background: var(--indigo-dim); }
.convo-avatar-wrap { position: relative; flex-shrink: 0; }
.convo-avatar { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; background: var(--indigo-dim); }
.online-dot {
  position: absolute;
  bottom: 1px; right: 1px;
  width: 11px; height: 11px;
  background: var(--online);
  border-radius: 50%;
  border: 2px solid var(--surface);
}
.convo-info { flex: 1; min-width: 0; }
.convo-name { font-weight: 700; font-size: .88rem; }
.convo-last-msg { font-size: .78rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.convo-meta { flex-shrink: 0; text-align: right; }
.convo-time { font-size: .72rem; color: var(--text-4); }
.convo-unread { background: var(--indigo); color: white; font-size: .68rem; font-weight: 700; border-radius: 10px; padding: 2px 7px; margin-top: 4px; }

/* Chat Window */
.chat-window {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-4);
  text-align: center;
  padding: 40px;
}
.chat-empty-icon { font-size: 3rem; margin-bottom: 16px; }
.chat-empty-state h3 { font-size: 1.1rem; font-weight: 700; color: var(--text-3); margin-bottom: 6px; }
.chat-empty-state p { font-size: .88rem; }

#active-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-header-user { display: flex; align-items: center; gap: 12px; }
.chat-avatar-wrap { position: relative; }
#chat-user-pic { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: var(--indigo-dim); }
.chat-user-name { font-weight: 700; font-size: .95rem; }
.chat-user-status { font-size: .75rem; color: var(--text-4); }
.chat-user-status.online { color: var(--online); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-group { display: flex; flex-direction: column; gap: 4px; }

.message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: msgIn .2s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.message.own { flex-direction: row-reverse; }

.msg-bubble {
  max-width: 68%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: .9rem;
  line-height: 1.5;
  word-break: break-word;
}
.message.own .msg-bubble {
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  color: white;
  border-bottom-right-radius: 4px;
}
.message:not(.own) .msg-bubble {
  background: var(--surface);
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}
.msg-time { font-size: .68rem; color: var(--text-4); white-space: nowrap; padding-bottom: 4px; }

.date-divider {
  text-align: center;
  font-size: .72rem;
  color: var(--text-4);
  margin: 12px 0;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.typing-indicator {
  padding: 8px 24px;
  font-size: .82rem;
  color: var(--text-4);
  font-style: italic;
}
.typing-dots span {
  animation: blink .8s infinite;
  font-style: normal;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }

.chat-input-area {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-input-area input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 10px 18px;
  font-size: .9rem;
  outline: none;
  color: var(--text);
  background: var(--surface-2);
  transition: border-color .2s;
}
.chat-input-area input:focus {
  border-color: var(--indigo);
  background: var(--surface);
}

.send-btn {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  transition: opacity .2s, transform .1s;
}
.send-btn:hover { opacity: .9; }
.send-btn:active { transform: scale(.92); }
.send-btn svg { width: 18px; height: 18px; }

/* ===================== */
/* UTILITY */
/* ===================== */
.loading-spinner {
  display: flex;
  justify-content: center;
  padding: 40px;
}
.spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--indigo);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-4);
}
.empty-state p { font-size: .9rem; }

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}
.toast {
  background: var(--text);
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: .88rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  animation: toastIn .3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
}
.toast.success { background: #065f46; }
.toast.error { background: #7f1d1d; }
.toast.info { background: var(--indigo); }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* Auth page switcher */
.auth-page { display: none; }
.auth-page.active { display: block; }

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

/* Responsive */
@media (max-width: 900px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .feed-layout { grid-template-columns: 1fr; }
  .feed-sidebar, .feed-right-sidebar { display: none; }
  .connections-layout { grid-template-columns: 1fr; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-sidebar { display: none; }
}
