/* ============================================================
   Sirr Chat & Conversation List Styles
   ============================================================ */

/* ===== Conversation List Container ===== */

.conv-list-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ===== Search Bar ===== */

.conv-search-bar {
  padding: 12px 16px 8px;
  flex-shrink: 0;
}

.conv-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.conv-search-icon {
  position: absolute;
  right: 12px;
  color: var(--text3);
  pointer-events: none;
}

[dir="ltr"] .conv-search-icon {
  right: auto;
  left: 12px;
}

.conv-search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 40px 10px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

[dir="ltr"] .conv-search-input {
  padding: 10px 14px 10px 40px;
}

.conv-search-input::placeholder {
  color: var(--text3);
}

.conv-search-input:focus {
  border-color: var(--gold);
}

/* ===== Filter Tabs ===== */

.conv-filter-bar {
  display: flex;
  gap: 4px;
  padding: 4px 16px 8px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.conv-filter-bar::-webkit-scrollbar {
  display: none;
}

.conv-filter-btn {
  background: transparent;
  border: none;
  color: var(--text3);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.conv-filter-btn:hover {
  background: var(--surface2);
  color: var(--text2);
}

.conv-filter-btn.active {
  background: var(--gold);
  color: #0A0A0F;
}

/* ===== Conversation Items ===== */

.conv-items {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--surface3) transparent;
}

.conv-items::-webkit-scrollbar {
  width: 4px;
}

.conv-items::-webkit-scrollbar-thumb {
  background: var(--surface3);
  border-radius: 2px;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  height: 72px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}

.conv-item.pinned {
  background: rgba(26, 26, 46, 0.4);
  border-top: 1px solid rgba(45, 45, 68, 0.3);
  border-bottom: 1px solid rgba(45, 45, 68, 0.3);
}

.conv-item:hover {
  background: var(--surface2);
}

.conv-item.active {
  background: var(--surface2);
  border-inline-start: 3px solid var(--gold);
  padding-inline-start: 13px;
}

/* ===== Avatar ===== */

.conv-avatar {
  width: 52px;
  height: 52px;
  min-width: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.conv-avatar-letter {
  font-size: 19px;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  user-select: none;
}

.conv-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.conv-online-dot {
  position: absolute;
  bottom: 1px;
  left: 1px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--teal);
  border: 2.5px solid var(--bg);
  box-shadow: 0 0 6px rgba(46, 205, 167, 0.5);
  animation: onlineDotPulse 2.5s ease-in-out infinite;
}

@keyframes onlineDotPulse {
  0%, 100% { box-shadow: 0 0 4px rgba(46, 205, 167, 0.4); }
  50% { box-shadow: 0 0 10px rgba(46, 205, 167, 0.7); }
}

[dir="ltr"] .conv-online-dot {
  left: auto;
  right: 1px;
}

/* ===== Conversation Info ===== */

.conv-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conv-info-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conv-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}

.conv-type-icon {
  flex-shrink: 0;
}

.conv-time {
  font-size: 12px;
  color: var(--text3);
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.conv-info-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conv-last-msg {
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.conv-typing-text {
  color: var(--teal);
  font-style: italic;
}

.conv-pinned-icon,
.conv-muted-icon {
  flex-shrink: 0;
}

/* ===== Unread Badge ===== */

.unread-badge {
  background: var(--gold);
  color: #0A0A0F;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.unread-badge.muted {
  background: var(--surface3);
  color: var(--text3);
}

/* ===== Empty State ===== */

.conv-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 8px;
}

.conv-empty-icon {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(201, 168, 76, 0.12), rgba(201, 168, 76, 0.04));
  border-radius: 24px;
  margin-bottom: 8px;
}

.conv-empty-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 14px;
  height: 14px;
  background: var(--gold);
  border-radius: 50%;
  border: 2px solid var(--bg);
}

.conv-empty-title {
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
}

.conv-empty-subtitle {
  color: var(--text3);
  font-size: 14px;
}

