/* ===========================
   CSS Variables - Dark Warm Theme (NOT Facebook)
   =========================== */
:root {
  --primary: #f59e0b;
  --primary-hover: #d97706;
  --primary-light: rgba(245, 158, 11, 0.12);
  --secondary: #06b6d4;
  --accent: #f97316;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #eab308;
  --info: #3b82f6;

  --bg: #0f0f14;
  --bg-secondary: #18181f;
  --card: #1c1c27;
  --card-hover: #24243a;
  --text: #f0ece4;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --border: #2a2a3a;
  --border-light: #1f1f2e;

  --gradient-primary: linear-gradient(135deg, #f59e0b 0%, #f97316 50%, #ef4444 100%);
  --gradient-secondary: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
  --gradient-success: linear-gradient(135deg, #22c55e 0%, #10b981 100%);
  --gradient-warning: linear-gradient(135deg, #eab308 0%, #f59e0b 100%);
  --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --gradient-sunset: linear-gradient(135deg, #f97316 0%, #ec4899 100%);
  --gradient-ocean: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
  --gradient-forest: linear-gradient(135deg, #22c55e 0%, #06b6d4 100%);
  --gradient-mesh: radial-gradient(at 40% 20%, rgba(245,158,11,0.08) 0px, transparent 50%),
                   radial-gradient(at 80% 0%, rgba(6,182,212,0.06) 0px, transparent 50%),
                   radial-gradient(at 0% 50%, rgba(249,115,22,0.05) 0px, transparent 50%);

  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 30px rgba(245, 158, 11, 0.2);

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

[data-theme="light"] {
  --bg: #f5f0e8;
  --bg-secondary: #ffffff;
  --card: #ffffff;
  --card-hover: #faf7f2;
  --text: #1a1612;
  --text-secondary: #6b6560;
  --text-muted: #9c9590;
  --border: #e8e0d6;
  --border-light: #f0ebe4;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 30px rgba(245, 158, 11, 0.15);
}

/* ===========================
   Base
   =========================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: var(--transition);
  background-image: var(--gradient-mesh);
  background-attachment: fixed;
}

a { text-decoration: none; color: var(--primary); transition: var(--transition-fast); }
a:hover { text-decoration: none; color: var(--primary-hover); }

button { cursor: pointer; border: none; font-family: inherit; font-size: 14px; transition: var(--transition); }

input, textarea, select {
  font-family: inherit; font-size: 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 16px; outline: none; transition: var(--transition);
  background: var(--bg-secondary); color: var(--text);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

/* ===========================
   Buttons
   =========================== */
.btn {
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-weight: 600; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; transition: var(--transition);
  position: relative; overflow: hidden; font-size: 13px;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
  opacity: 0; transition: var(--transition);
}
.btn:hover::after { opacity: 1; }

.btn-primary {
  background: var(--gradient-primary); color: white;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4); }

.btn-secondary {
  background: var(--card); color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--card-hover); border-color: var(--primary); }

.btn-success { background: var(--gradient-success); color: white; }
.btn-danger { background: var(--gradient-danger); color: white; }

.btn-outline {
  background: transparent; border: 1.5px solid var(--primary); color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }

.btn-block { width: 100%; }
.btn-icon {
  width: 40px; height: 40px; padding: 0;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
}

/* ===========================
   Avatars
   =========================== */
.avatar {
  width: 44px; height: 44px; border-radius: 14px;
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: white; overflow: hidden; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 34px; height: 34px; font-size: 12px; border-radius: 10px; }
.avatar-lg { width: 60px; height: 60px; font-size: 22px; border-radius: 18px; }
.avatar-xl { width: 130px; height: 130px; font-size: 48px; border-radius: 32px; border: 4px solid var(--card); box-shadow: var(--shadow-lg); }

/* ===========================
   Cards
   =========================== */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
  transition: var(--transition);
  border: 1px solid var(--border-light);
  backdrop-filter: blur(10px);
}
.card:hover { box-shadow: var(--shadow-md); }

/* ===========================
   Auth Pages
   =========================== */
.auth-container {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 20px;
  background: var(--bg); position: relative; overflow: hidden;
  background-image: var(--gradient-mesh);
}
.auth-container::before {
  content: ''; position: absolute; width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(245,158,11,0.08) 0%, transparent 70%);
  border-radius: 50%; top: -200px; right: -200px;
  animation: float 8s ease-in-out infinite;
}
.auth-container::after {
  content: ''; position: absolute; width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(6,182,212,0.06) 0%, transparent 70%);
  border-radius: 50%; bottom: -150px; left: -150px;
  animation: float 10s ease-in-out infinite reverse;
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(3deg); }
}

