/* ================================================
   Index.cshtml - 首頁樣式
   ================================================ */

/* ========================================
   輪播圖區域
   ======================================== */

/* 輪播圖外層容器 - 全寬顯示 */
.hero-section-wrapper {
    width: 100%;
    margin: 0;
    padding: 0;
}

/* Hero Banner 輪播樣式 */
.hero-carousel {
    position: relative;
    width: 100%;
    height: 480px; /* 配合網頁版圖片尺寸 1920x480 */
    margin: 0;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 根據視窗寬度動態調整高度，保持圖片比例 */
@media (min-width: 1920px) {
    .hero-carousel {
        height: 480px; /* 1920x480 = 4:1 比例 */
    }
}

@media (min-width: 1200px) and (max-width: 1919px) {
    .hero-carousel {
        height: calc(100vw / 4); /* 維持 4:1 比例 */
        max-height: 480px;
    }
}

@media (min-width: 769px) and (max-width: 1199px) {
    .hero-carousel {
        height: calc(100vw / 4); /* 維持 4:1 比例 */
        min-height: 300px;
    }
}

.hero-banner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    padding: 60px 40px;
    text-align: center;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    z-index: 1;
    overflow: hidden;
}

.hero-banner.active {
    opacity: 1;
    z-index: 2;
}

/* Banner 圖片容器 */
.banner-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
}

/* 添加遮罩層確保文字可讀性 */
.hero-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.hero-banner h2,
.hero-banner p {
    position: relative;
    z-index: 2;
}

.hero-banner h2 {
    font-size: 36px;
    margin-bottom: 15px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.hero-banner p {
    font-size: 18px;
    margin-bottom: 0;
    opacity: 0.95;
}

/* ========================================
   輪播指示器
   ======================================== */
.carousel-indicators {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}

.carousel-indicators .indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    cursor: pointer;
    transition: background 0.3s, transform 0.3s;
}

.carousel-indicators .indicator.active {
    background: white;
    transform: scale(1.2);
}

.carousel-indicators .indicator:hover {
    background: rgba(255,255,255,0.8);
}

/* ========================================
   內容載入狀態控制
   ======================================== */

/* 防止資料載入前的內容閃現 */
/* 在頁面載入完成前，隱藏可能閃現的內容 */
.category-grid,
.product-grid {
    opacity: 0;
    transition: opacity 0.4s ease-in;
}

/* 當資料載入完成後，JavaScript 會添加 'data-loaded' 屬性 */
.category-grid[data-loaded="true"],
.product-grid[data-loaded="true"] {
    opacity: 1;
}

/* 載入中的訊息保持可見 */
.loading-categories,
.loading-products {
    opacity: 1 !important;
}

/* 確保容器在載入時有最小高度，避免版面跳動 */
.category-grid {
    min-height: 150px;
}

.product-grid {
    min-height: 300px;
}

/* ========================================
   分類卡片樣式
   ======================================== */
.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15) !important;
}

/* ========================================
   商品卡片樣式
   ======================================== */
.product-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%; /* 確保連結填滿 grid 項目 */
}

.product-card-link:hover .product-card {
    transform: translateY(-8px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15) !important;
}

.product-card {
    height: 100%; /* 確保卡片填滿連結 */
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15) !important;
}

.product-card button:hover {
    background: var(--primary-hover) !important;
}

/* 確保商品卡片按鈕固定在底部 */
.product-card .product-info {
    display: flex;
    flex-direction: column;
}

.product-card .btn-add-to-cart {
    margin-top: auto; /* 將按鈕推到底部 */
}

/* ========================================
   精選商品區域
   ======================================== */
.featured-section {
    margin: 60px 0;
}

.featured-section h2 {
    font-size: 28px;
    margin-bottom: 30px;
    text-align: center;
}

.featured-section .product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
    align-items: stretch;
}

.featured-section .loading-products {
    text-align: center;
    padding: 40px;
    color: var(--text-tertiary);
}

.featured-section .loading-products i {
    font-size: 24px;
    margin-bottom: 10px;
}

/* ========================================
   公告跑馬燈（預設隱藏，僅手機版顯示）
   ======================================== */
.announcement-bar {
    display: none;
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    background-color: #fffdec96;
}

.announcement-content {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    gap: 12px;
}

.announcement-icon {
    color: white;
    font-size: 16px;
    flex-shrink: 0;
    opacity: 0.95;
}

.announcement-scroll {
    flex: 1;
    overflow: hidden;
    position: relative;
    height: 20px;
}

.announcement-text {
    color: black;
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    white-space: nowrap;
    display: block;
    text-align: center;
    transition: opacity 0.3s ease;
}

/* ========================================
   響應式設計 - 手機版
   ======================================== */
@media (max-width: 768px) {
    /* 手機版顯示公告跑馬燈 */
    .announcement-bar {
        display: block;
    }

    .hero-carousel {
        height: calc(100vw / 2); /* 手機版 1200x600 = 2:1 比例 */
        max-height: 600px;
        min-height: calc(100vw / 2); /* 改為動態計算，保持 2:1 比例 */
        margin: 0; /* 手機版也全寬 */
    }
    
    /* 手機版輪播圖片完整顯示 */
    .hero-carousel .banner-image {
        background-size: cover !important;
        background-color: #000; /* 添加黑色背景避免空白 */
    }
    
    .hero-banner {
        padding: 30px 20px !important;
    }

    .hero-banner h2 {
        font-size: 24px !important;
    }

    .hero-banner p {
        font-size: 14px !important;
    }
    
    .carousel-indicators {
        bottom: 15px;
    }
    
    .carousel-indicators .indicator {
        width: 8px;
        height: 8px;
    }

    .category-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
    }

    .product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }
}