.conv-empty p {
  color: var(--text3);
  font-size: 15px;
}

/* ===== Conversation Context Menu ===== */

.conv-context-menu {
  position: fixed;
  z-index: 1000;
  background: var(--surface1);
  border: 1px solid var(--surface3);
  border-radius: 12px;
  padding: 6px;
  min-width: 180px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  animation: menuFadeIn 0.15s ease;
}

.conv-ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
  text-align: start;
}

.conv-ctx-item:hover {
  background: var(--surface2);
}

.conv-ctx-item.danger {
  color: var(--red);
}

.conv-ctx-item.danger:hover {
  background: rgba(231, 76, 76, 0.1);
}

/* ============================================================
   Chat Panel
   ============================================================ */

#chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg, #07090F);
  position: relative;
}

/* ===== Chat Header ===== */

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface1, #0D1117);
  border-bottom: 1px solid var(--surface3, #252530);
  flex-shrink: 0;
  z-index: 10;
}

.chat-back-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: background 0.15s;
}

.chat-back-btn:hover {
  background: var(--surface2);
}

@media (max-width: 768px) {
  .chat-back-btn {
    display: flex;
  }
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-header-avatar span {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat-header-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-status {
  font-size: 12px;
  color: var(--text3);
}

.chat-header-status.online {
  color: var(--teal);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-header-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-header-btn:hover {
  background: var(--surface2);
}

/* ===== Messages Area ===== */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface3) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--surface3);
  border-radius: 2px;
}

.chat-messages-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text3);
  font-size: 14px;
}

/* ===== Empty Chat State ===== */

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
  margin: auto;
}

.chat-empty p {
  color: var(--text3);
  font-size: 15px;
}

.chat-empty-hint {
  font-size: 13px !important;
  color: var(--text3) !important;
  opacity: 0.7;
}

/* ===== Date Separator ===== */

.chat-date-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
}

.chat-date-separator span {
  background: var(--surface2);
  color: var(--text3);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 14px;
  border-radius: 12px;
}

/* ===== Message Rows ===== */

.message-row {
  display: flex;
  margin-bottom: 2px;
}

.message-row.outgoing {
  justify-content: flex-end;
}

[dir="rtl"] .message-row.outgoing {
  justify-content: flex-start;
}

.message-row.incoming {
  justify-content: flex-start;
}

[dir="rtl"] .message-row.incoming {
  justify-content: flex-end;
}

/* ===== Message Bubbles ===== */

.message-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 18px;
  position: relative;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.5;
}

.message-bubble.outgoing {
  background: #1E1E36;
  border-inline-start: 3px solid var(--gold);
  border-bottom-left-radius: 6px;
}

[dir="rtl"] .message-bubble.outgoing {
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 6px;
}

.message-bubble.incoming {
  background: #232338;
  border-bottom-right-radius: 6px;
}

[dir="rtl"] .message-bubble.incoming {
  border-bottom-right-radius: 18px;
  border-bottom-left-radius: 6px;
}

.message-row.message-highlight .message-bubble {
  animation: msgHighlight 1.5s ease;
}

@keyframes msgHighlight {
  0%, 30% { background: rgba(201, 168, 76, 0.15); }
  100% { background: inherit; }
}

/* ===== Message Content ===== */

.message-text {
  font-size: 14px;
  color: var(--text);
  display: inline;
}

.message-link {
  color: var(--blue);
  text-decoration: none;
}

.message-link:hover {
  text-decoration: underline;
}

/* ===== Message Meta ===== */

.message-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  float: left;
  margin-top: 4px;
  margin-inline-start: 8px;
}

[dir="rtl"] .message-meta {
  float: left;
}

[dir="ltr"] .message-meta {
  float: right;
}

.message-time {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
}

.message-edited {
  font-size: 10px;
  color: var(--text3);
  font-style: italic;
}

/* ===== Message Status ===== */

.message-status {
  font-size: 13px;
  line-height: 1;
  letter-spacing: -3px;
}

