/* ============================================================
   ShareCycle — style.css  (dark theme, photo-first)
   Reference layout: charcoal background, sage-green rounded
   hero panel with a big photo, stats row, pill search bar,
   category chips, photo cards with green "RM 0" price row.
   Mobile-first; @media upgrades for desktop.
   ============================================================ */

/* ---------- 1. Design tokens ---------- */
:root {
  /* dark surfaces */
  --bg: #16181a;            /* page background (charcoal) */
  --bg-card: #1f2224;       /* card surface */
  --bg-raised: #26292c;     /* inputs, hover surfaces */
  --line: #33373b;          /* hairline borders */

  /* sage green accents */
  --sage: #e7efdd;          /* hero panel background */
  --sage-ink: #2e4b34;      /* dark green text on sage */
  --green: #4ade80;         /* bright green — prices, accents on dark */
  --green-deep: #3fae67;

  /* text */
  --ink: #f2f3f1;           /* primary text on dark */
  --muted: #9aa3a0;         /* secondary text */

  /* status colours */
  --ok-bg: rgba(74, 222, 128, 0.14);   --ok-ink: #4ade80;
  --warn-bg: rgba(250, 204, 21, 0.14); --warn-ink: #facc15;
  --off-bg: rgba(255, 255, 255, 0.08); --off-ink: #9aa3a0;

  /* shadows + shapes */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  --radius-sm: 14px;
}

/* ---------- 2. Reset + base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* The hidden attribute must ALWAYS win, even over display rules below. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
code { background: var(--bg-raised); padding: 1px 6px; border-radius: 6px; font-size: 0.9em; color: var(--green); }

/* ---------- 3. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px;
  font-weight: 600; font-size: 0.95rem;
  border: none; cursor: pointer; text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--green); color: #0d2013; box-shadow: var(--shadow-md); }
.btn-primary:hover { transform: translateY(-2px); background: #5ce68e; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--green); color: var(--green); }

/* ---------- 4. Navbar ---------- */
.navbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(22, 24, 26, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1180px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink);
  font-weight: 700; font-size: 1.35rem; letter-spacing: -0.3px;
}
.logo-mark { color: var(--green); display: flex; }
.fav-pill {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: var(--bg-card);
  border-radius: 999px; padding: 10px 18px; cursor: pointer;
  font-weight: 600; font-size: 0.95rem; color: var(--ink);
  transition: all 0.15s ease;
}
.fav-pill:hover { border-color: var(--green); }
.fav-pill.active { border-color: var(--green); color: var(--green); }

/* ---------- 5. Hero panel (sage green, rounded, photo) ---------- */
.hero-panel {
  max-width: 1180px; margin: 20px auto 0;
  background: var(--sage); color: var(--sage-ink);
  border-radius: var(--radius); padding: 40px 40px 40px;
}
.hero-eyebrow {
  text-transform: uppercase; letter-spacing: 1.5px;
  font-size: 0.85rem; font-weight: 600; color: #52705a;
  margin-bottom: 14px;
}
.hero-copy h1 {
  font-size: clamp(1.9rem, 4.6vw, 3.1rem);
  line-height: 1.12; font-weight: 700; letter-spacing: -0.5px;
  color: #233c29; max-width: 640px;
}
.hero-sub { margin-top: 14px; max-width: 560px; color: #42604a; font-size: 1.02rem; }
.hero-media { margin-top: 26px; }
.hero-media img {
  width: 100%; height: clamp(240px, 42vw, 480px);
  object-fit: cover; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

/* ---------- 6. Stats row ---------- */
.stats-row {
  max-width: 1180px; margin: 26px auto 0; padding: 0 4px;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 28px;
}
@media (min-width: 760px) { .stats-row { grid-template-columns: repeat(4, 1fr); } }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; }
.stat-num { font-size: clamp(1.6rem, 3.4vw, 2.2rem); font-weight: 700; letter-spacing: -0.5px; }
.stat-label { font-size: 0.92rem; color: var(--muted); }

/* ---------- 7. Sections ---------- */
.section { max-width: 1180px; margin: 0 auto; padding: 58px 20px 0; }
.section-head { margin-bottom: 24px; }
.section-head h2 { font-size: clamp(1.5rem, 3.5vw, 2rem); font-weight: 700; letter-spacing: -0.3px; }
.section-head p { color: var(--muted); margin-top: 6px; max-width: 640px; }

/* ---------- 8. Donate form ---------- */
.donate-card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 24px;
}
.form-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 760px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .field-wide { grid-column: 1 / -1; }
}
.field span { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 6px; }
.field em { color: var(--green); font-style: normal; }
.field input,
.field select,
.field textarea {
  width: 100%; padding: 12px 16px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-raised); font: inherit; color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input::placeholder, .field textarea::placeholder { color: #6d7570; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
}
textarea { resize: vertical; }
.form-foot { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.form-error { color: #f87171; font-size: 0.88rem; font-weight: 600; }

/* ---------- 9. Browse: search + chips + controls ---------- */
.search-wrap { margin-bottom: 16px; }
#searchInput {
  width: 100%; padding: 16px 22px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-card); font: inherit; color: var(--ink);
}
#searchInput::placeholder { color: #6d7570; }
#searchInput:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
}

