/* ========================================
   CHAT BASE - Complete Final Version with Fixed Font Issues
   ======================================== */

/* Load Apple Color Emoji font with better unicode range */
/* @font-face {
  font-family: 'Apple Color Emoji Local';
  src: url('/assets/fonts/AppleColorEmoji.ttf') format('truetype');
  font-display: swap;
  unicode-range: U+1F000-1F02F, U+1F0A0-1F0FF, U+1F100-1F64F, U+1F680-1F6FF, U+1F700-1F77F, U+1F780-1F7FF, U+1F800-1F8FF, U+1F900-1F9FF, U+1FA00-1FA6F, U+1FA70-1FAFF, U+2600-26FF, U+2700-27BF;
} */

/* CSS Variables for consistency */
:root {
  --primary-blue: #0088cc;
  --light-blue: #40a7e3;
  --bubble-left-bg: #fdfdfd;
  --bubble-right-bg: #def1fd;
  --bubble-left-dark: #3f3f3f;
  --bubble-right-dark: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --text-gray: #7c7c7c;
  --border-gray: #e0e0e0;
  --background-gray: #dfe4e8;
  --background-dark: #0a0a0a;
  --typing-blue: #0088cc;
  --audio-blue: #0088cc;
  --audio-blue-hover: #2980b9;
  --shadow-light: rgba(0, 0, 0, 0.1);
  --shadow-medium: rgba(0, 0, 0, 0.2);
}

/* ========================================
     BASE STYLES
     ======================================== */
body {
  font-family: "Vazirmatn", sans-serif;
  background-color: var(--background-gray);
  margin: 0;
  font-variant-numeric: normal;
  font-feature-settings: normal;
}

/* ========================================
     SCROLLBAR STYLES
     ======================================== */
::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #888;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* ========================================
     CHAT CONTAINER
     ======================================== */
.chatHTML {
  font-family: "Vazirmatn", sans-serif;
  background-color: transparent;
  border: none;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  position: relative;
  flex: 1;
  width: 100%;
  font-size: smaller;
  font-variant-numeric: normal;
}

/* Removed old absolute positioning for audio and emoji picker - now using flexbox */

.backImage {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  opacity: 0.7;
  background-image: url(../../image/system/bg.png);
  background-repeat: repeat-x;
  background-position: 50% 0;
  background-size: auto;
  background-color: #764ba2;
}

/* ========================================
     NETWORK STATUS & LOADING INDICATORS
     ======================================== */
.network-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-family: "Vazirmatn", sans-serif;
  animation: slideDown 0.3s ease-out;
  z-index: 100;
}

.network-status-offline {
  background-color: #ff9800;
  color: white;
}

.network-status-online {
  background-color: #4caf50;
  color: white;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.loading-older-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  color: #666;
  font-size: 13px;
  font-family: "Vazirmatn", sans-serif;
}

.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #e0e0e0;
  border-top: 2px solid #0088cc;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* ========================================
     INTRO BOX & MESSAGE BOX
     ======================================== */
.introBox,
.messageBox {
  z-index: 1010;
  background: whitesmoke;
  padding: 7px;
  display: block;
  border-color: darkgray;
  border-style: solid;
  border-width: 0px;
  width: 100%;
  flex-shrink: 0;
}

.introBox {
  height: 40px;
  border-bottom-width: 1px;
  color: darkgray;
  direction: rtl;
}

.messageBox {
  display: flex !important;
  align-items: center !important;
  padding: 10px 12px !important;
  gap: 10px !important;
  min-height: 50px !important;
  background: whitesmoke !important;
  border-top: 1px solid darkgray !important;
  /* Remove any rounded corners or separate styling */
  border-radius: 0 !important;
  box-shadow: none !important;
  font-family: "Vazirmatn", sans-serif !important;
}

.introBoxTitle {
  margin-top: 3px;
  margin-left: 60px;
  text-align: right;
  color: black;
  font-family: "Vazirmatn", sans-serif !important;
  font-variant-numeric: normal !important;
}

.introBoxStatus {
  margin-top: -21px;
  color: gray;
  text-align: right;
  font-size: 12px;
  font-family: "Vazirmatn", sans-serif !important;
  font-variant-numeric: normal !important;
}

.introBoxIcons {
  position: absolute;
  top: 10px;
  left: 10px;
}

.introBoxIcons svg {
  height: 20px;
  width: 20px;
  fill: rgb(180, 180, 180);
  margin-right: 10px;
  cursor: pointer;
}

.introBoxIcons svg:hover {
  fill: darkgray;
}

/* ========================================
     CURRENT USER AVATAR
     ======================================== */
#currentUserAvatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  float: right;
  margin-left: 10px;
  margin-right: 10px;
  background-color: #cccccc;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#currentUserAvatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.profileInitials {
  font-size: 18px;
  color: #ffffff;
  font-weight: bold;
  text-transform: uppercase;
  font-family: "Vazirmatn", sans-serif !important;
}

/* ========================================
     MESSAGE INPUT - REORDERED LIKE MOBILE
     ======================================== */

