/* ================================================
   Index.cshtml - 首頁樣式
   預設：Web 四欄網格 / Mobile 雙欄（classic-grid + grid-2col）
   其他版型由 ui-layout.css 依 html[data-ui-*] 覆寫
   ================================================ */

/* ── 輪播 ── */
.hero-section-wrapper {
    width: 100%;
    margin: 0;
    padding: 0;
}

.hero-carousel {
    position: relative;
    width: 100%;
    height: 480px;
    margin: 0;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

@media (min-width: 1920px) {
    .hero-carousel { height: 480px; }
}

@media (min-width: 1200px) and (max-width: 1919px) {
    .hero-carousel {
        height: calc(100vw / 4);
        max-height: 480px;
    }
}

@media (min-width: 769px) and (max-width: 1199px) {
    .hero-carousel {
        height: calc(100vw / 4);
        min-height: 300px;
    }
}

.hero-banner {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    z-index: 1;
}

.hero-banner.active {
    opacity: 1;
    z-index: 2;
}

.banner-image {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
}

.carousel-indicators {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}

.carousel-indicators .indicator {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    transition: background 0.3s, width 0.3s;
}

.carousel-indicators .indicator.active {
    background: #fff;
    width: 56px;
}

/* ── 載入狀態 ── */
.product-grid {
    opacity: 0;
    transition: opacity 0.4s ease-in;
}

.product-grid[data-loaded="true"] {
    opacity: 1;
}

.loading-products {
    opacity: 1 !important;
    text-align: center;
    padding: 48px;
    color: var(--text-tertiary);
}

.loading-products i {
    font-size: 28px;
    margin-bottom: 12px;
    display: block;
    color: var(--primary-color);
}

/* ── Web 預設：四欄網格（classic-grid） ── */
@media (min-width: 769px) {
    .home-page {
        max-width: 1280px;
    }

    .featured-section {
        margin: 56px 0 80px;
        padding: 0 8px;
    }

    .section-header {
        display: flex;
        align-items: flex-end;
        justify-content: space-between;
        margin-bottom: 36px;
        padding-bottom: 20px;
        border-bottom: 2px solid var(--primary-color, #2e7d32);
    }

    .section-eyebrow--mobile,
    .section-subtitle--web {
        display: none;
    }

    .section-title {
        font-size: 32px;
        font-weight: 700;
        margin: 0;
        color: var(--text-primary, #1a1a1a);
        letter-spacing: -0.02em;
    }

    .section-badge--web {
        display: inline-block;
        padding: 6px 16px;
        background: var(--bg-primary-lightest, #e8f5e9);
        color: var(--primary-color);
        font-size: 12px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        border-radius: 4px;
    }

    .product-grid-wrapper {
        background: #fafafa;
        border-radius: 12px;
        padding: 28px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    }

    .home-page .product-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 24px;
        align-items: stretch;
        min-height: 320px;
    }

    .product-grid .product-card-shell {
        border-radius: 10px;
        border: 1px solid #eee;
        transition: transform 0.25s ease, box-shadow 0.25s ease;
    }

    .product-grid .product-card-shell:hover {
        transform: translateY(-6px);
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12) !important;
    }

    .announcement-bar {
        display: none !important;
    }
}

/* ── 手機預設：雙欄網格（grid-2col） ── */
@media (max-width: 768px) {
    .hero-section-wrapper {
        padding: 12px 12px 0;
    }

    .hero-carousel {
        height: calc((100vw - 24px) / 2);
        max-height: 220px;
        border-radius: 16px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    }

    .carousel-indicators {
        bottom: 12px;
    }

    .carousel-indicators .indicator {
        width: 8px;
        height: 8px;
        border-radius: 50%;
    }

    .carousel-indicators .indicator.active {
        width: 8px;
        transform: scale(1.25);
    }

    .announcement-bar {
        display: block;
        margin: 0 12px;
        border-radius: 999px;
        background: linear-gradient(90deg, #fff8e1, #fffdec);
        border: 1px solid rgba(0, 0, 0, 0.06);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    }

    .announcement-content {
        padding: 8px 14px;
    }

    .announcement-icon {
        color: var(--primary-color);
        font-size: 14px;
    }

    .announcement-text {
        font-size: 13px;
        color: #333;
    }

    .featured-section {
        margin: 20px 0 32px;
        padding: 0 4px;
    }

    .section-header {
        text-align: center;
        margin-bottom: 16px;
    }

    .section-eyebrow--mobile {
        display: inline-block;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        color: var(--primary-color);
        background: var(--bg-primary-lightest, #e8f5e9);
        padding: 4px 12px;
        border-radius: 999px;
        margin-bottom: 8px;
    }

    .section-title {
        font-size: 20px;
        font-weight: 700;
        margin: 0;
    }

    .section-subtitle--web,
    .section-badge--web {
        display: none !important;
    }

    .home-page .product-grid-wrapper {
        padding: 0 8px;
    }

    /* 模板1 預設：雙欄直向網格 */
    html[data-ui-home-mobile="grid-2col"] .home-page .product-grid,
    html:not([data-ui-home-mobile]) .home-page .product-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
        min-height: 280px;
    }

    /* 模板 horizontal-rail：全寬橫向滑動軌道 */
    html[data-ui-home-mobile="horizontal-rail"] .home-page .product-grid-wrapper {
        width: 100vw;
        max-width: 100vw;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        touch-action: pan-x pan-y;
        overscroll-behavior-x: contain;
        padding: 4px 12px 16px;
        scrollbar-width: none;
        cursor: grab;
    }

    html[data-ui-home-mobile="horizontal-rail"] .home-page .product-grid-wrapper.is-dragging {
        cursor: grabbing;
        scroll-snap-type: none;
        user-select: none;
    }

    html[data-ui-home-mobile="horizontal-rail"] .home-page .product-grid-wrapper.is-dragging .product-card-link {
        pointer-events: none;
    }

    html[data-ui-home-mobile="horizontal-rail"] .home-page .product-grid-wrapper.is-dragging .btn-add-to-cart {
        pointer-events: auto;
    }

    html[data-ui-home-mobile="horizontal-rail"] .home-page .product-grid-wrapper::-webkit-scrollbar {
        display: none;
    }

    html[data-ui-home-mobile="horizontal-rail"] .home-page .product-grid {
        display: flex;
        flex-wrap: nowrap;
        align-items: stretch;
        width: max-content;
        min-width: 100%;
        gap: 14px;
        overflow: visible;
        min-height: 280px;
        padding: 0;
    }

    html[data-ui-home-mobile="horizontal-rail"] .home-page .product-grid > .product-card-shell {
        flex: 0 0 auto;
        flex-shrink: 0;
        width: 42vw;
        max-width: 180px;
        min-width: 140px;
        scroll-snap-align: start;
    }

    html[data-ui-home-mobile="horizontal-rail"] .home-page .product-grid .product-card {
        border-radius: 14px !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08) !important;
    }
}

/* ── 共用商品卡 ── */
.product-card-shell {
    height: 100%;
}

.product-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.product-card {
    height: 100%;
}

.product-card .product-info {
    display: flex;
    flex-direction: column;
}

.product-card .btn-add-to-cart {
    margin-top: auto;
}

/* ── 商品来源标签（固定显示） ── */
.product-card .product-image .product-tags {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    pointer-events: none;
}

.origin-tag,
.product-card .product-tag--promo {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    line-height: 1.2;
}

.origin-tag.overseas {
    background: #eddaf1;
    color: #9C27B0;
}

.origin-tag.domestic {
    background: var(--bg-primary-lightest, #e8f5e9);
    color: var(--primary-color, #2e7d32);
}

.product-tag--promo {
    background: #FF5722;
    color: #fff;
}

.product-card .product-card-action-btn:hover,
.product-card .btn-view-product:hover,
.btn-add-to-cart:hover {
    background-color: var(--checkout-primary-dark) !important;
    color: #e8f5e9 !important;
}

.no-products,
.home-error-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
    grid-column: 1 / -1;
}

.home-error-icon {
    font-size: 48px;
    margin-bottom: 15px;
    color: #ff9800;
    display: block;
}