.auth-box {
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl); padding: 44px;
  width: 100%; max-width: 420px; position: relative; z-index: 1;
  border: 1px solid var(--border-light);
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo h1 {
  font-size: 32px; font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-logo p { color: var(--text-secondary); margin-top: 6px; font-size: 14px; }

.auth-form .form-group { margin-bottom: 18px; }
.auth-form label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--text); font-size: 13px; }
.auth-form input { width: 100%; }

.auth-divider { text-align: center; margin: 20px 0; position: relative; }
.auth-divider::before {
  content: ''; position: absolute; left: 0; top: 50%;
  width: 100%; height: 1px; background: var(--border);
}
.auth-divider span {
  background: var(--card); padding: 0 14px; position: relative;
  color: var(--text-muted); font-size: 12px; font-weight: 500;
}

.auth-footer { text-align: center; margin-top: 20px; color: var(--text-secondary); font-size: 13px; }

/* ===========================
   Navigation - Left Sidebar Style
   =========================== */
.navbar {
  background: rgba(28, 28, 39, 0.85); backdrop-filter: blur(20px);
  box-shadow: 0 1px 0 var(--border);
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 1000; height: 60px;
  display: flex; align-items: center;
  padding: 0 24px; border-bottom: 1px solid var(--border);
}
[data-theme="light"] .navbar { background: rgba(255,255,255,0.85); }

.navbar-brand {
  font-size: 20px; font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-right: 20px;
}

.navbar-search {
  flex: 1; max-width: 380px; position: relative;
}
.navbar-search input {
  width: 100%; background: var(--bg); border: 1.5px solid transparent;
  padding: 10px 16px 10px 40px; border-radius: var(--radius-full);
  font-size: 13px;
}
.navbar-search input:focus { border-color: var(--primary); }
.navbar-search i {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%); color: var(--text-muted); font-size: 13px;
}

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

.nav-link {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); position: relative; transition: var(--transition);
  font-size: 16px;
}
.nav-link:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.nav-link.active { background: var(--primary-light); color: var(--primary); }
.nav-link .badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--danger); color: white;
  font-size: 9px; padding: 2px 6px;
  border-radius: var(--radius-full); font-weight: 700;
}

.nav-profile {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border-radius: var(--radius-full);
  cursor: pointer; transition: var(--transition);
}
.nav-profile:hover { background: var(--primary-light); }
.nav-profile span { font-weight: 600; font-size: 13px; }

.theme-toggle {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--bg); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; transition: var(--transition);
}
.theme-toggle:hover { background: var(--primary-light); color: var(--primary); }

/* ===========================
   Layout
   =========================== */
.main-layout {
  display: flex; padding-top: 60px; min-height: 100vh;
}

.sidebar {
  width: 260px; position: fixed; top: 60px; left: 0; bottom: 0;
  padding: 16px 12px; overflow-y: auto;
  background: var(--bg-secondary); border-right: 1px solid var(--border-light);
}
.sidebar-menu { list-style: none; }
.sidebar-menu li { margin-bottom: 2px; }
.sidebar-menu a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 12px;
  color: var(--text-secondary); font-weight: 500;
  transition: var(--transition); font-size: 14px;
}
.sidebar-menu a:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.sidebar-menu a.active {
  background: var(--gradient-primary); color: white;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}
.sidebar-menu i { width: 22px; text-align: center; font-size: 17px; }

