/* 東協通社區便利平台 — 全域樣式（Mobile-First） */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f5f6f8;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --danger: #dc2626;
    --warning: #d97706;
    --success: #16a34a;
}
* { box-sizing: border-box; }
body {
    margin: 0; font-family: -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
    background: var(--bg); color: var(--text); line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }

/* 導覽列 */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.nav { display: flex; gap: 14px; align-items: center; font-size: .95rem; }
/* 社區主視覺（首頁 hero + 照片橫捲） */
.hero { position: relative; border-radius: 14px; overflow: hidden; margin-bottom: 16px; }
.hero img { width: 100%; aspect-ratio: 3/2; object-fit: cover; display: block; }
.hero-caption {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 34px 16px 12px;
    background: linear-gradient(transparent, rgba(0,0,0,.62)); color: #fff;
}
.hero-name-th { font-size: 1.15rem; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,.4); }
.hero-name-en { font-size: .76rem; letter-spacing: .14em; opacity: .92; text-transform: uppercase; }
.photo-strip { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; }
.photo-strip img {
    width: 86%; flex: 0 0 auto; aspect-ratio: 3/2; object-fit: cover;
    border-radius: 12px; scroll-snap-align: center; background: #eef0f3;
}
@media (min-width: 601px) {
    .hero img { aspect-ratio: 21/9; }
    .photo-strip img { width: 420px; }
}

/* 門牌輸入：固定 188/ 前綴 + 流水號（強制引導，老年人只填數字） */
.unit-group { display: flex; align-items: stretch; }
.unit-group .unit-prefix {
    display: flex; align-items: center; padding: 0 14px;
    background: #eef2ff; border: 1px solid var(--border); border-right: none;
    border-radius: 8px 0 0 8px; font-weight: 700; font-size: 1.15rem; color: var(--primary);
}
.unit-group input {
    flex: 1; border-radius: 0 8px 8px 0; font-size: 1.15rem; letter-spacing: .08em;
}

/* LINE 登入按鈕（品牌綠 #06C755，大點擊區，老年人友善） */
.btn-line {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 14px; background: #06C755; color: #fff;
    border-radius: 12px; font-size: 1.05rem; font-weight: 600; text-decoration: none;
}
.btn-line:hover { background: #05b34c; color: #fff; }
.or-divider {
    display: flex; align-items: center; text-align: center; color: var(--muted);
    font-size: .85rem; margin: 14px 0;
}
.or-divider::before, .or-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}
.or-divider span { padding: 0 12px; }

.lang-select {
    border: 1px solid var(--border); border-radius: 8px; padding: 5px 6px;
    font-size: .82rem; background: #fff; color: var(--text); cursor: pointer;
}
.btn-primary, button.btn-primary {
    background: var(--primary); color: #fff !important; padding: 7px 14px;
    border-radius: 8px; border: none; cursor: pointer; font-size: .95rem;
}
.btn-primary:hover { background: var(--primary-dark); }

/* 門牌審核橫幅 */
.verify-banner {
    background: #fef3c7; color: #92400e; padding: 10px 16px;
    text-align: center; font-size: .9rem;
}
.verify-banner.rejected { background: #fee2e2; color: #991b1b; }

/* 容器 */
.container { max-width: 960px; margin: 0 auto; padding: 20px 16px; }

/* 卡片 / 表單 */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 12px; padding: 20px; margin-bottom: 16px;
}
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 5px; font-size: .9rem; color: var(--muted); }
.form-control {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 1rem; background: #fff;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.btn-block { width: 100%; padding: 11px; font-size: 1rem; }
.text-muted { color: var(--muted); font-size: .85rem; }
.page-title { font-size: 1.3rem; margin: 0 0 16px; }

/* 表格 */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: .92rem; }
th { color: var(--muted); font-weight: 600; }
/* 後台表格按鈕間距 */
.table-responsive td button { margin: 2px; }