/* Camera button (leftmost like in image) */
.messageBoxCamera {
  width: 32px;
  height: 32px;
  color: rgb(120, 120, 120);
  cursor: pointer;
  transition: color 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  background: none;
  border: none;
}

.messageBoxCamera:hover {
  color: var(--light-blue);
  background-color: rgba(0, 0, 0, 0.05);
}

/* Message input wrapper (center) - NO ROUNDED BOX */
.messageInputWrapper {
  flex: 1;
  margin: 0;
  /* Remove all rounded styling */
  background: transparent;
  border: none;
  border-radius: 0;
}

.messageInputContainer {
  /* Remove rounded container styling - make it blend with message box */
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  min-height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

/* FIXED: Text input - ensure consistent font for numbers and text */
.custom-text-input {
  font-family: "Vazirmatn", sans-serif !important;
  font-size: 14px;
  direction: rtl;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  width: 100%;
  resize: none;
  min-height: 24px;
  max-height: 24px;
  /* Keep single line like mobile */
  overflow: hidden;
  line-height: 24px;
  /* Remove any styling that makes it look like a separate input */
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  /* Force consistent font for numbers */
  font-variant-numeric: normal !important;
  font-feature-settings: normal !important;
}

.custom-text-input::placeholder {
  color: #999;
  direction: rtl;
  font-family: "Vazirmatn", sans-serif !important;
}

/* When input contains emoji, use mixed font */
/* .custom-text-input[data-has-emoji="true"] {
  font-family: "Vazirmatn",  'Apple Color Emoji', 'Noto Color Emoji', sans-serif !important;
} */

/* Right buttons container */
.messageBoxRightButtons {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

/* Update existing messageBoxAttach */
.messageBoxAttach {
  position: static !important;
  width: 32px !important;
  height: 32px !important;
  right: auto !important;
  bottom: auto !important;
  color: rgb(120, 120, 120) !important;
  cursor: pointer;
  transition: color 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: none;
  border: none;
}

.messageBoxAttach:hover {
  color: var(--light-blue) !important;
  background-color: rgba(0, 0, 0, 0.05);
}

/* Update existing messageBoxEmoji */
.messageBoxEmoji {
  position: static !important;
  width: 32px !important;
  height: 32px !important;
  right: auto !important;
  bottom: auto !important;
  color: rgb(120, 120, 120) !important;
  cursor: pointer;
  transition: color 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: none;
  border: none;
}

.messageBoxEmoji:hover,
.messageBoxEmoji.active {
  color: var(--light-blue) !important;
  background-color: rgba(0, 0, 0, 0.05);
}

/* Update existing messageBoxSend */
.messageBoxSend {
  position: static !important;
  width: 32px !important;
  height: 32px !important;
  right: auto !important;
  left: auto !important;
  bottom: auto !important;
  background: var(--primary-blue) !important;
  color: white !important;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
}

.messageBoxSend:hover {
  background: var(--light-blue) !important;
  transform: scale(1.05);
}

.messageBoxSend.send-mode {
  transform: scale(1.1);
}

/* Update existing messageBoxSendSvg */
.messageBoxSendSvg {
  transform: none !important;
  color: white !important;
}

/* Button icons */
.messageBoxCamera svg,
.messageBoxAttach svg,
.messageBoxEmoji svg,
.messageBoxSend svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Voice/Send icon toggle */
.voice-icon {
  display: block;
}

.send-icon {
  display: none;
}

.messageBoxSend.send-mode .voice-icon {
  display: none;
}

.messageBoxSend.send-mode .send-icon {
  display: block;
}

/* Hide old input styles completely */
.messageBoxInput,
.emojionearea {
  display: none !important;
}

/* ========================================
   EMOJI PICKER - FIXED HEIGHT TO 390PX
   ======================================== */

/* Emoji picker overlay - FIXED HEIGHT */
.emoji-picker-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border-gray);
  z-index: 1020;
  transform: translateY(100%);
  transition: transform 0.3s ease, visibility 0.3s ease;
  height: 390px !important;
  /* Fixed height like mobile keyboard */
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.emoji-picker-overlay.active {
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
}

.emoji-picker-header {
  display: flex;
  justify-content: flex-end;
  /* Push close button to the right */
  align-items: center;
  padding: 8px 16px;
  /* Reduced padding since no title */
  border-bottom: 1px solid var(--border-gray);
  background: #f8f8f8;
  height: 36px;
  /* Reduced height since no title */
  flex-shrink: 0;
}

/* Remove title styles since we don't have a title anymore */
.emoji-picker-header h3 {
  display: none;
}

.emoji-picker-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #666;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.emoji-picker-close:hover {
  background: rgba(0, 0, 0, 0.1);
}

.emoji-picker-content {
  height: calc(390px - 36px);
  /* Updated height calculation with smaller header */
  overflow: hidden;
}

/* Emoji picker positioning now handled by flexbox layout */

