/* cards.css */

.grid {
    display: grid;
    gap: 20px;
}

.card {
    transition: transform .15s ease, box-shadow .15s ease;
    background: white;
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, .05);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 26px rgba(0, 0, 0, .08);
}

.card-top {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    align-items: flex-start;
}

.product-image {
    width: 140px;
    height: 140px;
    object-fit: contain;
    background: white;
    border-radius: 14px;
    border: 1px solid #eee;
    padding: 10px;
    flex-shrink: 0;
}

.product-right {
    flex: 1;
}

.product-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 16px;
}

.info {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.badge {
    background: #eef2ff;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 700;
}

.status-low {
    background: #fef3c7;
    color: #92400e;
}

.status-good {
    background: #dcfce7;
    color: #166534;
}

.status-normal {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-expensive {
    background: #fee2e2;
    color: #991b1b;
}

.badge-new {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-today {
    background: #f5f3ff;
    border-color: #ddd6fe;
    color: #6d28d9;
}

.action-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.favorite-btn {
    margin-top: 12px;
    padding: 8px 14px;
    border: 0;
    border-radius: 999px;
    background: #f3f4f6;
    cursor: pointer;
    font-weight: 700;
}

.favorite-btn.active {
    background: #fee2e2;
    color: #dc2626;
}

.view-product-btn {
    margin-top: 12px;
    padding: 8px 14px;
    border: 0;
    border-radius: 999px;
    background: #f3f4f6;
    color: #111827;
    text-decoration: none;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
}

.view-product-btn:hover {
    opacity: .9;
}

.view-product-btn:first-of-type {
    background: #111827;
    color: white;
}

.trend-btn {
    background: #111827;
    color: white;
}

.drop-badge {
    margin-top: 12px;
    padding: 8px 14px;
    border-radius: 999px;
    background: #dcfce7;
    color: #166534;
    font-weight: 700;
    font-size: 14px;
}

.empty-result {
    background: white;
    padding: 40px 20px;
    border-radius: 18px;
    text-align: center;
    color: #6b7280;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 4px 18px rgba(0, 0, 0, .05);
}

/* Compact mode */

.compact-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.card-compact {
    padding: 10px;
    border-radius: 14px;
}

.compact-card-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.compact-today-light {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;

    display: inline-flex;
    align-items: center;
    gap: 5px;

    padding: 5px 8px;
    border-radius: 999px;

    background: rgba(245, 243, 255, 0.96);
    border: 1px solid #ddd6fe;
    color: #6d28d9;

    font-size: 12px;
    font-weight: 900;
    line-height: 1;

    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.14);
}

.compact-today-light span {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

.compact-image-link {
    display: block;
    width: 100%;
}

.compact-product-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    border-radius: 12px;
    background: #f9fafb;
}

.compact-product-title {
    font-size: 13px;
    line-height: 1.35;
    font-weight: 600;
    color: #111827;

    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;

    min-height: 35px;
}

.compact-price-row {
    font-size: 18px;
    font-weight: 800;
    color: #111827;
}

.compact-low-row,
.compact-sub-row {
    font-size: 12px;
    color: #6b7280;
}

.compact-status-row {
    font-size: 12px;
    font-weight: 700;
    color: #111827;
}

.compact-drop-row {
    font-size: 12px;
    font-weight: 700;
    color: #dc2626;
}

.compact-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.compact-icon-btn,
.compact-icon-link {
    flex: 1;
    min-height: 32px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    color: #111827;
    font-size: 14px;
    text-align: center;
    text-decoration: none;

    display: flex;
    align-items: center;
    justify-content: center;
}

.compact-icon-btn {
    margin-top: 0;
    padding: 0;
    cursor: pointer;
}

.compact-icon-btn.active {
    color: #dc2626;
    border-color: #fecaca;
    background: #fff1f2;
}

@media (max-width: 768px) {
    .card-top {
        flex-direction: column;
    }

    .product-image {
        width: 100%;
        height: 220px;
    }
}

@media (min-width: 768px) {
    .compact-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* cards-price-signal.css */
/* 請貼到 cards.css 最底部。
   JS 會把價格加上 compact-price-low / compact-price-good / compact-price-normal。
   規則：追蹤低點、低於常態才紅；接近常態、高於常態維持黑色。 */

.compact-price-row {
    margin-top: 2px;
    font-size: 24px;
    line-height: 1.05;
    font-weight: 950;
    letter-spacing: -0.04em;
}

.compact-price-row.compact-price-low,
.compact-price-row.compact-price-good {
    color: #dc2626;
}

.compact-price-row.compact-price-normal {
    color: #111827;
}

.compact-product-title {
    font-weight: 800;
}

.compact-low-row {
    margin-top: 2px;
    font-size: 13px;
    font-weight: 700;
    color: #6b7280;
}

.compact-status-row {
    font-size: 13px;
    font-weight: 900;
    color: #111827;
}

.compact-sub-row {
    font-size: 13px;
    font-weight: 700;
    color: #6b7280;
}

.current-price-badge {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
}

.current-price-badge span {
    font-size: 20px;
    line-height: 1;
    font-weight: 950;
    letter-spacing: -0.03em;
}

.current-price-badge.detail-price-low,
.current-price-badge.detail-price-good {
    color: #dc2626;
    background: #fff1f2;
    border-color: #fecaca;
}

.current-price-badge.detail-price-normal {
    color: #111827;
}

/* 手機版價格再稍微壓一點，避免兩欄卡片爆版。 */

@media (max-width: 768px) {
    .compact-price-row {
        font-size: 23px;
    }

    .compact-low-row,
    .compact-status-row,
    .compact-sub-row {
        font-size: 12px;
    }
}

@media (max-width: 420px) {
    .compact-price-row {
        font-size: 22px;
    }
}

/* cards-home-comfort.css */
/* 首頁舒適版商品卡微調：讓一頁看到更多商品，但保留價格視覺重點。
   請貼到 cards.css 最底部，放在 cards-price-signal 之後也可以。 */

.compact-grid {
    gap: 12px;
}

.card-compact {
    padding: 10px;
    border: 1px solid #eef2f7;
    box-shadow: 0 3px 14px rgba(15, 23, 42, 0.035);
}

.compact-card-inner {
    gap: 6px;
}

.compact-product-image {
    background: #ffffff;
    border: 1px solid #f3f4f6;
    padding: 5px;
}

.compact-product-title {
    min-height: 36px;
    font-weight: 800;
}

.compact-price-row {
    margin-top: 1px;
    font-size: 24px;
    line-height: 1.05;
    font-weight: 950;
    letter-spacing: -0.04em;
}

.compact-actions {
    gap: 7px;
    margin-top: 5px;
}

.compact-icon-btn,
.compact-icon-link {
    min-height: 32px;
    border-radius: 11px;
}

.compact-today-light {
    top: 8px;
    right: 8px;
    padding: 4px 7px;
    font-size: 11px;
}

@media (max-width: 768px) {
    .compact-grid {
        gap: 10px;
    }

    .card-compact {
        padding: 9px;
    }

    .compact-product-title {
        min-height: 35px;
        font-size: 13px;
    }

    .compact-price-row {
        font-size: 23px;
    }
}

@media (max-width: 420px) {
    .compact-grid {
        gap: 9px;
    }

    .card-compact {
        padding: 8px;
    }

    .compact-product-title {
        font-size: 12.5px;
    }

    .compact-price-row {
        font-size: 22px;
    }
}
