/* --- 搜索模块样式 --- */

/* 聊天记录搜索屏幕 */
#search-history-screen {
    background-color: #f7f7f7;
    flex-direction: column;
}

.search-header {
    background-color: #fff;
    padding: 10px 15px;
    padding-top: max(10px, env(safe-area-inset-top));
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #eee;
}

.search-input-wrapper {
    flex-grow: 1;
    background-color: #f2f2f2;
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-input-wrapper svg {
    color: #999;
    flex-shrink: 0;
}

.search-input-wrapper input {
    border: none;
    background: transparent;
    width: 100%;
    font-size: 14px;
    color: #333;
    padding: 0;
}

.search-input-wrapper input:focus {
    outline: none;
}

.search-cancel-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 15px;
    font-weight: 500;
    padding: 0;
    cursor: pointer;
}

.search-filter-bar {
    background-color: #fff;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
}

.search-scope-select {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: #666;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.search-scope-select.active {
    background-color: #f0f0f0;
    color: #333;
    font-weight: 500;
}

.search-option-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0;
}

.search-result-item {
    background-color: #fff;
    padding: 12px 15px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.search-result-item:active {
    background-color: #f9f9f9;
}

/* 统计头部 */
.search-stat-header {
    background-color: #fff;
    padding: 15px;
    text-align: center;
    font-size: 14px;
    color: #666;
    border-bottom: 1px solid #f0f0f0;
}

.search-stat-header strong {
    color: var(--text-color);
}

/* 搜索分组列表（概览：按角色/群分组） */
.search-group-list {
    background-color: #fff;
}

.search-group-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    gap: 12px;
    transition: background-color 0.2s ease;
}

.search-group-item:hover {
    background-color: #fdf6f8;
}

.search-group-item:active {
    background-color: #f9f9f9;
}

.search-group-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background-color: #eee;
}

.search-group-info {
    flex-grow: 1;
    min-width: 0;
    overflow: hidden;
}

.search-group-name {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 4px;
}

.search-group-count {
    font-size: 12px;
    color: #999;
    font-weight: normal;
    flex-shrink: 0;
    margin-left: 6px;
}

.search-group-preview {
    font-size: 13px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 详情页头部 */
.search-detail-header {
    background-color: #fff;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #f0f0f0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-back-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}

.search-detail-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

/* 搜索结果列表（详情页消息列表） */
.search-result-list {
    background-color: #fff;
}

.search-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.search-result-name {
    font-size: 13px;
    font-weight: 500;
    color: #666;
}

.search-result-time {
    font-size: 11px;
    color: #aaa;
    white-space: nowrap;
}

.search-result-content {
    font-size: 14px;
    color: #333;
    line-height: 1.5;
    word-break: break-word;
}

/* 关键词高亮 */
.keyword-highlight {
    background-color: rgba(206, 228, 241, 0.4);
    color: var(--primary-color);
    font-weight: 600;
    padding: 0 2px;
    border-radius: 2px;
}

/* 空状态 / 占位符 */
.search-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.search-placeholder svg {
    color: #ccc;
    margin-bottom: 15px;
}

.search-placeholder p {
    color: #999;
    font-size: 14px;
    margin: 5px 0;
}

.result-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #999;
}

.result-sender {
    font-weight: 500;
    color: #666;
}

.result-text {
    font-size: 14px;
    color: #333;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.highlight {
    color: var(--primary-color);
    font-weight: bold;
}

.scope-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 100;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 100px;
}

.scope-modal.visible {
    display: flex;
}

.scope-modal-content {
    background-color: #fff;
    width: 80%;
    max-width: 300px;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.scope-list {
    margin-top: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.scope-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background-color 0.2s ease;
}

.scope-item:hover {
    background-color: #f9f9f9;
}

.scope-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background-color: #eee;
}

.scope-item:last-child {
    border-bottom: none;
}

.scope-item.selected {
    color: var(--primary-color);
    font-weight: bold;
}

/* --- 表情包搜索 Tag 样式 --- */
.sticker-search-tag {
    display: flex;
    align-items: center;
    padding: 0 10px !important; /* 覆盖默认 padding */
    width: 36px; /* 初始宽度，只够放图标 */
    height: 30px; /* 与其他 tag 高度一致 */
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.25, 0.8, 0.5, 1), background-color 0.3s ease, border-color 0.3s ease;
    background-color: #f5f5f5; /* 默认背景 */
    cursor: pointer;
    box-sizing: border-box;
    border-radius: 15px !important; /* 圆角 */
    border: 1px solid transparent;
}

.sticker-search-tag:hover {
    background-color: #e0e0e0;
}

.sticker-search-tag.expanded {
    width: 140px; /* 展开宽度 */
    background-color: #fff; /* 展开后背景变白 */
    border-color: var(--primary-color); /* 高亮边框 */
    cursor: text;
}

.sticker-search-tag .search-icon {
    flex-shrink: 0;
    color: #666;
    width: 16px;
    height: 16px;
}

.sticker-search-tag.expanded .search-icon {
    color: var(--primary-color);
}

.sticker-search-tag .sticker-search-input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    margin-left: 6px;
    width: 100%;
    color: #333;
    padding: 0;
    height: 100%;
    opacity: 0;
    transition: opacity 0.2s ease 0.1s; /* 延迟显示文字 */
    pointer-events: auto !important;
    user-select: text !important;
    -webkit-user-select: text !important;
    z-index: 10;
    position: relative;
}

.sticker-search-tag.expanded .sticker-search-input {
    opacity: 1;
}
