/* =========================================
   KAY Studio 線上購物 | 核心樣式表 (style.css)
   開發維護：KAY Studio
========================================= */

/* --- 1. 全域變數與基礎重置 --- */
:root { 
    --primary: #2c3e50; 
    --accent: #3498db;     /* 統一品牌藍色 */
    --accent-hover: #2980b9;
    --warning: #f39c12;    /* 原本的橘色作為輔助/警告色 */
    --success: #27ae60; 
    --success-hover: #219a52;
    --danger: #e74c3c; 
    --danger-hover: #c0392b;
    --bg-color: #f4f7f9; 
    --text-main: #2c3e50;
    --text-muted: #7f8c8d;
    --border-color: #eeeeee;
    --radius: 12px;        /* 稍微加圓，更有現代感 */
    --shadow: 0 4px 15px rgba(0,0,0,0.05);
    --shadow-hover: 0 8px 25px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body { 
    font-family: "PingFang TC", "Heiti TC", "Microsoft JhengHei", sans-serif; 
    margin: 0; 
    padding: 0; 
    background-color: var(--bg-color); 
    color: var(--text-main); 
    line-height: 1.6; 
    overflow-x: hidden; /* 防止手機版意外溢出 */
}

a { 
    text-decoration: none; 
    color: inherit; 
    transition: 0.3s; 
}

/* =========================================
   2. 頂部導覽列 (Header & Nav) - 💡跑版修復區
========================================= */
header {
    background-color: white;
    padding: 15px 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-wrap: nowrap; /* 強制不換行，避免跑版 */
}

.logo {
    font-size: 24px;
    font-weight: 900;
    color: var(--primary);
    white-space: nowrap;
}

/* 搜尋框容器 */
.search-bar {
    flex: 1;
    max-width: 400px;
    margin: 0 30px;
    display: flex;
}

.search-bar form {
    display: flex;
    width: 100%;
}

.search-bar input {
    width: 100%;
    padding: 8px 15px;
    border: 1px solid #ddd;
    border-radius: 20px 0 0 20px;
    outline: none;
    font-size: 14px;
}

.search-bar input:focus { border-color: var(--accent); }

.search-bar button {
    padding: 8px 20px;
    background: var(--warning);
    color: white;
    border: none;
    border-radius: 0 20px 20px 0;
    cursor: pointer;
    font-weight: bold;
}

/* 使用者功能區 */
.user-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 14px;
    color: var(--text-main);
}

.user-actions a:hover { color: var(--accent); }

/* 下方選單列 */
nav {
    background-color: var(--primary);
    padding: 12px 5%;
    display: flex;
    flex-direction: row; /* 強制橫向排列 */
    justify-content: flex-start;
    gap: 25px;
    overflow-x: auto; /* 項目過多時允許左右滑動 */
    white-space: nowrap;
    scrollbar-width: none; /* 隱藏 Firefox 捲軸 */
}
nav::-webkit-scrollbar { display: none; /* 隱藏 Chrome 捲軸 */ }

nav a {
    color: #ecf0f1;
    font-size: 14px;
    font-weight: bold;
    opacity: 0.9;
}

nav a:hover {
    opacity: 1;
    color: var(--accent);
}

/* =========================================
   3. 佈局容器與標題
========================================= */
.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 30px 20px 60px; 
}

.section-title { 
    border-left: 5px solid var(--accent); 
    padding-left: 15px; 
    margin: 40px 0 25px 0; 
    font-size: 24px; 
    font-weight: 800;
    color: var(--primary);
}

/* =========================================
   4. 商品卡片與網格
========================================= */
.product-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); 
    gap: 25px; 
}

.product-card { 
    background: white; 
    border-radius: var(--radius); 
    overflow: hidden; 
    box-shadow: var(--shadow); 
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s; 
    display: flex; 
    flex-direction: column; 
    border: 1px solid rgba(0,0,0,0.02);
}

