/*
Theme Name: Template Site
Theme URI: https://your-domain.com
Author: Template Site Team
Description: PPT/简历/Excel模板站主题
Version: 5.0
*/

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* 管理员前台有 WP 管理栏时，sticky 顶栏下移，避免叠住或上方留白 */
body.admin-bar header.site-header,
body.admin-bar header {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar header.site-header,
    body.admin-bar header {
        top: 46px;
    }
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: inline-block;
    background: transparent !important;
    background-color: transparent !important;
}

.logo a {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    background: transparent !important;
    background-color: transparent !important;
}

.logo-text {
    font-size: 36px;
    font-weight: 900;
    letter-spacing: 0.12em;
    font-family: 'KaiTi', 'STKaiti', '楷体', 'SimKai', '华文楷体', 'Microsoft YaHei', sans-serif;
    color: white !important;
    text-decoration: none;
    display: inline-block;
    -webkit-text-stroke: 0.3px white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.logo-image {
    height: 50px;
    width: auto;
    vertical-align: middle;
    display: inline-block;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    filter: none !important;
    mix-blend-mode: normal !important;
    padding: 0 !important;
    margin: 0 !important;
}

.logo a img {
    background: transparent !important;
    background-color: transparent !important;
}

header .container .logo * {
    background: transparent !important;
    background-color: transparent !important;
}

nav ul,
nav .menu {
    display: flex;
    list-style: none;
    gap: 30px;
    margin: 0;
    padding: 0;
}

nav a,
nav .menu a {
    color: white;
    text-decoration: none;
    font-weight: 700;
    font-size: 20px;
}

nav a:hover,
nav .menu a:hover {
    opacity: 0.8;
}

/* 站点头部导航 */
.site-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 24px;
}

.site-nav-menu,
.site-nav-auth {
    display: flex;
    list-style: none;
    gap: 24px;
    margin: 0;
    padding: 0;
}

.site-nav a {
    color: white;
    text-decoration: none;
    font-weight: 700;
    font-size: 18px;
}

.header-auth-btn {
    display: inline-block;
    color: #ffd700 !important;
    background: rgba(255, 255, 255, 0.12);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 15px !important;
    white-space: nowrap;
}

.mobile-menu-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    padding: 10px;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
}

.mobile-menu-bar {
    display: block;
    width: 100%;
    height: 2px;
    background: white;
    border-radius: 2px;
}

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 900px) {
    header {
        padding: 14px 0;
    }

    .logo-text {
        font-size: 24px;
        letter-spacing: 0.06em;
    }

    .logo-image {
        height: 40px;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .site-nav {
        position: fixed;
        top: 0;
        right: 0;
        width: min(320px, 88vw);
        height: 100vh;
        background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 80px 24px 24px;
        transform: translateX(100%);
        transition: transform 0.25s ease;
        z-index: 1100;
        box-shadow: -8px 0 24px rgba(0, 0, 0, 0.18);
        overflow-y: auto;
    }

    body.mobile-nav-open .site-nav {
        transform: translateX(0);
    }

    body.mobile-nav-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 1050;
    }

    .site-nav-menu,
    .site-nav-auth {
        flex-direction: column;
        gap: 0;
        width: 100%;
    }

    .site-nav-menu li,
    .site-nav-auth li {
        border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    }

    .site-nav a {
        display: block;
        padding: 14px 0;
        font-size: 16px;
    }

    .header-auth-btn {
        margin-top: 12px;
        text-align: center;
    }
}

.hero-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 60px 0;
    text-align: center;
}

.hero-title {
    font-size: 42px;
    font-weight: bold;
    margin-bottom: 15px;
}

.hero-subtitle {
    font-size: 18px;
    opacity: 0.9;
    margin-bottom: 30px;
}

.stats-bar {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 32px;
    font-weight: bold;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
}

/* Search */
.search-section {
    padding: 40px 0;
    text-align: center;
}

.search-box {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
}

.search-box input {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
}

.search-box button {
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
}

/* Categories */
.categories {
    padding: 20px 0;
    background: white;
    /* 锚点定位时避开顶部 sticky 导航（JS 会再按实测高度校正） */
    scroll-margin-top: 120px;
}

/* 结果较少时补足滚动高度，保证分类区能滚到上端 */
#category-scroll-pad {
    width: 100%;
    pointer-events: none;
}

.category-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 15px;
}

.category-item {
    flex: 0 0 auto;
    width: auto;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
    box-sizing: border-box;
}

.category-item:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-2px);
}

.category-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Template Grid */
.templates-section {
    padding: 40px 0;
}

.section-title {
    font-size: 28px;
    margin-bottom: 30px;
    color: #333;
    font-weight: bold;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

/* Template Card */
.template-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    position: relative;
}

.template-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.12);
}

/* Badges */
.template-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
}

.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: bold;
    margin-right: 6px;
}

.badge-hot {
    background: #ef4444;
    color: white;
}

.badge-free {
    background: #22c55e;
    color: white;
}

.badge-premium {
    background: #f59e0b;
    color: white;
}

.badge-member {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Quick Actions */
.template-quick-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    z-index: 10;
    opacity: 0;
    transform: translateY(-8px);
    transition: all 0.3s ease;
}