.message-status.sent {
  color: var(--text3);
}

.message-status.delivered {
  color: var(--text3);
}

.message-status.read {
  color: var(--gold);
}

/* ===== Message Appear Animation ===== */
.message-row {
  animation: msgSlideIn 0.2s ease-out;
}

@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Reply Preview in Message ===== */

.message-reply-preview {
  background: rgba(201, 168, 76, 0.08);
  border-inline-start: 3px solid var(--gold);
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background 0.15s ease;
}

.message-reply-preview:hover {
  background: rgba(255, 255, 255, 0.08);
}

.message-reply-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
}

.message-reply-text {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Forwarded Header ===== */

.message-forwarded {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text3);
  font-style: italic;
}

/* ===== Typing Indicator ===== */

.chat-typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
}

.typing-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold, var(--text3));
  animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

.typing-label {
  font-size: 12px;
  color: var(--text3);
  font-style: italic;
}

/* ===== Input Area ===== */

.chat-input-area {
  background: var(--surface1, #0D1117);
  border-top: 1px solid var(--surface3, #252530);
  flex-shrink: 0;
}

.reply-preview {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background: var(--surface2);
  border-inline-start: 3px solid var(--gold);
  gap: 12px;
}

.reply-preview.editing {
  border-inline-start-color: var(--blue);
}

.reply-preview-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.reply-preview-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
}

.reply-preview.editing .reply-preview-name {
  color: var(--blue);
}

.reply-preview-text {
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-preview-close {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s;
}

.reply-preview-close:hover {
  color: var(--text);
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 16px 14px;
}

.chat-input-wrapper {
  flex: 1;
  min-width: 0;
}

.chat-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  outline: none;
  resize: none;
  max-height: 120px;
  transition: border-color 0.2s;
}

.chat-input::placeholder {
  color: var(--text3);
}

.chat-input:focus {
  border-color: var(--gold);
}

.chat-input-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.chat-input-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.chat-send-btn {
  background: linear-gradient(135deg, var(--gold), var(--gold-light, #E8B450));
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 8px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(201, 168, 76, 0.3);
}

.chat-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(201, 168, 76, 0.45);
}

.chat-send-btn:active {
  transform: scale(0.92);
}

.chat-send-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
  box-shadow: none;
}

/* Flip send icon for RTL */
[dir="rtl"] .chat-send-btn svg {
  transform: scaleX(-1);
}

/* Mic button (shown when input is empty) */
.chat-mic-btn {
  background: rgba(15, 184, 160, 0.15);
  border: none;
  color: var(--teal);
  cursor: pointer;
  padding: 8px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
  flex-shrink: 0;
}

.chat-mic-btn:hover {
  background: rgba(15, 184, 160, 0.25);
  transform: scale(1.05);
}

.chat-mic-btn:active {
  transform: scale(0.92);
  background: var(--teal);
  color: #fff;
}

/* Emoji toggle button */
.chat-emoji-btn {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.chat-emoji-btn:hover {
  color: var(--gold);
  background: var(--surface2);
}

.chat-emoji-btn.active {
  color: var(--gold);
}

/* ===== Emoji Picker Panel ===== */

.emoji-picker-panel {
  background: var(--surface1);
  border-top: 1px solid var(--surface3);
  height: 0;
  opacity: 0;
  overflow: hidden;
  transition: height 0.2s ease, opacity 0.2s ease;
}

.emoji-picker-panel.emoji-picker-open {
  height: 300px;
  opacity: 1;
}

.emoji-picker-search {
  padding: 8px 12px 4px;
}

.emoji-picker-search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 8px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.emoji-picker-search-input:focus {
  border-color: var(--gold);
}

.emoji-picker-search-input::placeholder {
  color: var(--text3);
}

.emoji-picker-grid {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-content: flex-start;
  height: 210px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface3) transparent;
}

.emoji-picker-grid::-webkit-scrollbar {
  width: 4px;
}

.emoji-picker-grid::-webkit-scrollbar-thumb {
  background: var(--surface3);
  border-radius: 2px;
}

.emoji-grid-item {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  transition: background 0.1s, transform 0.1s;
  padding: 0;
}

.emoji-grid-item:hover {
  background: var(--surface2);
  transform: scale(1.15);
}

.emoji-grid-item:active {
  transform: scale(0.95);
}

.emoji-picker-tabs {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 4px 8px;
  background: var(--surface2);
  border-top: 1px solid var(--surface3);
  flex-shrink: 0;
  height: 40px;
}

.emoji-tab {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 4px 6px;
  border-radius: 8px;
  opacity: 0.5;
  transition: opacity 0.15s, background 0.15s, transform 0.1s;
  line-height: 1;
}

.emoji-tab:hover {
  opacity: 0.8;
  background: var(--surface3);
}

.emoji-tab.active {
  opacity: 1;
  background: var(--surface3);
}

.emoji-picker-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--text3);
  font-size: 14px;
}

