/**
 * 历史记录搜索UI样式
 *
 * 功能：覆盖式全屏搜索界面样式
 * 特点：
 * - 使用z-index: 10确保覆盖主界面
 * - 毛玻璃背景效果
 * - 流畅的淡入/滑入动画
 * - 响应式设计（移动端适配）
 *
 * @author 云大阁团队
 * @date 2025-01-29
 */

/* ===================== 主容器（覆盖式全屏） ===================== */

.history-search-mode {
    /* 布局 */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;  /* 高于主界面(z-index: 1-5)，低于弹窗(z-index: 20+) */

    /* Flexbox布局 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;

    /* 毛玻璃背景 */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px); /* Safari支持 */

    /* 动画 */
    animation: fadeIn 0.3s ease-out;

    /* 溢出处理 */
    overflow-y: auto;
    padding: 2rem 1rem;
}

/* 淡入动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ===================== 搜索容器 ===================== */

.history-search-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;

    /* 滑入动画 */
    animation: slideDown 0.4s ease-out;
}

/* 滑入动画 */
@keyframes slideDown {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ===================== 搜索头部 ===================== */

.history-search-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

/* 返回按钮 */
.history-back-btn {
    padding: 0.75rem;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #666;
    font-size: 1.25rem;
}

.history-back-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}

.history-back-btn:active {
    transform: scale(0.95);
}

/* 标题 */
.history-search-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    flex: 1;
}

/* ===================== 搜索输入框 ===================== */

.history-search-input-wrapper {
    position: relative;
    margin-bottom: 1.5rem;
}

.history-search-input {
    width: 100%;
    padding: 1rem 3rem 1rem 3rem;
    font-size: 1rem;
    border: 2px solid #e5e5e5;
    border-radius: 1rem;
    outline: none;
    transition: all 0.3s ease;
    background: white;
}

/* 聚焦状态 */
.history-search-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* 搜索图标 */
.history-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 1.2rem;
    pointer-events: none;
}

/* 清除按钮 */
.history-search-clear {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 1.2rem;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    opacity: 0;
    pointer-events: none;
}

/* 输入框有内容时显示清除按钮 */
.history-search-input:not(:placeholder-shown) + .history-search-icon + .history-search-clear {
    opacity: 1;
    pointer-events: auto;
}

.history-search-clear:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #666;
}

/* ===================== 结果统计 ===================== */

.history-search-stats {
    margin-bottom: 1rem;
    color: #666;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 数据来源标识 */
.history-search-source-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.history-search-source-badge.api {
    background: #e0f2fe;
    color: #0369a1;
}

.history-search-source-badge.local {
    background: #fef3c7;
    color: #a16207;
}

/* ===================== 搜索结果列表 ===================== */

.history-search-results {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* 单个结果项 */
.history-search-result-item {
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 0.75rem;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;

    /* 渐入动画 */
    animation: fadeInUp 0.3s ease-out backwards;
}

/* 逐个延迟渐入 */
.history-search-result-item:nth-child(1) { animation-delay: 0.05s; }
.history-search-result-item:nth-child(2) { animation-delay: 0.10s; }
.history-search-result-item:nth-child(3) { animation-delay: 0.15s; }
.history-search-result-item:nth-child(4) { animation-delay: 0.20s; }
.history-search-result-item:nth-child(5) { animation-delay: 0.25s; }

/* 渐入向上动画 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 悬停效果 */
.history-search-result-item:hover {
    border-color: #2563eb;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
    transform: translateY(-2px);
}

/* 点击效果 */
.history-search-result-item:active {
    transform: translateY(0);
}

/* 结果项标题 */
.history-search-result-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;

    /* 多行省略 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 匹配关键词高亮 */
.history-search-result-title .highlight {
    background: #fef3c7;
    color: #a16207;
    padding: 0 0.2rem;
    border-radius: 0.2rem;
}

/* 结果项元数据 */
.history-search-result-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    color: #999;
    font-size: 0.85rem;
}

.history-search-result-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* 匹配类型徽章 */
.history-search-match-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.history-search-match-badge.title {
    background: #dbeafe;
    color: #1e40af;
}

.history-search-match-badge.content {
    background: #dcfce7;
    color: #166534;
}

/* ===================== 空状态 ===================== */

.history-search-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: #999;
}

.history-search-empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.history-search-empty-text {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.history-search-empty-hint {
    font-size: 0.9rem;
    color: #bbb;
}

/* ===================== 加载状态 ===================== */

.history-search-loading {
    text-align: center;
    padding: 3rem 2rem;
    color: #999;
}

.history-search-loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.history-search-loading-text {
    font-size: 1rem;
}

/* ===================== 响应式设计（移动端） ===================== */

@media (max-width: 768px) {
    .history-search-mode {
        padding: 1rem 0.75rem;
    }

    .history-search-container {
        max-width: 100%;
    }

    .history-search-title {
        font-size: 1.25rem;
    }

    .history-search-input {
        font-size: 0.95rem;
        padding: 0.875rem 2.5rem 0.875rem 2.5rem;
    }

    .history-search-result-item {
        padding: 0.875rem;
    }

    .history-search-result-title {
        font-size: 0.95rem;
    }

    .history-search-result-meta {
        font-size: 0.8rem;
        gap: 0.75rem;
    }
}

/* ===================== 超小屏幕适配 ===================== */

@media (max-width: 480px) {
    .history-search-mode {
        padding: 0.75rem 0.5rem;
    }

    .history-search-header {
        gap: 0.5rem;
        margin-bottom: 1.5rem;
    }

    .history-back-btn {
        padding: 0.5rem;
        font-size: 1.1rem;
    }

    .history-search-title {
        font-size: 1.1rem;
    }

    .history-search-input {
        font-size: 0.9rem;
        padding: 0.75rem 2.25rem 0.75rem 2.25rem;
        border-radius: 0.75rem;
    }

    .history-search-icon {
        left: 0.75rem;
        font-size: 1.1rem;
    }

    .history-search-clear {
        right: 0.75rem;
        font-size: 1.1rem;
    }

    .history-search-result-item {
        padding: 0.75rem;
        border-radius: 0.5rem;
    }

    .history-search-result-title {
        font-size: 0.9rem;
    }

    .history-search-result-meta {
        font-size: 0.75rem;
        gap: 0.5rem;
    }

    .history-search-empty {
        padding: 3rem 1rem;
    }

    .history-search-empty-icon {
        font-size: 3rem;
    }
}

/* ===================== 打印样式（隐藏） ===================== */

@media print {
    .history-search-mode {
        display: none;
    }
}

/* ===================== 深色模式支持（可选） ===================== */

@media (prefers-color-scheme: dark) {
    .history-search-mode {
        background: rgba(30, 30, 30, 0.95);
    }

    .history-search-title {
        color: #e5e5e5;
    }

    .history-search-input {
        background: #2a2a2a;
        border-color: #404040;
        color: #e5e5e5;
    }

    .history-search-input:focus {
        border-color: #3b82f6;
    }

    .history-search-result-item {
        background: #2a2a2a;
        border-color: #404040;
    }

    .history-search-result-item:hover {
        border-color: #3b82f6;
    }

    .history-search-result-title {
        color: #e5e5e5;
    }

    .history-search-result-meta {
        color: #999;
    }

    .history-search-stats {
        color: #999;
    }

    .history-search-empty {
        color: #999;
    }

    .history-search-loading {
        color: #999;
    }

    .history-back-btn {
        color: #999;
    }

    .history-back-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #e5e5e5;
    }
}
