.cp-chat-tool,
.cs-chat-tool {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #833ab4 0%, #c13584 45%, #e1306c 100%);
  color: #fff;
  flex-shrink: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(193, 53, 132, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.cp-chat-tool:hover,
.cs-chat-tool:hover {
  transform: scale(1.05);
  box-shadow: 0 3px 12px rgba(193, 53, 132, 0.45);
}
.cp-chat-footer .cp-chat-tool {
  background: linear-gradient(135deg, #833ab4 0%, #c13584 45%, #e1306c 100%);
  color: #fff;
}
.cp-chat-tool.is-recording,
.cs-chat-tool.is-recording {
  background: #e74c3c;
  color: #fff;
  animation: chat-pulse 1s infinite;
}
@keyframes chat-pulse {
  50% { opacity: 0.65; }
}
.cp-chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.cp-chat-text { margin: 0; white-space: pre-wrap; word-break: break-word; }
.cp-chat-voice,
.ig-voice {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  max-width: min(100%, 260px);
  padding: 10px 12px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255, 67, 164, 0.14), rgba(131, 58, 180, 0.1));
  border: 1px solid rgba(255, 67, 164, 0.22);
  box-shadow: 0 4px 14px rgba(255, 67, 164, 0.08);
}

.ig-voice-play {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #ff43a4, #833ab4);
  box-shadow: 0 4px 12px rgba(255, 67, 164, 0.35);
}

.ig-voice-wave {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 48px;
  height: 22px;
}

.ig-voice-wave span {
  display: block;
  width: 3px;
  height: 8px;
  border-radius: 2px;
  background: rgba(255, 67, 164, 0.45);
  transition: height 0.15s ease;
}

.ig-voice.is-playing .ig-voice-wave span {
  animation: ig-voice-bar 0.55s ease-in-out infinite alternate;
}

.ig-voice.is-playing .ig-voice-wave span:nth-child(2) { animation-delay: 0.08s; }
.ig-voice.is-playing .ig-voice-wave span:nth-child(3) { animation-delay: 0.16s; }
.ig-voice.is-playing .ig-voice-wave span:nth-child(4) { animation-delay: 0.1s; }
.ig-voice.is-playing .ig-voice-wave span:nth-child(5) { animation-delay: 0.2s; }

@keyframes ig-voice-bar {
  from { height: 6px; }
  to { height: 18px; }
}

.ig-voice-audio {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.ig-voice--error .ig-voice-play {
  opacity: 0.45;
  cursor: not-allowed;
}

.cp-chat-voice audio:not(.ig-voice-audio) {
  width: 100%;
  min-height: 36px;
  border-radius: 12px;
  accent-color: #ff43a4;
}

.ig-voice-dur,
.cp-chat-voice .ig-voice-dur {
  font-size: 0.75rem;
  font-weight: 700;
  color: #ff43a4;
  align-self: flex-end;
}
.cp-chat-img,
.cp-chat-video {
  max-width: min(100%, 320px);
  border-radius: 12px;
  display: block;
}
.cp-chat-media-locked {
  position: relative;
  max-width: 280px;
  border-radius: 12px;
  overflow: hidden;
}
.cp-chat-media-placeholder {
  width: 100%;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #831843 0%, #4c1d95 48%, #1e1b4b 100%);
  color: #fce7f3;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  padding: 24px 16px;
}
.cp-chat-media-placeholder span {
  opacity: 0.95;
}
.cp-chat-media-placeholder i {
  font-size: 2rem;
  margin-bottom: 8px;
  opacity: 0.9;
}
.cp-chat-media-placeholder--video {
  min-height: 220px;
}
.ig-media--video {
  width: 100%;
  max-width: min(100%, 280px);
  min-height: 160px;
  max-height: 420px;
  background: #0f0f14;
  object-fit: contain;
}
.cp-chat-media-blur {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: blur(18px);
  transform: scale(1.08);
}
.cp-chat-unlock-btn {
  position: absolute;
  inset: 0;
  margin: auto;
  height: fit-content;
  width: fit-content;
  padding: 10px 16px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #a855f7, #ec4899);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.cs-chat-layout {
  display: grid;
  grid-template-columns: minmax(200px, 280px) 1fr;
  gap: 12px;
  min-height: 65vh;
}
@media (max-width: 768px) {
  .cs-chat-layout { grid-template-columns: 1fr; }
  .cs-chat-inbox { max-height: 180px; overflow: auto; }
}
.cs-chat-inbox {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 14px;
  padding: 10px;
}
.cs-chat-inbox-title { font-size: 0.95rem; margin: 0 0 10px; }
.cs-chat-inbox-list { display: flex; flex-direction: column; gap: 6px; }
.cs-chat-inbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: right;
  padding: 10px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.cs-chat-inbox-item.active { background: rgba(168, 85, 247, 0.25); }
.cs-chat-inbox-item.unread { border: 1px solid rgba(236, 72, 153, 0.45); }
.cs-chat-inbox-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #7c3aed;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.cs-chat-inbox-meta { flex: 1; min-width: 0; text-align: right; }
.cs-chat-inbox-meta small { display: block; opacity: 0.7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-chat-badge {
  background: #ec4899;
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
}
.cs-chat-pane {
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 14px;
  overflow: hidden;
}
.cs-chat-pane-head {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.cs-chat-thread {
  flex: 1;
  overflow: auto;
  padding: 12px;
  min-height: 280px;
}
.cs-chat-composer-bar {
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.cs-chat-paid-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.cs-chat-composer-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}
.cs-chat-composer-tools textarea {
  flex: 1 1 120px;
  min-width: 0;
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: #f1f5f9;
  padding: 10px 12px;
  font-family: inherit;
  box-sizing: border-box;
}
.cs-chat-composer-tools .cs-btn-primary,
.cs-chat-composer-tools .cs-chat-send-btn {
  width: auto;
  flex: 0 0 auto;
  margin-top: 0;
  padding: 10px 16px;
  white-space: nowrap;
}
.cs-chat-media-pending {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(236, 72, 153, 0.35);
  font-size: 0.85rem;
}
.cs-chat-media-pending.hidden {
  display: none !important;
}
.cs-chat-media-pending-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cs-chat-media-cancel {
  border: none;
  background: transparent;
  color: #fca5a5;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
}
.cs-chat-empty { text-align: center; opacity: 0.75; padding: 24px; }

.cp-chat-locked-hint {
  display: block;
  text-align: center;
  padding: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

/* ——— Instagram-style messages ——— */
.cp-chat-body,
.cs-chat-thread {
  background: #fafafa;
  background-image: radial-gradient(circle at 20% 20%, rgba(168, 85, 247, 0.04), transparent 40%),
    radial-gradient(circle at 80% 0%, rgba(236, 72, 153, 0.05), transparent 35%);
}

.ig-day {
  text-align: center;
  margin: 16px 0 10px;
}
.ig-day span {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  color: #65676b;
  font-size: 0.72rem;
  font-weight: 600;
}

.ig-msg {
  display: flex;
  flex-direction: column;
  margin-bottom: 4px;
  max-width: 82%;
  animation: ig-msg-in 0.22s ease;
}
@keyframes ig-msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
/* عمود الرسائل LTR: أنا يمين، الطرف الآخر يسار (مثل إنستغرام) */
.cp-chat-thread,
.cs-chat-thread {
  direction: ltr;
}

.ig-msg--out {
  align-self: flex-end;
  align-items: flex-end;
}
.ig-msg--in {
  align-self: flex-start;
  align-items: flex-start;
}
.ig-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 4px;
}
/* يمين: الفقاعة على الحافة، زر الخيارات باتجاه الوسط */
.ig-msg--out .ig-msg-row {
  flex-direction: row;
}
/* يسار: الفقاعة على الحافة، زر الخيارات باتجاه الوسط */
.ig-msg--in .ig-msg-row {
  flex-direction: row-reverse;
}
.ig-msg-menu {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #8e8e8e;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  flex-shrink: 0;
}
.ig-msg:hover .ig-msg-menu,
.ig-msg-menu:focus {
  opacity: 1;
}
.ig-msg-menu:hover {
  background: rgba(0, 0, 0, 0.06);
}
.ig-bubble {
  padding: 10px 14px;
  border-radius: 22px;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
  direction: rtl;
  text-align: right;
}
.ig-msg--out .ig-bubble {
  background: linear-gradient(135deg, #833ab4 0%, #c13584 45%, #e1306c 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ig-msg--in .ig-bubble {
  background: #efefef;
  color: #262626;
  border-bottom-left-radius: 4px;
}
.ig-text {
  margin: 0;
  white-space: pre-wrap;
}
.ig-msg-time {
  font-size: 0.68rem;
  color: #8e8e8e;
  margin-top: 2px;
  padding: 0 4px;
}
.ig-msg--deleted .ig-bubble--deleted {
  background: #efefef !important;
  color: #8e8e8e !important;
  font-size: 0.85rem;
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: none;
}
.ig-media {
  display: block;
  max-width: min(100%, 280px);
  border-radius: 16px;
  margin-bottom: 4px;
}
.ig-media--img {
  width: 100%;
  height: auto;
}
.ig-voice-dur {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.9;
  margin: 0;
}

.cp-chat-thread,
.cs-chat-thread {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px 20px;
}

.ig-day {
  direction: rtl;
}

/* Delete sheet */
.ig-delete-sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.ig-delete-sheet.hidden {
  display: none !important;
}
.ig-delete-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.ig-delete-panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 12px 16px 24px;
  text-align: center;
  animation: ig-sheet-up 0.28s ease;
}
@keyframes ig-sheet-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}
.ig-delete-handle {
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: #dbdbdb;
  margin: 0 auto 12px;
}
.ig-delete-panel h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  color: #262626;
}
.ig-delete-opt {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: #fafafa;
  color: #262626;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 8px;
}
.ig-delete-opt--danger {
  color: #ed4956;
  background: #fff5f5;
}
.ig-delete-cancel {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  background: transparent;
  color: #8e8e8e;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* Composer — pill style */
.cp-chat-footer .cp-chat-composer {
  background: #fff;
  border: 1px solid #dbdbdb;
  border-radius: 24px;
  padding: 6px 8px 6px 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.cp-chat-footer .cp-chat-composer textarea {
  border: none;
  background: transparent;
  resize: none;
  min-height: 24px;
  max-height: 100px;
  padding: 8px 4px;
  font-size: 0.95rem;
}
.cp-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #833ab4, #e1306c);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}
.cp-chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