.main-content {
  flex: 1; margin-left: 260px; padding: 24px;
  max-width: calc(100% - 260px);
}

.right-sidebar {
  width: 300px; position: fixed; top: 60px; right: 0; bottom: 0;
  padding: 16px; overflow-y: auto;
  background: var(--bg-secondary); border-left: 1px solid var(--border-light);
}
.main-content.has-right-sidebar { margin-right: 300px; max-width: calc(100% - 560px); }

/* ===========================
   Stories
   =========================== */
.stories-container {
  display: flex; gap: 12px; margin-bottom: 24px;
  padding: 4px 0; overflow-x: auto; scrollbar-width: none;
}
.stories-container::-webkit-scrollbar { display: none; }

.story-card {
  min-width: 110px; height: 190px; border-radius: var(--radius);
  position: relative; cursor: pointer; overflow: hidden;
  box-shadow: var(--shadow); transition: var(--transition);
}
.story-card:hover { transform: scale(1.03); }
.story-card::before {
  content: ''; position: absolute; inset: 0;
  background: var(--gradient-primary); opacity: 0.9;
}
.story-card:nth-child(2)::before { background: var(--gradient-secondary); }
.story-card:nth-child(3)::before { background: var(--gradient-sunset); }
.story-card:nth-child(4)::before { background: var(--gradient-ocean); }
.story-card:nth-child(5)::before { background: var(--gradient-forest); }