.template-card:hover .template-quick-actions {
    opacity: 1;
    transform: translateY(0);
}

.quick-action-btn {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.95);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.quick-action-btn:hover {
    background: white;
    transform: scale(1.1);
}

.favorite-btn {
    font-size: 20px !important;
}

.favorite-btn:hover {
    transform: scale(1.2) !important;
}

.heart-icon {
    display: inline-block;
    font-size: 22px;
    line-height: 1;
}

.heart-icon:not(.favorited) {
    color: #666 !important;
    filter: none !important;
}

.heart-icon.favorited {
    color: #ef4444;
}

/* Template Preview */
.template-preview {
    height: 200px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    position: relative;
    overflow: hidden;
}

.preview-icon {
    font-size: 56px;
}

.preview-label {
    font-size: 16px;
    font-weight: bold;
    margin-top: 8px;
}

/* Template Info */
.template-info {
    padding: 20px;
}

.template-category-top {
    font-size: 16px;
    color: #667eea;
    font-weight: bold;
    margin-bottom: 8px;
}

.template-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 12px;
    color: #333;
    line-height: 1.4;
}

.template-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.template-stats {
    display: flex;
    gap: 16px;
}

.template-stats .stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.template-price {
    font-size: 18px;
    font-weight: 800;
    color: #667eea;
}

.template-price.free {
    color: #22c55e;
}

.template-actions {
    display: flex;
    gap: 10px;
}

.btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 700;
    transition: all 0.2s ease;
}

.btn-view {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-view:hover {
    background: #667eea;
    color: white;
}

.btn-download {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-buy {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-buy:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}

/* Footer */
footer {
    background: #2d3748;
    color: white;
    padding: 40px 0;
    margin-top: 60px;
}

footer .container {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 30px;
}

.footer-section h4 {
    margin-bottom: 15px;
    font-size: 16px;
}

.footer-section ul {
    list-style: none;
}

.footer-section a {
    color: #a0aec0;
    text-decoration: none;
}

.footer-section a:hover {
    color: white;
}

.copyright {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    padding-top: 30px;
    color: #cbd5e0;
    font-size: 14px;
    gap: 8px;
}

.copyright p {
    margin: 0;
    width: 100%;
    text-align: center;
}

.site-beian {
    margin: 0;
}

footer .copyright .site-beian a,
footer .copyright .site-beian a:link,
footer .copyright .site-beian a:visited {
    color: #e2e8f0;
    text-decoration: none;
}

footer .copyright .site-beian a:hover,
footer .copyright .site-beian a:focus {
    color: #ffffff;
    text-decoration: underline;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 40px;
}

.pagination a, .pagination span {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-decoration: none;
    color: #333;
    font-weight: 600;
}

.pagination a:hover {
    border-color: #667eea;
    color: #667eea;
}

.pagination .current {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

/* Single Template Page
 * 必须用 div. 限定：WP 会给详情页 body 加上 class="single-template"（single-{post_type}），
 * 若写成 .single-template 会给 body 加上 padding-top，未登录也会在顶栏上方露出背景留白 */
div.single-template {
    padding: 40px 0;
}

.template-detail {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 32px;
}

.template-main {
    background: white;
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.template-main h1 {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 24px;
    color: #333;
    line-height: 1.4;
}

.template-main-content {
    color: #444;
    line-height: 1.8;
}

.template-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.sidebar-section h4 {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 16px;
    color: #333;
}

.sidebar-section .price {
    font-size: 36px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 8px;
}

.sidebar-section .price.free {
    color: #22c55e;
}

.download-btn-large {
    display: block;
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    margin-top: 16px;
    transition: all 0.2s ease;
}

.download-btn-large:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.35);
}

.sidebar-section table {
    width: 100%;
}

.sidebar-section table td {
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.sidebar-section table td:first-child {
    color: #666;
}

.sidebar-section table td:last-child {
    text-align: right;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 968px) {
    .template-detail {
        grid-template-columns: 1fr;
    }
    
    .template-sidebar {
        order: -1;
    }
}

/* Force active category style - HIGH PRIORITY */
.category-grid .category-item.active,
div.category-item.active,
.category-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    background-color: #667eea !important;
    color: white !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4) !important;
}

.category-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
    width: auto;
    flex: 0 0 auto;
}

.category-select-label {
    font-size: 15px;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

.custom-select {
    position: relative;
    min-width: 150px;
    flex-shrink: 0;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 18px !important;
    transition: all 0.3s;
    gap: 10px;
}

.custom-select-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.custom-select-arrow {
    font-size: 12px;
    transition: transform 0.3s;
}

.custom-select.open .custom-select-arrow {
    transform: rotate(180deg);
}

.custom-select-options {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s;
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.custom-select.open .custom-select-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-select-option {
    padding: 14px 20px;
    cursor: pointer;
    font-weight: 500;
    color: #475569;
    transition: all 0.2s;
    border-bottom: 1px solid #f1f5f9;
    font-size: 17px !important;
}

.custom-select-option:last-child {
    border-bottom: none;
}

.custom-select-option:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.custom-select-option.selected {
    background: #f0f4ff;
    color: #667eea;
    font-weight: 600;
}

.category-select-option.selected:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.user-avatar {
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.user-avatar img {
    border-radius: 50%;
}