/* ===== Message appear animation (only for new messages) ===== */

.message-row.msg-new {
  animation: msgAppear 0.2s ease-out;
}

@keyframes msgAppear {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Pending message (optimistic, before server confirms) */
.message-row.pending .message-bubble {
  opacity: 0.7;
}

/* ===== Clickable header for profile ===== */

.chat-header-avatar,
.chat-header-info {
  cursor: pointer;
  transition: opacity 0.15s;
}

.chat-header-avatar:hover,
.chat-header-info:hover {
  opacity: 0.8;
}

/* ===== Context Menu ===== */

.message-context-menu {
  position: fixed;
  z-index: 1000;
  background: var(--surface1);
  border: 1px solid var(--surface3);
  border-radius: 12px;
  padding: 6px;
  min-width: 160px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  animation: menuFadeIn 0.15s ease;
}

@keyframes menuFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
  text-align: start;
}

.context-menu-item:hover {
  background: var(--surface2);
}

.context-menu-item.danger {
  color: var(--red);
}

.context-menu-item.danger:hover {
  background: rgba(231, 76, 76, 0.1);
}

/* ===== Dialogs ===== */

.sirr-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 20px;
  animation: overlayFadeIn 0.2s ease;
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sirr-dialog {
  background: var(--surface1);
  border: 1px solid var(--surface3);
  border-radius: 16px;
  padding: 24px;
  min-width: 300px;
  max-width: 420px;
  width: 100%;
  animation: dialogSlideIn 0.2s ease;
}

@keyframes dialogSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sirr-dialog h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.sirr-dialog p {
  font-size: 14px;
  color: var(--text2);
  margin-bottom: 20px;
  line-height: 1.6;
}

