/* app.css — ACHAT Campus, mobile-first, system fonts only */

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: #1a1a1a;
  background: #fff;
  margin: 0;
}

/* --- Layout ------------------------------------------------------- */

header, main, footer { max-width: 40rem; margin: 0 auto; padding: 0 1rem; }

/* --- Header ------------------------------------------------------- */

header {
  position: sticky;
  top: 0;
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  max-width: 100%;
  z-index: 10;
}

.site-name { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: #1a1a1a; }
header nav { display: flex; align-items: center; gap: 0.75rem; flex-wrap: nowrap; }
header nav span { color: #555; font-size: 0.9rem; white-space: nowrap; }
header nav a { color: #6f35d4; text-decoration: none; font-size: 0.9rem; }
header nav a:hover { text-decoration: underline; }
header nav .nav-messages {
    color: #6f35d4;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}
header nav .nav-messages:hover { text-decoration: underline; }
.messaging-unread-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: #6f35d4;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    min-width: 1.5rem;
    text-align: center;
    line-height: 1.2;
}
header nav .btn-logout {
    background: #6f35d4;
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}
header nav .btn-logout:hover { background: #5b28b8; }
.inline-form { display: inline; margin: 0; padding: 0; }

/* --- Main --------------------------------------------------------- */

main { padding-top: 2rem; padding-bottom: 2rem; min-height: 60vh; }

/* --- Hero / Dashboard --------------------------------------------- */

.hero, .dashboard { text-align: center; padding: 3rem 0 2rem; }
.hero h1, .dashboard h1 { font-size: 1.75rem; margin-bottom: 0.5rem; }
.hero p, .hero-sub, .dashboard p, .muted { color: #555; margin-bottom: 1rem; }

.hero-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

/* --- Buttons ------------------------------------------------------ */

.btn {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  background: #0066cc;
  color: #fff;
  border: 1px solid #0066cc;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  min-height: 2.75rem;
  line-height: 1.5;
}
.btn:hover { background: #0055aa; border-color: #0055aa; }
.btn-secondary { background: transparent; color: #0066cc; }
.btn-secondary:hover { background: #f0f4ff; }

.btn-logout {
  background: none;
  border: none;
  color: #0066cc;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
  text-decoration: underline;
}
.btn-logout:hover { color: #0055aa; }

/* --- Forms -------------------------------------------------------- */

form { max-width: 24rem; }
.field { margin-bottom: 1.25rem; }
.field label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 0.3rem; }

.field input {
  display: block;
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid #bbb;
  border-radius: 4px;
  min-height: 2.75rem;
}
.field input:focus { outline: 2px solid #0066cc; outline-offset: 1px; border-color: #0066cc; }

button[type="submit"] {
  margin-top: 0.25rem;
  padding: 0.65rem 1.5rem;
  background: #0066cc;
  color: #fff;
  border: 1px solid #0066cc;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  min-height: 2.75rem;
}
button[type="submit"]:hover { background: #0055aa; border-color: #0055aa; }
.form-alt { margin-top: 1.25rem; font-size: 0.9rem; color: #555; }

/* --- Errors ------------------------------------------------------- */

.errors {
  background: #fff0f0;
  border: 1px solid #f5b5b5;
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  max-width: 24rem;
}
.errors ul { margin: 0; padding-left: 1.25rem; }
.errors li { color: #cc0000; font-size: 0.9rem; line-height: 1.6; }

/* --- Footer ------------------------------------------------------- */

footer {
  border-top: 1px solid #e5e5e5;
  padding-top: 1rem;
  padding-bottom: 1.5rem;
  font-size: 0.8rem;
  color: #888;
  text-align: center;
  max-width: 100%;
}

/* --- Category filter ---------------------------------------------- */

.category-filter { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.category-filter a { font-size: 0.85rem; padding: 0.25rem 0.65rem; border: 1px solid #ccc; border-radius: 3px; text-decoration: none; color: #333; }
.category-filter a:hover, .category-filter a.active { background: #0066cc; color: #fff; border-color: #0066cc; }

/* --- Listings browse ---------------------------------------------- */

.listings { display: grid; gap: 1rem; margin-top: 1.5rem; }

.listing-card { border: 1px solid #e5e5e5; border-radius: 6px; padding: 1rem; }
.listing-card h2 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.listing-card h2 a { text-decoration: none; color: #1a1a1a; }
.listing-card h2 a:hover { color: #0066cc; }
.listing-card .price { font-size: 1.1rem; font-weight: 700; margin: 0.25rem 0; }
.listing-card .meta { font-size: 0.8rem; color: #888; margin: 0; }

/* --- Pagination ---------------------------------------------------- */

.pagination { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 2rem; font-size: 0.9rem; }
.pagination a { color: #0066cc; text-decoration: none; }
.pagination a:hover { text-decoration: underline; }

/* --- Listing detail ------------------------------------------------ */

.back { font-size: 0.9rem; color: #0066cc; text-decoration: none; display: inline-block; margin-bottom: 1rem; }
.back:hover { text-decoration: underline; }
.description { line-height: 1.75; margin: 1.25rem 0; }

.warning {
  background: #fff7e6;
  border: 1px solid #f5c842;
  border-radius: 4px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  margin: 1rem 0;
}

.owner-actions { display: flex; align-items: center; gap: 0.75rem; margin-top: 1.5rem; flex-wrap: wrap; }

.btn-danger {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  background: #cc0000;
  color: #fff;
  border: 1px solid #cc0000;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  min-height: 2.75rem;
  line-height: 1.5;
}
.btn-danger:hover { background: #aa0000; border-color: #aa0000; }

/* --- My listings table -------------------------------------------- */

.my-listings { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-top: 1.25rem; }
.my-listings th { text-align: left; font-weight: 600; padding: 0.5rem; border-bottom: 2px solid #e5e5e5; }
.my-listings td { padding: 0.5rem; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.my-listings tr:last-child td { border-bottom: none; }

/* --- Photos ------------------------------------------------------- */

.listing-photo { margin: 1rem 0; text-align: center; }
.listing-photo img { max-width: 100%; height: auto; border-radius: 4px; display: block; margin: 0 auto; }

.listing-thumb { display: block; margin-bottom: 0.75rem; }
.listing-thumb img { width: 100%; height: auto; max-height: 200px; object-fit: cover; border-radius: 4px; display: block; }

.hint { font-size: 0.85rem; color: #777; margin: 0.25rem 0 0 0; }

.flash-error {
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.search-form {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
  max-width: 500px;
}
.search-form input[type=search] {
  flex: 1;
}

/* --- Mobile header (< 600px) ─────────────────────────────────── */
@media (max-width: 600px) {
    header { padding: 0.6rem 1rem; }
    .site-name { font-size: 1rem; }
    header nav { gap: 0.5rem; }
    header nav span {
        /* Hide the greeting on phones — saves space, user is logged in anyway */
        display: none;
    }
    header nav .btn-logout {
        padding: 0.4rem 0.85rem;
        font-size: 0.85rem;
    }
    header nav a {
        font-size: 0.85rem;
    }
}
