/**
 * FileCat Elementor Widget Styles
 * 文件分类展示样式
 */

/* ========================================
   页面加载优化 - 防止内容闪烁和错乱
   ======================================== */

/* 页面加载时隐藏内容，避免未样式化内容闪烁 (FOUC) */
.filecat-elementor-archive-wrapper,
.filecat-elementor-single-wrapper {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* 页面加载完成后显示内容 */
.filecat-elementor-archive-wrapper.loaded,
.filecat-elementor-single-wrapper.loaded {
    opacity: 1;
}

/* 加载动画容器 */
.filecat-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
}

.filecat-loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

/* 加载内容容器 */
.filecat-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* 加载动画 - 简洁的旋转圆圈 */
.filecat-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #e61f12;
    border-radius: 50%;
    animation: filecat-spin 1s linear infinite;
}

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

/* 加载文字 */
.filecat-loading-text {
    font-size: 16px;
    color: #666;
    font-weight: 500;
    letter-spacing: 1px;
    animation: filecat-loading-dots 1.5s ease-in-out infinite;
}

@keyframes filecat-loading-dots {
    0%, 20% { opacity: 0.3; }
    50% { opacity: 1; }
    100% { opacity: 0.3; }
}

/* 防止图片加载时的布局跳动 - 只在 filecat 相关页面生效 */
.tax-filecat .filecat-subcategory-image img,
.tax-filecat .filecat-post-image img,
.single-filecenter .filecat-subcategory-image img,
.single-filecenter .filecat-post-image img,
.single-filecenter .filecat-captcha-image {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.tax-filecat .filecat-subcategory-image img.loaded,
.tax-filecat .filecat-post-image img.loaded,
.single-filecenter .filecat-subcategory-image img.loaded,
.single-filecenter .filecat-post-image img.loaded,
.single-filecenter .filecat-captcha-image.loaded {
    opacity: 1;
}

/* 其他页面的图片正常显示（包括 downloadcenter 等其他页面） */
body:not(.tax-filecat):not(.single-filecenter) .filecat-subcategory-image img,
body:not(.tax-filecat):not(.single-filecenter) .filecat-post-image img,
body:not(.tax-filecat):not(.single-filecenter) .filecat-captcha-image {
    opacity: 1 !important;
}

/* 骨架屏效果 - 加载时的占位动画 */
.filecat-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: filecat-skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes filecat-skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* 确保Elementor容器不限制宽度 */
.elementor-widget-filecat-subcategories-widget {
    width: 100% !important;
}

.elementor-widget-filecat-subcategories-widget .elementor-widget-container {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

/* 覆盖可能的Section/Container限制 */
.elementor-section .elementor-widget-filecat-subcategories-widget,
.elementor-container .elementor-widget-filecat-subcategories-widget,
.elementor-column .elementor-widget-filecat-subcategories-widget {
    width: 100% !important;
    max-width: none !important;
}

/* 网格容器 */
.filecat-subcategories-grid {
    display: grid;
    gap: 30px;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none;
    box-sizing: border-box;
}

/* 根据列数设置网格 */
.filecat-subcategories-grid[data-columns="2"] {
    grid-template-columns: repeat(2, 1fr);
    gap: 40px;
}

.filecat-subcategories-grid[data-columns="3"] {
    grid-template-columns: repeat(3, 1fr);
    gap: 35px;
}

.filecat-subcategories-grid[data-columns="4"] {
    grid-template-columns: repeat(4, 1fr);
    gap: 30px;
}

.filecat-subcategories-grid[data-columns="5"] {
    grid-template-columns: repeat(5, 1fr);
    gap: 25px;
}

.filecat-subcategories-grid[data-columns="6"] {
    grid-template-columns: repeat(6, 1fr);
    gap: 20px;
}

/* 响应式布局 */
@media (max-width: 1024px) {
    .filecat-subcategories-grid[data-columns="5"],
    .filecat-subcategories-grid[data-columns="6"] {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .filecat-subcategories-grid[data-columns="4"],
    .filecat-subcategories-grid[data-columns="5"],
    .filecat-subcategories-grid[data-columns="6"] {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .filecat-subcategories-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* 分类项目 */
.filecat-subcategory-item {
    position: relative;
    overflow: hidden;
    background: #f8f8f8;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.filecat-subcategory-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 24px rgba(230, 31, 18, 0.15);
    background: #fff;
}

/* 链接 */
.filecat-subcategory-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

/* 图片容器 */
.filecat-subcategory-image {
    position: relative;
    width: 100%;
    padding-bottom: 60%; /* 5:3 宽高比，更宽松 */
    overflow: hidden;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filecat-subcategory-image img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 80%;
    max-height: 80%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.filecat-subcategory-item:hover .filecat-subcategory-image img {
    transform: translate(-50%, -50%) scale(1.08);
}

/* 分类名称 */
.filecat-subcategory-name {
    padding: 20px 15px;
    text-align: center;
    background: transparent;
}

.filecat-subcategory-name h3 {
    margin: 0;
    padding: 0;
    font-size: 15px;
    font-weight: 500;
    color: #e61f12;
    line-height: 1.6;
    letter-spacing: 0.3px;
    transition: all 0.3s ease;
}

.filecat-subcategory-item:hover .filecat-subcategory-name h3 {
    color: #c01810;
    font-weight: 600;
}

/* 文章数量 */
.filecat-count {
    display: inline-block;
    margin-left: 5px;
    font-size: 13px;
    color: #999;
    font-weight: normal;
    opacity: 0.8;
}

/* 加载状态 */
.filecat-subcategories-grid.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* 空状态 */
.filecat-subcategories-grid:empty::after {
    content: "暂无分类";
    display: block;
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 16px;
}

/* ========================================
   文章列表样式
   ======================================== */

/* 文章列表容器 */
.filecat-posts-wrapper {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

/* 文章列表头部 */
.filecat-posts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #e61f12;
}

.filecat-posts-title {
    margin: 0;
    padding: 0;
    font-size: 24px;
    font-weight: 600;
    color: #e61f12;
}

.filecat-posts-count {
    font-size: 14px;
    color: #999;
    font-weight: normal;
}

/* 文章列表 */
.filecat-posts-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
}

/* 文章项目 */
.filecat-post-item {
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
}

.filecat-post-item:hover {
    background-color: #f8f8f8;
}

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

/* 文章链接 */
.filecat-post-link {
    display: flex;
    align-items: center;
    padding: 15px 10px;
    text-decoration: none;
    color: #333;
    gap: 15px;
    transition: all 0.2s ease;
}

.filecat-post-link:hover {
    color: #e61f12;
}

/* 文章图标 */
.filecat-post-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 30px;
    text-align: center;
}

/* 文章标题 */
.filecat-post-title {
    flex: 1;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.6;
}

.filecat-post-link:hover .filecat-post-title {
    font-weight: 500;
}

/* 文章日期 */
.filecat-post-date {
    font-size: 13px;
    color: #999;
    flex-shrink: 0;
    min-width: 100px;
    text-align: right;
}

/* 空状态 */
.filecat-posts-empty {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 16px;
}

/* 响应式 */
@media (max-width: 768px) {
    .filecat-posts-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .filecat-posts-title {
        font-size: 20px;
    }

    .filecat-post-link {
        flex-wrap: wrap;
        gap: 10px;
    }

    .filecat-post-date {
        width: 100%;
        text-align: left;
        margin-left: 45px;
        font-size: 12px;
    }
}

/* ========================================
   文件下载验证码样式
   ======================================== */

.filecat-download-wrapper {
    max-width: 600px;
    margin: 60px auto;
    padding: 40px;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.filecat-download-filename {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 35px;
    padding-bottom: 25px;
    border-bottom: 2px solid #f5f5f5;
}

.filecat-download-icon {
    font-size: 28px;
    margin-right: 12px;
}

.filecat-download-title {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    text-align: center;
}

.filecat-download-form {
    display: flex;
    flex-direction: column;
    gap: 25px;
    align-items: center;
}

.filecat-captcha-wrapper {
    text-align: center;
    width: 100%;
}

.filecat-captcha-image {
    max-width: 250px;
    height: auto;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.filecat-captcha-image:hover {
    border-color: #e61f12;
    box-shadow: 0 4px 12px rgba(230, 31, 18, 0.2);
    transform: translateY(-2px);
}

.filecat-input-wrapper {
    text-align: center;
    width: 100%;
}

.filecat-captcha-input {
    width: 100%;
    max-width: 350px;
    padding: 14px 24px;
    font-size: 18px;
    border: 2px solid #ddd;
    border-radius: 6px;
    text-align: center;
    transition: all 0.3s ease;
    letter-spacing: 2px;
}

.filecat-captcha-input:focus {
    outline: none;
    border-color: #e61f12;
    box-shadow: 0 0 0 3px rgba(230, 31, 18, 0.1);
}

.filecat-captcha-input::placeholder {
    color: #999;
    letter-spacing: normal;
}

.filecat-button-wrapper {
    text-align: center;
    width: 100%;
}

.filecat-download-button {
    padding: 14px 50px;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    background-color: #e61f12;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(230, 31, 18, 0.3);
}

.filecat-download-button:hover {
    background-color: #c51a0f;
    box-shadow: 0 6px 16px rgba(230, 31, 18, 0.4);
    transform: translateY(-2px);
}

.filecat-download-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(230, 31, 18, 0.3);
}

.filecat-download-message {
    text-align: center;
    margin-top: 20px;
    font-size: 15px;
    min-height: 24px;
    font-weight: 500;
}

.filecat-back-wrapper {
    text-align: center;
    margin-top: 30px;
    padding-top: 25px;
    border-top: 2px solid #f5f5f5;
}

.filecat-back-button {
    padding: 10px 30px;
    font-size: 15px;
    font-weight: 500;
    color: #666;
    background-color: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filecat-back-button:hover {
    color: #333;
    background-color: #e8e8e8;
    border-color: #ccc;
    transform: translateX(-3px);
}

.filecat-back-button:active {
    transform: translateX(-1px);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .filecat-download-wrapper {
        padding: 30px 20px;
        margin: 40px 20px;
    }

    .filecat-download-title {
        font-size: 18px;
    }

    .filecat-captcha-input {
        max-width: 100%;
        font-size: 16px;
    }

    .filecat-download-button {
        padding: 12px 40px;
        font-size: 16px;
    }

    .filecat-captcha-image {
        max-width: 200px;
    }

    .filecat-back-button {
        padding: 10px 25px;
        font-size: 14px;
    }
}