.story-card .story-avatar {
  position: absolute; top: 10px; left: 10px;
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--gradient-primary);
  border: 2.5px solid white; display: flex;
  align-items: center; justify-content: center;
  color: white; font-size: 13px;
}
.story-card .story-name {
  position: absolute; bottom: 10px; left: 10px; right: 10px;
  color: white; font-weight: 600; font-size: 12px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.story-card.create-story { background: var(--card); border: 2px dashed var(--border); }
.story-card.create-story::before { display: none; }
.story-card.create-story .story-name {
  color: var(--text); text-shadow: none; bottom: 36px; font-size: 11px;
}
.story-card.create-story .add-story-icon {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 18px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* ===========================
   News Feed
   =========================== */
.feed-container { max-width: 580px; margin: 0 auto; }

.post-form { margin-bottom: 24px; }
.post-form-inner { display: flex; gap: 12px; align-items: center; }
.post-form input {
  flex: 1; background: var(--bg); border: none;
  border-radius: var(--radius-full); padding: 12px 20px; cursor: pointer;
}
.post-form input:hover { background: var(--border); }

.post-actions {
  display: flex; justify-content: space-around;
  padding-top: 14px; border-top: 1px solid var(--border); margin-top: 14px;
}
.post-action-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 10px;
  background: none; color: var(--text-secondary); font-weight: 500; font-size: 13px;
}
.post-action-btn:hover { background: var(--primary-light); }
.post-action-btn i { font-size: 20px; }
.post-action-btn.photo i { color: #22c55e; }
.post-action-btn.feeling i { color: #eab308; }
.post-action-btn.video i { color: #ef4444; }

/* ===========================
   Post Card
   =========================== */
.post-card { margin-bottom: 24px; }
.post-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.post-header-info h4 { font-size: 14px; margin-bottom: 1px; font-weight: 600; }
.post-header-info span { font-size: 12px; color: var(--text-muted); }

.post-content { margin-bottom: 12px; line-height: 1.7; font-size: 14px; }
.post-image {
  width: 100%; border-radius: var(--radius-sm);
  margin-bottom: 12px; max-height: 500px; object-fit: cover;
}

.post-stats {
  display: flex; justify-content: space-between;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text-muted);
}
.post-stats span { display: flex; align-items: center; gap: 6px; }

.post-buttons { display: flex; padding: 6px 0; }
.post-btn {
  flex: 1; display: flex; align-items: center;
  justify-content: center; gap: 8px;
  padding: 10px; border-radius: 10px;
  background: none; color: var(--text-secondary);
  font-weight: 500; font-size: 13px;
}
.post-btn:hover { background: var(--primary-light); }
.post-btn.liked { color: var(--primary); }
.post-btn.liked i { animation: likeAnimation 0.4s ease; }

@keyframes likeAnimation {
  0% { transform: scale(1); } 50% { transform: scale(1.3); } 100% { transform: scale(1); }
}

.post-comments { padding-top: 12px; }
.comment-form { display: flex; gap: 10px; margin-bottom: 12px; }
.comment-form input {
  flex: 1; background: var(--bg); border: none;
  border-radius: var(--radius-full); padding: 8px 16px;
}

.comment { display: flex; gap: 10px; margin-bottom: 10px; }
.comment-body {
  background: var(--bg); border-radius: 14px;
  padding: 8px 14px;
}
.comment-body h5 { font-size: 12px; margin-bottom: 2px; color: var(--primary); font-weight: 600; }
.comment-body p { font-size: 13px; }

/* ===========================
   Right Sidebar
   =========================== */
.sidebar-section { margin-bottom: 24px; }
.sidebar-section h3 {
  font-size: 15px; margin-bottom: 12px;
  color: var(--text); font-weight: 700;
}

.friend-item { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.friend-item-info { flex: 1; }
.friend-item-info h4 { font-size: 13px; margin-bottom: 1px; font-weight: 600; }
.friend-item-info span { font-size: 11px; color: var(--text-muted); }

.online-dot {
  width: 10px; height: 10px; background: var(--success);
  border-radius: 50%; border: 2.5px solid var(--card);
  position: absolute; bottom: 0; right: 0;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
  50% { box-shadow: 0 0 0 5px rgba(34, 197, 94, 0); }
}
.avatar-wrapper { position: relative; }

/* ===========================
   Profile Page
   =========================== */
.profile-cover {
  height: 340px; background: var(--gradient-primary);
  border-radius: var(--radius-lg); position: relative;
  margin-bottom: 80px; overflow: hidden;
}
.profile-cover::before {
  content: ''; position: absolute; inset: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320"><path fill="rgba(255,255,255,0.08)" d="M0,96L48,112C96,128,192,160,288,165.3C384,171,480,149,576,128C672,107,768,85,864,90.7C960,96,1056,128,1152,133.3C1248,139,1344,117,1392,106.7L1440,96L1440,320L1392,320C1344,320,1248,320,1152,320C1056,320,960,320,864,320C768,320,672,320,576,320C480,320,384,320,288,320C192,320,96,320,48,320L0,320Z"/></svg>') no-repeat bottom;
  background-size: cover;
}

.profile-avatar { position: absolute; bottom: -60px; left: 24px; }
.profile-info { padding: 0 24px; margin-bottom: 24px; }
.profile-info h1 { font-size: 28px; margin-bottom: 4px; font-weight: 700; }
.profile-info p { color: var(--text-secondary); margin-bottom: 12px; font-size: 14px; }

.profile-stats { display: flex; gap: 24px; color: var(--text-secondary); font-size: 14px; }
.profile-actions { position: absolute; right: 24px; bottom: 24px; display: flex; gap: 8px; }

.profile-tabs {
  display: flex; border-bottom: 2px solid var(--border); margin-bottom: 24px;
}
.profile-tab {
  padding: 12px 24px; font-weight: 600; font-size: 14px;
  color: var(--text-secondary); background: none;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.profile-tab:hover { background: var(--primary-light); }
.profile-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.profile-grid { display: grid; grid-template-columns: 360px 1fr; gap: 24px; }
.profile-sidebar .card { margin-bottom: 16px; }
.profile-sidebar h3 { font-size: 18px; margin-bottom: 12px; font-weight: 700; }

.about-item { display: flex; align-items: center; gap: 12px; padding: 8px 0; color: var(--text-secondary); font-size: 14px; }
.about-item i { width: 22px; text-align: center; color: var(--primary); font-size: 16px; }

/* ===========================
   Friends Page
   =========================== */
.friends-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.friend-card { text-align: center; padding: 24px; transition: var(--transition); }
.friend-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.friend-card .avatar { margin: 0 auto 12px; width: 80px; height: 80px; font-size: 28px; border-radius: 20px; }
.friend-card h3 { font-size: 16px; margin-bottom: 4px; font-weight: 600; }
.friend-card .status { font-size: 13px; color: var(--text-secondary); margin-bottom: 14px; }
.friend-card .status.online { color: var(--success); font-weight: 500; }
.friend-card .actions { display: flex; gap: 8px; justify-content: center; }

/* ===========================
   Settings Page
   =========================== */
.settings-layout { display: grid; grid-template-columns: 260px 1fr; gap: 24px; max-width: 900px; }
.settings-nav { list-style: none; }
.settings-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 12px;
  color: var(--text); font-weight: 500; font-size: 14px;
}
.settings-nav a:hover { background: var(--primary-light); text-decoration: none; }
.settings-nav a.active { background: var(--gradient-primary); color: white; }

.settings-content .card { margin-bottom: 16px; }
.settings-content h2 {
  font-size: 20px; margin-bottom: 20px;
  padding-bottom: 12px; border-bottom: 2px solid var(--border); font-weight: 700;
}

.settings-row { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.settings-row:last-child { border-bottom: none; }
.settings-row .avatar { width: 56px; height: 56px; border-radius: 16px; }
.settings-row-info { flex: 1; }
.settings-row-info h4 { margin-bottom: 2px; font-weight: 600; font-size: 14px; }
.settings-row-info p { color: var(--text-secondary); font-size: 13px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.form-group input, .form-group textarea { width: 100%; }
.form-group textarea { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ===========================
   Messenger
   =========================== */
.messenger-layout {
  display: flex; height: calc(100vh - 60px);
  background: var(--card); width: 100%;
  position: relative; overflow: hidden;
}

.messenger-layout.chat-open .chat-panel {
  flex: 1; width: 100%;
}

.conversations-panel {
  width: 360px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.conversations-header { padding: 18px; border-bottom: 1px solid var(--border); }
.conversations-header h2 { font-size: 22px; margin-bottom: 12px; font-weight: 700; }

.conversations-search { position: relative; }
.conversations-search input {
  width: 100%; background: var(--bg); border: none;
  padding: 10px 16px 10px 40px; border-radius: var(--radius-full); font-size: 13px;
}
.conversations-search i {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%); color: var(--text-muted); font-size: 13px;
}

.conversations-list { flex: 1; overflow-y: auto; }

.conversation-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; cursor: pointer; transition: var(--transition);
}
.conversation-item:hover { background: var(--primary-light); }
.conversation-item.active { background: var(--primary-light); }

.conversation-info { flex: 1; min-width: 0; }
.conversation-info h4 { font-size: 14px; margin-bottom: 2px; font-weight: 600; }
.conversation-info p {
  font-size: 12px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.conversation-meta { text-align: right; flex-shrink: 0; }
.conversation-meta .time { font-size: 11px; color: var(--text-muted); }
.conversation-meta .unread {
  background: var(--gradient-primary); color: white;
  font-size: 10px; padding: 2px 7px;
  border-radius: var(--radius-full); margin-top: 4px;
  display: inline-block; font-weight: 700;
}

.chat-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.chat-panel.active {
  flex: 1; width: 100%;
}

#activeChat {
  display: flex; flex-direction: column;
  height: 100%; width: 100%;
}

.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
}
.chat-header-info { flex: 1; }
.chat-header-info h3 { font-size: 15px; margin-bottom: 2px; font-weight: 600; }
.chat-header-info span { font-size: 12px; color: var(--success); font-weight: 500; }

.chat-header-actions { display: flex; gap: 8px; }
.chat-header-actions button {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--bg); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.chat-header-actions button:hover { background: var(--primary); color: white; }

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

.message { display: flex; gap: 8px; max-width: 70%; }
.message.sent { margin-left: auto; flex-direction: row-reverse; }

.message-bubble {
  padding: 10px 14px; border-radius: 16px;
  font-size: 13px; line-height: 1.5; position: relative;
}
.message.received .message-bubble { background: var(--bg); }
.message.sent .message-bubble { background: var(--gradient-primary); color: white; }

.message-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; text-align: right; }
.message.sent .message-time { text-align: left; }
.message-status { font-size: 11px; color: var(--text-muted); }
.message-status i { color: var(--info); }

.date-separator { text-align: center; font-size: 12px; color: var(--text-muted); padding: 14px 0; font-weight: 500; }

.typing-indicator { display: flex; align-items: center; gap: 8px; padding: 8px 18px; font-size: 12px; color: var(--text-muted); font-style: italic; }

.chat-input {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--border);
}
.chat-input button {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--bg); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.chat-input button:hover { background: var(--primary); color: white; }
.chat-input input { flex: 1; border: none; background: var(--bg); border-radius: var(--radius-full); padding: 10px 16px; }
.chat-input .send-btn { background: var(--gradient-primary); color: white; }
.chat-input .send-btn:hover { transform: scale(1.05); box-shadow: var(--shadow-glow); }

.no-chat-selected {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: var(--text-muted);
  width: 100%; text-align: center;
}
.no-chat-selected i { font-size: 64px; margin-bottom: 16px; color: var(--border); }

/* ===========================
   Emoji Picker
   =========================== */
.emoji-picker {
  position: absolute; bottom: 100%; left: 0;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow-xl); padding: 12px;
  display: none; width: 320px; max-height: 300px;
  overflow-y: auto; z-index: 100; border: 1px solid var(--border);
}
.emoji-picker.show { display: block; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emoji-btn {
  width: 36px; height: 36px; border-radius: 8px;
  background: none; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition-fast);
}
.emoji-btn:hover { background: var(--primary-light); transform: scale(1.15); }

/* ===========================
   Mobile Nav
   =========================== */
.mobile-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(28, 28, 39, 0.95); backdrop-filter: blur(20px);
  border-top: 1px solid var(--border); padding: 8px 0; z-index: 1000;
}
[data-theme="light"] .mobile-nav { background: rgba(255,255,255,0.95); }
.mobile-nav-items { display: flex; justify-content: space-around; }
.mobile-nav a {
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; color: var(--text-muted); font-size: 9px;
  padding: 4px 12px; font-weight: 500;
}
.mobile-nav a.active { color: var(--primary); }
.mobile-nav a i { font-size: 22px; }

/* ===========================
   Theme Toggle (Settings)
   =========================== */
.theme-switch { position: relative; width: 52px; height: 28px; }
.theme-switch input { opacity: 0; width: 0; height: 0; }
.theme-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 28px; transition: var(--transition);
}
.theme-slider::before {
  content: ''; position: absolute; height: 22px; width: 22px;
  left: 3px; bottom: 3px; background: white;
  border-radius: 50%; transition: var(--transition);
}
.theme-switch input:checked + .theme-slider { background: var(--gradient-primary); }
.theme-switch input:checked + .theme-slider::before { transform: translateX(24px); }

