/* LinkUp Premium Custom CSS Design System */
:root {
  /* HSL Tailored Colors (Premium LinkUp Blue Palette) */
  --hue: 220;
  --primary: hsl(var(--hue), 85%, 55%);
  --primary-hover: hsl(var(--hue), 85%, 45%);
  --primary-light: hsl(var(--hue), 85%, 95%);
  --success: hsl(145, 80%, 45%);
  --danger: hsl(355, 80%, 55%);
  --warning: hsl(45, 90%, 50%);

  /* Light Theme Variables */
  --bg-app: hsl(var(--hue), 20%, 97%);
  --bg-card: hsl(0, 0%, 100%);
  --bg-sidebar: hsl(var(--hue), 30%, 99%);
  --border: hsl(var(--hue), 10%, 90%);
  --text-main: hsl(var(--hue), 25%, 15%);
  --text-muted: hsl(var(--hue), 15%, 50%);
  --text-on-primary: hsl(0, 0%, 100%);
  
  --shadow: 0 4px 20px -2px rgba(18, 38, 75, 0.08), 0 2px 8px -1px rgba(18, 38, 75, 0.04);
  --glass-bg: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(255, 255, 255, 0.4);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
  --blur: blur(12px);
  --radius: 12px;
}

[data-theme="dark"] {
  /* Dark Theme Variables */
  --bg-app: hsl(var(--hue), 22%, 8%);
  --bg-card: hsl(var(--hue), 20%, 12%);
  --bg-sidebar: hsl(var(--hue), 20%, 10%);
  --border: hsl(var(--hue), 15%, 18%);
  --text-main: hsl(var(--hue), 15%, 90%);
  --text-muted: hsl(var(--hue), 10%, 60%);
  --primary-light: hsl(var(--hue), 50%, 18%);
  
  --shadow: 0 4px 24px -3px rgba(0, 0, 0, 0.3), 0 2px 10px -2px rgba(0, 0, 0, 0.2);
  --glass-bg: rgba(15, 23, 42, 0.75);
  --glass-border: rgba(255, 255, 255, 0.05);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --blur: blur(16px);
}

/* Reset and Global Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Layout Architecture */
.app-container {
  display: flex;
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
}

/* Sidebar Styling (Desktop) */
.sidebar {
  width: 260px;
  height: 100vh;
  position: sticky;
  top: 0;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 100;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--text-on-primary);
  font-weight: 800;
  font-size: 20px;
  box-shadow: 0 4px 14px rgba(45, 107, 245, 0.3);
}

.logo-text {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #5274ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 15px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item.active a, .nav-item a:hover {
  color: var(--primary);
  background-color: var(--primary-light);
  transform: translateX(4px);
}

/* Main Content Wrapper */
.main-content {
  flex: 1;
  padding: 24px;
  padding-bottom: 80px; /* Space for mobile navbar */
}

/* Glass Card Component */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  position: relative;
}

.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

