/* includes/theme.css - Carousell 風格前台樣式 */

:root {
    --color-brand: #008f79;
    --color-brand-dark: #007a67;
    --color-brand-light: #e6f5f2;
    --color-whatsapp: #25D366;
    --color-whatsapp-hover: #1da851;
    --color-price: #2c2c2d;
    --color-text: #2c2c2d;
    --color-muted: #6b6b6b;
    --color-border: #e5e5e5;
    --color-bg: #f0f0f0;
    --color-card: #ffffff;
    --color-sold: #cc1e1e;
    --color-available: #008f79;
    --radius: 8px;
    --radius-lg: 12px;
    --font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --header-h: 56px;
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-family);
    color: var(--color-text);
    background: var(--color-bg);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ── 頂部導航（Carousell 風格） ── */
.site-header {
    background: var(--color-card);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
}

.site-header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-logo {
    font-size: 1.25em;
    font-weight: 800;
    color: var(--color-brand);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.site-logo:hover {
    color: var(--color-brand-dark);
    text-decoration: none;
}

.site-subtitle {
    font-size: 0.88em;
    color: var(--color-muted);
    padding-left: 12px;
    border-left: 1px solid var(--color-border);
}

.back-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--color-text);
    text-decoration: none;
    font-size: 1.3em;
    flex-shrink: 0;
    transition: background 0.15s;
}

.back-link:hover {
    background: var(--color-bg);
    text-decoration: none;
    color: var(--color-text);
}

.header-title {
    font-size: 1em;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── 頁面容器 ── */
.page-wrap {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px;
}

.list-intro {
    margin-bottom: 16px;
}

.list-intro h1 {
    font-size: 1.35em;
    font-weight: 800;
    margin: 0 0 8px;
    color: var(--color-text);
    line-height: 1.3;
}

.list-intro p {
    margin: 0;
    font-size: 0.92em;
    color: var(--color-muted);
    line-height: 1.6;
    max-width: 720px;
}

.breadcrumb {
    max-width: 1100px;
    margin: 0 auto 12px;
    padding: 0 16px;
}

.breadcrumb ol {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 0.82em;
    color: var(--color-muted);
}

.breadcrumb li + li::before {
    content: '›';
    margin-right: 6px;
    color: #bbb;
}

.breadcrumb a {
    color: var(--color-brand);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb span[aria-current="page"] {
    color: var(--color-text);
    font-weight: 500;
}

.error-page {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 40px 24px;
    text-align: center;
    max-width: 480px;
    margin: 40px auto;
}

.error-page h1 {
    font-size: 1.4em;
    margin: 0 0 12px;
}

.error-page p {
    color: var(--color-muted);
    margin: 0 0 20px;
}

.notice-bar {
    background: var(--color-brand-light);
    color: var(--color-brand-dark);
    text-align: center;
    padding: 10px 16px;
    font-size: 0.88em;
    font-weight: 500;
    border-bottom: 1px solid #c8e6df;
}

/* ── 篩選晶片（Carousell 風格） ── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}

.filter-bar::-webkit-scrollbar { display: none; }

.filter-chip {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.88em;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    border: 1px solid var(--color-border);
    background: var(--color-card);
    color: var(--color-text);
    transition: all 0.15s;
}

.filter-chip:hover {
    border-color: var(--color-brand);
    color: var(--color-brand);
    text-decoration: none;
}

.filter-chip.active {
    background: var(--color-brand);
    border-color: var(--color-brand);
    color: #fff;
}

.filter-count {
    font-size: 0.9em;
    color: var(--color-muted);
    margin-bottom: 12px;
}

/* ── 列表卡片（Carousell 風格） ── */
.listing-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

.listing-card {
    display: block;
    background: var(--color-card);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s;
}

.listing-card:hover {
    transform: translateY(-2px);
    text-decoration: none;
    color: inherit;
}

.listing-card--sold {
    opacity: 0.72;
}

.listing-card--sold:hover {
    transform: none;
}

.listing-corner-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    background: rgba(241, 196, 15, 0.95);
    color: #000;
    font-size: 0.68em;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
}

.listing-img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: #f5f5f5;
    overflow: hidden;
}

.listing-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.listing-sold-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 1em;
}

.listing-body {
    padding: 10px 10px 12px;
}

.listing-sku {
    font-size: 0.72em;
    color: var(--color-muted);
    margin: 0 0 4px;
}

