/**
 * AIVB Frontend Styles
 * 动态列表前端样式
 */

/* ========== Header样式 ========== */
.overflow-visible {
    overflow: visible !important;
}

/* ========== 容器样式 ========== */
.aivb-dynamic-list {
    margin: 30px 0;
    padding: 0;
    /* CSS变量：主题色，会被JS动态设置 */
    --aivb-theme-color: #3b82f6;
    --aivb-theme-color-hover: #2563eb;
    --aivb-theme-color-light: rgba(59, 130, 246, 0.1);
}

/* ========== 筛选器样式 ========== */
.aivb-filters {
    background: linear-gradient(145deg, #ffffff 0%, #f9fafb 100%);
    border: 1px solid #e0e7ff;
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 40px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    position: relative;
    overflow: hidden;
}

.aivb-filters::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--aivb-theme-color), var(--aivb-theme-color-hover));
    border-radius: 16px 16px 0 0;
}

.aivb-filters-title {
    margin: 0 0 28px 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    letter-spacing: -0.03em;
    display: flex;
    align-items: center;
    gap: 12px;
}

.aivb-filters-title::before {
    content: '🎯';
    font-size: 1.4rem;
}

.aivb-filters-grid {
    display: grid;
    grid-template-rows: auto auto; /* 第一行：搜索；第二行：其余筛选 */
    grid-auto-flow: column;        /* 其余筛选横向扩展为一行 */
    grid-auto-columns: 1fr;        /* 其余筛选平分宽度 */
    gap: 16px 20px;
    margin-bottom: 20px;
}

/* 搜索框独占第一行整行 */
.aivb-filter-search {
    grid-row: 1;
    grid-column: 1 / -1;
}

/* 其余筛选放在第二行，自动均分 */
.aivb-filter-group:not(.aivb-filter-search) {
    grid-row: 2;
}

.aivb-filter-group {
    display: flex;
    flex-direction: column;
    position: relative;
}

.aivb-filter-group label {
    font-weight: 600;
    margin-bottom: 10px;
    color: #374151;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
}

.aivb-filter-group label::before {
    content: '▶';
    font-size: 0.6rem;
    color: var(--aivb-theme-color);
}

/* 搜索框特殊样式 */
.aivb-filter-search {
    grid-column: 1 / -1;
}

.aivb-filter-search label::before {
    content: '';
}

.aivb-filter-search .aivb-filter {
    font-size: 15px;
    padding: 14px 20px 14px 48px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%233b82f6" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/></svg>');
    background-repeat: no-repeat;
    background-position: 16px center;
    background-size: 20px;
}

