/* ============================================================
   MERIK APP STYLES — community.php, inbox.php, playground.php
   ============================================================ */



:root {
  --primary:       #00bcd4;
  --primary-dark:  #0097a7;
  --primary-glow:  rgba(0,188,212,0.2);
  --navy:          #0d1b2a;
  --navy-light:    #162032;
  --surface:       #ffffff;
  --surface-alt:   #f4f6f9;
  --text:          #1a1a2e;
  --text-muted:    #6b7280;
  --border:        #e5e7eb;
  --radius:        12px;
  --radius-lg:     18px;
  --transition:    0.3s ease;
  --font-display:  'Segoe UI', system-ui, sans-serif;
  --font-body:     'Segoe UI', system-ui, sans-serif;
  --nav-h:         60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-body); color: var(--text); background: var(--surface-alt); -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; }
a { text-decoration: none; color: inherit; }

.app-body { background: var(--surface-alt); min-height: 100vh; }

/* ── App Nav ────────────────────────────────────────────── */
.app-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--navy);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  z-index: 100;
}

.app-nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.app-nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.app-nav-logo img { height: 34px; border-radius: 6px; }
.app-nav-logo span { font-family: var(--font-display); font-size: 1rem; font-weight: 700; color: #fff; }

.app-nav-center { display: flex; align-items: center; gap: 4px; }

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 8px;
  color: rgba(255,255,255,0.72);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}
.app-nav-link:hover, .app-nav-link.active { color: #fff; background: rgba(255,255,255,0.1); }

.app-nav-right { display: flex; align-items: center; gap: 10px; }

/* Notification bell */
.app-notif-wrap { position: relative; }
.app-notif-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  transition: all var(--transition);
  position: relative;
}
.app-notif-btn:hover { background: rgba(255,255,255,0.14); color: #fff; }
.app-notif-count {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px;
  background: #ef4444; color: #fff;
  border-radius: 50px; font-size: 0.7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.app-notif-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px); right: 0;
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  z-index: 200;
  max-height: 360px;
  overflow-y: auto;
}
.app-notif-wrap.open .app-notif-dropdown { display: block; }

/* ── Three-column layout ────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  gap: 0;
  max-width: 1400px;
  margin: var(--nav-h) auto 0;
  min-height: calc(100vh - var(--nav-h));
}

/* Sidebar */
.app-sidebar, .app-right-panel {
  padding: 20px 0;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
}

.app-sidebar { border-right: 1px solid var(--border); background: var(--surface); }
.app-right-panel { border-left: 1px solid var(--border); background: var(--surface); }

.app-sidebar-inner, .app-right-inner { padding: 16px; }

.app-sidebar-title {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.app-sidebar-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 24px; }
.app-sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
  text-decoration: none;
}
.app-sidebar-nav a:hover, .app-sidebar-nav a.active {
  background: rgba(0,188,212,0.08);
  color: var(--primary);
}
.app-sidebar-nav a i { width: 16px; text-align: center; }
.app-sidebar-divider { height: 1px; background: var(--border); margin: 20px 0; }

.sidebar-cta {
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
  margin-top: 12px;
}

/* Quick links (right panel) */
.quick-links { display: flex; flex-direction: column; gap: 4px; margin-bottom: 20px; }
.quick-link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.88rem;
  color: var(--text-muted);
  transition: all var(--transition);
  text-decoration: none;
}
.quick-link-item:hover { background: rgba(0,188,212,0.07); color: var(--primary); }
.quick-link-item i { width: 16px; text-align: center; }

/* ── Feed ───────────────────────────────────────────────── */
.app-feed {
  padding: 20px 24px;
  min-height: calc(100vh - var(--nav-h));
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

.feed-search-bar {
  position: relative;
  margin-bottom: 20px;
}
.feed-search-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  transition: border-color var(--transition);
}
.feed-search-inner:focus-within { border-color: var(--primary); }
.feed-search-inner i { color: var(--text-muted); font-size: 0.88rem; }
.feed-search-inner input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--text);
}

.suggestions-box {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  z-index: 50;
  display: none;
}

.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.feed-header h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Feed empty state */
.feed-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.feed-empty h3 { font-family: var(--font-display); font-size: 1.3rem; margin-bottom: 10px; color: var(--text); }

