/**
 * 历史记录窗口 v3.0 - 全新分页设计
 * @description 完全重写的历史记录窗口，采用5个卡片分页设计
 */

/* ================================
   历史窗口遮罩
   ================================ */
.history-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.history-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* ================================
   历史窗口主体
   ================================ */
.history-window {
    width: 95%;
    max-width: 1200px;
    height: 85vh;
    max-height: 700px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.history-overlay.show .history-window {
    transform: scale(1);
}

/* ================================
   窗口标题栏 - 包含分页控件
   ================================ */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex-shrink: 0;
}

.history-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.history-title::before {
    content: '📱';
    font-size: 24px;
}

/* 标题栏控件容器 */
.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* 清空全部按钮 */
.clear-all-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 87, 87, 0.2);
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 87, 87, 0.3);
    white-space: nowrap;
}

.clear-all-btn:hover {
    background: rgba(255, 87, 87, 0.8);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 87, 87, 0.3);
}

.clear-all-btn:active {
    transform: translateY(0);
}

/* 分页控件在标题栏中 */
.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.page-nav-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.page-nav-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.page-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    color: white;
    font-size: 13px;
    font-weight: 500;
    margin: 0 8px;
    white-space: nowrap;
}

.page-input {
    width: 50px; /* 增加宽度 */
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    text-align: center;
    font-size: 13px; /* 稍微增大字体 */
    font-weight: 600;
    outline: none;
}

/* 隐藏页码输入框的spinner按钮，防止遮挡数字 */
.page-input::-webkit-outer-spin-button,
.page-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.page-input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.page-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.page-input:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

/* 关闭按钮 */
.close-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: rgba(255, 87, 87, 0.8);
    transform: scale(1.05);
}

/* ================================
   内容区域
   ================================ */
.history-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 统计信息 */
.history-stats {
    padding: 16px 24px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #6c757d;
    flex-shrink: 0;
}

.stats-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stats-value {
    font-weight: 600;
    color: #495057;
}

/* 卡片网格容器 */
.cards-container {
    flex: 1;
    padding: 24px;
    overflow: hidden;
    background: #fafbfc;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
    height: 100%;
    align-content: center;
}

/* ================================
   历史卡片样式
   ================================ */
.history-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    overflow: hidden;
    height: 100%;
    min-height: 280px;
}

.history-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #667eea;
}

/* 卡片头部 */
.card-header {
    padding: 16px;
    border-bottom: 1px solid #f1f3f4;
    flex-shrink: 0;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: center;
}

/* 卡片内容 */
.card-content {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.gif-preview {
    max-width: 100%;
    max-height: 120px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 12px;
}

.card-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
}

.info-tag {
    background: #f8f9fa;
    color: #6c757d;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 12px;
    border: 1px solid #e9ecef;
    white-space: nowrap;
}

/* 卡片底部按钮 */
.card-footer {
    padding: 10px 12px; /* 稍微减少padding */
    border-top: 1px solid #f1f3f4;
    display: flex;
    gap: 6px; /* 减小按钮间距 */
    justify-content: center;
    flex-shrink: 0;
}

.card-btn {
    flex: 1;
    max-width: 70px; /* 进一步减小最大宽度 */
    height: 30px; /* 稍微减小高度 */
    border: none;
    border-radius: 6px;
    font-size: 9px; /* 更小的字体 */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px; /* 减小图标和文字间距 */
    white-space: nowrap; /* 防止换行 */
    overflow: hidden; /* 隐藏溢出内容 */
    padding: 0 4px; /* 添加内边距 */
}

.btn-download {
    background: #28a745;
    color: white;
}

.btn-download:hover {
    background: #218838;
    transform: translateY(-1px);
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.btn-preview {
    background: #007bff;
    color: white;
}

.btn-preview:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.btn-import {
    background: #17a2b8;
    color: white;
}

.btn-import:hover {
    background: #138496;
    transform: translateY(-1px);
}

/* ================================
   空状态
   ================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
    text-align: center;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-text {
    font-size: 16px;
    margin: 0;
}

/* ================================
   响应式设计
   ================================ */
@media (max-width: 1200px) {
    .cards-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 900px) {
    .cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .history-window {
        width: 98%;
        height: 90vh;
    }
    
    .history-header {
        padding: 16px 20px;
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .header-controls {
        order: 3;
        width: 100%;
        justify-content: space-between;
        gap: 12px;
    }
    
    .clear-all-btn {
        flex-shrink: 0;
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .pagination-controls {
        flex: 1;
        justify-content: center;
    }
}

@media (max-width: 600px) {
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .cards-container {
        padding: 16px;
    }
    
    .history-card {
        min-height: 240px;
    }
    
    .gif-preview {
        max-height: 80px;
    }
    
    .card-btn {
        font-size: 9px; /* 进一步减小按钮文字 */
        max-width: 70px; /* 减小按钮最大宽度 */
        gap: 1px; /* 进一步减小间距 */
    }
    
    .header-controls {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }
    
    .clear-all-btn {
        align-self: center;
        font-size: 11px;
        padding: 6px 10px;
    }
}

@media (max-width: 400px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }
    
    .pagination-controls {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .page-nav-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    .page-input {
        width: 45px; /* 小屏幕上也保持足够宽度 */
        height: 24px;
        font-size: 12px;
    }
}

/* ================================
   加载动画
   ================================ */
.history-card {
    opacity: 1;
    transform: translateY(0);
}