/* ===========================
   Modal
   =========================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px); display: flex;
  align-items: center; justify-content: center;
  z-index: 2000; opacity: 0; visibility: hidden; transition: var(--transition);
}
.modal-overlay.show { opacity: 1; visibility: visible; }

.modal {
  background: var(--card); border-radius: var(--radius-lg);
  width: 90%; max-width: 500px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-xl);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--bg); display: flex;
  align-items: center; justify-content: center; font-size: 16px;
}
.modal-body { padding: 22px; }
.modal-body textarea {
  width: 100%; border: none; resize: none;
  font-size: 16px; min-height: 120px; background: transparent;
}
.modal-footer {
  padding: 12px 22px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ===========================
   Context Menu
   =========================== */
.context-menu {
  position: absolute; background: var(--card);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-xl);
  padding: 8px 0; min-width: 180px; z-index: 1500;
  display: none; border: 1px solid var(--border);
}
.context-menu.show { display: block; }
.context-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; width: 100%; background: none;
  text-align: left; color: var(--text); font-size: 13px;
}
.context-menu-item:hover { background: var(--primary-light); }
.context-menu-item.danger { color: var(--danger); }

/* ===========================
   Toast
   =========================== */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 3000; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--card); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xl); padding: 12px 20px;
  display: flex; align-items: center; gap: 12px;
  animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border); font-size: 13px;
}
@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }

/* ===========================
   Dropdown
   =========================== */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: 100%; right: 0;
  background: var(--card); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xl); padding: 8px 0;
  min-width: 200px; z-index: 1500; display: none;
  margin-top: 8px; border: 1px solid var(--border);
}
.dropdown-menu.show { display: block; }
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; width: 100%; background: none;
  text-align: left; color: var(--text); font-size: 13px;
}
.dropdown-item:hover { background: var(--primary-light); }

/* ===========================
   Loading
   =========================== */
.spinner {
  width: 40px; height: 40px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 44px 20px; color: var(--text-muted); }
.empty-state i { font-size: 52px; margin-bottom: 16px; color: var(--border); }
.empty-state h3 { color: var(--text); margin-bottom: 8px; }

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

/* ===========================
   Sidebar User
   =========================== */
.sidebar-user {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 12px; margin-bottom: 6px;
  border-radius: 12px; transition: var(--transition);
}
.sidebar-user:hover { background: var(--primary-light); }
.sidebar-user .avatar { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; }
.sidebar-user-name { font-weight: 600; font-size: 14px; }

.sidebar-footer {
  margin-top: 20px; padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-muted); line-height: 1.8;
}

/* ===========================
   Profile Photos & Friends Grids
   =========================== */
.profile-photos-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.profile-photo {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px;
  cursor: pointer; transition: var(--transition);
}
.profile-photo:hover { opacity: 0.85; transform: scale(1.02); }