/* Posts grid */
.posts-grid { display: flex; flex-direction: column; gap: 16px; }

/* Post card */
.post-card {
  overflow: visible !important;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  transition: box-shadow var(--transition);
}
.post-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.07); }

/* Post header */
.post-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.post-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
}
.post-author-info { flex: 1; }
.post-author { display: block; font-weight: 700; font-size: 0.92rem; color: var(--text); }
.post-time { font-size: 0.78rem; color: var(--text-muted); }
.post-message-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  transition: all var(--transition);
  text-decoration: none;
}
.post-message-btn:hover { background: rgba(0,188,212,0.1); color: var(--primary); border-color: var(--primary); }

/* Project title */
.post-project-title {
  margin-bottom: 12px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
}
.post-project-title a { color: var(--primary); display: flex; align-items: center; gap: 7px; text-decoration: none; }
.post-project-title a:hover { text-decoration: underline; }

/* Post content */
.post-content { font-size: 0.92rem; color: var(--text); line-height: 1.65; }
.post-content p { margin: 0; }
.post-content.expanded p { }
.post-read-more {
  background: none; border: none; color: var(--primary);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  padding: 4px 0; margin-top: 4px;
  font-family: var(--font-body);
}
.post-read-more:hover { text-decoration: underline; }

/* Post actions */
.post-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.post-reactions { display: flex; align-items: center; gap: 8px; }

.reaction-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-body);
}
.reaction-btn:hover { border-color: var(--primary); color: var(--primary); background: rgba(0,188,212,0.06); }
.reaction-btn.reacted { border-color: #ef4444; color: #ef4444; background: rgba(239,68,68,0.06); }
.reaction-btn.reacted-dis { border-color: var(--text-muted); color: var(--text); background: var(--surface-alt); }

/* Comments section */
.post-comments {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.comment-box { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.comment-loading { font-size: 0.85rem; color: var(--text-muted); }
.comment-form-inner {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.comment-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700;
  flex-shrink: 0;
}
.comment-form textarea {
  flex: 1;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.88rem;
  resize: none;
  outline: none;
  background: var(--surface-alt);
  transition: border-color var(--transition);
}
.comment-form textarea:focus { border-color: var(--primary); background: var(--surface); }
.comment-login-msg { font-size: 0.85rem; color: var(--text-muted); }
.comment-login-msg a { color: var(--primary); font-weight: 600; }

/* ── INBOX ──────────────────────────────────────────────── */
.inbox-body { background: var(--surface); }

.inbox-wrap {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - var(--nav-h));
  margin-top: var(--nav-h);
}

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

.inbox-sidebar-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.inbox-sidebar-header h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.inbox-threads { flex: 1; overflow-y: auto; }

.inbox-empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.inbox-empty-state i { font-size: 2.5rem; opacity: 0.3; }

/* Thread item */
.inbox-thread {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
  color: var(--text);
  position: relative;
}
.inbox-thread:hover { background: var(--surface-alt); }
.inbox-thread.active { background: rgba(0,188,212,0.07); border-left: 3px solid var(--primary); }
.inbox-thread.unread .thread-name { font-weight: 700; }

.thread-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 1rem; font-weight: 700;
  flex-shrink: 0;
  position: relative;
}
.thread-online-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid var(--surface);
  position: absolute; bottom: 1px; right: 1px;
  display: none;
}
.thread-online-dot.online { display: block; }

.thread-info { flex: 1; min-width: 0; }
.thread-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.thread-name { font-size: 0.92rem; font-weight: 600; color: var(--text); }
.thread-time { font-size: 0.75rem; color: var(--text-muted); }
.thread-preview { display: flex; align-items: center; gap: 6px; }
.thread-msg { font-size: 0.82rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }

