/*
    SEHS3245 Web Systems and Technologies Project
    Otaku 網上公仔商店 - 主要樣式表
    
    作者: [學生姓名]
    學號: [學生學號]
    創建日期: 2025年11月17日
    
    檔案描述:
    - 這個 CSS 檔案包含所有購物頁面的樣式
    - 使用 CSS3 特性如漸層、動畫、陰影等
    - 采用響應式設計支持手機、平板、桌面裝置
    - 使用 Grid 和 Flexbox 進行版面配置
    
    樣式組織:
    1. 基本設定
    2. 導航列樣式
    3. 主要內容區
    4. 商品展示網格
    5. 商品資訊樣式
    6. 商品操作區
    7. 頁面導航
    8. 頁腳樣式
    9. 響應式設計
    10. 動畫效果
*/

/* ===== 1. 基本設定 ===== */
/* 重設所有元素的預設樣式，確保一致性 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft JhengHei', 'PingFang TC', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #2e7d32;
    background: linear-gradient(135deg, #f8f9fa 0%, #e8f5e8 50%, #ffebee 100%);
    background-attachment: fixed;
    position: relative;
    overflow-x: hidden;
}

/* 聖誕節雪花動畫背景 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 100px 50px, #fff, transparent),
        radial-gradient(2px 2px at 200px 150px, #fff, transparent),
        radial-gradient(1px 1px at 300px 250px, #fff, transparent),
        radial-gradient(1px 1px at 400px 350px, #fff, transparent),
        radial-gradient(2px 2px at 500px 450px, #fff, transparent);
    background-size: 600px 600px;
    animation: snowfall 15s linear infinite;
    opacity: 0.6;
    pointer-events: none;
    z-index: 1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== 2. 導航列樣式 ===== */
/* 頂部導航列：使用聖誕節紅綠漸層背景和粘性定位 */
.navbar {
    background: linear-gradient(135deg, #d32f2f 0%, #1b5e20 50%, #d32f2f 100%); /* 聖誕節紅綠漸層背景 */
    box-shadow: 0 2px 15px rgba(211, 47, 47, 0.3); /* 紅色陰影效果 */
    position: sticky; /* 粘性定位，滾動時始終顯示在頂部 */
    top: 0;
    z-index: 1000; /* 確保在最頂層 */
    border-bottom: 3px solid #ffd700; /* 金色底邊 */
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    max-width: 1200px;
    margin: 0 auto;
    padding-left: 20px;
    padding-right: 20px;
    position: relative;
}

.logo a {
    color: #ffd700;
    text-decoration: none;
    font-size: 1.8rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    position: relative;
}

.logo a::before {
    content: '🎄 ';
    font-size: 1.2em;
}

.logo a::after {
    content: ' 🎅';
    font-size: 1.2em;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
    justify-content: flex-end;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.cart-link {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

#cart-count {
    background: #ff4757;
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.8rem;
    margin-left: 5px;
}

/* ===== 主要內容 ===== */
.main-content {
    min-height: calc(100vh - 120px);
    padding: 2rem 0;
}

.page-header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.page-header h1 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 2.5rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-header p {
    color: #666;
    font-size: 1.1rem;
}

/* ===== 4. 商品展示網格 ===== */
/* 使用 CSS Grid 創建響應式的商品展示網格 */
.product-grid {
    display: grid; /* 使用 Grid 布局 */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* 自適應欄位，最小寬度280px */
    gap: 2rem; /* 網格間距 */
    margin-bottom: 3rem; /* 底部間距 */
}

/* 商品卡片容器：白色背景，圓角設計，陰影效果 */
.product-card {
    background: white; /* 白色背景 */
    border-radius: 15px; /* 圓角設計 */
    overflow: hidden; /* 隐藏超出內容 */
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1); /* 陰影效果 */
    transition: all 0.3s ease; /* 平滑轉場動畫 */
    position: relative; /* 相對定位，方便子元素絕對定位 */
}

.product-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

.product-image {
    position: relative;
    overflow: hidden;
    height: 250px;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.product-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    color: white;
    z-index: 10;
}

.product-badge:not([class*=" "]):not([class$=" "]) {
    background: #ff6b6b;
}

.product-badge.new {
    background: #4ecdc4;
}

.product-badge.limited {
    background: #ff9ff3;
}

.product-badge.exclusive {
    background: #ffd93d;
    color: #333;
}

.product-badge.anniversary {
    background: #6c5ce7;
}

.product-badge.set {
    background: #a29bfe;
}

.product-badge.memorial {
    background: #fd79a8;
}

/* ===== 商品資訊 ===== */
.product-info {
    padding: 1.5rem;
}

.product-name {
    color: #2c3e50;
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
}

.product-description {
    color: #666;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.product-price {
    margin-bottom: 1rem;
}

.current-price {
    font-size: 1.3rem;
    font-weight: bold;
    color: #e74c3c;
}

.original-price {
    font-size: 1rem;
    color: #999;
    text-decoration: line-through;
    margin-left: 10px;
}

.stock-info {
    margin-bottom: 1rem;
}

.stock-count {
    font-size: 0.9rem;
    color: #e67e22;
    font-weight: 500;
}

/* ===== 商品操作區 ===== */
.product-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.quantity-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quantity-selector label {
    font-weight: 500;
    color: #555;
}

.quantity-select {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.quantity-select:focus {
    outline: none;
    border-color: #667eea;
}

.add-to-cart-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.add-to-cart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.add-to-cart-btn:active {
    transform: translateY(0);
}

/* ===== 限定商品說明 ===== */
.limited-notice {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    margin-bottom: 3rem;
    border-left: 5px solid #ff9ff3;
}

.limited-notice h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.limited-notice ul {
    list-style: none;
    padding-left: 0;
}

.limited-notice li {
    padding: 0.5rem 0;
    color: #666;
    position: relative;
    padding-left: 20px;
}

.limited-notice li:before {
    content: "•";
    color: #ff9ff3;
    font-weight: bold;
    position: absolute;
    left: 0;
}

/* ===== 頁面導航 ===== */
.page-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 3rem 0;
    gap: 1rem;
}

.nav-btn {
    display: inline-block;
    padding: 12px 24px;
    background: white;
    color: #667eea;
    text-decoration: none;
    border-radius: 25px;
    border: 2px solid #667eea;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
    min-width: 180px;
}

.nav-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.checkout-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    border: none;
}