.chip-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.chip {
  padding: 10px 20px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-card);
  color: var(--ink); font: inherit; font-weight: 600; font-size: 0.92rem;
  cursor: pointer; transition: all 0.15s ease;
}
.chip:hover { border-color: var(--green); color: var(--green); }
.chip.selected { background: var(--sage); border-color: var(--sage); color: var(--sage-ink); }

.controls-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.filter-select {
  padding: 10px 16px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--bg-card); font: inherit;
  cursor: pointer; color: var(--ink);
}
.result-count { color: var(--muted); font-size: 0.9rem; margin-left: auto; }

/* ---------- 10. Item grid + photo cards ---------- */
.grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: #3d4348; }

.card-photo { position: relative; aspect-ratio: 4 / 3; background: var(--bg-raised); }
.card-photo img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.3s ease;
}
.card:hover .card-photo img { transform: scale(1.03); }

.status-chip {
  position: absolute; top: 12px; left: 12px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.3px;
  padding: 5px 12px; border-radius: 999px;
  backdrop-filter: blur(6px);
}
.status-chip.available { background: var(--ok-bg); color: var(--ok-ink); }
.status-chip.reserved  { background: var(--warn-bg); color: var(--warn-ink); }
.status-chip.given     { background: rgba(0, 0, 0, 0.55); color: #c9d1cc; }

/* Inside the modal the chip must flow inline, not float over the photo. */
.m-row .status-chip { position: static; }

.match-chip {
  position: absolute; top: 12px; right: 12px;
  background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(6px);
  font-size: 0.72rem; font-weight: 700; color: var(--green);
  padding: 5px 12px; border-radius: 999px;
}

.card-body { padding: 16px 18px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { font-size: 1.08rem; font-weight: 700; letter-spacing: -0.2px; }
.card-loc { font-size: 0.9rem; color: var(--muted); }
.card-cond { font-size: 0.9rem; color: var(--muted); }
.card-cond .sep { margin: 0 6px; opacity: 0.5; }

/* tag pills under the card text */
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 0.72rem; background: var(--bg-raised); color: var(--muted);
  padding: 3px 10px; border-radius: 999px; font-weight: 600;
}

/* emoji tile shown when a listing has no photo (user-created items) */
.photo-fallback {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 3.2rem;
  background: linear-gradient(135deg, #2a2e31 0%, #1f2224 100%);
}

/* price row: green RM 0 left, Save button right — like the reference */
.card-foot {
  margin-top: auto; padding-top: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.price { color: var(--green); font-weight: 700; font-size: 1rem; }
.save-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: transparent; border: none; cursor: pointer;
  color: var(--ink); font: inherit; font-weight: 600; font-size: 0.95rem;
  padding: 8px 10px; border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}
.save-btn:hover { background: var(--bg-raised); }
.save-btn.faved { color: var(--green); }
.details-link {
  font-size: 0.85rem; color: var(--muted); text-decoration: none;
  border-bottom: 1px dotted var(--line); cursor: pointer; margin-right: auto;
}
.details-link:hover { color: var(--green); }

/* ---------- 11. Empty state ---------- */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state h3 { font-size: 1.2rem; margin-bottom: 6px; }
.empty-state p { color: var(--muted); margin-bottom: 16px; }

/* ---------- 12. Dashboard ---------- */
.dash-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 860px) { .dash-grid { grid-template-columns: repeat(4, 1fr); } }
.dash-card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 20px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.dash-num { font-size: 1.9rem; font-weight: 700; color: var(--green); letter-spacing: -0.5px; }
.dash-label { font-size: 0.82rem; color: var(--muted); }
.dash-note {
  margin-top: 16px; padding: 14px 18px;
  background: var(--bg-card); border: 1px dashed var(--line);
  border-radius: var(--radius-sm); color: var(--muted); font-size: 0.9rem;
}

/* ---------- 13. How it works ---------- */
.how-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .how-grid { grid-template-columns: repeat(4, 1fr); } }
.how-card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 20px 18px; position: relative;
}
.how-num {
  position: absolute; top: -13px; left: 16px;
  width: 30px; height: 30px; border-radius: 999px;
  background: var(--green); color: #0d2013;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.9rem;
}
.how-card h3 { margin: 8px 0 6px; font-size: 1rem; }
.how-card p { font-size: 0.86rem; color: var(--muted); }