/* Tick styles */
.tick { font-size: 0.75rem; color: var(--text-muted); }
.tick-read { color: #00bcd4; }
.tick-delivered { color: #9ca3af; }

/* Chat area */
.inbox-chat {
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  height: 100%;
  overflow: hidden;
}

.chat-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-placeholder-inner {
  text-align: center;
  color: var(--text-muted);
}
.chat-placeholder-inner i { font-size: 3rem; opacity: 0.2; margin-bottom: 16px; }
.chat-placeholder-inner h3 { font-family: var(--font-display); font-size: 1.2rem; color: var(--text); margin-bottom: 8px; }

/* Chat header */
.chat-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-back-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: all var(--transition);
}
.chat-back-btn:hover { color: var(--primary); }

.chat-head-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700; font-size: 0.95rem;
  flex-shrink: 0;
}
.chat-head-info { display: flex; flex-direction: column; gap: 2px; }
.chat-head-name { font-weight: 700; font-size: 0.95rem; }
.chat-head-status { font-size: 0.78rem; color: var(--text-muted); }
.chat-typing { font-size: 0.78rem; color: #10b981; font-style: italic; }

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

.msg-row { display: flex; }
.msg-sent { justify-content: flex-end; }
.msg-received { justify-content: flex-start; }

.msg-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.55;
  word-break: break-word;
}
.msg-sent .msg-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-received .msg-bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  font-size: 0.68rem;
  opacity: 0.75;
}

/* Chat input */
.chat-input-bar {
  padding: 14px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input-bar form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.chat-input-bar textarea {
  flex: 1;
  padding: 11px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.92rem;
  resize: none;
  outline: none;
  max-height: 120px;
  transition: border-color var(--transition);
  background: var(--surface-alt);
}
.chat-input-bar textarea:focus { border-color: var(--primary); background: var(--surface); }
.chat-send-btn {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: all var(--transition);
  flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--primary-dark); }

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  .app-right-panel { display: none; }
  .app-layout { grid-template-columns: 200px 1fr; }
}

@media (max-width: 768px) {
  /* Layout */
  .app-layout { grid-template-columns: 1fr; padding-bottom: 64px; }
  .app-sidebar  { display: none; }
  .app-nav-center { display: none; }

  /* Feed padding */
  .app-feed { padding: 12px 14px; }

  /* Search bar */
  .feed-search-inner { padding: 9px 12px; }

  /* Sort tabs — scroll horizontally */
  .feed-sort-tabs { overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; padding-bottom: 4px; }
  .feed-sort-tabs::-webkit-scrollbar { display: none; }
  .feed-sort-tab { white-space: nowrap; font-size: .78rem; padding: 6px 12px; }

  /* Post cards */
  .post-card {
  overflow: visible !important; padding: 14px; border-radius: 14px; }
  .post-card-header { gap: 8px; margin-bottom: 10px; }
  .post-avatar { width: 34px; height: 34px; font-size: .88rem; }
  .post-author { font-size: .85rem; }
  .post-time   { font-size: .72rem; }
  .post-content { font-size: .88rem; }

  /* Actions */
  .post-actions { flex-wrap: wrap; gap: 8px; }
  .post-reactions { gap: 6px; }
  .reaction-btn { padding: 5px 10px; font-size: .8rem; }

  /* Comments */
  .comment-form-inner { gap: 8px; }
  .comment-avatar { width: 28px; height: 28px; font-size: .75rem; }
  .comment-form textarea { font-size: .85rem; padding: 8px 10px; }

  /* Inbox */
  .inbox-wrap { grid-template-columns: 1fr; }
  .inbox-chat { display: none; }
  .inbox-chat.active { display: flex; }
  .inbox-sidebar.hidden { display: none; }
  .chat-back-btn { display: flex; }

  /* Notification dropdown full width on mobile */
  .app-notif-dropdown { width: calc(100vw - 24px); right: -8px; }

  /* Nav adjustments */
  .app-nav-inner { padding: 0 12px; }
  .app-nav-logo span { display: none; }
  .app-notif-btn { width: 32px; height: 32px; }
}

/* ── MOBILE BOTTOM NAV ──────────────────────────────────────── */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 58px;
  background: var(--navy);
  border-top: 1px solid rgba(255,255,255,.08);
  z-index: 200;
  padding: 0 8px;
  backdrop-filter: blur(12px);
}

.mobile-bottom-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 100%;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 16px;
  border-radius: 10px;
  color: rgba(255,255,255,.45);
  text-decoration: none;
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .02em;
  transition: all .2s;
  min-width: 52px;
  position: relative;
}