.sirr-dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.sirr-btn-cancel {
  background: transparent;
  border: 1px solid var(--surface3);
  color: var(--text2);
  padding: 8px 20px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.sirr-btn-cancel:hover {
  background: var(--surface2);
  color: var(--text);
}

.sirr-btn-secondary {
  background: var(--surface3);
  border: none;
  color: var(--text);
  padding: 8px 20px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.sirr-btn-secondary:hover {
  background: var(--surface2);
}

.sirr-btn-danger {
  background: var(--red);
  border: none;
  color: #fff;
  padding: 8px 20px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.sirr-btn-danger:hover {
  opacity: 0.9;
}

/* ===== New Chat / Forward Dialog ===== */

.sirr-dialog-new-chat,
.sirr-dialog-forward {
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.new-chat-search-wrapper,
.forward-search-wrapper {
  margin-bottom: 12px;
}

.new-chat-search-input,
.forward-search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.new-chat-search-input:focus,
.forward-search-input:focus {
  border-color: var(--gold);
}

.new-chat-search-input::placeholder,
.forward-search-input::placeholder {
  color: var(--text3);
}

.new-chat-results,
.forward-list {
  flex: 1;
  overflow-y: auto;
  max-height: 360px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface3) transparent;
}

.new-chat-hint,
.new-chat-loading,
.new-chat-empty,
.forward-loading,
.forward-empty {
  text-align: center;
  padding: 30px 20px;
  color: var(--text3);
  font-size: 14px;
}

/* ===== User Search Result Item ===== */

.user-search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s;
}

.user-search-item:hover {
  background: var(--surface2);
}

.user-search-avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-search-avatar span {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.user-search-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.user-search-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.user-search-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.user-search-handle {
  font-size: 12px;
  color: var(--text3);
  direction: ltr;
  text-align: start;
}

/* ===== Forward Item ===== */

.forward-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s;
}

.forward-item:hover {
  background: var(--surface2);
}

.forward-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.forward-avatar span {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

.forward-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

/* ============================================================
   Mobile Responsive
   ============================================================ */

/* ===== MOBILE CHAT (max 768px) ===== */
@media (max-width: 768px) {
  #sidebar {
    width: 100%;
    position: fixed;
    inset: 0;
    z-index: 50;
  }

  #sidebar.hidden-mobile {
    display: none;
  }

  #chat-panel {
    width: 100%;
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
  }

  #chat-panel.active {
    display: flex;
  }

  /* Message bubbles wider */
  .message-bubble {
    max-width: 85%;
  }

  /* Conversation items */
  .conv-item {
    padding: 10px 12px;
  }

  .conv-avatar {
    width: 48px;
    height: 48px;
    min-width: 48px;
  }

  /* Search */
  .conv-search-bar {
    padding: 8px 12px;
  }

  /* Filter tabs scroll */
  .conv-filter-bar {
    padding: 0 8px;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .conv-filter-bar::-webkit-scrollbar { display: none; }

  .conv-filter-btn {
    white-space: nowrap;
    min-height: 44px;
    padding: 0 12px;
  }

  /* Context menu */
  .message-context-menu {
    min-width: 180px;
    max-width: 90vw;
  }

  .context-menu-item {
    min-height: 44px;
    padding: 10px 16px;
  }

  /* Dialog */
  .sirr-dialog {
    width: 95vw;
    max-width: 95vw;
    max-height: 85vh;
    min-width: auto;
    margin: 10px;
  }

  /* New chat dialog */
  .sirr-dialog-new-chat {
    width: 95vw;
    max-height: 90vh;
  }

  /* Date separator */
  .chat-date-separator span {
    font-size: 11px;
    padding: 4px 10px;
  }

  /* Input area */
  .chat-input-row {
    padding: 8px;
  }

  .chat-input {
    font-size: 16px; /* prevents iOS zoom */
    min-height: 40px;
  }

  .chat-send-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  .chat-input-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  /* Reply preview */
  .reply-preview {
    padding: 8px 12px;
    font-size: 13px;
  }

  /* Unread badge */
  .unread-badge {
    min-width: 20px;
    height: 20px;
    font-size: 11px;
  }

  /* Forward dialog */
  .sirr-dialog-forward {
    width: 95vw;
  }

  /* Message time */
  .message-time {
    font-size: 10px;
  }

  /* Message status */
  .message-status {
    font-size: 12px;
  }

  /* Typing animation mobile sizing */
  .typing-dots span {
    width: 5px;
    height: 5px;
  }

  .typing-label {
    font-size: 11px;
  }
}

/* ===== SMALL PHONES (max 414px) ===== */
@media (max-width: 414px) {
  .message-bubble {
    max-width: 90%;
    padding: 8px 12px;
    border-radius: 14px;
  }

  .conv-item {
    padding: 8px 10px;
  }

  .conv-name {
    font-size: 14px;
  }

  .conv-last-msg {
    font-size: 12px;
  }

  .conv-time {
    font-size: 10px;
  }

  .sirr-dialog,
  .sirr-dialog-new-chat,
  .sirr-dialog-forward {
    width: 98vw;
    max-width: 98vw;
    border-radius: 12px;
  }
}