/* 狀態標籤 */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; }
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-verified { background: #dcfce7; color: #166534; }
.badge-rejected { background: #fee2e2; color: #991b1b; }

/* Toast */
.toast-box { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px; border-radius: 8px; color: #fff; font-size: .92rem;
    opacity: 0; transform: translateY(12px); transition: all .3s; box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); }
.toast-warning { background: var(--warning); }
.toast-danger  { background: var(--danger); }
.toast-info    { background: #334155; }

/* 商品/二手卡片 grid — 手機 2 欄為預設（mobile-first） */
.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.pcard {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 12px; overflow: hidden; display: flex; flex-direction: column;
}
.pcard .thumb {
    width: 100%; aspect-ratio: 1/1; object-fit: cover; background: #eef0f3; display: block;
}
.pcard .pbody { padding: 10px; }
.pcard .ptitle { font-size: .92rem; font-weight: 600; margin: 0 0 4px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard .pprice { color: var(--danger); font-weight: 700; font-size: .95rem; }
.pcard .pmeta { color: var(--muted); font-size: .78rem; margin-top: 4px; }

/* 商品詳情大圖輪播（簡易橫向捲動） */
.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; }
.gallery img { width: 86%; flex: 0 0 auto; aspect-ratio: 1/1; object-fit: cover;
    border-radius: 12px; scroll-snap-align: center; background: #eef0f3; }

/* 大型主要按鈕（手機點擊區） */
.btn-cta { display: block; width: 100%; text-align: center; padding: 14px;
    background: var(--primary); color: #fff; border: none; border-radius: 12px;
    font-size: 1.05rem; font-weight: 600; cursor: pointer; }
.btn-cta:hover { background: var(--primary-dark); }

/* 圖片上傳預覽 */
.upload-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.upload-grid .slot { aspect-ratio: 1/1; border: 1px dashed var(--border); border-radius: 10px;
    display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; background: #fafbfc; }
.upload-grid .slot img { width: 100%; height: 100%; object-fit: cover; }
.upload-grid .slot .rm { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6);
    color: #fff; border: none; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; }

/* 手機底部導覽列 */
.tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    display: flex; background: var(--card); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
.tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 0 7px; font-size: .7rem; color: var(--muted);
}
.tab.active { color: var(--primary); }
.tab-ico { font-size: 1.25rem; line-height: 1; }
body { padding-bottom: 64px; }   /* 預留底部導覽空間 */

/* 響應式：桌面放大 grid 欄數、頂部 nav 顯示 */
@media (max-width: 600px) {
    .nav { gap: 10px; font-size: .85rem; }
    .nav a:not(.btn-primary) { display: none; }   /* 手機隱藏頂部連結，改用底部 tab */
    .brand { font-size: 1rem; }
    .container { padding: 16px 12px; }

    /* 後台表格：手機改為堆疊卡片式，避免水平溢出與操作鈕被切（修 F4/F5） */
    .table-responsive thead { display: none; }
    .table-responsive, .table-responsive tbody, .table-responsive tr, .table-responsive td { display: block; width: 100%; }
    .table-responsive tr { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; }
    .table-responsive td { border: none; padding: 5px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
    .table-responsive td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; flex: 0 0 auto; }
    .table-responsive td:last-child { justify-content: flex-end; flex-wrap: wrap; }
    .table-responsive td:last-child::before { display: none; }
}
@media (min-width: 601px) {
    .grid { grid-template-columns: repeat(4, 1fr); }
    .gallery img { width: 360px; }
    .tabbar { display: none; }     /* 桌面用頂部 nav，隱藏底部 tab */
    body { padding-bottom: 0; }
    .mobile-only { display: none; } /* 手機專用區塊：桌面已有頂部 nav，隱藏 */
}

/* 手機專用：帳號區（訊息／後台／登出），補足底部 tab 缺少的入口 */
.account-links { display: flex; flex-direction: column; gap: 10px; }
.account-links a, .account-links button {
    display: block; width: 100%; text-align: center; box-sizing: border-box;
    padding: 12px; border-radius: 8px; border: 1px solid #e5e7eb;
    background: #fff; color: var(--primary); font-size: 1rem; cursor: pointer;
    text-decoration: none;
}
.account-links .logout-link { color: var(--danger); border-color: var(--danger); }