.mobile-nav-item i {
  font-size: 1.15rem;
  transition: transform .2s;
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
  color: #fff;
}

.mobile-nav-item.active i { color: var(--primary); transform: translateY(-2px); }
.mobile-nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--primary);
}

.mobile-nav-badge {
  position: absolute;
  top: 4px; right: 10px;
  min-width: 16px; height: 16px;
  background: #ef4444;
  color: #fff;
  border-radius: 50px;
  font-size: .62rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* FAB — new post button */
.mobile-fab {
  display: none;
  position: fixed;
  bottom: 72px;
  right: 16px;
  width: 50px; height: 50px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,188,212,.4);
  align-items: center; justify-content: center;
  z-index: 199;
  transition: all .2s;
  text-decoration: none;
}
.mobile-fab:hover { transform: scale(1.08); background: var(--primary-dark); }

@media (max-width: 768px) {
  .mobile-bottom-nav { display: flex; }
  .mobile-fab { display: flex; }
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   NOTIFICATION DROPDOWN
   ============================================================ */
.app-notif-dropdown {
  display: none;
  position: fixed;
  top: calc(var(--nav-h) + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px rgba(0,0,0,0.18);
  z-index: 300;
  overflow: hidden;
  animation: notifSlideIn 0.2s ease;
}

.app-notif-wrap.open .app-notif-dropdown { display: block; }

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

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}

.notif-mark-all {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--transition);
  font-family: var(--font-body);
}
.notif-mark-all:hover { background: rgba(0,188,212,0.08); }

.notif-list {
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background var(--transition);
  cursor: pointer;
}
.notif-item:hover { background: var(--surface-alt); }
.notif-item:last-child { border-bottom: none; }

.notif-unread { background: rgba(0,188,212,0.04); }
.notif-read   { opacity: 0.7; }

.notif-icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.notif-emoji { font-size: 1.15rem; line-height: 1; }

.notif-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: transparent;
  flex-shrink: 0;
}
.notif-dot-active { background: var(--primary); }

.notif-content { flex: 1; min-width: 0; }
.notif-msg  { font-size: 0.85rem; line-height: 1.5; margin: 0 0 3px; color: var(--text); }
.notif-time { font-size: 0.75rem; color: var(--text-muted); }

.notif-empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
}
.notif-empty i  { font-size: 1.8rem; opacity: 0.25; margin-bottom: 10px; display: block; }
.notif-empty p  { font-size: 0.88rem; margin: 0; }

.notif-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.notif-spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ============================================================
   COMMUNITY SEARCH SUGGESTIONS
   ============================================================ */
.suggestions-box {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  z-index: 50;
  max-height: 320px;
  overflow-y: auto;
}

.suggestion-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background var(--transition);
}
.suggestion-item:hover { background: var(--surface-alt); }
.suggestion-item:last-child { border-bottom: none; }

.suggestion-item .title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.suggestion-item .meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.suggestion-item .username { color: var(--primary); font-weight: 600; }
.suggestion-item mark {
  background: rgba(0,188,212,0.2);
  color: var(--primary);
  border-radius: 2px;
  padding: 0 2px;
}

.suggestion-item.recent .title  { color: var(--text-muted); }
.suggestion-item.trending .title { color: var(--text); }

.no-result {
  padding: 16px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Trending searches below the search box */
#trending-searches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.trend {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.trend:hover { border-color: var(--primary); color: var(--primary); }

/* Sort tabs for feed */
.feed-sort-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}
.feed-sort-tab {
  padding: 6px 16px;
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  background: var(--surface);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}
.feed-sort-tab:hover, .feed-sort-tab.active {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(0,188,212,0.06);
}
.feed-sort-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ── Comment items ─────────────────────────────────────────── */
.comment-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.comment-item:last-child { border-bottom: none; }

.comment-item-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
  flex-shrink: 0;
}

.comment-item-body { flex: 1; min-width: 0; }

.comment-item-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 3px;
}
.comment-item-user { font-weight: 700; font-size: 0.82rem; color: var(--text); }
.comment-item-time { font-size: 0.72rem; color: var(--text-muted); }
.comment-item-text { font-size: 0.88rem; color: var(--text); line-height: 1.5; margin: 0; }

