/* ========================================
   CHAT BUBBLES - Updated with Apple Emoji Support
   ======================================== */

/* ========================================
     CHAT BUBBLES
     ======================================== */
.bubbleLeft,
.bubbleLeftEx {
  position: relative;
  clear: right;
  max-width: min(70vw, 450px);
  min-height: 24px;
  min-width: 90px;
  margin-right: auto;
  margin-bottom: 5px;
  height: auto;
  padding: 4px 10px;
  left: 45px;
  margin-left: -25px;
  border: var(--bubble-left-bg) solid 0px;
  color: black;
  background: var(--bubble-left-bg);
  user-select: text;
  -moz-user-select: text;
  -webkit-user-select: text;
  -ms-user-select: text;
  z-index: 2;
  word-wrap: break-word;
  border-bottom: 2px solid var(--shadow-medium);
  overflow: hidden;
  font-family: "Vazirmatn", 'Apple Color Emoji', 'Noto Color Emoji', 'Segoe UI Emoji', sans-serif !important;
  font-variant-numeric: normal !important;
  text-rendering: optimizeLegibility;
}

.bubbleRight,
.bubbleRightEx {
  position: relative;
  clear: left;
  min-width: 90px;
  max-width: min(70vw, 450px);
  min-height: 24px;
  margin-left: auto;
  margin-bottom: 5px;
  height: auto;
  padding: 4px 10px;
  right: 45px;
  margin-right: -25px;
  border: var(--bubble-right-bg) solid 0px;
  color: #1c0000;
  background: var(--bubble-right-bg);
  z-index: 2;
  word-wrap: break-word;
  border-bottom: 2px solid var(--shadow-medium);
  overflow: hidden;
  font-family: "Vazirmatn", 'Apple Color Emoji', 'Noto Color Emoji', 'Segoe UI Emoji', sans-serif !important;
  font-variant-numeric: normal !important;
  text-rendering: optimizeLegibility;
}

/* Bubble corners and arrows */
.bubbleLeft {
  border-radius: 0px 10px 10px 10px;
}

.bubbleLeft:after {
  border-width: 0px 10px 10px 0;
  border-color: transparent var(--bubble-left-bg) transparent transparent;
  top: 0;
  left: -10px;
  position: absolute;
  content: "";
  width: 0;
  height: 0;
  border-style: solid;
  box-sizing: inherit;
}

.bubbleRight {
  border-radius: 10px 0px 10px 10px;
}

.bubbleRight:after {
  border-width: 0px 0 10px 10px;
  border-color: transparent transparent transparent #dff2fd;
  top: 0;
  right: -9px;
  position: absolute;
  content: "";
  width: 0;
  height: 0;
  border-style: solid;
}

/* Extended bubbles (no arrows) */
.bubbleLeftEx,
.bubbleRightEx {
  border-radius: 10px;
  margin-top: -10px;
}

.bubbleLeftEx:after,
.bubbleRightEx:after {
  display: none;
}

/* ========================================
          BUBBLE CONTENT
          ======================================== */
.bubbleText {
  margin-top: -5px;
  font-size: 11px;
  margin-bottom: -2px;
  direction: ltr;
  text-align: right;
  color: var(--text-gray);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 21px;
  gap: 5px;
  margin-right: -5px;
  padding-right: 5px;
  font-family: "Vazirmatn", sans-serif !important;
}

/* Bubble footer elements order */
.bubbleText .deliveryImage {
  margin: 0;
  width: 16px;
  height: 16px;
  order: 4;
  margin-left: 3px;
}

.bubbleText .timeSpan {
  vertical-align: middle;
  min-height: 21px;
  order: 3;
  transform: translateY(2px);
}

.bubbleText .edited {
  padding-left: 2px;
  order: 2;
}

.bubbleText .favIcon {
  margin-right: 5px;
  position: relative;
  top: 2px;
  display: none;
  order: 1;
}

/* Titles */
.titleLeft {
  font-weight: bold;
  font-size: 12px;
  color: #2b579a;
  line-height: 80%;
  margin-top: 0px;
  padding-bottom: -5px;
  margin-bottom: -1px;
  /* direction: ltr; */
  text-align: right;
  z-index: 2;
  padding-top: 7px;
  font-family: "Vazirmatn", sans-serif !important;
}

.titleRight {
  font-weight: bold;
  font-size: 12px;
  color: white;
  line-height: 80%;
  margin-top: 0px;
  padding-bottom: -5px;
  margin-bottom: -1px;
  padding-top: 7px;
  direction: ltr;
  z-index: 2;
  font-family: "Vazirmatn", sans-serif !important;
}

/* ========================================
          REPLY & SUBJECT STYLES
          ======================================== */
.replyRight,
.replyLeft {
  margin: 3px auto 2px auto;
  border-right-width: 2px;
  border-right-style: double;
  padding: 0px 2px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right-color: #37a4de;
  padding-right: 5px;
  font-family: "Vazirmatn", 'Apple Color Emoji Local', 'Apple Color Emoji', 'Noto Color Emoji', 'Segoe UI Emoji', sans-serif !important;
}

.subjectRight,
.subjectLeft {
  margin: 3px auto 2px auto;
  border-width: 1px;
  border-style: solid;
  padding: 0px 2px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-color: darkorange;
  padding-right: 5px;
  background: rgba(255, 140, 0, 0.3);
  font-family: "Vazirmatn", 'Apple Color Emoji Local', 'Apple Color Emoji', 'Noto Color Emoji', 'Segoe UI Emoji', sans-serif !important;
}