.listing-sku::before {
    content: '#';
    opacity: 0.6;
}

.listing-title {
    font-size: 0.9em;
    font-weight: 500;
    margin: 0 0 6px;
    line-height: 1.4;
    color: var(--color-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.listing-price {
    font-size: 1.05em;
    font-weight: 800;
    color: var(--color-price);
    margin: 0 0 4px;
}

.listing-price.is-sold {
    color: var(--color-muted);
    text-decoration: line-through;
    font-weight: 600;
}

.listing-meta {
    font-size: 0.78em;
    color: var(--color-muted);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.listing-tag {
    display: inline-block;
    font-size: 0.72em;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 4px;
}

.listing-tag-used {
    background: #fff3cd;
    color: #856404;
}

.empty-msg {
    text-align: center;
    padding: 80px 20px;
    color: var(--color-muted);
}

/* ── 詳情頁 ── */
.detail-wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 0 80px;
}

.detail-card {
    background: var(--color-card);
}

.detail-top {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    padding: 20px;
}

.gallery-main {
    width: 100%;
    aspect-ratio: 1;
    background: #f5f5f5;
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-in;
}

.gallery-main img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.2s;
}

.gallery-thumbs {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.gallery-thumb {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    border: 2px solid transparent;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    background: #f5f5f5;
    padding: 0;
}

.gallery-thumb.active {
    border-color: var(--color-brand);
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-hidden { display: none; }

.detail-info .price-display {
    font-size: 1.75em;
    font-weight: 800;
    color: var(--color-price);
    margin: 0 0 8px;
    line-height: 1.2;
}

.detail-info .price-display.is-sold {
    color: var(--color-muted);
    text-decoration: line-through;
}

.detail-info h1 {
    font-size: 1.15em;
    font-weight: 500;
    margin: 0 0 16px;
    line-height: 1.45;
    color: var(--color-text);
}

.detail-condition-badge {
    display: inline-block;
    font-size: 0.82em;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
    background: #fff3cd;
    color: #856404;
    margin-bottom: 12px;
}

.seller-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--color-bg);
    border-radius: var(--radius);
    margin: 16px 0;
}

.seller-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1em;
    flex-shrink: 0;
}

.seller-name {
    font-weight: 700;
    font-size: 0.95em;
    margin: 0;
}

.seller-location {
    font-size: 0.82em;
    color: var(--color-muted);
    margin: 2px 0 0;
}

.meta-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0;
}

.meta-tag {
    font-size: 0.82em;
    padding: 4px 10px;
    border-radius: 4px;
    background: var(--color-bg);
    color: var(--color-muted);
}

.meta-tag-warranty { background: var(--color-brand-light); color: var(--color-brand-dark); }

