/* ============================================================================
   HaaDai — website styles (modern classifieds UI)
   Shared brand palette also used by iOS (AppTheme.swift) & Android (Theme.kt).
============================================================================ */
:root {
    --brand:      #12B886;
    --brand-dark: #0CA678;
    --brand-soft: #E7F8F1;
    --accent:     #FF6B35;
    --accent-dark:#E85826;
    --ink:        #14181F;
    --muted:      #6B7280;
    --line:       #E7EAEF;
    --bg:         #F6F7F9;
    --surface:    #FFFFFF;
    --radius:     16px;
    --radius-sm:  10px;
    --shadow:     0 1px 2px rgba(16,24,40,.04), 0 8px 24px rgba(16,24,40,.06);
    --shadow-lg:  0 12px 40px rgba(16,24,40,.12);
    --maxw:       1200px;
    font-family: 'Inter', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: 15px;
    border: 1px solid transparent; cursor: pointer; transition: .15s ease; white-space: nowrap; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-block { display: flex; width: 100%; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.site-header { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.9);
    backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 18px; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; color: #fff; font-weight: 800;
    display: grid; place-items: center; background: linear-gradient(135deg, var(--brand), #0DBB8A);
    box-shadow: 0 4px 12px rgba(18,184,134,.35); }
.brand-name { letter-spacing: -.02em; }
.search-bar { flex: 1; display: flex; align-items: center; background: var(--bg);
    border: 1px solid var(--line); border-radius: 999px; padding: 4px 4px 4px 16px; max-width: 560px; }
.search-bar input { flex: 1; border: 0; background: transparent; font-size: 15px; outline: none; padding: 8px 0; }
.search-bar button { border: 0; background: var(--brand); color: #fff; width: 38px; height: 38px;
    border-radius: 999px; cursor: pointer; font-size: 15px; }
.header-nav { display: flex; align-items: center; gap: 14px; }
.nav-link { font-weight: 600; font-size: 15px; }
.nav-link:hover { color: var(--brand); }
.inline-form { display: inline; margin: 0; }
.nav-button { appearance: none; border: 0; background: transparent; padding: 0; cursor: pointer; font-family: inherit; }
.locale-switch { display: inline-grid; place-items: center; min-width: 38px; height: 32px; padding: 0 9px;
    border: 1px solid var(--line); border-radius: 999px; color: var(--brand-dark); font-size: 12px; font-weight: 800; }

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero { background: linear-gradient(135deg, #0CA678 0%, #12B886 55%, #17C3B2 100%); color: #fff; padding: 56px 0 64px; }
.hero h1 { font-size: clamp(28px, 4vw, 46px); font-weight: 800; max-width: 720px; }
.hero .hl { color: #FFE8A3; }
.hero-sub { font-size: 18px; opacity: .92; max-width: 560px; margin-bottom: 24px; }
.hero-search { display: flex; gap: 10px; max-width: 620px; background: #fff; padding: 8px; border-radius: 999px; box-shadow: var(--shadow-lg); }
.hero-search input { flex: 1; border: 0; outline: none; font-size: 16px; padding: 10px 16px; border-radius: 999px; }

/* ── Sections ────────────────────────────────────────────────────────────── */
.section { padding: 36px 0; }
.section-title { font-size: 22px; font-weight: 800; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.see-all { color: var(--brand); font-weight: 600; }

/* ── Category grid ───────────────────────────────────────────────────────── */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; margin-top: 8px; }
.category-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px 14px; text-align: center; transition: .15s ease; }
.category-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: transparent; }
.category-icon { display: block; width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 12px; background: var(--brand-soft); }
.category-name { display: block; font-weight: 700; font-size: 14px; }
.category-name-th { display: block; font-size: 12px; color: var(--muted); }

/* ── Listing cards ───────────────────────────────────────────────────────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: .15s ease; }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: transparent; }
.card-media { position: relative; aspect-ratio: 4/3; background: #EEF1F4; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-media-placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); font-weight: 600; font-size: 13px; }
.badge { position: absolute; top: 10px; font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; color: #fff; }
.badge-featured { left: 10px; background: var(--accent); }
.badge-type { right: 10px; background: rgba(20,24,31,.78); }
.card-body { padding: 12px 14px 14px; }
.card-price { font-weight: 800; font-size: 17px; color: var(--ink); }
.card-title { font-size: 14px; font-weight: 500; color: #333; margin-top: 2px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 40px; }
.card-meta { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.card-meta .dot { opacity: .5; }

/* ── Search layout ───────────────────────────────────────────────────────── */
.search-layout { display: grid; grid-template-columns: 260px 1fr; gap: 26px; align-items: start; }
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; position: sticky; top: 88px; }
.filters h3 { font-size: 16px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line);
    border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; background: #fff; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.results-head { margin-bottom: 16px; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 48px; text-align: center; color: var(--muted); }

/* ── Listing detail ──────────────────────────────────────────────────────── */
.breadcrumb { color: var(--muted); font-size: 13.5px; margin-bottom: 16px; }
.breadcrumb a:hover { color: var(--brand); }
.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 28px; align-items: start; }
.gallery-main { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: var(--radius); background: #EEF1F4; }
.gallery-thumbs { display: flex; gap: 10px; margin-top: 10px; }
.gallery-thumbs img { width: 84px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.detail-title { font-size: 26px; font-weight: 800; margin-top: 20px; }
.detail-price { font-size: 30px; font-weight: 800; color: var(--brand-dark); }
.detail-price .per { font-size: 16px; color: var(--muted); font-weight: 600; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 8px; }
.chip { background: var(--brand-soft); color: var(--brand-dark); font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 999px; }
.detail-h { font-size: 17px; margin-top: 26px; }
.attr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.attr { display: flex; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; }
.attr-k { color: var(--muted); font-size: 14px; }
.attr-v { font-weight: 600; font-size: 14px; }
.detail-desc { color: #333; }
.detail-side { position: sticky; top: 88px; }
.seller-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.seller-top { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.seller-avatar { width: 48px; height: 48px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), #0DBB8A); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 20px; }
.seller-name { font-weight: 700; }
.verified { color: var(--brand); }
.seller-card .btn { margin-bottom: 10px; }
.safety { font-size: 12.5px; margin: 8px 0 0; }
.moderation-panel { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.moderation-panel summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 700; }
.moderation-form { margin-top: 12px; }
.moderation-panel .btn-danger { margin-top: 8px; }

/* ── Auth & post forms ───────────────────────────────────────────────────── */
.auth-wrap, .post-wrap { display: flex; justify-content: center; padding-top: 40px; padding-bottom: 60px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 420px; }
.post-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 680px; }
.auth-card h1, .post-card h1 { font-size: 24px; }
.auth-alt { text-align: center; margin-top: 16px; font-size: 14px; }
.consent-row { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; margin: 4px 0 6px; }
.consent-row input { margin-top: 4px; flex: 0 0 auto; }
.consent-links { margin: 0 0 16px; font-size: 13px; color: var(--brand-dark); }
.auth-alt a, .demo-hint code { color: var(--brand-dark); font-weight: 600; }
.demo-hint { text-align: center; font-size: 12.5px; margin-top: 14px; }
.alert { background: #FEECEC; color: #B42318; border: 1px solid #FBD5D5; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }

/* ── Account & messaging ────────────────────────────────────────────────── */
.account-hero { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 20px; margin-bottom: 32px; box-shadow: var(--shadow); }
.account-hero h1, .account-hero p { margin: 0; }
.account-post { margin-left: auto; }
.account-section { margin-top: 44px; }
.conversation-list { display: grid; gap: 10px; }
.conversation-row { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius-sm); padding: 12px; transition: .15s ease; }
.conversation-row:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.conversation-thumb { flex: 0 0 58px; width: 58px; height: 58px; border-radius: 10px; overflow: hidden; background: var(--brand-soft);
    display: grid; place-items: center; color: var(--brand-dark); font-weight: 800; }
.conversation-thumb img { width: 100%; height: 100%; object-fit: cover; }
.conversation-copy { min-width: 0; display: grid; gap: 2px; }
.conversation-copy span, .conversation-copy small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.conversation-copy span { color: var(--muted); font-size: 13px; }
.conversation-copy small { color: var(--ink); }
.unread-badge { margin-left: auto; min-width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; }
.danger-zone { margin-top: 48px; padding: 22px; border: 1px solid #F3B4AE; border-radius: var(--radius); background: #FFF7F6; }
.danger-zone h2 { margin: 0 0 8px; color: #A4261D; font-size: 20px; }
.danger-zone p { max-width: 760px; color: var(--muted); line-height: 1.55; }
.delete-account-form { display: grid; gap: 14px; max-width: 460px; margin-top: 18px; }
.btn-danger { background: #B42318; color: #fff; border-color: #B42318; }
.btn-danger:hover { background: #8F1C13; border-color: #8F1C13; }
.blocked-list { display: grid; gap: 8px; }
.blocked-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.messages-page { max-width: 820px; }
.message-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.message-header { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.message-header-actions { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.moderation-panel.compact { width: min(300px, 100%); margin-top: 0; padding-top: 0; border-top: 0; }
.message-header h1 { font-size: 20px; margin: 0; }
.message-header a { color: var(--brand-dark); font-size: 13px; }
.message-thread { min-height: 360px; max-height: 58vh; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.message-empty { margin: auto; }
.message-bubble { max-width: min(76%, 560px); padding: 10px 13px; border-radius: 16px; }
.message-bubble p { margin: 0; white-space: normal; overflow-wrap: anywhere; }
.message-bubble time { display: block; margin-top: 4px; font-size: 10px; opacity: .65; }
.message-report-form button { border: 0; background: transparent; padding: 4px 0 0; color: inherit; opacity: .7; cursor: pointer; font-size: 10px; text-decoration: underline; }
.message-bubble.mine { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.message-bubble.theirs { align-self: flex-start; background: var(--bg); border-bottom-left-radius: 4px; }
.message-compose { display: flex; align-items: flex-end; gap: 10px; padding: 14px; border-top: 1px solid var(--line); }
.message-compose textarea { flex: 1; resize: none; min-height: 46px; max-height: 130px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 14px; font: inherit; }

/* ── Public information pages ───────────────────────────────────────────── */
.info-page { max-width: 820px; }
.info-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(24px, 5vw, 48px); box-shadow: var(--shadow); }
.info-card h1 { font-size: clamp(28px, 5vw, 42px); margin-bottom: 22px; }
.info-card p { font-size: 16px; line-height: 1.75; }
.delete-account-info h2 { margin-top: 28px; font-size: 21px; }
.delete-account-info ol { padding-left: 22px; line-height: 1.8; }
.delete-account-info li + li { margin-top: 5px; }
.policy-copy h2 { margin-top: 30px; font-size: 21px; }
.policy-copy ul { padding-left: 22px; line-height: 1.75; }
.policy-copy li + li { margin-top: 7px; }
.info-date { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 28px; font-size: 13px !important; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 40px; padding-top: 40px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 24px; padding-bottom: 30px; }
.footer-grid h4 { font-size: 14px; }
.footer-grid a { display: block; color: var(--muted); font-size: 14px; padding: 3px 0; }
.footer-grid a:hover { color: var(--brand); }
.footer-brand { margin-bottom: 10px; }
.footer-bottom { border-top: 1px solid var(--line); padding: 18px 20px; font-size: 13px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .detail-grid, .search-layout { grid-template-columns: 1fr; }
    .filters, .detail-side { position: static; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .search-bar { display: none; }
}
@media (max-width: 560px) {
    .header-inner { gap: 10px; }
    .header-nav { gap: 8px; }
    .header-nav .nav-link, .brand-name { display: none; }
    .header-nav .btn { padding: 9px 12px; font-size: 13px; }
    .locale-switch { min-width: 34px; padding: 0 7px; }
    .hero { padding: 40px 0 46px; }
    .hero-search { border-radius: var(--radius); align-items: stretch; }
    .hero-search input { min-width: 0; padding-left: 8px; }
    .hero-search .btn { padding-inline: 14px; }
    .field-row { flex-direction: column; gap: 0; }
    .post-card, .auth-card { padding: 22px; }
    .account-hero { align-items: flex-start; flex-wrap: wrap; }
    .account-post { width: 100%; margin-left: 0; }
    .message-bubble { max-width: 88%; }
    .message-compose { align-items: stretch; flex-direction: column; }
    .footer-grid { grid-template-columns: 1fr; }
}