.profile-friends-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.profile-friend {
  text-align: center; color: var(--text); font-size: 11px; font-weight: 500;
}
.profile-friend:hover { color: var(--primary); text-decoration: none; }
.profile-friend-img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px;
  margin-bottom: 4px;
}

/* ===========================
   Sponsored & Group Chat
   =========================== */
.sponsored-ad {
  display: block; margin-bottom: 14px; border-radius: var(--radius-sm);
  overflow: hidden; transition: var(--transition);
}
.sponsored-ad:hover { opacity: 0.9; }
.sponsored-img {
  width: 100%; height: 120px; object-fit: cover; border-radius: var(--radius-sm);
}
.sponsored-info { padding: 8px 0; }
.sponsored-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; color: var(--text); }
.sponsored-url { font-size: 11px; color: var(--text-muted); }

.group-chat-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 0;
  color: var(--text); font-size: 13px; font-weight: 500;
}
.group-chat-item:hover { color: var(--primary); text-decoration: none; }

.avatar-stack { display: flex; }
.avatar-stack img { margin-right: -10px; }

/* ===========================
   Responsive
   =========================== */
@media (max-width: 1200px) {
  .right-sidebar { display: none; }
  .main-content.has-right-sidebar { margin-right: 0; max-width: 100%; }
}

@media (max-width: 992px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; max-width: 100%; }
  .mobile-nav { display: block; }
  .main-layout { padding-bottom: 70px; }
  .profile-grid { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .auth-box { padding: 28px; }
  .navbar-search { display: none; }
  .nav-profile span { display: none; }
  .conversations-panel { width: 100%; }
  .chat-panel { display: none; }
  .messenger-layout.chat-open .chat-panel,
  .chat-panel.active {
    display: flex; position: fixed;
    top: 60px; left: 0; right: 0; bottom: 0;
    width: 100%; z-index: 999; background: var(--card);
  }
  .conversations-panel.hidden { display: none; }
  .friends-grid { grid-template-columns: repeat(2, 1fr); }
  .profile-cover { height: 200px; margin-bottom: 60px; }
}