.checkout-btn:hover {
    background: linear-gradient(135deg, #ee5a24 0%, #ff6b6b 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(238, 90, 36, 0.4);
}

/* ===== 頁腳 ===== */
.footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

/* ===== 9. 響應式設計 ===== */
/* 平板和手機裝置的樣式調整 */
/* 螢幕寬度小於等於 768px 時的樣式 (平板直向模式和手機) */
@media (max-width: 768px) {
    /* 導航列調整為垂直排列 */
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-menu {
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 1rem;
        align-items: center;
    }

    .page-header h1 {
        font-size: 2rem;
    }

    .product-grid {
        grid-template-columns: 1fr;
    }

    .page-navigation {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .product-info {
        padding: 1rem;
    }

    .page-header {
        padding: 1.5rem 1rem;
    }

    .page-header h1 {
        font-size: 1.8rem;
    }
}

/* ===== 10. 動畫效果 ===== */
/* 從下到上淡入動畫，用於元素載入 */
@keyframes fadeInUp {
    from {
        opacity: 0; /* 初始透明度為0 */
        transform: translateY(30px); /* 初始位置向下偏移30px */
    }
    to {
        opacity: 1; /* 最終透明度為1 */
        transform: translateY(0); /* 最終位置在原位 */
    }
}

.product-card {
    animation: fadeInUp 0.6s ease forwards;
}

.product-card:nth-child(1) { animation-delay: 0.1s; }
.product-card:nth-child(2) { animation-delay: 0.2s; }
.product-card:nth-child(3) { animation-delay: 0.3s; }
.product-card:nth-child(4) { animation-delay: 0.4s; }
.product-card:nth-child(5) { animation-delay: 0.5s; }

/* ===== 載入狀態 ===== */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading .add-to-cart-btn {
    background: #ccc;
    cursor: not-allowed;
}

/* ===== 成功訊息 ===== */
.success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #2ecc71;
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(46, 204, 113, 0.3);
    z-index: 2000;
    animation: slideInRight 0.5s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== 聖誕節特效動畫 ===== */
@keyframes snowfall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
    }
}

@keyframes christmasGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    }
    50% {
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 0 40px rgba(211, 47, 47, 0.3);
    }
}

@keyframes jingleBell {
    0%, 100% {
        transform: rotate(-5deg);
    }
    50% {
        transform: rotate(5deg);
    }
}

/* ===== 聖誕節商品卡片樣式 ===== */
.product-card {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.product-card::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #d32f2f, #ffd700, #1b5e20, #d32f2f);
    border-radius: 22px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-card:hover::before {
    opacity: 1;
    animation: christmasGlow 2s ease-in-out infinite;
}

.product-card:hover {
    transform: translateY(-10px) scale(1.02);
}

/* 聖誕節商品徽章樣式 */
.product-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    z-index: 10;
    animation: jingleBell 2s ease-in-out infinite;
}

.product-badge:before {
    content: '🎄 ';
}

.product-badge:after {
    content: ' ✨';
}

/* ===== 聖誕節頁面標題樣式 ===== */
.page-header {
    text-align: center;
    margin: 3rem 0;
    padding: 2rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.7));
    border-radius: 20px;
    border: 3px solid #d32f2f;
    position: relative;
    overflow: hidden;
}

.page-header h1 {
    font-size: 2.5rem;
    color: #d32f2f;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.page-header p {
    font-size: 1.1rem;
    color: #1b5e20;
}

/* 聖誕節按鈕和價格樣式 */
.add-to-cart-btn {
    background: linear-gradient(45deg, #d32f2f, #1b5e20);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.add-to-cart-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(211, 47, 47, 0.4);
}

.current-price {
    color: #d32f2f;
    font-size: 1.4rem;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

/* 聖誕節頁腳樣式 */
.footer {
    background: linear-gradient(135deg, #1b5e20, #388e3c);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
    border-top: 3px solid #ffd700;
}