/*
==========================================================
  FRIENDS.HTML — INSTAGRAM-LIKE ADDITIONS
  Yeh CSS aur JS friends.html mein add karo
  <link rel="stylesheet" href="css/friends-ig.css">
  ya seedha friends.html ki <style> tag mein paste karo
==========================================================
*/

/* ─── ONLINE STATUS STORIES (Instagram-like top bar) ─── */
.story-bar {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  scrollbar-width: none;
}
.story-bar::-webkit-scrollbar { display: none; }
.story-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  cursor: pointer;
}
.story-ring {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  padding: 2.5px;
  background: var(--grad-magic);
  position: relative;
  transition: transform 0.2s;
}
.story-ring:hover { transform: scale(1.06); }
.story-ring.seen { background: var(--border2); }
.story-ring-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2.5px solid var(--void);
  overflow: hidden;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
}
.story-ring-inner img { width: 100%; height: 100%; object-fit: cover; }
.story-name {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--t3);
  max-width: 52px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}
.story-online-dot {
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--void);
  box-shadow: 0 0 6px var(--green);
}

/* ─── MESSAGE REACTIONS ─── */
.msg-reactions {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: 3px;
}
.msg-react-chip {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 2px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--t2);
}
.msg-react-chip:hover, .msg-react-chip.mine {
  background: rgba(168,85,247,0.15);
  border-color: rgba(168,85,247,0.3);
  color: var(--violet);
}
.msg-react-count { font-size: 0.65rem; }

/* React menu (appears on hover) */
.msg-react-menu {
  position: absolute;
  bottom: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 50px;
  padding: 5px 8px;
  display: none;
  gap: 3px;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  white-space: nowrap;
}
.msg-react-menu.open { display: flex; }
.msg-own { right: 0; }
.msg-other { left: 0; }
.mrm-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: 50%;
  transition: transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mrm-btn:hover { transform: scale(1.35); }

/* ─── MESSAGE HOVER ACTIONS ─── */
.msg {
  position: relative;
}
.msg-actions {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  gap: 4px;
}
.msg.own .msg-actions { right: calc(100% + 6px); }
.msg:not(.own) .msg-actions { left: calc(100% + 6px); }
.msg:hover .msg-actions { display: flex; }
.ma-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--t3);
  cursor: pointer;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.ma-btn:hover { background: rgba(255,255,255,0.12); color: var(--t1); }

/* ─── READ RECEIPTS ─── */
.m-time .read-tick {
  margin-left: 4px;
  font-size: 0.65rem;
}
.read-tick.sent { color: var(--t4); }
.read-tick.delivered { color: var(--t3); }
.read-tick.seen { color: var(--violet); }

/* ─── TYPING INDICATOR ─── */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.typing-dots {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px;
  padding: 8px 14px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--t4);
  animation: typeBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typeBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ─── MESSAGE REPLY ─── */
.reply-preview {
  background: rgba(168,85,247,0.08);
  border-left: 3px solid var(--violet);
  border-radius: 0 8px 8px 0;
  padding: 5px 10px;
  margin-bottom: 4px;
  font-size: 0.76rem;
  color: var(--t3);
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.reply-preview strong { color: var(--violet); }

/* ─── CHAT HEADER IMPROVEMENTS ─── */
.ch-user-status {
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ch-last-seen {
  font-size: 0.7rem;
  color: var(--t4);
}
/* Animated online pill */
@keyframes onlinePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0.4); }
  50% { box-shadow: 0 0 0 4px rgba(52,211,153,0); }
}
.ch-online { animation: onlinePulse 2.5s infinite; }

/* ─── MESSAGE SEARCH OVERLAY ─── */
.msg-search-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  z-index: 20;
  transform: translateY(-100%);
  transition: transform 0.25s;
}
.msg-search-bar.open { transform: translateY(0); }
.msg-search-bar input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  color: var(--t1);
  padding: 9px 14px;
  font-family: var(--font-b);
  font-size: 0.85rem;
  outline: none;
}
.msg-search-bar input:focus { border-color: var(--violet); }
.msg-search-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--t3);
  cursor: pointer;
  font-size: 0.9rem;
}

