﻿/* ============================================
   云禾优选 - 首页样式
   依赖：shared/variables.css
   ============================================ */

/* ========== CSS变量 ========== */
:root {
    --shop-primary-color: #b8860b;
    --shop-bg-gradient: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
}

/* ========== 顶部固定区域 ========== */
.shop-header {
    width: 100%;
    z-index: 1010;
    display: block;
    box-sizing: border-box;
    background-color: #e8f5e9;
    background: var(--shop-bg-gradient);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.shop-header .header-top {
    display: -webkit-flex;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
}

.shop-header .header-title {
    font-weight: 700;
    font-size: 1rem;
    color: #1a1a1a;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.shop-header .header-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    font-size: 1.1rem;
    text-decoration: none;
}

.shop-header .placeholder-btn {
    width: 36px;
    height: 36px;
}

.shop-header .category-nav {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.shop-header .category-tabs {
    display: -webkit-flex;
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    gap: 8px;
    margin: 0 -4px;
    padding: 10px 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-behavior: smooth;
}

.shop-header .category-tabs::-webkit-scrollbar {
    display: none;
}

.shop-header .sub-tabs {
    padding-top: 8px;
    padding-bottom: 10px;
    border-top: 1px solid #f0f0f0;
    background: #fff;
}

@supports (backdrop-filter: blur(5px)) {
    .shop-header .sub-tabs {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(5px);
    }
}

.shop-header .category-tab {
    flex-shrink: 0;
    margin: 0 4px;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid transparent;
    background: transparent;
    color: #888;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.shop-header .category-tab:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #666;
}

.shop-header .category-tab:active {
    transform: scale(0.95);
    transition-duration: 0.1s;
}

.shop-header .category-tab.active {
    color: var(--shop-primary-color);
    font-weight: 600;
    background: #fffdf5;
    border-color: #f0d060;
    box-shadow: 0 2px 8px rgba(240, 208, 96, 0.2);
    transform: translateY(-1px);
}

.shop-header .sub-tabs .category-tab {
    font-size: 0.78rem;
    padding: 4px 14px;
    transition: all 0.2s ease;
}

.shop-header .sub-tabs .category-tab.active {
    background: #fff8e1;
    border-color: #ffd54f;
    box-shadow: 0 1px 4px rgba(255, 213, 79, 0.3);
}

.header-search-inline {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 16px;
    padding: 0 8px;
    margin-left: auto;
    flex-shrink: 0;
}
.header-search-inline input {
    width: 70px;
    border: none;
    outline: none;
    font-size: 0.75rem;
    padding: 5px 4px;
    background: transparent;
}
.header-search-inline button {
    border: none;
    background: none;
    color: #999;
    padding: 2px;
    cursor: pointer;
}

.farm-search {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 25px;
    padding: 0 12px;
    width: 60%;
    border: 1px solid #e0e0e0;
}
.farm-search input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.8rem;
    padding: 8px 6px;
    background: transparent;
}
.farm-search button {
    border: none;
    background: #198754;
    color: #fff;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* 移动端优化 */
@media (max-width: 768px) {
    .shop-header .category-tabs {
        padding: 8px 12px;
        gap: 6px;
    }

    .shop-header .category-tab {
        padding: 6px 12px;
        font-size: 0.82rem;
    }

    .shop-header .sub-tabs .category-tab {
        padding: 4px 10px;
        font-size: 0.75rem;
    }
}

/* ========== 页面容器 ========== */
.shop-page {
    padding-bottom: calc(var(--bottom-bar-height) + 10px);
    padding-top: 0;
    margin-top: 0;
    background: var(--color-bg);
    min-height: 100vh;
}

/* ========== 产品网格 ========== */
.shop-page .product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding: var(--spacing-md);
    padding-bottom: 80px; 
}

@media (min-width: 768px) {
    .shop-page .product-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--spacing-lg);
        padding: var(--spacing-lg);
    }
}

/* ========== 产品卡片 ========== */
.shop-page .product-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
}

.shop-page .product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.shop-page .product-card .card-img-link {
    display: block;
    cursor: pointer;
}

.shop-page .product-card .card-img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: linear-gradient(110deg, #f0f7f3 8%, #e5f0eb 18%, #f0f7f3 33%);
    background-size: 200% 100%;
    animation: 1.5s shine linear infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

@keyframes shine {
    to {
        background-position-x: -200%;
    }
}

.shop-page .product-card .card-img[src] {
    animation: none;
    background: #f0f7f3;
}

.shop-page .product-card .card-body {
    padding: 10px 12px 36px 12px;
}

.shop-page .product-card .product-name {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-primary);
    line-height: 1.3;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.shop-page .product-card .price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.shop-page .product-card .product-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: #dc3545;
}

.shop-page .product-card .product-price .unit {
    font-size: 0.7rem;
    font-weight: 400;
    color: #999;
}

