/*
Theme Name: 鲜活红主题
Theme URI: https://www.xyhw.hl.cn
Author: XYHW
Author URI: https://www.xyhw.hl.cn
Description: 中文红色主题，鲜明活泼，专业严谨，扁平化设计，支持WooCommerce，响应式布局
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: vibrant-red
Tags: e-commerce, responsive-layout, custom-colors, flat-design, woocommerce
*/

/* ==========================================================================
   颜色定义
   ========================================================================== */
:root {
    --primary-red: #E74C3C;        /* 蕉红 - 主色调 */
    --background-jade: transparent; /* 透明背景 */
    --text-black: #1A1A1A;         /* 乌黑 - 文字色 */
    --white: #FFFFFF;
    --hover-red: #C0392B;          /* 深红 - 悬停效果 */
    --light-gray: #EFEFEF;
    --border-gray: #DDDDDD;
    --shadow: rgba(0, 0, 0, 0.1);

    /* 文章卡片多彩颜色 */
    --card-color-1: #FFE5E5;  /* 浅粉红 */
    --card-color-2: #E5F5FF;  /* 浅蓝 */
    --card-color-3: #FFF5E5;  /* 浅橙 */
    --card-color-4: #F0FFE5;  /* 浅绿 */
    --card-color-5: #FFE5F5;  /* 浅紫粉 */
    --card-color-6: #FFFAE5;  /* 浅黄 */
}

/* ==========================================================================
   全局样式
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-black);
    background: #FFFFFF; /* 纯白色背景 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* WordPress管理栏存在时的body调整 */
body.admin-bar .site-header {
    top: 32px; /* WordPress管理栏高度 */
}

body.admin-bar .site-content {
    padding-top: 112px; /* 80px (导航) + 32px (管理栏) */
}

/* 移动端WordPress管理栏 */
@media screen and (max-width: 782px) {
    body.admin-bar .site-header {
        top: 46px;
    }

    body.admin-bar .site-content {
        padding-top: 126px; /* 80px + 46px */
    }
}

a {
    color: var(--primary-red);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--hover-red);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ==========================================================================
   容器和布局
   ========================================================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.site-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-content {
    flex: 1;
    padding-top: 80px; /* 为固定导航栏留空间 */
}

/* ==========================================================================
   顶部固定导航栏
   ========================================================================== */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: var(--white);
    box-shadow: 0 2px 10px var(--shadow);
    z-index: 1000;
    height: 70px;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
    padding: 0 30px;
}

/* Logo和标题 */
.site-branding {
    display: flex;
    align-items: center;
    gap: 15px;
}

.site-logo {
    height: 50px;
    width: auto;
    display: flex;
    align-items: center;
}

.site-logo img,
.site-logo .custom-logo-link img {
    height: 50px;
    width: auto;
    max-width: none;
    object-fit: contain;
    vertical-align: middle;
}

.site-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-red);
    margin: 0;
    line-height: 1.2;
    display: flex;
    align-items: center;
}

.site-title a {
    color: var(--primary-red);
    display: inline-block;
}

.site-title a:hover {
    color: var(--hover-red);
}

/* 主导航菜单 */
.main-navigation {
    flex: 1;
    display: flex;
    justify-content: center;
}

.main-navigation ul {
    display: flex;
    list-style: none;
    gap: 40px;
    margin: 0;
    padding: 0;
}

.main-navigation li {
    position: relative;
}

.main-navigation a {
    color: var(--text-black);
    font-size: 16px;
    font-weight: 500;
    padding: 10px 0;
    display: block;
    transition: color 0.3s ease;
}

.main-navigation a:hover,
.main-navigation .current-menu-item a {
    color: var(--primary-red);
}

/* 下拉菜单 */
.main-navigation .sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--white);
    box-shadow: 0 4px 12px var(--shadow);
    min-width: 200px;
    padding: 10px 0;
    z-index: 100;
}

.main-navigation li:hover > .sub-menu {
    display: block;
}

.main-navigation .sub-menu li {
    display: block;
}

.main-navigation .sub-menu a {
    padding: 10px 20px;
    white-space: nowrap;
}

/* 购物车图标 */
.header-cart {
    display: flex;
    align-items: center;
    margin-left: 20px;
}

.cart-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-red);
    cursor: pointer;
    transition: color 0.3s ease;
    text-decoration: none;
}