/* ===== VERY SMALL (max 320px) ===== */
@media (max-width: 320px) {
  .message-bubble {
    max-width: 92%;
    padding: 6px 10px;
    font-size: 14px;
  }

  .conv-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    font-size: 14px;
  }

  .conv-item {
    min-height: 60px;
  }
}

@media (min-width: 769px) {
  .chat-back-btn {
    display: none;
  }
}

/* ============================================================
   Utility: Animations
   ============================================================ */

.conv-item {
  animation: fadeInUp 0.2s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   Feature: Message Reactions
   ============================================================ */

.reaction-picker {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: var(--surface2);
  border: 1px solid var(--surface3);
  border-radius: 24px;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: reactionPickerIn 0.15s ease-out;
}

@keyframes reactionPickerIn {
  from { opacity: 0; transform: translateX(-50%) scale(0.9) translateY(6px); }
  to { opacity: 1; transform: translateX(-50%) scale(1) translateY(0); }
}

.reaction-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: transform 0.15s, background 0.15s;
  line-height: 1;
}

.reaction-btn:hover {
  transform: scale(1.3);
  background: rgba(255,255,255,0.1);
}

.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  padding-top: 4px;
}

.reaction-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s, border-color 0.15s;
}

.reaction-badge:hover {
  background: rgba(255,255,255,0.12);
}

.reaction-badge.mine {
  background: rgba(201, 144, 42, 0.15);
  border-color: rgba(201, 144, 42, 0.3);
}

.reaction-emoji {
  font-size: 15px;
  line-height: 1;
}

.reaction-count {
  font-size: 11px;
  color: var(--text3);
  font-weight: 500;
}

/* Hover react button on messages */
.msg-react-hover-btn {
  position: absolute;
  top: -4px;
  opacity: 0;
  background: var(--surface2);
  border: 1px solid var(--surface3);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.message-row.outgoing .msg-react-hover-btn {
  left: -4px;
}

.message-row.incoming .msg-react-hover-btn {
  right: -4px;
}

[dir="rtl"] .message-row.outgoing .msg-react-hover-btn {
  left: auto;
  right: -4px;
}

[dir="rtl"] .message-row.incoming .msg-react-hover-btn {
  right: auto;
  left: -4px;
}

.message-row:hover .msg-react-hover-btn {
  opacity: 1;
}

.msg-react-hover-btn:hover {
  transform: scale(1.15);
}

/* ============================================================
   Feature: Pinned Message Banner
   ============================================================ */

.pinned-message-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(201, 144, 42, 0.08);
  border-bottom: 1px solid rgba(201, 144, 42, 0.15);
  cursor: pointer;
  animation: slideDown 0.2s ease;
  flex-shrink: 0;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-100%); }
  to { opacity: 1; transform: translateY(0); }
}

.pinned-message-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.pinned-message-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.pinned-label {
  font-size: 11px;
  color: var(--gold);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pinned-text {
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-close-btn {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: background 0.15s;
}

.pinned-close-btn:hover {
  background: rgba(255,255,255,0.1);
}

/* ============================================================
   Feature: Message Search Bar
   ============================================================ */

.msg-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface2);
  border-bottom: 1px solid var(--surface3);
  animation: slideDown 0.2s ease;
  flex-shrink: 0;
}

.msg-search-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--surface3);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.msg-search-input:focus {
  border-color: var(--gold);
}

.msg-search-count {
  font-size: 12px;
  color: var(--text3);
  white-space: nowrap;
  min-width: 60px;
  text-align: center;
}

.msg-search-nav-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.15s;
  display: flex;
  align-items: center;
}

.msg-search-nav-btn:hover {
  background: rgba(255,255,255,0.1);
}

.msg-search-close-btn {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 20px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background 0.15s;
}

.msg-search-close-btn:hover {
  background: rgba(255,255,255,0.1);
}

.search-highlight .message-bubble {
  background: rgba(201, 144, 42, 0.12) !important;
  border: 1px solid rgba(201, 144, 42, 0.3) !important;
}