/* Feed Headers & Post Creator */
.post-creator-header {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.user-avatar-sm {
  width: 32px;
  height: 32px;
}

.user-avatar-lg {
  width: 90px;
  height: 90px;
  border: 4px solid var(--bg-card);
  box-shadow: var(--shadow);
}

.post-input {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  resize: none;
  color: var(--text-main);
  font-size: 16px;
}

.post-creator-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Stories Tray */
.stories-tray {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.stories-tray::-webkit-scrollbar {
  display: none;
}

.story-item {
  position: relative;
  min-width: 90px;
  height: 140px;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.story-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.85);
  transition: transform 0.3s ease;
}

.story-item:hover .story-bg {
  transform: scale(1.05);
}

.story-avatar {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  object-fit: cover;
}

.story-name {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Post Styling */
.post-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.post-meta {
  display: flex;
  flex-direction: column;
}

.post-author {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-main);
  text-decoration: none;
  display: flex;
  align-items: center;
}

.post-time {
  font-size: 12px;
  color: var(--text-muted);
}

.post-body {
  margin-bottom: 16px;
  font-size: 15px;
  word-break: break-word;
}

.post-media {
  width: 100%;
  max-height: 450px;
  border-radius: var(--radius);
  object-fit: cover;
  margin-top: 12px;
}

/* Post Actions & Custom Reactions Popup */
.post-stats {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 13px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.post-actions {
  display: flex;
  justify-content: space-between;
  position: relative;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.action-btn:hover {
  background-color: var(--border);
  color: var(--primary);
}

/* Hover Reactions Menu */
.reactions-box {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 8px 12px;
  display: flex;
  gap: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  z-index: 10;
}

.action-btn-like:hover .reactions-box {
  opacity: 1;
  visibility: visible;
  transform: translateY(-5px);
}

.reaction-emoji {
  font-size: 24px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.reaction-emoji:hover {
  transform: scale(1.3) translateY(-4px);
}

/* Custom Comments Thread */
.comments-section {
  background-color: var(--bg-sidebar);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
  display: none;
}

.comment-input-area {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.comment-box {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 16px;
  outline: none;
  background: var(--bg-card);
  color: var(--text-main);
}

.comment-item {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.comment-content {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  flex: 1;
  font-size: 13.5px;
}

.comment-author {
  font-weight: 700;
}

/* Chat/Messages Layout */
.chat-container {
  display: flex;
  height: calc(100vh - 48px);
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
}

.chat-sidebar {
  width: 300px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.chat-search {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.chat-input-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-app);
  color: var(--text-main);
  outline: none;
}

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

.chat-user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s ease;
}

.chat-user-item:hover, .chat-user-item.active {
  background-color: var(--primary-light);
}

.chat-user-info {
  flex: 1;
  overflow: hidden;
}

.chat-user-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
}

.chat-user-lastmsg {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--bg-app);
}

/* Chat Bubbles */
.chat-bubble {
  max-width: 60%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14.5px;
  word-wrap: break-word;
}

.chat-bubble.sent {
  align-self: flex-end;
  background-color: var(--primary);
  color: #fff;
  border-bottom-right-radius: 2px;
}

.chat-bubble.received {
  align-self: flex-start;
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
}

.chat-time {
  font-size: 10px;
  margin-top: 4px;
  text-align: right;
  opacity: 0.8;
}

.chat-input-area {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
}

.chat-input-msg {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  outline: none;
  background: var(--bg-app);
  color: var(--text-main);
}

/* Forms & Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(45, 107, 245, 0.3);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--border);
  color: var(--text-main);
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 14px;
}

.form-control {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background-color: var(--bg-app);
  color: var(--text-main);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
}

/* Profile Header Widget */
.profile-cover {
  width: 100%;
  height: 250px;
  border-radius: var(--radius) var(--radius) 0 0;
  object-fit: cover;
}

.profile-avatar-container {
  display: flex;
  margin-top: -45px;
  padding: 0 24px;
  align-items: flex-end;
  gap: 16px;
}

.profile-info {
  margin-bottom: 12px;
}

.profile-name {
  font-size: 24px;
  font-weight: 800;
  display: flex;
  align-items: center;
}

.profile-stats {
  display: flex;
  gap: 24px;
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.stat-item {
  text-align: center;
}

.stat-num {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* Mobile Bottom Navigation Bar (Washes out on Desktop) */
.mobile-navbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background-color: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  z-index: 1000;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.05);
}

.mobile-nav-item {
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
}

.mobile-nav-item.active, .mobile-nav-item:hover {
  color: var(--primary);
}

.mobile-nav-item svg {
  width: 24px;
  height: 24px;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Responsive Rules */
@media (max-width: 768px) {
  .sidebar {
    display: none; /* Hide desktop sidebar */
  }
  
  .mobile-navbar {
    display: flex; /* Show mobile bottom nav */
  }
  
  .main-content {
    padding: 12px;
    padding-bottom: 80px;
  }
  
  .chat-container {
    flex-direction: column;
    height: calc(100vh - 120px);
  }
  
  .chat-sidebar {
    width: 100%;
    height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  
  .chat-bubble {
    max-width: 85%;
  }
}
