/* ==========================================================================
   SellAndBuyHere — design tokens
   Palette: Philly Navy #1B2A4A · Brick #A63D33 · Paper #EFE9DE · Brass #C08A2E · Ink #201C16
   Type: "Zilla Slab" (headlines) + "Public Sans" (body/UI)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Zilla+Slab:wght@500;600;700&family=Public+Sans:wght@400;500;600;700&display=swap');

:root{
  --navy:      #1B2A4A;
  --navy-dark: #12203A;
  --brick:     #A63D33;
  --brick-dark:#8A2F27;
  --paper:     #EFE9DE;
  --paper-dark:#E2DAC9;
  --brass:     #C08A2E;
  --ink:       #201C16;
  --ink-soft:  #55503F;
  --line:      #D8CFBC;
  --white:     #FFFFFF;
  --good:      #2E6B4F;
  --good-bg:   #E4F0E8;
  --bad:       #8A2F27;
  --bad-bg:    #F5E3E1;

  --font-head: 'Zilla Slab', Georgia, serif;
  --font-body: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius: 4px;
  --shadow: 0 1px 2px rgba(32,28,22,.08), 0 4px 14px rgba(32,28,22,.06);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  font-size: 16px;
}
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; color: var(--navy); }
h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; color: var(--ink-soft); max-width: 68ch; }
a { color: var(--brick); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
ul { padding: 0; margin: 0; list-style: none; }

:focus-visible {
  outline: 3px solid var(--brass);
  outline-offset: 2px;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------------- Header ---------------- */
.site-header {
  background: var(--navy);
  border-bottom: 3px solid var(--brick);
  position: sticky; top: 0; z-index: 40;
}
.header-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--white); flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--brass); color: var(--navy-dark);
  font-family: var(--font-head); font-weight: 700; font-size: .95rem;
}
.brand-mark.small { margin-bottom: 8px; }
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 1.25rem; color: var(--white); }

