/* ============================================================
   আপনজন v4.0 — WhatsApp-স্টাইল চ্যাট CSS (css/chat.css)
   ============================================================ */

.wa-screen {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 204px);
  min-height: 440px;
  margin: 0;
  border-radius: 14px;
  overflow: hidden;
  background: var(--card, #fff);
  box-shadow: 0 2px 14px rgba(0, 0, 0, .10);
}

/* ---------- হেডার ---------- */
.wa-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .8rem;
  background: #075E54;
  color: #fff;
  flex-shrink: 0;
}
.wa-havatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #128C7E;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.wa-hinfo { flex: 1; min-width: 0; line-height: 1.15; }
.wa-hinfo b { display: block; font-size: .98rem; }
.wa-hinfo small { color: rgba(255,255,255,.82); font-size: .72rem; }
.wa-hbtn {
  background: none; border: 0; color: #fff;
  font-size: 1.05rem; cursor: pointer; padding: .3rem .35rem;
  border-radius: 50%;
}
.wa-hbtn:active { background: rgba(255,255,255,.15); }

/* ---------- সার্চ ---------- */
.wa-search {
  display: none;
  padding: .4rem .6rem;
  background: #128C7E;
  flex-shrink: 0;
}
.wa-search.open { display: block; }
.wa-search input {
  width: 100%;
  border: 0; border-radius: 18px;
  padding: .42rem .9rem;
  font-size: .85rem;
  background: rgba(255,255,255,.92);
}