/* ---------- 14. Footer ---------- */
.footer {
  margin-top: 58px; padding: 28px 20px 36px;
  border-top: 1px solid var(--line);
  text-align: center; color: var(--muted); font-size: 0.9rem;
}
.footer-dim { margin-top: 6px; opacity: 0.75; font-size: 0.8rem; }

/* ---------- 15. Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.65);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius);
  max-width: 540px; width: 100%; max-height: 86vh; overflow-y: auto;
  padding: 24px; position: relative; box-shadow: var(--shadow-md);
}
.modal-close {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  width: 34px; height: 34px; border-radius: 999px;
  border: none; background: var(--bg-raised); font-size: 1rem;
  cursor: pointer; color: var(--ink);
}
.modal h3 { font-size: 1.3rem; margin-bottom: 12px; padding-right: 34px; }
.modal .m-photo { border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 14px; }
.modal .m-photo img { width: 100%; height: 220px; object-fit: cover; }
.modal .m-row { display: flex; gap: 10px; margin: 8px 0; font-size: 0.92rem; align-items: baseline; }
.modal .m-label { font-weight: 600; color: var(--muted); min-width: 92px; }
.modal .m-desc { margin: 10px 0; color: var(--muted); font-size: 0.92rem; }
.modal .m-score {
  margin-top: 12px; background: var(--bg-raised); border-radius: var(--radius-sm);
  padding: 14px 16px; font-size: 0.9rem;
}
.m-score-bar { height: 8px; background: #2e3337; border-radius: 999px; margin-top: 10px; overflow: hidden; }
.m-score-fill { height: 100%; background: var(--green); }

/* ---------- 16. Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--sage); color: var(--sage-ink);
  padding: 12px 22px; border-radius: 999px;
  font-weight: 600; font-size: 0.9rem;
  box-shadow: var(--shadow-md); z-index: 200;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- 17. Small screens ---------- */
@media (max-width: 560px) {
  .hero-panel { margin: 12px 12px 0; padding: 26px 22px; }
  .stats-row { padding: 0 12px; gap: 12px; }
  .section { padding: 44px 16px 0; }
  .result-count { margin-left: 0; width: 100%; }
}
