/* ==========================================================================
   SecureChat Pro - In-Chat Message Search & Navigator CSS
   (会话内消息精准搜索、关键词高亮与跳转导航)
   ========================================================================== */

/* Active Chat Window context */
.chat-window {
  position: relative;
}

/* Floating Search Bar beneath the Chat Header */
.chat-search-bar {
  position: absolute;
  top: 70px;
  right: 24px;
  z-index: 50;
  display: flex;
  align-items: center;
  background: var(--bg-card, #161b29);
  background: rgba(22, 27, 41, 0.95);
  border: 1px solid var(--border-color, #232a3d);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  padding: 6px 10px;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-search-bar.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chat-search-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Search Input Wrapper */
.chat-search-input-wrapper {
  display: flex;
  align-items: center;
  position: relative;
  background: var(--bg-input, #151a27);
  border: 1px solid var(--border-light, rgba(255, 255, 255, 0.08));
  border-radius: 8px;
  padding: 4px 10px;
  width: 240px;
  gap: 8px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.chat-search-input-wrapper:focus-within {
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.chat-search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #9ba3b5);
  flex-shrink: 0;
}

.chat-search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-main, #f3f5f9);
  padding: 2px 0;
  min-width: 0;
}

.chat-search-input::placeholder {
  color: var(--text-dim, #647087);
}

/* Clear Button */
.chat-search-clear-btn {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-dim, #647087);
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  transition: color 0.15s ease, background 0.15s ease;
}

.chat-search-clear-btn:hover {
  color: var(--text-main, #f3f5f9);
  background: rgba(255, 255, 255, 0.1);
}

/* Match Counter Indicator */
.chat-search-counter {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted, #9ba3b5);
  white-space: nowrap;
  padding: 0 6px;
  min-width: 95px;
  text-align: center;
  user-select: none;
}

/* Navigation Buttons Group */
.chat-search-nav-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-search-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--bg-hover, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border-light, rgba(255, 255, 255, 0.08));
  border-radius: 6px;
  color: var(--text-main, #f3f5f9);
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.chat-search-nav-btn:hover:not(:disabled) {
  background: var(--bg-active, rgba(59, 130, 246, 0.2));
  border-color: var(--primary, #3b82f6);
  color: #fff;
}

.chat-search-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* Close Button */
.chat-search-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted, #9ba3b5);
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.chat-search-close-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* Header Trigger Button Active State */
#btn-search-in-chat.active {
  background: var(--bg-active, rgba(59, 130, 246, 0.2));
  color: var(--primary, #3b82f6);
  border-color: var(--primary, #3b82f6);
}

/* ==========================================================================
   Keyword Highlighting Styles
   ========================================================================== */

mark.search-highlight {
  background-color: rgba(245, 158, 11, 0.38); /* Warm amber highlight */
  color: inherit;
  border-radius: 3px;
  padding: 1px 2px;
  margin: 0;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  transition: background-color 0.15s ease, outline 0.15s ease;
}

mark.search-highlight.current {
  background-color: #f59e0b; /* Bright radiant amber */
  color: #000000 !important;
  font-weight: 700;
  outline: 2px solid #fbbf24;
  outline-offset: 1px;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.75);
}

/* Focused Message Bubble Pulse Animation */
@keyframes searchBubblePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.75);
    transform: scale(1);
  }
  25% {
    box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.35);
    transform: scale(1.02);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(59, 130, 246, 0.12);
    transform: scale(1.01);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    transform: scale(1);
  }
}

.msg-bubble.search-focus-pulse {
  animation: searchBubblePulse 1.2s cubic-bezier(0.25, 1, 0.5, 1) !important;
  position: relative;
  z-index: 2;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .chat-search-bar {
    top: 64px;
    left: 10px;
    right: 10px;
    padding: 6px 8px;
    border-radius: 10px;
  }

  .chat-search-inner {
    width: 100%;
    gap: 6px;
  }

  .chat-search-input-wrapper {
    width: auto;
    flex: 1;
    min-width: 0;
    padding: 4px 6px;
  }

  .chat-search-counter {
    min-width: auto;
    font-size: 11px;
    padding: 0 2px;
  }

  .chat-search-nav-btn,
  .chat-search-close-btn {
    width: 26px;
    height: 26px;
  }
}