/* ---------- মেসেজ বডি ---------- */
.wa-body {
  flex: 1;
  overflow-y: auto;
  padding: .8rem .7rem .4rem;
  background-color: #EFE7DB;
  background-image:
    radial-gradient(rgba(11, 93, 75, .05) 1px, transparent 1.6px),
    radial-gradient(rgba(212, 162, 76, .05) 1px, transparent 1.6px);
  background-size: 26px 26px, 34px 34px;
  background-position: 0 0, 13px 13px;
}
.wa-daypill {
  align-self: center;
  margin: .5rem auto .7rem;
  width: fit-content;
  background: rgba(255, 255, 255, .92);
  color: #5B6B66;
  font-size: .68rem;
  padding: .18rem .7rem;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.wa-empty {
  margin: 2.2rem auto;
  width: fit-content;
  max-width: 80%;
  text-align: center;
  background: rgba(255,255,255,.9);
  padding: .8rem 1.2rem;
  border-radius: 14px;
  color: #5B6B66;
  font-size: .85rem;
  line-height: 1.5;
}
.wa-empty span { font-size: 1.6rem; display: block; margin-bottom: .3rem; }

/* ---------- বাবল ---------- */
.wa-row { display: flex; margin-bottom: .34rem; align-items: flex-end; gap: .3rem; }
.wa-row.me { justify-content: flex-end; }
.wa-row.them { justify-content: flex-start; }

.wa-av {
  width: 26px; height: 26px;
  border-radius: 50%;
  color: #fff; font-size: .72rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
img.wa-av { object-fit: cover; }

.wa-bubble {
  position: relative;
  max-width: 78%;
  padding: .38rem .55rem .3rem;
  border-radius: 10px;
  font-size: .87rem;
  line-height: 1.35;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0,0,0,.13);
}
.wa-row.them .wa-bubble { background: #FFFFFF; border-top-left-radius: 2px; }
.wa-row.me .wa-bubble { background: #D9FDD3; border-top-right-radius: 2px; }
.wa-row.them .wa-bubble::before {
  content: '';
  position: absolute;
  left: -7px; top: 0;
  border: 7px solid transparent;
  border-right-color: #FFFFFF;
  border-left: 0; border-top: 0;
}
.wa-row.me .wa-bubble::after {
  content: '';
  position: absolute;
  right: -7px; top: 0;
  border: 7px solid transparent;
  border-left-color: #D9FDD3;
  border-right: 0; border-top: 0;
}

.wa-msgtxt { margin-top: .05rem; }

/* প্রেরকের নাম (গ্রুপ চ্যাট) */
.wa-sender { font-size: .72rem; font-weight: 700; margin-bottom: .08rem; }
[data-theme="dark"] .wa-sender { filter: brightness(1.6); }

/* রিপ্লাই কোট */
.wa-quote {
  border-left: 3px solid #06CF9C;
  background: rgba(0,0,0,.05);
  border-radius: 6px;
  padding: .22rem .45rem;
  margin: .05rem 0 .3rem;
  font-size: .74rem;
  color: #444;
}
.wa-row.me .wa-quote { border-left-color: #D4A24C; background: rgba(0,0,0,.055); }
.wa-quote b { color: #06A08A; font-size: .72rem; }
.wa-row.me .wa-quote b { color: #9A7420; }
.wa-quote .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }

/* ছবি */
.wa-msgimg {
  display: block;
  max-width: 220px;
  max-height: 220px;
  width: 100%;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: .15rem;
}
.wa-imgview img { max-width: 100%; max-height: 62dvh; border-radius: 10px; display: block; margin: 0 auto; }

/* ভয়েস */
.wa-voice { display: flex; align-items: center; gap: .45rem; min-width: 190px; padding: .1rem 0; }
.wa-play {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 0;
  background: #128C7E;
  color: #fff;
  font-size: .8rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.wa-bars { display: flex; align-items: center; gap: 2px; flex: 1; height: 26px; overflow: hidden; }
.wa-bars span {
  width: 3px;
  border-radius: 2px;
  background: #9DB8B2;
  display: inline-block;
}
.wa-dur { font-size: .68rem; color: #6B7B76; flex-shrink: 0; }

/* মেটা + টিক */
.wa-meta {
  display: inline-block;
  float: right;
  margin: .25rem 0 0 .5rem;
  font-size: .62rem;
  color: rgba(0,0,0,.45);
  transform: translateY(3px);
}
.wa-ticks { color: #53BDEB; font-size: .62rem; letter-spacing: -2px; }

/* বাবল অ্যাকশন */
.wa-acts { position: absolute; top: -12px; right: 6px; display: flex; gap: 2px; }
.wa-act {
  background: var(--card, #fff);
  border: 1px solid var(--line, #ddd);
  border-radius: 50%;
  width: 24px; height: 24px;
  font-size: .68rem;
  cursor: pointer;
  color: #54655F;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.wa-act:active { transform: scale(.92); }

/* টাইপিং ডট */
.wa-typing { padding: .5rem .8rem; }
.wa-typing span {
  width: 7px; height: 7px;
  background: #9DB8B2;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
  animation: waBlink 1.2s infinite;
}
.wa-typing span:nth-child(2) { animation-delay: .2s; }
.wa-typing span:nth-child(3) { animation-delay: .4s; margin-right: 0; }
@keyframes waBlink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---------- রিপ্লাই / রেকর্ডিং বার ---------- */
.wa-replybar, .wa-recbar {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .7rem;
  background: #F0F2F5;
  border-top: 1px solid #DADDE0;
  flex-shrink: 0;
}
.wa-replybar { background: #E8F3E8; }
.wa-replyinner { flex: 1; min-width: 0; font-size: .74rem; color: #3B4A45; line-height: 1.25; }
.wa-replyinner b { color: #128C7E; }
.wa-recdot {
  width: 11px; height: 11px;
  background: #E53935;
  border-radius: 50%;
  animation: waPulse 1s infinite;
  flex-shrink: 0;
}
@keyframes waPulse { 50% { opacity: .25; } }

/* ---------- কুইক চিপ ---------- */
.wa-chips {
  display: flex;
  gap: .4rem;
  overflow-x: auto;
  padding: .4rem .6rem;
  background: #F5F1E8;
  flex-shrink: 0;
  scrollbar-width: none;
}
.wa-chips::-webkit-scrollbar { display: none; }

/* ---------- কম্পোজার ---------- */
.wa-composer {
  display: flex;
  align-items: flex-end;
  gap: .35rem;
  padding: .4rem .5rem;
  background: #F0F2F5;
  position: relative;
  flex-shrink: 0;
}
.wa-composer input[type="text"] {
  flex: 1;
  border: 0;
  border-radius: 20px;
  padding: .5rem .95rem;
  font-size: .9rem;
  background: #fff;
  min-width: 0;
}
.wa-cbtn {
  background: none; border: 0;
  font-size: 1.25rem;
  cursor: pointer;
  padding: .25rem;
  border-radius: 50%;
  flex-shrink: 0;
  line-height: 1;
}
.wa-cbtn:active { background: rgba(0,0,0,.08); }
.wa-send {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 0;
  background: #075E54;
  color: #fff;
  font-size: 1.15rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.wa-send.rec { background: #E53935; animation: waPulse 1s infinite; }

/* ইমোজি প্যানেল */
.wa-emoji {
  position: absolute;
  bottom: calc(100% + 4px);
  left: .5rem; right: .5rem;
  max-height: 180px;
  overflow-y: auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(0,0,0,.22);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  padding: .5rem;
  gap: .15rem;
  z-index: 30;
}
.wa-emoji button { background: none; border: 0; font-size: 1.3rem; cursor: pointer; padding: .22rem; border-radius: 8px; }
.wa-emoji button:active { background: #ECE5DD; }

/* অ্যাটাচ মেনু */
.wa-attach {
  position: absolute;
  bottom: calc(100% + 4px);
  right: .5rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(0,0,0,.22);
  overflow: hidden;
  z-index: 30;
}
.wa-attach button {
  display: block;
  width: 100%;
  text-align: left;
  background: none; border: 0;
  padding: .6rem 1.1rem;
  font-size: .85rem;
  cursor: pointer;
  white-space: nowrap;
}
.wa-attach button:active { background: #ECE5DD; }

/* প্রাইভেসি নোট */
.wa-privacy {
  text-align: center;
  font-size: .62rem;
  color: #7A8B85;
  padding: .25rem 0 .4rem;
  background: #F0F2F5;
  flex-shrink: 0;
}

/* ---------- ডার্ক থিম ---------- */
[data-theme="dark"] .wa-body { background-color: #0B141A; background-image: radial-gradient(rgba(255,255,255,.04) 1px, transparent 1.6px); }
[data-theme="dark"] .wa-header { background: #1F2C34; }
[data-theme="dark"] .wa-search { background: #202C33; }
[data-theme="dark"] .wa-row.them .wa-bubble { background: #202C33; color: #E9EDEF; }
[data-theme="dark"] .wa-row.them .wa-bubble::before { border-right-color: #202C33; }
[data-theme="dark"] .wa-row.me .wa-bubble { background: #005C4B; color: #E9EDEF; }
[data-theme="dark"] .wa-row.me .wa-bubble::after { border-left-color: #005C4B; }
[data-theme="dark"] .wa-meta { color: rgba(255,255,255,.5); }
[data-theme="dark"] .wa-daypill { background: #182229; color: #8696A0; box-shadow: none; }
[data-theme="dark"] .wa-empty { background: #182229; color: #8696A0; }
[data-theme="dark"] .wa-quote { background: rgba(255,255,255,.06); color: #D1D7DB; }
[data-theme="dark"] .wa-composer, [data-theme="dark"] .wa-recbar, [data-theme="dark"] .wa-privacy { background: #111B21; }
[data-theme="dark"] .wa-replybar { background: #111B21; }
[data-theme="dark"] .wa-composer input[type="text"] { background: #2A3942; color: #E9EDEF; }
[data-theme="dark"] .wa-chips { background: #111B21; }
[data-theme="dark"] .wa-send { background: #00A884; }
[data-theme="dark"] .wa-emoji, [data-theme="dark"] .wa-attach { background: #233138; }
[data-theme="dark"] .wa-act { background: #233138; border-color: #374850; color: #AEBAC1; }
[data-theme="dark"] .wa-bars span { background: #8696A0; }
[data-theme="dark"] .wa-dur, [data-theme="dark"] .wa-privacy { color: #8696A0; }

/* ---------- অ্যাপ হেডার রেসপনসিভ ফিক্স (v4.0) — ছোট ফোনে ওভারফ্লো বন্ধ ---------- */
@media (max-width: 430px) {
  header { padding-left: .55rem; padding-right: .55rem; }
  .hsub { display: none; }
  .hright { gap: .3rem; }
  .hbtn { padding: .3rem .42rem; }
  #uname { max-width: 92px; font-size: .7rem; padding: .2rem .5rem; }
}

/* ---------- ছোট স্ক্রিন ---------- */
@media (max-width: 640px) {
  .wa-screen { height: calc(100dvh - 204px); border-radius: 0; }
  .wa-bubble { max-width: 84%; }
  .wa-msgimg { max-width: 190px; max-height: 190px; }
  .wa-voice { min-width: 160px; }
}