.cart-icon svg {
    width: 28px;
    height: 28px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.cart-icon:hover {
    color: var(--hover-red);
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: var(--primary-red);
    color: var(--white);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

/* 移动端菜单按钮 */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--primary-red);
    cursor: pointer;
    padding: 5px;
}

/* ==========================================================================
   按钮样式
   ========================================================================== */
.btn,
.button,
button[type="submit"],
input[type="submit"],
.woocommerce a.button,
.woocommerce button.button,
.woocommerce input.button,
.woocommerce #respond input#submit {
    background-color: var(--primary-red);
    color: var(--white);
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    text-align: center;
    box-shadow: 0 2px 6px var(--shadow);
}

.btn:hover,
.button:hover,
button[type="submit"]:hover,
input[type="submit"]:hover,
.woocommerce a.button:hover,
.woocommerce button.button:hover,
.woocommerce input.button:hover,
.woocommerce #respond input#submit:hover {
    background-color: var(--hover-red);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

/* ==========================================================================
   首页文章展示区
   ========================================================================== */
.articles-section {
    padding: 60px 0;
    background-color: var(--white);
}

.section-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-black);
    text-align: center;
    margin-bottom: 50px;
    position: relative;
    padding-bottom: 20px;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background-color: var(--primary-red);
    border-radius: 2px;
}

.articles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

.article-card {
    background-color: var(--white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), 0 4px 16px rgba(0, 0, 0, 0.08); /* 双层阴影增强立体感 */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

/* 文章卡片多彩背景 - 使用nth-child分配不同颜色 */
.article-card:nth-child(6n+1) {
    background-color: var(--card-color-1);
}

.article-card:nth-child(6n+2) {
    background-color: var(--card-color-2);
}

.article-card:nth-child(6n+3) {
    background-color: var(--card-color-3);
}

.article-card:nth-child(6n+4) {
    background-color: var(--card-color-4);
}

.article-card:nth-child(6n+5) {
    background-color: var(--card-color-5);
}

.article-card:nth-child(6n+6) {
    background-color: var(--card-color-6);
}

.article-card:hover {
    transform: translateY(-8px); /* 增加上浮距离 */
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15), 0 16px 48px rgba(0, 0, 0, 0.12); /* 悬停时更强的阴影 */
}

.article-thumbnail {
    width: 100%;
    height: 220px;
    object-fit: cover;
}

.article-content {
    padding: 20px;
}

.article-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-black);
    margin-bottom: 10px;
    line-height: 1.4;
}

.article-title a {
    color: var(--text-black);
}

.article-title a:hover {
    color: var(--primary-red);
}

.article-excerpt {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 15px;
}

.article-meta {
    font-size: 13px;
    color: #999;
    display: flex;
    gap: 15px;
}

/* ==========================================================================
   产品展示区（仅首页）
   ========================================================================== */
.homepage-products-section {
    padding: 60px 0;
    background-color: #FFFFFF; /* 白色背景 */
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-bottom: 40px;
}

.product-card {
    background-color: var(--white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), 0 4px 16px rgba(0, 0, 0, 0.08); /* 双层阴影增强立体感 */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 商品卡片多彩背景 */
.product-card:nth-child(6n+1) {
    background-color: var(--card-color-1);
}

.product-card:nth-child(6n+2) {
    background-color: var(--card-color-2);
}

.product-card:nth-child(6n+3) {
    background-color: var(--card-color-3);
}

.product-card:nth-child(6n+4) {
    background-color: var(--card-color-4);
}

.product-card:nth-child(6n+5) {
    background-color: var(--card-color-5);
}

.product-card:nth-child(6n+6) {
    background-color: var(--card-color-6);
}

.product-card:hover {
    transform: translateY(-8px); /* 增加上浮距离 */
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15), 0 16px 48px rgba(0, 0, 0, 0.12); /* 悬停时更强的阴影 */
}

.product-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
}

.product-info {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-black);
    margin-bottom: 10px;
    line-height: 1.4;
}

.product-title a {
    color: var(--text-black);
}

.product-title a:hover {
    color: var(--primary-red);
}

.product-price {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-red);
    margin-bottom: 15px;
}

.product-price del {
    font-size: 16px;
    color: #999;
    margin-right: 10px;
}

.add-to-cart-btn {
    margin-top: auto;
    width: 100%;
}