/* ============================================================
   Feature: Enhanced Read Receipts
   ============================================================ */

.message-status.status-animated {
  transition: color 0.3s ease, opacity 0.3s ease;
}

.message-status.sent {
  color: var(--text3);
}

.message-status.delivered {
  color: var(--text3);
}

.message-status.read {
  color: var(--gold);
  text-shadow: 0 0 4px rgba(201, 144, 42, 0.3);
}

/* ============================================================
   Feature: Enhanced Typing Indicator
   ============================================================ */

.typing-dots-animated {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

.typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  animation: typingBounce 1.2s ease-in-out infinite;
  display: inline-block;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-header-status.typing {
  color: var(--gold);
  font-size: 12px;
}

/* Typing dots in conversation list */
.typing-dots-inline {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-right: 3px;
  vertical-align: middle;
}

.typing-dots-inline span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--teal);
  animation: typingBounce 1.2s ease-in-out infinite;
  display: inline-block;
}

.typing-dots-inline span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots-inline span:nth-child(3) {
  animation-delay: 0.4s;
}

/* ============================================================
   Feature: Draft Preview in Conversation List
   ============================================================ */

.conv-draft-text {
  color: var(--text3);
}

.draft-label {
  color: #E74C3C;
  font-weight: 600;
  font-size: 12px;
}

/* ============================================================
   Feature: Chat Folders
   ============================================================ */

.folders-bar {
  flex-shrink: 0;
  border-bottom: 1px solid var(--surface3);
  background: var(--bg);
}

.folders-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.folders-tabs::-webkit-scrollbar {
  display: none;
}

.folder-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: var(--text3);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 16px;
  transition: all 0.2s;
}

.folder-tab:hover {
  background: var(--surface2);
  color: var(--text2);
}

.folder-tab.active {
  background: var(--gold);
  color: #0A0A0F;
}

.folder-tab.drag-over {
  background: rgba(201, 144, 42, 0.2);
  border: 1px dashed var(--gold);
}

.folder-tab-icon {
  display: flex;
  align-items: center;
}

.folder-add-btn {
  color: var(--text3);
  opacity: 0.6;
}

.folder-add-btn:hover {
  opacity: 1;
  background: var(--surface2);
}

/* Folder icon picker in dialogs */
.folder-icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
}

.folder-icon-option {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface2);
  border: 2px solid transparent;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.folder-icon-option:hover {
  background: var(--surface3);
}

.folder-icon-option.active {
  border-color: var(--gold);
  background: rgba(201, 144, 42, 0.15);
  color: var(--gold);
}

/* Drag state on conversation items */
.conv-item.dragging {
  opacity: 0.5;
}

/* ============================================================
   Feature: Online Status - Green Dot
   ============================================================ */

.online-dot,
.conv-online-dot {
  background: #2ECD96;
  box-shadow: 0 0 6px rgba(46, 205, 167, 0.5);
}

/* ============================================================
   Feature: Link Preview Styling
   ============================================================ */

.message-link {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
  word-break: break-all;
}

.message-link:hover {
  border-bottom-color: var(--gold);
}

/* ============================================================
   Feature: Swipe to Reply Visual Feedback
   ============================================================ */

.message-row {
  position: relative;
  will-change: transform;
}

.message-row::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  background: var(--gold);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

[dir="rtl"] .message-row::before {
  right: auto;
  left: 100%;
}

/* ============================================================
   Feature: Message Highlight Animation
   ============================================================ */

.message-highlight .message-bubble {
  animation: highlightPulse 1.5s ease;
}

@keyframes highlightPulse {
  0% { box-shadow: 0 0 0 0 rgba(201, 144, 42, 0.4); }
  30% { box-shadow: 0 0 0 6px rgba(201, 144, 42, 0.2); }
  100% { box-shadow: 0 0 0 0 rgba(201, 144, 42, 0); }
}