.aivb-filter {
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    background: #ffffff;
    color: #1f2937;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.aivb-filter:hover {
    border-color: var(--aivb-theme-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.aivb-filter:focus {
    outline: none;
    border-color: var(--aivb-theme-color);
    box-shadow: 0 0 0 4px var(--aivb-theme-color-light), 0 4px 12px rgba(59, 130, 246, 0.2);
    transform: translateY(-2px);
}

.aivb-filter[multiple] {
    min-height: 120px;
    background: linear-gradient(to bottom, #ffffff 0%, #f9fafb 100%);
}

/* 价格范围和日期范围 */
.aivb-price-range,
.aivb-date-range {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 14px;
    align-items: center;
}

.aivb-price-range span,
.aivb-date-range span {
    text-align: center;
    color: #9ca3af;
    font-weight: 700;
    font-size: 1rem;
}

/* 筛选器操作按钮 */
.aivb-filter-actions {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
    margin-top: 8px;
}

/* ========== 按钮样式 ========== */
.aivb-btn {
    padding: 13px 28px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    letter-spacing: 0.02em;
    position: relative;
    overflow: hidden;
}

.aivb-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.aivb-btn:hover::before {
    width: 300px;
    height: 300px;
}

.aivb-btn-primary {
    background: linear-gradient(135deg, var(--aivb-theme-color) 0%, var(--aivb-theme-color-hover) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.aivb-btn-primary:hover {
    background: linear-gradient(135deg, var(--aivb-theme-color-hover) 0%, var(--aivb-theme-color) 100%);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}

.aivb-btn-primary:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.aivb-btn-secondary {
    background: #ffffff;
    color: #374151;
    border: 2px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.aivb-btn-secondary:hover {
    background: #f9fafb;
    border-color: var(--aivb-theme-color);
    color: var(--aivb-theme-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.aivb-btn-secondary:active {
    transform: translateY(0);
}

.aivb-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ========== 列表容器 ========== */
.aivb-list-container {
    min-height: 300px;
    position: relative;
}

/* ========== 加载状态 ========== */
.aivb-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #6b7280;
}

.aivb-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid var(--aivb-theme-color);
    border-radius: 50%;
    animation: aivb-spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes aivb-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.aivb-loading p {
    margin: 0;
    font-size: 16px;
}

/* ========== 错误状态 ========== */
.aivb-error {
    text-align: center;
    padding: 40px 20px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #856404;
}

.aivb-error p {
    margin: 0 0 15px 0;
    font-size: 16px;
}

.aivb-notice {
    padding: 15px 20px;
    border-radius: 4px;
    margin: 20px 0;
}

.aivb-notice.aivb-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* ========== 分页样式 ========== */
.aivb-pagination {
    margin-top: 30px;
    padding: 20px 0;
}

.aivb-pagination-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.aivb-pagination-info {
    color: #666;
    font-size: 14px;
    font-weight: 500;
}

.aivb-pagination-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.aivb-page-btn {
    min-width: 40px;
    height: 40px;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    background: white;
    color: #374151;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.aivb-page-btn:hover {
    background: var(--aivb-theme-color-light);
    border-color: var(--aivb-theme-color);
    color: var(--aivb-theme-color);
}

.aivb-page-btn.aivb-active {
    background: var(--aivb-theme-color);
    color: white;
    border-color: var(--aivb-theme-color);
    cursor: default;
}

.aivb-page-btn.aivb-active:hover {
    background: var(--aivb-theme-color-hover);
    border-color: var(--aivb-theme-color-hover);
    color: white;
}

.aivb-page-btn.aivb-prev,
.aivb-page-btn.aivb-next {
    font-weight: 600;
}

.aivb-pagination-dots {
    padding: 0 5px;
    color: #999;
    font-weight: bold;
}

/* ========== 响应式设计 ========== */
@media (max-width: 768px) {
    .aivb-filters {
        padding: 24px 18px;
        border-radius: 12px;
    }

    .aivb-filters-title {
        font-size: 1.3rem;
        margin-bottom: 20px;
    }

    .aivb-filters-grid {
        grid-template-rows: auto;
        grid-auto-flow: row; /* 小屏改为纵向堆叠 */
        grid-auto-columns: unset;
        gap: 14px;
    }

    .aivb-filter-actions {
        flex-direction: column;
        gap: 12px;
    }

    .aivb-btn {
        width: 100%;
        text-align: center;
        padding: 14px 24px;
    }

    .aivb-pagination-buttons {
        gap: 5px;
    }

    .aivb-page-btn {
        min-width: 35px;
        height: 35px;
        padding: 6px 10px;
        font-size: 13px;
    }

    .aivb-page-btn.aivb-prev,
    .aivb-page-btn.aivb-next {
        padding: 6px 12px;
    }
}

@media (max-width: 480px) {
    .aivb-filters {
        padding: 20px 16px;
    }

    .aivb-filters-title {
        font-size: 1.2rem;
    }

    .aivb-filters-title::before {
        font-size: 1.2rem;
    }

    .aivb-filter {
        padding: 10px 14px;
    }

    .aivb-pagination-buttons {
        gap: 4px;
    }

    .aivb-page-btn {
        min-width: 32px;
        height: 32px;
        padding: 5px 8px;
        font-size: 12px;
    }

    /* 在小屏幕上隐藏一些页码 */
    .aivb-pagination-buttons .aivb-page-btn:not(.aivb-active):not(.aivb-prev):not(.aivb-next) {
        display: none;
    }

    .aivb-pagination-buttons .aivb-page-btn.aivb-active {
        display: inline-block;
    }

    /* 显示当前页附近的页码 */
    .aivb-pagination-buttons .aivb-page-btn.aivb-active + .aivb-page-btn,
    .aivb-pagination-buttons .aivb-page-btn:has(+ .aivb-active) {
        display: inline-block;
    }
}

/* ========== 平滑过渡 ========== */
.aivb-list-container {
    transition: opacity 0.3s ease;
}

.aivb-list-container.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ========== 无结果提示 ========== */
.no-products,
.no-posts {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 16px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px dashed #ddd;
}

/* ========== 确保产品和文章网格在动态列表中正确显示 ========== */
.aivb-dynamic-list .custom-product-grid,
.aivb-dynamic-list .custom-post-grid {
    margin: 0;
}

/* ========== 可访问性增强 ========== */
.aivb-btn:focus,
.aivb-page-btn:focus {
    outline: 2px solid var(--aivb-theme-color);
    outline-offset: 2px;
}

/* 减少动画效果（尊重用户偏好） */
@media (prefers-reduced-motion: reduce) {
    .aivb-spinner,
    .aivb-btn,
    .aivb-page-btn,
    .aivb-filter,
    .aivb-list-container {
        animation: none;
        transition: none;
    }
}