/* ─── IMPROVED CHAT BUBBLES ─── */
/* Grouped messages (same sender, consecutive) */
.msg.grouped-top .m-bubble {
  border-radius: 14px 14px 14px 4px !important;
}
.msg.grouped-mid .m-bubble {
  border-radius: 4px 14px 14px 4px !important;
}
.msg.grouped-bot .m-bubble {
  border-radius: 4px 14px 14px 14px !important;
}
.msg.own.grouped-top .m-bubble {
  border-radius: 14px 14px 4px 14px !important;
}
.msg.own.grouped-mid .m-bubble {
  border-radius: 14px 4px 4px 14px !important;
}
.msg.own.grouped-bot .m-bubble {
  border-radius: 14px 4px 14px 14px !important;
}

/* ─── VOICE NOTE PLAYER ─── */
.voice-msg {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(168,85,247,0.12);
  border: 1px solid rgba(168,85,247,0.2);
  border-radius: 12px;
  min-width: 180px;
}
.vm-play {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--grad-violet);
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vm-waves {
  flex: 1;
  height: 28px;
  background: rgba(168,85,247,0.1);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}
.vm-progress {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: rgba(168,85,247,0.3);
  transition: width 0.1s;
}
.vm-dur {
  font-size: 0.7rem;
  color: var(--t3);
  flex-shrink: 0;
}

/* ─── IMPROVED CONV LIST ─── */
.conv-item .conv-preview.unread {
  color: var(--t1);
  font-weight: 600;
}
.conv-item .unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--violet);
  flex-shrink: 0;
}

/* ─── VIDEO CALL — IMPROVED ─── */
.vcall-pip {
  position: absolute;
  bottom: 88px;
  right: 12px;
  width: 120px;
  height: 90px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.2);
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transition: transform 0.15s;
}
.vcall-pip:hover { transform: scale(1.03); }
.vcall-pip video { width: 100%; height: 100%; object-fit: cover; }

/* ─── FRIENDS SECTION — INSTAGRAM-LIKE GRID ─── */
.friends-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 16px;
}
.friend-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.friend-card:hover {
  border-color: rgba(168,85,247,0.3);
  background: rgba(255,255,255,0.06);
  transform: translateY(-2px);
}
.friend-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--grad-magic);
  opacity: 0;
  transition: opacity 0.2s;
}
.friend-card:hover::before { opacity: 1; }
.fc-av {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin: 0 auto 10px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
  color: #fff;
  overflow: visible;
}
.fc-av-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fc-av-inner img { width: 100%; height: 100%; object-fit: cover; }
.fc-online {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--card);
  box-shadow: 0 0 6px var(--green);
}
.fc-name {
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.fc-country {
  font-size: 0.68rem;
  color: var(--t3);
  margin-bottom: 10px;
}
.fc-msg-btn {
  width: 100%;
  padding: 7px;
  border-radius: 50px;
  border: 1px solid rgba(168,85,247,0.3);
  background: transparent;
  color: var(--violet);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-b);
  transition: all 0.15s;
}
.fc-msg-btn:hover {
  background: rgba(168,85,247,0.12);
}

/* ─── NOTIFICATION DOT ON CHAT HEADER ICON ─── */
.ch-action { position: relative; }
.ch-action .notif-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rose3);
  border: 2px solid var(--deep);
  display: none;
}
.ch-action .notif-dot.show { display: block; }

/* ─── BOTTOM SEND AREA — INSTAGRAM-LIKE ─── */
.chat-input-wrap .ia-btn.record {
  color: var(--rose);
  border-color: rgba(244,63,94,0.2);
}
.chat-input-wrap .ia-btn.record.recording {
  background: rgba(244,63,94,0.12);
  border-color: rgba(244,63,94,0.35);
  color: var(--rose);
  animation: recPulse 1.2s infinite;
}
@keyframes recPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ─── FORWARD MESSAGE MODAL ─── */
.forward-modal {
  position: fixed;
  inset: 0;
  background: rgba(6,0,14,0.85);
  backdrop-filter: blur(12px);
  z-index: 250;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.forward-modal.open { display: flex; }
.forward-box {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 18px;
  padding: 24px;
  width: 380px;
  max-width: 100%;
  max-height: 70vh;
  overflow-y: auto;
}
.forward-box h3 { font-size: 1rem; font-weight: 700; margin-bottom: 16px; }
.fw-friend {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.fw-friend:hover { background: var(--card2); }
.fw-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--border2);
  margin-left: auto;
  transition: all 0.15s;
}
.fw-friend.sel .fw-check {
  background: var(--grad-violet);
  border-color: transparent;
}
.fw-send {
  width: 100%;
  margin-top: 14px;
  padding: 11px;
  border-radius: 50px;
  border: none;
  background: var(--grad-violet);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-b);
  font-size: 0.88rem;
}
