/* 基礎重置與佈局 */
:root {
    --primary-color: #FF85A2; /* 粉嫩主色 */
    --secondary-color: #FFB7C5; /* 淺粉色 */
    --accent-color: #FF4D6D; /* 強調粉 */
    --bg-color: #FFF5F7; /* 極淺粉背景 */
    --line-color: #06C755;
    --fb-color: #1877F2;
    --text-color: #5D4037; /* 暖深色，比純黑更柔和 */
    --card-bg: #fff;
    --border-radius: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent; /* 移除手機點擊高亮 */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    padding-bottom: 100px; /* 留出底部懸浮列空間 */
    line-height: 1.6;
}

.header {
    text-align: center;
    padding: 20px 20px;
    background: #fff;
    margin-bottom: 20px;
    position: sticky;
    top: 0;
    z-index: 99;
    box-shadow: 0 2px 15px rgba(255, 133, 162, 0.1);
    border-bottom: 2px solid #FFE4E9;
}

.header h1 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--accent-color);
}

.back-btn {
    position: absolute;
    left: 15px;
    top: 22px;
    text-decoration: none;
    color: var(--primary-color);
    font-size: 0.85rem;
    font-weight: bold;
    background: #FFF0F5;
    padding: 4px 10px;
    border-radius: 12px;
}

.header h1 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.header p {
    font-size: 0.9rem;
    color: #666;
}

/* 產品網格佈局 (純手機版單列) */
.product-container {
    display: grid;
    grid-template-columns: 1fr; /* 強制單列，一行一張 */
    gap: 20px;
    padding: 0 16px;
    max-width: 600px; /* 限制最大寬度以維持手機版感官 */
    margin: 0 auto;
}

/* 產品卡片 */
.product-card {
    position: relative;
    background: #fff; /* 背景改為純白 */
    border-radius: var(--border-radius);
    overflow: hidden;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-card:active {
    transform: scale(0.97);
}

.product-card img {
    width: 100%;
    height: 100%;
    object-fit: fill; /* 改為強制拉伸鋪滿，確保所有圖片尺寸視覺一致 */
    display: block;
}

/* 選取角標 */
.badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 10px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.85);
    color: var(--text-color);
    font-size: 0.75rem;
    font-weight: bold;
    z-index: 2;
    transition: all 0.2s ease;
    border: 1px solid var(--secondary-color);
}

.product-card.selected .badge {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* 放大按鈕樣式 */
.zoom-icon {
    position: absolute;
    bottom: 10px;
    right: 10px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    opacity: 0.9;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(255, 133, 162, 0.2);
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--primary-color);
    border: 1px solid #FFE4E9;
}

.zoom-icon::before {
    content: '放大';
}

.zoom-icon:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Lightbox 樣式 */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox.show {
    display: flex;
    opacity: 1;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lightbox.show img {
    transform: scale(1);
}

.close-lightbox {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    z-index: 1001;
}

/* 底部懸浮列 */
.floating-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    min-height: 110px; /* 增加高度以容納上下排列按鈕 */
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(15px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom)); /* 支援手機安全區域 */
    box-shadow: 0 -4px 15px rgba(0,0,0,0.12);
    z-index: 100;
}

.selection-info {
    font-weight: bold;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column; /* 改回垂直排列以容納多行金額 */
    align-items: flex-start;
    gap: 4px;
    flex-shrink: 0;
    margin-right: 8px;
    min-width: 100px;
}

.count-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-clear {
    background: #ff4d4f;
    border: none;
    color: #fff;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    font-weight: bold;
    transition: background 0.2s ease;
    white-space: nowrap;
    margin-top: 0;
}

.btn-clear:hover {
    background: #ff7875;
}

#selectedCount {
    color: var(--accent-color);
    font-size: 1.1rem;
}

.share-buttons {
    display: flex;
    flex-direction: row; /* 改回橫向，因為只有一個按鈕 */
    gap: 10px;
    flex-grow: 1;
    max-width: 220px; /* 增加寬度給單個大按鈕 */
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    height: 48px; /* 增加高度，讓單個按鈕更好點擊 */
    width: 100%;
    border-radius: 24px;
    border: none;
    font-weight: bold;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #fff;
    box-shadow: 0 4px 12px rgba(255, 133, 162, 0.3);
    white-space: nowrap;
}

/* 移除舊按鈕顏色，新增保存按鈕顏色 */
.btn-save { 
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%); 
}

.btn .icon {
    width: 18px;
    height: 18px;
}

/* 懶加載佔位 */
.lazy-loading {
    background: #eee;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}
