/* 全局樣式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft JhengHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* 頭部 */
header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-family: 'Zen Maru Gothic', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft JhengHei', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 搜尋區域 */
.search-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#searchInput {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

#searchInput:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #e0e0e0;
    color: #666;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-share {
    background: #10b981;
    color: white;
    margin-left: 10px;
    display: none;
}

.btn-share:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

.btn-success {
    background: #22c55e !important;
}

.search-options {
    display: flex;
    gap: 20px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.95rem;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* 統計區域 */
.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-text {
    font-size: 1.2rem;
    color: #666;
    font-weight: 500;
}

.stat-label {
    color: #999;
    font-size: 0.9rem;
}

/* 載入動畫 */
.loading {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 10px;
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 錯誤訊息 */
.error-message {
    background: #fee;
    border: 1px solid #fcc;
    color: #c33;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* 商品容器 */
.items-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* 日期分組 */
.date-group {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.date-group.upcoming-section {
    border-left: 5px solid #667eea;
}

.date-group.past-section {
    border-left: 5px solid #bbb;
    opacity: 0.9;
}

.date-group-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 18px 25px;
}

.date-group.past-section .date-group-header {
    background: linear-gradient(135deg, #888 0%, #666 100%);
}

.date-group-title {
    color: white;
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.item-count-badge {
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.25);
    padding: 4px 12px;
    border-radius: 15px;
    font-weight: 500;
}

.date-group-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    padding: 20px;
    background: #f8f9fa;
}

/* 商品卡片 */
.item-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
}

.item-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.item-header {
    margin-bottom: 15px;
}

.item-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    line-height: 1.4;
}

.item-date {
    display: inline-block;
    background: #f0f0f0;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
    color: #666;
}

.item-date.upcoming {
    background: #e3f2fd;
    color: #1976d2;
}

.item-date.past {
    background: #fafafa;
    color: #999;
}

.item-body {
    flex: 1;
    margin-bottom: 15px;
}

.item-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 8px;
    background: #f9f9f9;
    border-radius: 6px;
}

.status-label {
    font-weight: 500;
    color: #666;
    font-size: 0.9rem;
}

.status-value {
    flex: 1;
    color: #333;
    font-size: 0.9rem;
}

.tokuten-section {
    margin-top: 10px;
}

.tokuten-title {
    font-weight: 500;
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.tokuten-item {
    background: #fff8e1;
    border-left: 3px solid #ffc107;
    padding: 8px 12px;
    margin-bottom: 6px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.tokuten-item:last-child {
    margin-bottom: 0;
}

/* 特典圖片樣式 */
.tokuten-item.with-image {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px;
}

.tokuten-image-container {
    flex-shrink: 0;
    position: relative;
}

.tokuten-image {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid #ffd54f;
}

.tokuten-image:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tokuten-text {
    flex: 1;
    display: flex;
    align-items: center;
    line-height: 1.4;
}

.image-error {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 6px;
    color: #999;
    font-size: 0.8rem;
    text-align: center;
}

/* 圖片彈窗 */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2rem;
    color: #666;
    cursor: pointer;
    transition: color 0.3s;
    z-index: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-image {
    max-width: 100%;
    max-height: 70vh;
    display: block;
    margin: 0 auto;
    border-radius: 8px;
}

.modal-caption {
    text-align: center;
    margin-top: 15px;
    color: #666;
    font-size: 0.95rem;
}

.item-footer {
    margin-top: auto;
}

.item-link {
    display: inline-block;
    color: #667eea;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 8px 16px;
    border: 1px solid #667eea;
    border-radius: 6px;
    transition: all 0.3s;
}

.item-link:hover {
    background: #667eea;
    color: white;
}

/* 空狀態 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 10px;
    grid-column: 1 / -1;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.empty-state-text {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 10px;
}

.empty-state-hint {
    color: #999;
    font-size: 0.95rem;
}

/* 響應式設計 */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .search-bar {
        flex-direction: column;
    }

    .date-group-items {
        grid-template-columns: 1fr;
        padding: 15px;
    }

    .stat-number {
        font-size: 2rem;
    }
    
    .date-group-header {
        padding: 15px 18px;
    }
    
    .date-group-title {
        font-size: 1.1rem;
    }
    
    .item-count-badge {
        font-size: 0.75rem;
    }
}