.header-search { flex: 1 1 260px; display: flex; max-width: 480px; }
.header-search input {
  flex: 1; border: none; padding: 10px 14px; font-size: .95rem;
  border-radius: var(--radius) 0 0 var(--radius); font-family: var(--font-body);
}
.header-search button {
  background: var(--brass); border: none; color: var(--navy-dark);
  padding: 0 16px; border-radius: 0 var(--radius) var(--radius) 0; cursor: pointer;
}
.header-search button:hover { background: #d29a3c; }

.nav-toggle { display: none; flex-direction: column; gap: 4px; background: none; border: none; cursor: pointer; padding: 8px; }
.nav-toggle span { width: 22px; height: 2px; background: var(--white); display: block; }

.main-nav { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.main-nav a { color: var(--paper); font-weight: 500; font-size: .95rem; position: relative; }
.main-nav a:hover { color: var(--white); text-decoration: none; }
.main-nav .btn-sell {
  background: var(--brick); color: var(--white); padding: 9px 16px;
  border-radius: var(--radius); font-weight: 600;
}
.main-nav .btn-sell:hover { background: var(--brick-dark); }
.icon-link { display: inline-flex; align-items: center; gap: 4px; }
.badge {
  background: var(--brass); color: var(--navy-dark); font-size: .7rem; font-weight: 700;
  border-radius: 999px; padding: 1px 6px; margin-left: 2px;
}

/* ---------------- Buttons & forms ---------------- */
.btn {
  display: inline-block; padding: 11px 20px; border-radius: var(--radius);
  font-weight: 600; font-family: var(--font-body); border: 2px solid transparent;
  cursor: pointer; font-size: .95rem; text-align: center;
}
.btn-primary { background: var(--brick); color: var(--white); }
.btn-primary:hover { background: var(--brick-dark); text-decoration: none; }
.btn-outline { background: transparent; border-color: var(--navy); color: var(--navy); }
.btn-outline:hover { background: var(--navy); color: var(--white); text-decoration: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: .85rem; }
.btn-danger { background: var(--bad); color: var(--white); }

.card-form {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; box-shadow: var(--shadow); max-width: 520px; margin: 40px auto;
}
.card-form.wide { max-width: 760px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .9rem; color: var(--navy); }
.field { margin-bottom: 18px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel],
textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  font-family: var(--font-body); font-size: .95rem; background: var(--white); color: var(--ink);
}
textarea { resize: vertical; min-height: 120px; }
input:focus, textarea:focus, select:focus { border-color: var(--navy); }
.field-row { display: flex; gap: 14px; }
.field-row > .field { flex: 1; }
.help-text { font-size: .8rem; color: var(--ink-soft); margin-top: 4px; }
.form-error { color: var(--bad); font-size: .85rem; margin-top: 4px; }

.alert { padding: 12px 16px; border-radius: var(--radius); margin: 16px 0; font-size: .92rem; }
.alert-success { background: var(--good-bg); color: var(--good); border: 1px solid #c3e0cd; }
.alert-error { background: var(--bad-bg); color: var(--bad); border: 1px solid #e6c3bf; }

/* ---------------- Hero / search bar on homepage ---------------- */
.hero {
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: var(--paper); padding: 56px 0 64px; border-bottom: 4px solid var(--brass);
}
.hero h1 { color: var(--white); max-width: 16ch; }
.hero p.lede { color: #C9D2E0; font-size: 1.1rem; max-width: 46ch; }
.hero-form {
  background: var(--white); border-radius: var(--radius); padding: 18px;
  display: flex; gap: 10px; flex-wrap: wrap; box-shadow: var(--shadow); margin-top: 24px;
}
.hero-form input, .hero-form select { flex: 1; min-width: 160px; }
.hero-form button { flex-shrink: 0; }
.hero-stats { display: flex; gap: 28px; margin-top: 28px; flex-wrap: wrap; }
.hero-stats div strong { display: block; font-family: var(--font-head); font-size: 1.6rem; color: var(--brass); }
.hero-stats div span { font-size: .85rem; color: #C9D2E0; }

/* ---------------- Category chips ---------------- */
.category-strip { padding: 34px 0 10px; }
.chip-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.chip {
  flex: 0 0 auto; background: var(--white); border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 18px; font-size: .88rem; font-weight: 600; color: var(--navy); white-space: nowrap;
}
.chip:hover { border-color: var(--brick); color: var(--brick); text-decoration: none; }

/* ---------------- Listing grid & cards ---------------- */
.section { padding: 30px 0 50px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; flex-wrap: wrap; gap: 8px; }
.listing-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px;
}
.listing-card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease;
}
.listing-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(32,28,22,.12); }
.listing-card a.thumb-link { display: block; text-decoration: none; }
.listing-thumb { width: 100%; aspect-ratio: 4/3; object-fit: cover; background: var(--paper-dark); }
.listing-body { padding: 14px 14px 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.listing-price { font-family: var(--font-head); font-weight: 700; color: var(--brick); font-size: 1.2rem; }
.listing-title { font-weight: 600; color: var(--ink); font-size: .96rem; }
.listing-title a { color: inherit; }
.listing-title a:hover { color: var(--brick); }
.listing-meta { font-size: .8rem; color: var(--ink-soft); margin-top: auto; display: flex; justify-content: space-between; }
.listing-status {
  position: absolute; margin: 10px; background: var(--navy); color: var(--white);
  font-size: .7rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase;
}
.thumb-wrap { position: relative; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-soft); }
.empty-state h3 { color: var(--navy); }

/* ---------------- Pagination ---------------- */
.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 30px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--navy); font-size: .9rem; background: var(--white);
}
.pagination .current { background: var(--navy); color: var(--white); border-color: var(--navy); }
.pagination a:hover { border-color: var(--brick); text-decoration: none; }

/* ---------------- Listing detail page ---------------- */
.listing-detail { display: grid; grid-template-columns: 1.4fr 1fr; gap: 36px; padding: 34px 0 60px; }
.gallery-main { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); aspect-ratio: 4/3; background: var(--white); }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.gallery-thumbs img { width: 70px; height: 70px; object-fit: cover; border-radius: var(--radius); border: 2px solid transparent; cursor: pointer; }
.gallery-thumbs img.active { border-color: var(--brick); }

.detail-panel {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); align-self: start;
}
.detail-price { font-family: var(--font-head); font-size: 2rem; color: var(--brick); font-weight: 700; }
.detail-title { margin-top: 4px; }
.detail-meta-row { display: flex; gap: 14px; color: var(--ink-soft); font-size: .88rem; margin: 10px 0 18px; flex-wrap: wrap; }
.detail-meta-row span { display: flex; align-items: center; gap: 4px; }
.seller-box { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 18px 0; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--navy); color: var(--white);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-family: var(--font-head); flex-shrink: 0;
  object-fit: cover;
}
.description-box { margin: 26px 0; }
.description-box p { white-space: pre-line; color: var(--ink); }
.badge-condition { display: inline-block; background: var(--paper-dark); color: var(--navy); padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; }