/* Emoji-mart picker customization - make it fill the space properly */
em-emoji-picker {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  font-family: "Vazirmatn", sans-serif !important;
  /* UI text uses Vazirmatn */
}

/* Override emoji-mart internal styles for better mobile look */
em-emoji-picker .category {
  padding: 8px 12px !important;
}

em-emoji-picker .emoji {
  font-family: 'Apple Color Emoji', 'Noto Color Emoji', sans-serif !important;
  /* Only emojis use Apple font */
  font-size: 22px !important;
  padding: 8px !important;
}

em-emoji-picker .search {
  padding: 8px 12px !important;
}

em-emoji-picker .search input {
  border-radius: 8px !important;
  border: 1px solid #ddd !important;
  padding: 8px 12px !important;
  font-size: 14px !important;
  font-family: "Vazirmatn", sans-serif !important;
  direction: rtl;
}

/* Emoji picker search and UI text - Force Vazirmatn */
em-emoji-picker .category-label,
em-emoji-picker .nav-button,
em-emoji-picker .search-results {
  font-family: "Vazirmatn", sans-serif !important;
}

/* ========================================
     UTILITY CLASSES
     ======================================== */
.linefeed {
  clear: both;
  margin-bottom: -5px;
}

.selectable {
  user-select: text;
  -moz-user-select: text;
  -webkit-user-select: text;
  -ms-user-select: text;
}

.unselectable {
  user-select: none;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
}

.chat-main-container {
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: var(--background-gray);
}

.introBoxProfileImageContainer {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  float: right;
  margin-left: 10px;
  margin-right: 10px;
  background-color: #cccccc;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.current-user-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.avatarLeft,
.avatarRight {
  position: relative;
  height: 32px;
  width: 32px;
  border-radius: 16px;
  z-index: 4;
}

.avatarLeft {
  float: left;
  left: 7px;
}

.avatarRight {
  float: right;
  right: 7px;
}

.replyToBox {
  height: 60px;
  z-index: 50;
  background: #1a1a1a !important;
  width: 100%;
  padding: 0 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: none;
  flex-shrink: 0;
  color: white;
  max-height: 0;
  opacity: 0;
  transform: translateY(8px);
  overflow: hidden;
  transition: max-height 0.18s ease, opacity 0.18s ease, transform 0.18s ease, padding 0.18s ease;
}

.replyToBox.active {
  max-height: 80px;
  opacity: 1;
  transform: translateY(0);
  padding: 7px;
}

.replyToBox.closing {
  opacity: 0;
  transform: translateY(10px);
}

/* ========================================
     FONT FIXING CLASSES
     ======================================== */

/* Force Vazirmatn for all UI text elements */
.bubbleText,
.timeSpan,
.file-name,
.file-size,
.audio-title,
.audio-meta,
.audio-duration,
.file-name-final,
.file-size-final {
  font-family: "Vazirmatn", sans-serif !important;
  font-variant-numeric: normal !important;
}

/* Apple emoji class for emoji characters only */
/* .apple-emoji {
  font-family:  'Apple Color Emoji', 'Noto Color Emoji', sans-serif !important;
  font-variant-emoji: emoji !important;
  text-rendering: optimizeLegibility;
} */

/* Vazirmatn text class for text and numbers */
.vazirmatn-text {
  font-family: "Vazirmatn", sans-serif !important;
  font-variant-numeric: normal !important;
}

/* Preload the font for better performance */
/* .emoji-font-preload {
  font-family: 'Apple Color Emoji Local';
  visibility: hidden;
  position: absolute;
  top: -9999px;
} */

/* Loading state while font loads */
/* .emoji-loading {
  font-family: 'Noto Color Emoji', 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif !important;
} */

/* Override any system emoji fonts that might interfere */
* {
  -webkit-font-feature-settings: normal;
  -moz-font-feature-settings: normal;
  font-feature-settings: normal;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .messageBox {
    padding: 8px 10px !important;
    gap: 8px !important;
    height: 48px !important;
  }

  .messageBoxCamera,
  .messageBoxAttach,
  .messageBoxEmoji,
  .messageBoxSend {
    width: 30px !important;
    height: 30px !important;
  }

  .messageBoxCamera svg,
  .messageBoxAttach svg,
  .messageBoxEmoji svg,
  .messageBoxSend svg {
    width: 18px !important;
    height: 18px !important;
  }

  .custom-text-input {
    font-size: 16px !important;
    /* Prevent zoom on iOS */
    line-height: 22px;
    min-height: 22px;
    max-height: 22px;
    font-family: "Vazirmatn", sans-serif !important;
  }

  /* Smaller emoji picker on very small screens */
  .emoji-picker-overlay {
    height: 350px !important;
  }

  .emoji-picker-content {
    height: calc(350px - 32px) !important;
  }

  /* Emoji picker positioning now handled by flexbox layout */

  .emoji-picker-header {
    padding: 6px 14px;
    height: 32px;
    /* Even smaller on mobile */
  }

  .emoji-picker-close {
    width: 28px;
    height: 28px;
    font-size: 18px;
  }
}