.product-card:hover { 
    transform: translateY(-8px); 
    box-shadow: var(--shadow-hover); 
}

.product-image { 
    width: 100%; 
    height: 220px; 
    background-color: #f8f9fa; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    overflow: hidden; 
    position: relative;
}

.product-image img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    transition: transform 0.5s; 
}

.product-card:hover .product-image img { transform: scale(1.08); }

.product-info { padding: 18px; flex-grow: 1; display: flex; flex-direction: column; }
.product-title { font-size: 16px; margin: 0 0 8px 0; font-weight: bold; color: var(--primary); line-height: 1.4; height: 44px; overflow: hidden; }

.product-desc { 
    font-size: 13px; 
    color: var(--text-muted); 
    margin-bottom: 12px; 
    height: 40px; 
    overflow: hidden; 
    line-height: 1.5; 
}

.product-price { color: var(--danger); font-weight: 900; font-size: 20px; margin-bottom: 15px; margin-top: auto; }

/* =========================================
   5. 按鈕、提示框與特殊 UI (如進度條)
========================================= */
.btn { 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px; 
    border: none; 
    border-radius: 8px; 
    cursor: pointer; 
    font-weight: bold; 
    transition: 0.3s; 
}

.btn-cart { 
    background-color: var(--accent); 
    color: white;
    width: 100%; 
    padding: 12px; 
    border-radius: 8px; 
    font-size: 14px; 
    gap: 8px;
}
.btn-cart:hover { background-color: var(--accent-hover); transform: scale(1.02); }
.btn-cart:active { transform: scale(0.98); }
.btn-cart:disabled { background-color: #bdc3c7; cursor: not-allowed; transform: none; }

.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: bold;
    font-size: 14px;
}
.alert.success { background-color: #e8f8f5; color: var(--success); border: 1px solid #d1f2eb; }
.alert.error { background-color: #fdeded; color: var(--danger); border: 1px solid #fadbd8; }

/* 訂單詳情專屬：退貨/成功橫幅 */
.status-alert {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #6c757d;
}
.status-alert.returned { border-left: 5px solid var(--danger); }

/* 進度條文字修正 */
.step p { margin-top: 8px; font-size: 13px; color: #7f8c8d; }
.step.active p { color: var(--accent); font-weight: bold; }
.step.danger p { color: var(--danger); font-weight: bold; }

/* =========================================
   📱 6. 手機版 RWD 修正
========================================= */
@media (max-width: 768px) {
    /* Header 與 Nav 修正 */
    header {
        flex-wrap: wrap; /* 允許換行 */
        padding: 12px 15px;
        gap: 10px;
    }
    .logo { font-size: 20px; }
    
    .search-bar { 
        order: 3; /* 將搜尋框排到第二行 */
        width: 100%; 
        max-width: 100%; 
        margin: 5px 0 0 0; 
    }
    
    nav { padding: 10px 15px; gap: 15px; }
    nav a { font-size: 13px; }

    /* 版面微調 */
    .container { padding: 20px 15px 40px; }
    .section-title { font-size: 20px; margin: 30px 0 15px 0; }

    /* 手機版商品網格強制雙欄 */
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }

    .product-card { border-radius: 10px; }
    .product-image { height: 160px; }
    .product-info { padding: 12px; }
    .product-title { font-size: 14px; height: 40px; margin-bottom: 5px; }
    .product-desc { display: none; /* 手機版隱藏描述讓版面更清爽 */ }
    .product-price { font-size: 17px; margin-bottom: 10px; }
    .btn-cart { padding: 10px; font-size: 13px; border-radius: 6px; }

    /* 首頁 Banner 縮放 */
    .hero-banner { height: 160px !important; border-radius: 10px !important; }
    .hero-banner h1 { font-size: 20px !important; }
}

@media (max-width: 360px) {
    /* 針對窄螢幕如 iPhone SE */
    .product-grid { gap: 8px; }
    .product-image { height: 140px; }
    .product-price { font-size: 16px; }
}