.shop-page .product-card .product-sub-price {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* 农场链接 */
.farm-link {
    font-size: 0.75rem;
    color: #2d6a4f;
    text-decoration: none;
    display: flex;
    align-items: center;
    margin-top: 4px;
}

.farm-link:hover {
    text-decoration: underline;
}

/* 购物车按钮 */
.shop-page .product-card .cart-icon {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #2d6a4f;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    cursor: pointer;
    z-index: 2;
    border: none;
    transition: background 0.2s, transform 0.2s;
}

.shop-page .product-card .cart-icon:hover {
    background: #1b4332;
    transform: scale(1.1);
}

.shop-page .product-card .cart-icon.loading {
    background: #6c757d;
    pointer-events: none;
}

.shop-page .product-card .cart-icon.loading i {
    animation: spin 0.8s linear infinite;
}

.shop-page .product-card .cart-icon.success {
    background: #28a745;
    transform: scale(1.1);
}

.shop-page .product-card .cart-icon.added {
    animation: pulse 0.5s ease;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(40, 167, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}

.shop-page .product-card .badge-tag {
    display: none;
}

/* ========== 产品状态标签 ========== */
.product-status-tag {
    display: inline-block;
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 4px;
    font-weight: 500;
}

.product-status-tag.on-sale {
    background: #e8f5e9;
    color: #2d6a4f;
}

.product-status-tag.growing {
    background: #fff3e0;
    color: #e65100;
}

/* 生产中产品卡片微调 */
.product-card.growing .card-img {
    opacity: 0.9;
}

/* ========== 生长阶段进度条 ========== */
.stage-progress-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    margin: 4px 0;
    font-size: 0.6rem;
    color: #999;
}

.stage-progress-bar .stage-step {
    white-space: nowrap;
    color: #bbb;
}

.stage-progress-bar .stage-step.current {
    color: #e65100;
    font-weight: 600;
}

.stage-progress-bar .stage-arrow {
    color: #ddd;
    margin: 0 1px;
}

/* ========== 标签徽章 ========== */
.badge-featured {
    background: #fff3e0;
    color: #e65100;
}

.badge-organic {
    background: #e8f5e9;
    color: #2d6a4f;
}

/* ========== _Header 默认顶部样式 ========== */
.consumer-header.simple-header {
    display: -webkit-flex;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.consumer-header .back-btn,
.consumer-header .placeholder-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    font-size: 1.1rem;
    text-decoration: none;
}

.consumer-header .header-title {
    font-weight: 700;
    font-size: 1rem;
    color: #1a1a1a;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========== 底部搜索 ========== */
.shop-search-bar {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    padding: 10px 16px;
    background: transparent;
    z-index: 999;
}
.shop-search-bar form {
    display: flex;
    background: #fff;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}
.shop-search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 20px;
    font-size: 0.9rem;
    outline: none;
}
.shop-search-bar button {
    border: none;
    background: #198754;
    color: #fff;
    padding: 0 20px;
    cursor: pointer;
    border-radius: 0 24px 24px 0;
}

/* ========== 底部导航栏 ========== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #ffffff;
    border-top: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 4px 8px;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
    height: 52px;
}

.bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #b0b0b0;
    font-size: 0.78rem;
    padding: 2px 10px;
    transition: color 0.2s;
    min-width: 48px;
    gap: 2px;
    position: relative;
}

.bottom-nav .nav-item i {
    font-size: 1.4rem;
    -webkit-text-stroke: 1px #b0b0b0;
    color: transparent;
    transition: all 0.2s;
}

.bottom-nav .nav-item.active {
    color: #2d6a4f;
    font-weight: 600;
}

.bottom-nav .nav-item.active i {
    -webkit-text-stroke: 1px #2d6a4f;
    color: transparent;
}

/* ========== 购物车角标 ========== */
.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    font-size: 0.65rem;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    font-weight: 700;
    border: 2px solid #fff;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    white-space: nowrap;
    animation: badgeBounce 0.3s ease;
}

@keyframes badgeBounce {
    0% { transform: scale(0.5); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ========== Toast 提示 ========== */
.toast-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #2d6a4f;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 90%;
    text-align: center;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.1);
}

.toast-notification.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.toast-notification.hide {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-20px);
}

.toast-notification.success {
    background: #2d6a4f;
    border-left: 4px solid #1b4332;
}

.toast-notification.error {
    background: #dc3545;
    border-left: 4px solid #c82333;
}

.toast-notification.info {
    background: #17a2b8;
    border-left: 4px solid #138496;
}

.toast-icon {
    font-size: 1.2rem;
}

/* ========== 空状态 ========== */
.shop-page .empty-state {
    text-align: center;
    padding: var(--spacing-8) 0;
    color: var(--color-text-muted);
}

.shop-page .empty-state i {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    display: block;
    opacity: 0.3;
}

/* ========== 可访问性 ========== */
@media (prefers-reduced-motion: reduce) {
    .cart-badge,
    .toast-notification,
    .shop-page .product-card,
    .shop-page .product-card .cart-icon {
        animation: none !important;
        transition: none !important;
    }

    .shop-header .category-tab,
    .shop-header .category-tab.active {
        transition: none;
    }
}

/* ========== 移动端调整 ========== */
@media (max-width: 768px) {
    .toast-notification {
        top: 10px;
        padding: 10px 16px;
        font-size: 0.9rem;
        max-width: calc(100% - 20px);
    }

    .cart-badge {
        top: -4px;
        right: -2px;
        min-width: 16px;
        height: 16px;
        font-size: 0.6rem;
    }
}

/* ========== 打印样式 ========== */
@media print {
    .shop-header,
    .bottom-nav {
        display: none;
    }

    .shop-page {
        padding: 0;
        margin: 0;
    }  /* ✅ 添加这个闭合大括号 */
}  /* ✅ 添加这个闭合大括号 */

/* ========== 滚动优化 ========== */
/* 确保main可以滚动 */
main {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 100vh;
}

/* 平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* 防止页面跳动 */
body {
    overflow-x: hidden;
}

/* 移动端优化 */
@media (max-width: 768px) {
    main {
        padding-top: 0; /* JS会动态设置 */
    }
    
    .shop-page {
        margin-top: 0; /* JS会动态设置 */
    }

/* 修复底部导航遮挡 */
.shop-page {
    padding-bottom: 80px !important;
  }

}