/* ---------------- Dashboard / tables ---------------- */
.dash-grid { display: grid; grid-template-columns: 220px 1fr; gap: 30px; padding: 30px 0 60px; }
.dash-nav { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; align-self: start; }
.dash-nav a { display: block; padding: 10px 12px; border-radius: var(--radius); color: var(--ink); font-weight: 500; font-size: .92rem; }
.dash-nav a.active, .dash-nav a:hover { background: var(--paper); color: var(--brick); text-decoration: none; }

table.data-table { width: 100%; border-collapse: collapse; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.data-table th, table.data-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: .9rem; }
table.data-table th { background: var(--paper-dark); color: var(--navy); font-family: var(--font-head); font-weight: 600; }
table.data-table tr:last-child td { border-bottom: none; }
.thumb-sm { width: 52px; height: 52px; object-fit: cover; border-radius: var(--radius); }
.status-pill { padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.status-active { background: var(--good-bg); color: var(--good); }
.status-sold { background: #EAE2F3; color: #5B3B8C; }
.status-inactive { background: var(--paper-dark); color: var(--ink-soft); }

/* ---------------- Messaging ---------------- */
.messages-shell { display: grid; grid-template-columns: 300px 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--white); min-height: 520px; margin: 30px 0 60px; }
.conv-list { border-right: 1px solid var(--line); overflow-y: auto; max-height: 640px; }
.conv-item { display: block; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.conv-item:hover { background: var(--paper); text-decoration: none; }
.conv-item.active { background: var(--paper-dark); }
.conv-item .who { font-weight: 700; color: var(--navy); font-size: .92rem; }
.conv-item .preview { font-size: .82rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.conv-item .unread-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brick); margin-left: 6px; }

.thread-pane { display: flex; flex-direction: column; height: 100%; }
.thread-header { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.thread-body { flex: 1; padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; max-height: 480px; }
.msg-bubble { max-width: 70%; padding: 10px 14px; border-radius: 12px; font-size: .92rem; }
.msg-bubble.mine { align-self: flex-end; background: var(--navy); color: var(--white); border-bottom-right-radius: 2px; }
.msg-bubble.theirs { align-self: flex-start; background: var(--paper-dark); color: var(--ink); border-bottom-left-radius: 2px; }
.msg-time { font-size: .7rem; opacity: .7; margin-top: 4px; display: block; }
.thread-form { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); align-items: center; }
.thread-form input[type=text] { flex: 1; }
.thread-attach-btn {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 38px; height: 38px; border-radius: var(--radius); border: 1px solid var(--line);
  color: var(--navy); cursor: pointer; background: var(--white);
}
.thread-attach-btn:hover { border-color: var(--brick); color: var(--brick); }
.thread-attach-btn.has-file { background: var(--brick); border-color: var(--brick); color: var(--white); }
.msg-image {
  display: block; max-width: 220px; max-height: 220px; width: 100%; height: auto;
  border-radius: 8px; margin-bottom: 6px; object-fit: cover;
}
.no-conv-selected { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--ink-soft); padding: 40px; text-align: center; }

/* ---------------- Notifications page ---------------- */
.notif-list { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 24px 0 60px; }
.notif-item { display: flex; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: #FBF6EC; }
.notif-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brass); flex-shrink: 0; margin-top: 6px; }
.notif-item.read .notif-dot { background: transparent; }

/* ---------------- Footer ---------------- */
.site-footer { background: var(--navy-dark); color: #B9C2D4; padding: 44px 0 0; margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 30px; padding-bottom: 30px; }
.footer-grid h3 { color: var(--white); font-size: .95rem; margin-bottom: 12px; }
.footer-grid a { color: #B9C2D4; }
.footer-grid a:hover { color: var(--brass); }
.footer-grid li { margin-bottom: 8px; }
.footer-bottom { border-top: 1px solid #2A3B5C; padding: 16px 20px; font-size: .82rem; }

/* ---------------- Responsive ---------------- */
@media (max-width: 880px) {
  .listing-detail { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-nav { display: flex; overflow-x: auto; gap: 4px; }
  .dash-nav a { white-space: nowrap; }
  .messages-shell { grid-template-columns: 1fr; }
  .conv-list { max-height: 220px; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  .nav-toggle { display: flex; }
  .main-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--navy); flex-direction: column; align-items: stretch;
    padding: 10px 20px 20px; gap: 6px; border-bottom: 3px solid var(--brick);
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 10px 4px; border-bottom: 1px solid #2A3B5C; }
  .header-search { order: 3; flex-basis: 100%; }
  .footer-grid { grid-template-columns: 1fr; }
  .hero { padding: 40px 0 46px; }
}

@media (max-width: 480px) {
  .listing-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .card-form { padding: 20px; margin: 20px auto; }
  .field-row { flex-direction: column; gap: 0; }
}