/* ============================================================
   THREADED COMMENTS SYSTEM
   ============================================================ */

/* Comment item layout */
.comment-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 14px;
  animation: fadeInUp .3s ease;
}

.comment-reply { margin-bottom: 10px; }

/* Avatar column */
.comment-avatar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

.comment-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  text-decoration: none;
  flex-shrink: 0;
  transition: transform .15s, box-shadow .15s;
  cursor: pointer;
}
.comment-avatar:hover {
  transform: scale(1.08);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.comment-thread-line {
  width: 2px;
  flex: 1;
  min-height: 12px;
  background: var(--border);
  margin-top: 4px;
}

/* Content column */
.comment-content-col { flex: 1; min-width: 0; }

/* Bubble */
.comment-bubble {
  background: var(--surface-alt);
  border-radius: 0 12px 12px 12px;
  padding: 10px 14px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  transition: border-color .2s;
}
.comment-item:hover .comment-bubble { border-color: rgba(0,188,212,.2); }

.comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.comment-author {
  font-size: .85rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  transition: color .15s;
}
.comment-author:hover { color: var(--primary-dark); text-decoration: underline; }

.comment-time {
  font-size: .72rem;
  color: var(--text-muted);
}

.comment-reply-badge {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: rgba(0,188,212,.1);
  color: var(--primary);
  padding: 2px 7px;
  border-radius: 50px;
}

.comment-text {
  font-size: .88rem;
  color: var(--text);
  line-height: 1.55;
  margin: 0;
  word-break: break-word;
}

/* Read-more text block */
.comment-text-wrap { position: relative; }

.ct-full { display: none; }

.ct-dots { color: var(--text-muted); }

.cm-readmore-btn {
  display: inline-block;
  margin-top: 2px;
  padding: 0;
  background: none;
  border: none;
  color: var(--primary);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: opacity .15s;
}
.cm-readmore-btn:hover { opacity: .75; }

/* Action row */
.comment-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 2px;
  margin-bottom: 2px;
}

.comment-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  font-family: var(--font-body);
}
.comment-action-btn:hover { background: var(--surface-alt); color: var(--text); }

.comment-like-btn:hover, .comment-like-btn.liked {
  color: #ef4444;
  background: rgba(239,68,68,.07);
}
.comment-like-btn.liked i { font-weight: 900; }

.comment-reply-btn:hover { color: var(--primary); background: rgba(0,188,212,.07); }

/* Replies container */
.comment-replies {
  margin-left: 16px;
  border-left: 2px solid var(--border);
  padding-left: 12px;
  margin-top: 4px;
  margin-bottom: 8px;
}

/* Reply form */
.reply-form-wrap {
  margin-top: 8px;
  margin-bottom: 4px;
  animation: fadeInUp .2s ease;
}
.reply-form-inner {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.reply-input-wrap { flex: 1; }
.reply-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .85rem;
  resize: none;
  outline: none;
  background: var(--surface-alt);
  color: var(--text);
  transition: border-color .2s;
}
.reply-textarea:focus { border-color: var(--primary); background: var(--surface); }

.reply-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

.reply-submit-btn {
  background: var(--primary) !important;
  color: #fff !important;
  border-radius: var(--radius) !important;
  padding: 6px 14px !important;
}
.reply-submit-btn:hover { background: var(--primary-dark) !important; }

/* Loading state */
.comments-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px;
  color: var(--text-muted);
  font-size: .85rem;
}
.comment-spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

.comment-empty {
  padding: 16px 0;
  color: var(--text-muted);
  font-size: .88rem;
  text-align: center;
}

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

/* ── Comment fold button ──────────────────────────────────── */
.comment-fold-btn {
  color: var(--primary) !important;
  font-size: .76rem !important;
}
.comment-fold-btn:hover {
  background: rgba(0,188,212,.08) !important;
}
.comment-fold-btn i {
  font-size: .72rem;
  transition: transform .2s;
}