.reply-close-button {
  position: absolute;
  right: 5px;
  color: gray;
}

.reply-content {
  margin-right: 20px;
}

.replyLeft {
  /* direction: rtl; */
  border-style: none;
  /* color: black; */
  cursor: auto;
}

/* ========================================
          TYPING INDICATOR
          ======================================== */
.typing-dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 5px;
}

.dot {
  width: 6px;
  height: 6px;
  background-color: var(--typing-blue);
  border-radius: 50%;
  display: inline-block;
  animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
  animation-delay: -0.32s;
}

.dot:nth-child(2) {
  animation-delay: -0.16s;
}

.dot:nth-child(3) {
  animation-delay: 0s;
}

@keyframes bounce {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1);
  }
}

#typingText,
#typingDots {
  display: none;
}

/* ========================================
          UNREAD INDICATOR
          ======================================== */
.unread-indicator {
  position: absolute;
  bottom: 80px;
  right: 15px;
  background: #0088cc;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 999;
  transform: translateY(60px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light mode (default) */
.unread-indicator.light-mode {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(79, 172, 254, 0.4);
}

.unread-indicator.light-mode:hover {
  background: linear-gradient(135deg, #40a7e3 0%, #00d8e8 100%);
  box-shadow: 0 6px 16px rgba(79, 172, 254, 0.5);
  transform: translateY(0) scale(1.05);
}

.unread-indicator.light-mode .unread-arrow {
  border-color: white;
}

/* Dark mode */
.unread-indicator.dark-mode {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.unread-indicator.dark-mode:hover {
  background: linear-gradient(135deg, #5568d3 0%, #6a4190 100%);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
  transform: translateY(0) scale(1.05);
}

.unread-indicator.dark-mode .unread-arrow {
  border-color: #e0e0e0;
}

/* General hover state */
.unread-indicator:hover {
  transform: translateY(0) scale(1.05);
}

.unread-indicator.show {
  transform: translateY(0);
  opacity: 1;
}

.unread-indicator.hide {
  transform: translateY(60px);
  opacity: 0;
}

.unread-indicator .unread-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  height: 22px;
  width: 22px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 11px;
  font-weight: bold;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.unread-arrow {
  width: 10px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ========================================
          EMOJI STYLES
          ======================================== */
.emojiInBubble {
  width: 20px;
  height: 20px;
  vertical-align: middle;
  margin: -3px 0 0 0;
}

.inline-emoji {
  height: 24px;
  top: 5px;
  position: relative;
}

.only-emojis img.emojione {
  height: 32px;
  vertical-align: middle;
}

/* Updated emoji styles for local Apple font */
.emoji-in-message {
  font-family: 'Apple Color Emoji Local', 'Apple Color Emoji', 'Noto Color Emoji', 'Segoe UI Emoji', sans-serif !important;
  font-size: 1.2em;
  vertical-align: middle;
  font-variant-emoji: emoji;
  text-rendering: optimizeLegibility;
}

.only-emojis .emoji-in-message,
.emoji-only-message .emoji-in-message {
  font-size: 2.5em;
  line-height: 1;
}

.lottie-container {
  max-height: 128px;
}

.chat-image {
  max-width: 100%;
  margin: 5px 0px;
  border-radius: 3px;
  cursor: pointer;
  transition: opacity 0.3s;
}

/* Placeholder state while decrypting */
.chat-image.encrypted-image {
  width: 200px;
  height: 150px;
  object-fit: contain;
  background: #f0f0f0;
}

/* Reset size after image is loaded to use natural dimensions */
.chat-image.loaded {
  opacity: 1;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 400px;
  object-fit: contain;
}

.bubble-image {
  margin-bottom: -25px;
}

.bubble-text {
  margin: 3px auto 2px;
  margin-left: 70px;
  font-family: "Vazirmatn", 'Apple Color Emoji', 'Noto Color Emoji', 'Segoe UI Emoji', sans-serif !important;
  font-variant-numeric: normal !important;
  text-rendering: optimizeLegibility;
}

.bubble-text-emoji {
  margin: 3px auto 2px;
  margin-left: 70px;
  font-size: 1.2em;
  font-family: "Vazirmatn", 'Apple Color Emoji', 'Noto Color Emoji', 'Segoe UI Emoji', sans-serif !important;
  font-variant-numeric: normal !important;
  text-rendering: optimizeLegibility;
}

.emoji-only-bubble {
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-bottom: 0px !important;
  padding: 25px !important;
}

.lottie-margin-right {
  margin-right: -50px;
}

.lottie-margin-left {
  margin-left: -40px;
}

.lottie-fixed-size {
  width: 128px !important;
  height: 128px !important;
}

.hidden-audio {
  display: none;
}

.fav-icon-img {
  height: 12px;
  width: 12px;
}

/* ========================================
          DATE SEPARATOR
          ======================================== */
.date-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px 0;
  clear: both;
  position: relative;
}

.date-separator::before,
.date-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
}

.date-separator-text {
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  font-family: "Vazirmatn", sans-serif;
  margin: 0 10px;
  font-weight: 500;
  white-space: nowrap;
}

/* Light mode (for chat.html if needed) */
.chatHTML:not(.dark-mode) .date-separator::before,
.chatHTML:not(.dark-mode) .date-separator::after {
  background: rgba(0, 0, 0, 0.1);
}

.chatHTML:not(.dark-mode) .date-separator-text {
  background: rgba(0, 0, 0, 0.05);
  /* color: rgba(0, 0, 0, 0.5); */
}