/* ==========================================================================
   页脚
   ========================================================================== */
.site-footer {
    background-color: var(--text-black);
    color: var(--white);
    padding: 30px 0;
    text-align: center;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.footer-site-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--white);
}

.footer-info {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.8;
}

.footer-info a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: underline;
}

.footer-info a:hover {
    color: var(--white);
}

/* ==========================================================================
   响应式设计 - 平板 (768px - 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
    .articles-grid,
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 25px;
    }

    .main-navigation ul {
        gap: 25px;
    }

    .section-title {
        font-size: 28px;
    }
}

/* ==========================================================================
   响应式设计 - 手机 (< 768px)
   ========================================================================== */
@media (max-width: 767px) {
    .site-header {
        height: 60px;
    }

    .header-container {
        height: 60px;
        padding: 0 15px;
    }

    .site-content {
        padding-top: 60px;
    }

    .site-title {
        font-size: 18px;
    }

    .site-logo {
        height: 40px;
    }

    /* 移动端菜单 */
    .mobile-menu-toggle {
        display: block;
    }

    .main-navigation {
        position: fixed;
        top: 60px;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: calc(100vh - 60px);
        background-color: var(--white);
        box-shadow: 2px 0 10px var(--shadow);
        overflow-y: auto;
        transition: left 0.3s ease;
        z-index: 999;
    }

    .main-navigation.active {
        left: 0;
    }

    .main-navigation ul {
        flex-direction: column;
        gap: 0;
        padding: 20px 0;
    }

    .main-navigation li {
        border-bottom: 1px solid var(--light-gray);
    }

    .main-navigation a {
        padding: 15px 20px;
    }

    .main-navigation .sub-menu {
        position: static;
        box-shadow: none;
        background-color: var(--light-gray);
        padding: 0;
    }

    .main-navigation .sub-menu a {
        padding-left: 40px;
    }

    /* 文章和产品网格 */
    .articles-grid,
    .products-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .articles-section,
    .products-section {
        padding: 40px 0;
    }

    .section-title {
        font-size: 24px;
        margin-bottom: 30px;
    }

    .container {
        padding: 0 15px;
    }

    /* 按钮 */
    .btn,
    .button {
        padding: 10px 20px;
        font-size: 14px;
    }

    /* 页脚 */
    .site-footer {
        padding: 25px 0;
    }

    .footer-site-title {
        font-size: 18px;
    }

    .footer-info {
        font-size: 13px;
    }
}

/* ==========================================================================
   手势操作支持
   ========================================================================== */