/* ── Extra mobile polish ──────────────────────────────────── */
@media (max-width: 480px) {
  /* Tighter nav */
  .app-nav-inner { padding: 0 10px; gap: 8px; }
  .app-nav-logo img { height: 28px; }

  /* Post card */
  .post-card {
  overflow: visible !important; padding: 12px; border-radius: 12px; margin-bottom: 2px; }
  .posts-grid { gap: 10px; }

  /* Feed search */
  .feed-search-bar { margin-bottom: 12px; }

  /* Trending pill tags small */
  .trend { font-size: .72rem; padding: 3px 10px; }

  /* Reactions tighter */
  .reaction-btn { padding: 5px 8px; gap: 4px; font-size: .78rem; }

  /* Comment section */
  .post-comments { margin-top: 10px; padding-top: 10px; }
  .comment-bubble { padding: 8px 10px; }
  .comment-text   { font-size: .83rem; }
  .comment-avatar { width: 26px; height: 26px; font-size: .72rem; }

  /* Feed header */
  .feed-header h2 { font-size: 1rem; }
  .feed-header .btn { font-size: .78rem; padding: 6px 12px; }

  /* Notification full-width */
  .app-notif-dropdown { width: 100vw; right: -50px; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
}

/* Desktop only elements */
.desktop-only { display: flex; }
@media (max-width: 768px) {
  .desktop-only { display: none !important; }
}

/* Post anchor highlight — when navigating from notification */
.post-card:target {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow), var(--shadow-md);
  animation: postHighlight 2s ease forwards;
}

@keyframes postHighlight {
  0%   { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-glow); }
  70%  { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-glow); }
  100% { border-color: var(--border);  box-shadow: var(--shadow-sm); }
}

/* ── Community Premium badges ──────────────────────────────── */
.post-avatar { position: relative; }
.post-avatar-check {
  position: absolute; bottom: -2px; right: -2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: .55rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface);
}

.post-pro-badge {
  background: linear-gradient(90deg,#f59e0b,#d97706);
  color: #fff; font-size: .62rem; font-weight: 800;
  padding: 1px 6px; border-radius: 50px;
  letter-spacing: .04em; vertical-align: middle;
}

.post-promoted-badge {
  font-size: .68rem; color: #8b5cf6; font-weight: 700;
}

/* Promoted post card — subtle purple top border */
.post-card:has(.post-promoted-badge) {
  border-top: 2px solid rgba(139,92,246,.4);
}

/* Feed post buttons group */
.feed-post-btns {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Text posts in feed — different style */
.post-card[data-type="text"] .post-project-link { display: none; }

/* ── Community post media ──────────────────────────────────── */
.post-media { margin-top: 10px; border-radius: 12px; overflow: hidden; }

.post-media-single img,
.post-media-single video { width: 100%; max-height: 400px; object-fit: cover; display: block; border-radius: 12px; }

.post-media-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  border-radius: 12px;
  overflow: hidden;
}
.post-media-grid img:first-child:nth-last-child(1) { grid-column: 1/-1; }
.post-media-grid img:first-child:nth-last-child(3),
.post-media-grid img:first-child:nth-last-child(3) ~ img { grid-column: auto; }

.post-media-img {
  width: 100%; height: 180px;
  object-fit: cover; display: block;
  cursor: zoom-in;
  transition: opacity .2s;
}
.post-media-img:hover { opacity: .92; }

.post-media-video {
  width: 100%; max-height: 380px;
  border-radius: 12px; display: block;
  background: #000;
}

/* 3+ images — first one takes full width */
.post-media-grid:has(img:nth-child(3)) img:first-child { grid-column: 1/-1; height: 220px; }

/* ── Post chat/message button in actions ───────────────────── */
.post-action-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.post-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(0,188,212,.08);
  border: 1.5px solid rgba(0,188,212,.2);
  color: var(--primary);
  font-size: .85rem;
  text-decoration: none;
  transition: all .2s;
  flex-shrink: 0;
}
.post-chat-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: scale(1.08);
}

/* ── Post media grid ───────────────────────────────────────── */
.post-media {
  margin-top: 10px;
  border-radius: 12px;
  overflow: hidden;
}

.post-media-single .post-media-img,
.post-media-single video {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  display: block;
  border-radius: 12px;
}