/* 商品狀況等級（Carousell 風格） */
.condition-brand-new { background: #e8f4fd; color: #1a5276; }
.condition-like-new { background: #e8f8f0; color: #1e8449; }
.condition-good { background: var(--color-brand-light); color: var(--color-brand-dark); }
.condition-lightly-used { background: #fef9e7; color: #9a7d0a; }
.condition-fair { background: #fdf2e9; color: #d35400; }

.listing-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.listing-tag {
    display: inline-block;
    font-size: 0.72em;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.listing-tag-warranty { background: var(--color-brand-light); color: var(--color-brand-dark); }

/* 列表頁查詢區 */
.list-inquiry-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.list-inquiry-text {
    margin: 0;
    font-size: 0.9em;
    color: var(--color-text);
    font-weight: 500;
}

.btn-whatsapp-sm {
    width: auto;
    padding: 10px 18px;
    font-size: 0.9em;
}

.floating-wa {
    display: none;
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 200;
    align-items: center;
    gap: 8px;
    background: var(--color-whatsapp);
    color: #fff;
    padding: 12px 18px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.9em;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4);
}

.floating-wa:hover {
    color: #fff;
    text-decoration: none;
    filter: brightness(1.05);
}

.floating-wa svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
    flex-shrink: 0;
}

.has-list-wa-bar {
    padding-bottom: 72px;
}

.floating-wa--visible {
    display: flex;
}

@media (min-width: 769px) {
    .has-list-wa-bar {
        padding-bottom: 0;
    }

    .floating-wa--visible {
        display: none;
    }
}

.condition-desc-box {
    margin-top: 12px;
    padding: 12px 14px;
    background: #f8f9fb;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    font-size: 0.88em;
    color: var(--color-muted);
    line-height: 1.5;
}

.condition-desc-box strong {
    display: block;
    margin-bottom: 4px;
    color: var(--color-text);
    font-size: 0.95em;
}

.product-sku {
    font-size: 0.85em;
    color: var(--color-muted);
    margin: 4px 0 12px;
}

.product-sku code {
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.95em;
    color: var(--color-text);
}

.status-pill {
    display: inline-block;
    font-size: 0.82em;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.status-pill-available { background: var(--color-brand-light); color: var(--color-brand); }
.status-pill-sold { background: #fdecea; color: var(--color-sold); }

.detail-divider {
    border: none;
    border-top: 8px solid var(--color-bg);
    margin: 0;
}

.detail-section {
    padding: 20px;
}

.detail-section h2,
.detail-section h3 {
    font-size: 1em;
    font-weight: 700;
    margin: 0 0 14px;
    color: var(--color-text);
}

.section-note {
    font-size: 0.85em;
    color: var(--color-muted);
    margin: -8px 0 14px;
}

.specs-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.specs-list li {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.92em;
}

.specs-list li:last-child { border-bottom: none; }

.specs-list .spec-key {
    flex: 0 0 120px;
    color: var(--color-muted);
}

.accessory-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.accessory-pill {
    padding: 8px 14px;
    background: var(--color-bg);
    border-radius: 20px;
    font-size: 0.88em;
}

.condition-text {
    font-size: 0.95em;
    line-height: 1.7;
    color: var(--color-text);
    white-space: pre-line;
}

.screenshots-row {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.screenshot-thumb {
    flex: 0 0 200px;
    height: 150px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #f5f5f5;
    display: block;
}

.screenshot-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ── 按鈕 ── */
.btn-whatsapp {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: var(--color-whatsapp);
    color: #fff !important;
    font-weight: 700;
    font-size: 1em;
    padding: 14px 20px;
    border-radius: var(--radius);
    text-decoration: none !important;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-whatsapp:hover {
    background: var(--color-whatsapp-hover);
    color: #fff;
}

.btn-whatsapp svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.btn-brand {
    display: inline-block;
    width: 100%;
    text-align: center;
    padding: 14px 20px;
    background: var(--color-brand);
    color: #fff !important;
    font-weight: 700;
    border-radius: var(--radius);
    text-decoration: none !important;
    border: none;
    transition: background 0.15s;
}

.btn-brand:hover {
    background: var(--color-brand-dark);
    color: #fff;
}

.btn-outline {
    display: inline-block;
    width: 100%;
    text-align: center;
    padding: 12px 20px;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    background: var(--color-card);
}

.btn-outline:hover {
    background: var(--color-bg);
    text-decoration: none;
    color: var(--color-text);
}

.desktop-cta { margin-top: 16px; }

.sold-notice {
    background: #fdecea;
    color: var(--color-sold);
    text-align: center;
    padding: 12px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.92em;
    margin-bottom: 12px;
}

/* ── 手機底部固定列（Carousell Chat 風格） ── */
.sticky-contact-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-card);
    border-top: 1px solid var(--color-border);
    padding: 10px 16px;
    z-index: 200;
    align-items: center;
    gap: 12px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
}

.sticky-contact-bar .sticky-price {
    font-size: 1.2em;
    font-weight: 800;
    color: var(--color-price);
    flex-shrink: 0;
}

.sticky-contact-bar .btn-whatsapp {
    flex: 1;
    padding: 12px 16px;
}

/* ── 響應式 ── */
@media (max-width: 1200px) {
    .listing-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 992px) {
    .listing-grid { grid-template-columns: repeat(3, 1fr); }
    .detail-top { grid-template-columns: 1fr; gap: 20px; }
}

@media (max-width: 768px) {
    .listing-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .site-subtitle { display: none; }
    .sticky-contact-bar { display: flex; }
    .detail-wrap { padding-bottom: 72px; }
    .desktop-cta { display: none; }
    .detail-top { padding: 0; }
    .detail-info { padding: 16px; }
    .detail-section { padding: 16px; }
}

@media (max-width: 400px) {
    .listing-grid { gap: 8px; }
    .listing-body { padding: 8px; }
    .listing-title { font-size: 0.85em; }
}

@media (min-width: 769px) {
    .sticky-contact-bar { display: none !important; }
}