@media (hover: none) and (pointer: coarse) {
    /* 触摸设备优化 */
    .article-card,
    .product-card {
        -webkit-tap-highlight-color: transparent;
    }

    button,
    a,
    input[type="submit"] {
        -webkit-tap-highlight-color: rgba(231, 76, 60, 0.3);
    }

    /* 增加触摸区域 */
    .main-navigation a,
    .cart-icon,
    .mobile-menu-toggle {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ==========================================================================
   工具类
   ========================================================================== */
.text-center {
    text-align: center;
}

.mt-40 {
    margin-top: 40px;
}

.mb-40 {
    margin-bottom: 40px;
}

.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* ==========================================================================
   WooCommerce通用样式
   ========================================================================== */

/* WooCommerce消息提示 */
.woocommerce-message,
.woocommerce-info,
.woocommerce-error {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 4px;
    border-left: 4px solid;
    font-size: 14px;
    line-height: 1.6;
}

.woocommerce-message {
    background-color: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.woocommerce-info {
    background-color: var(--card-color-3);
    border-color: #ffc107;
    color: #856404;
}

.woocommerce-error {
    background-color: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.woocommerce-message a,
.woocommerce-info a,
.woocommerce-error a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

/* WooCommerce面包屑 */
.woocommerce-breadcrumb {
    font-size: 14px;
    color: #666;
    margin-bottom: 30px;
}

.woocommerce-breadcrumb a {
    color: var(--primary-red);
}

.woocommerce-breadcrumb a:hover {
    text-decoration: underline;
}

/* 星级评分 */
.star-rating {
    position: relative;
    height: 1em;
    line-height: 1;
    font-size: 16px;
    width: 5.4em;
    font-family: star;
    display: inline-block;
}

.star-rating::before {
    content: "\2605\2605\2605\2605\2605";
    color: #e0e0e0;
    float: left;
    top: 0;
    left: 0;
    position: absolute;
}

.star-rating span {
    overflow: hidden;
    float: left;
    top: 0;
    left: 0;
    position: absolute;
    padding-top: 1.5em;
}

.star-rating span::before {
    content: "\2605\2605\2605\2605\2605";
    top: 0;
    position: absolute;
    left: 0;
    color: #FFC107;
}

/* 价格样式 */
.price {
    color: var(--primary-red);
    font-weight: 700;
}

.price ins {
    text-decoration: none;
    color: var(--primary-red);
}

.price del {
    opacity: 0.7;
    color: #999;
}

/* 按钮样式 */
.woocommerce a.button,
.woocommerce button.button,
.woocommerce input.button,
.woocommerce #respond input#submit {
    background-color: var(--primary-red);
    color: var(--white);
    padding: 12px 24px;
    border-radius: 4px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.woocommerce a.button:hover,
.woocommerce button.button:hover,
.woocommerce input.button:hover,
.woocommerce #respond input#submit:hover {
    background-color: var(--hover-red);
    color: var(--white);
}

.woocommerce a.button.alt,
.woocommerce button.button.alt,
.woocommerce input.button.alt {
    background-color: var(--primary-red);
}

.woocommerce a.button.alt:hover,
.woocommerce button.button.alt:hover,
.woocommerce input.button.alt:hover {
    background-color: var(--hover-red);
}

/* 输入框样式 */
.woocommerce input[type="text"],
.woocommerce input[type="email"],
.woocommerce input[type="tel"],
.woocommerce input[type="password"],
.woocommerce input[type="number"],
.woocommerce textarea,
.woocommerce select {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--border-gray);
    border-radius: 4px;
    font-size: 14px;
}

.woocommerce input:focus,
.woocommerce textarea:focus,
.woocommerce select:focus {
    outline: none;
    border-color: var(--primary-red);
}

/* 表格样式 */
.woocommerce table.shop_table {
    border: 1px solid var(--border-gray);
    border-radius: 8px;
    overflow: hidden;
}

.woocommerce table.shop_table th {
    background-color: var(--card-color-1);
    font-weight: 600;
    padding: 15px;
}

.woocommerce table.shop_table td {
    padding: 15px;
    border-top: 1px solid var(--border-gray);
}

/* 加载状态 */
.woocommerce .blockUI.blockOverlay {
    background-color: rgba(255, 255, 255, 0.8) !important;
}

.woocommerce .loader {
    border: 3px solid var(--border-gray);
    border-top: 3px solid var(--primary-red);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

/* 数量选择器通用样式 */
.woocommerce .quantity {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border-gray);
    border-radius: 4px;
    overflow: hidden;
}

.woocommerce .quantity input[type="number"] {
    width: 60px;
    height: 40px;
    border: none;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    -moz-appearance: textfield;
}

.woocommerce .quantity input[type="number"]::-webkit-outer-spin-button,
.woocommerce .quantity input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* "添加到购物车"成功消息 */
.woocommerce-message .button {
    float: right;
    padding: 8px 16px;
    margin-left: 15px;
}

/* 商品标签/徽章 */
.woocommerce span.onsale {
    background-color: var(--primary-red);
    color: var(--white);
    padding: 5px 10px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1;
}

/* 无库存标识 */
.woocommerce .out-of-stock {
    color: #dc3545;
    font-weight: 600;
}

/* 结账页面表单验证 */
.woocommerce form .form-row.woocommerce-invalid input,
.woocommerce form .form-row.woocommerce-invalid select,
.woocommerce form .form-row.woocommerce-invalid textarea {
    border-color: #dc3545;
}

.woocommerce form .form-row.woocommerce-validated input,
.woocommerce form .form-row.woocommerce-validated select,
.woocommerce form .form-row.woocommerce-validated textarea {
    border-color: #28a745;
}

/* 响应式WooCommerce */
@media screen and (max-width: 768px) {
    .woocommerce table.shop_table {
        font-size: 14px;
    }

    .woocommerce table.shop_table td,
    .woocommerce table.shop_table th {
        padding: 10px;
    }

    .woocommerce-message .button {
        float: none;
        display: block;
        margin: 10px 0 0 0;
    }
}