.post-media-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  border-radius: 12px;
  overflow: hidden;
}

/* 1 image — full width */
.post-media-grid .post-media-img:only-child {
  grid-column: 1 / -1;
}

/* 3 images — first full width */
.post-media-grid .post-media-img:first-child:nth-last-child(3) {
  grid-column: 1 / -1;
  height: 220px;
}

.post-media-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
  transition: opacity .2s;
}
.post-media-img:hover { opacity: .9; }

.post-media-more {
  height: 180px;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  border-radius: 0;
}
.post-media-more:hover { background: rgba(0,0,0,.7); }

@media (max-width: 480px) {
  .post-media-img { height: 130px; }
}

/* ── Feed filter row ──────────────────────────────────────── */
.feed-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.feed-type-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.feed-type-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 50px;
  font-size: .8rem;
  font-weight: 700;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  background: var(--surface);
  text-decoration: none;
  transition: all .2s;
  white-space: nowrap;
}
.feed-type-tab:hover { border-color: var(--primary); color: var(--primary); }
.feed-type-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Post type badge (text posts) */
.post-type-badge {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 50px;
}

/* Text post cards — slightly different left border */
.post-card[data-type="text"] {
  border-left: 3px solid rgba(0,188,212,.3);
}

@media (max-width: 600px) {
  .feed-filter-row { gap: 8px; }
  .feed-type-tab { padding: 5px 10px; font-size: .74rem; }
}

/* ── Post owner menu (edit/delete) ────────────────────────── */
.post-header-actions {
  display: flex; align-items: center;
  gap: 6px; flex-shrink: 0; margin-left: auto;
  position: relative;
}

.post-owner-menu { position: relative; display: inline-block; }
.post-owner-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; transition: all .2s;
}
.post-owner-btn:hover { background: var(--surface-alt); color: var(--text); }

/* Dropdown uses fixed position set by JS — just styling here */
.post-owner-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  min-width: 140px;
  overflow: hidden;
  z-index: 999;
  animation: slideDown .15s ease;
}
@keyframes slideDown { from { opacity:0; transform:translateY(-4px); } }

.post-owner-dropdown button {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 11px 16px;
  background: none; border: none;
  font-family: var(--font-body); font-size: .88rem;
  color: var(--text); cursor: pointer;
  transition: background .15s; text-align: left;
}
.post-owner-dropdown button:hover { background: var(--surface-alt); }

/* ── Period filter tabs ───────────────────────────────────── */
.feed-period-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
}

.feed-period-tab {
  padding: 4px 10px; border-radius: 50px;
  font-size: .74rem; font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text-muted); background: var(--surface);
  text-decoration: none; transition: all .2s;
  white-space: nowrap;
}
.feed-period-tab:hover { border-color: var(--primary); color: var(--primary); }
.feed-period-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

@media (max-width: 600px) {
  .feed-filter-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .feed-period-tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; padding-bottom: 2px; }
  .feed-period-tabs::-webkit-scrollbar { display: none; }
}

/* ── Feed controls ───────────────────────────────────────── */
.feed-type-tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.feed-type-tab {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 16px; border-radius: 50px;
  font-size: .82rem; font-weight: 700;
  border: 1.5px solid var(--border);
  color: var(--text-muted); background: var(--surface);
  text-decoration: none; transition: all .2s; white-space: nowrap;
}
.feed-type-tab:hover { border-color: var(--primary); color: var(--primary); }
.feed-type-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.feed-controls-row {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-bottom: 14px;
}
.feed-controls-row .feed-sort-tabs { flex: 1; min-width: 0; }

.feed-period-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.feed-period-tab {
  padding: 5px 10px; border-radius: 50px;
  font-size: .74rem; font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text-muted); background: var(--surface);
  text-decoration: none; transition: all .2s; white-space: nowrap;
}
.feed-period-tab:hover  { border-color: var(--primary); color: var(--primary); }
.feed-period-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

@media (max-width: 600px) {
  .feed-controls-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .feed-period-tabs  { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .feed-period-tabs::-webkit-scrollbar { display: none; }
  .feed-type-tabs    { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .feed-type-tabs::-webkit-scrollbar { display: none; }
}
