/* Listing / marketplace pages — uses shared vars + nav from auth.css */

.page-title {
    font-family: "Plus Jakarta Sans", sans-serif;
    font-size: 30px;
    letter-spacing: -1.2px;
    margin-bottom: 6px;
}

.page-subtitle {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 28px;
}

/* ---------- Filters ---------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 28px;
    padding: 16px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.filter-bar input[type="search"] {
    flex: 1;
    min-width: 200px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
}

.filter-bar input[name="location"] {
    flex: 0 1 190px;
    min-width: 140px;
}

.filter-bar select {
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
    background: var(--white);
    min-width: 150px;
}

.filter-bar input:focus,
.filter-bar select:focus {
    outline: none;
    border-color: var(--green);
}

.filter-bar .btn {
    width: auto;
    padding: 11px 22px;
}

.filter-bar .btn-link {
    color: var(--green);
    font-size: 14px;
    font-weight: 600;
    padding: 11px 8px;
}

/* ---------- Listing grid ---------- */
.listing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
    gap: 20px;
}

.listing-card {
    position: relative;
    display: block;
    overflow: hidden;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.listing-card-link {
    display: block;
    color: inherit;
}

.card-edit-form {
    position: absolute;
    right: 12px;
    bottom: 12px;
    margin: 0;
}

.card-edit {
    padding: 0;
    background: none;
    border: 0;
    color: var(--green);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.card-edit:hover {
    text-decoration: underline;
}

/* ---------- Seller CTA ---------- */
.sell-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 28px;
    padding: 20px 24px;
    background: var(--mint);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.sell-cta strong { display: block; font-size: 16px; }
.sell-cta span { color: var(--muted); font-size: 13px; }
.sell-cta .btn { width: auto; padding: 11px 22px; }

.listing-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(19, 43, 34, 0.12);
}

.listing-thumb {
    position: relative;
    display: grid;
    height: 170px;
    place-items: center;
    background: var(--mint);
    color: var(--green);
    font-size: 56px;
    overflow: hidden;
}

.badge-new {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 3px 10px;
    background: var(--lime);
    color: var(--ink);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.listing-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.listing-body { padding: 15px; }

.listing-body small {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.listing-body h3 {
    margin: 5px 0 8px;
    font-size: 15px;
    line-height: 1.35;
}

.listing-price {
    color: var(--green);
    font-size: 17px;
    font-weight: 800;
}

/* ---------- Ads ---------- */
.ad-banner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    margin-bottom: 20px;
    padding: 10px;
    background: var(--white);
    border: 1px dashed var(--line);
    border-radius: 14px;
    overflow: hidden;
}

.ad-label {
    position: absolute;
    top: 6px;
    left: 10px;
    z-index: 1;
    color: #9ba59f;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.ad-card {
    border-style: dashed;
    border-color: var(--line);
    cursor: default;
}

.ad-card:hover {
    transform: none;
    box-shadow: none;
}

.ad-label-thumb {
    position: absolute;
    top: 8px;
    right: 8px;
    left: auto;
}

/* Side rails — only when the viewport has room for 160px gutters
   (container is 1160px; rails center inside (100vw - 1160)/2 each side) */
.ad-rail {
    display: none;
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 160px;
    z-index: 5;
}

@media (min-width: 1500px) {
    .ad-rail {
        display: block;
        /* Temporary placeholder so the rail footprint is visible
           until real AdSense IDs are configured */
        background: var(--white);
        border: 1px dashed var(--line);
        border-radius: 12px;
    }
    .ad-rail-left { left: calc((100vw - 1160px) / 4 - 80px); }
    .ad-rail-right { right: calc((100vw - 1160px) / 4 - 80px); }

    /* Rails replace the leaderboard on wide screens to keep ad density sane */
    .ad-banner { display: none; }
}

.results-count {
    margin: -10px 0 18px;
    color: var(--muted);
    font-size: 13px;
}

.pagination {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 28px;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: border-color 0.2s, background 0.2s;
}

.page-link:hover {
    border-color: var(--green);
    color: var(--green);
}

.page-link.active {
    background: var(--green);
    border-color: var(--green);
    color: var(--white);
}

.empty-state {
    padding: 70px 20px;
    background: var(--white);
    border: 1px dashed var(--line);
    border-radius: 16px;
    text-align: center;
    color: var(--muted);
}

/* ---------- Detail page ---------- */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 28px;
    align-items: start;
}

.detail-main,
.seller-card {
    padding: 30px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 16px;
}

.detail-image {
    display: grid;
    height: 320px;
    place-items: center;
    margin-bottom: 24px;
    background: var(--mint);
    color: var(--green);
    border-radius: 14px;
    font-size: 90px;
    overflow: hidden;
}

.detail-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.detail-title {
    font-family: "Plus Jakarta Sans", sans-serif;
    font-size: 28px;
    letter-spacing: -1px;
    margin-bottom: 10px;
}

.detail-price {
    color: var(--green);
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 20px;
}

.detail-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 22px;
}

.detail-description {
    color: #444;
    font-size: 15px;
    line-height: 1.7;
    white-space: pre-wrap;
}

.seller-card h2 {
    font-family: "Plus Jakarta Sans", sans-serif;
    font-size: 18px;
    margin-bottom: 16px;
}

.seller-card .seller-name {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
}

.seller-card .seller-meta {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 16px;
}

.contact-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 0;
    border-top: 1px solid var(--line);
    font-size: 14px;
}

.contact-row .icon {
    color: var(--green);
    font-size: 16px;
    width: 22px;
}

.contact-row a { color: var(--green); font-weight: 600; word-break: break-all; }

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active { background: var(--mint); color: var(--green-dark); }
.status-sold { background: #fbe4e1; color: #a63a2e; }
.status-expired { background: #f4dfc3; color: #8a5a1f; }

/* ---------- Chat ---------- */
.chat-box {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.chat-box h2 { margin-bottom: 12px; }

.chat-form textarea {
    width: 100%;
    padding: 11px 13px;
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
    resize: vertical;
}

.chat-form textarea:focus {
    outline: none;
    border-color: var(--green);
}

.chat-context {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 14px 18px;
    margin-bottom: 18px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.chat-back {
    color: var(--green);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.chat-listing-title {
    color: #333;
    font-weight: 700;
    text-decoration: none;
}

.chat-listing-title:hover { color: var(--green); }

.chat-listing-price {
    margin-left: 8px;
    color: var(--green);
    font-weight: 800;
}

.chat-with {
    margin-left: auto;
    color: var(--muted);
    font-size: 13px;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
    max-height: 55vh;
    padding: 18px;
    margin-bottom: 14px;
    overflow-y: auto;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.msg {
    display: flex;
    flex-direction: column;
    max-width: 75%;
}

.msg-own {
    align-self: flex-end;
    align-items: flex-end;
}

.msg-bubble {
    padding: 10px 14px;
    background: #f0f2f1;
    border-radius: 14px;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.msg-own .msg-bubble {
    background: var(--green);
    color: #fff;
}

.msg-time {
    margin-top: 4px;
    padding: 0 4px;
    color: var(--muted);
    font-size: 11px;
}

.chat-input { display: flex; gap: 10px; }

.chat-input input[type="text"] {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
}

.chat-input input[type="text"]:focus {
    outline: none;
    border-color: var(--green);
}

.chat-input .btn { width: auto; padding: 12px 24px; }

.conv-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    margin-bottom: 10px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 14px;
    color: inherit;
    text-decoration: none;
    transition: box-shadow 0.2s ease;
}

.conv-row:hover { box-shadow: 0 8px 24px rgba(19, 43, 34, 0.10); }

.conv-avatar {
    position: relative;
    display: grid;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    place-items: center;
    background: var(--mint);
    color: var(--green);
    border-radius: 50%;
    font-weight: 800;
}

.conv-info { flex: 1; min-width: 0; }

.conv-name { font-weight: 700; font-size: 14px; }

.conv-listing {
    color: var(--green);
    font-size: 12px;
    font-weight: 600;
}

.conv-preview {
    margin-top: 2px;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time {
    flex-shrink: 0;
    color: var(--muted);
    font-size: 12px;
}

.conv-unread .conv-name,
.conv-unread .conv-preview {
    font-weight: 800;
    color: #333;
}

.conv-unread .conv-avatar::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    background: #c0392b;
    border: 2px solid var(--white);
    border-radius: 50%;
}

.msg-badge {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 4px;
    background: #c0392b;
    color: #fff;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
    vertical-align: middle;
}

.safety-note {
    margin-top: 12px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.report-box {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.report-form {
    display: flex;
    gap: 8px;
}

.report-form select {
    flex: 1;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-size: 13px;
    color: var(--muted);
    background: var(--white);
}

.report-btn {
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: transparent;
    color: #a63a2e;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.report-btn:hover {
    background: #fbe4e1;
    border-color: #e0b7b2;
}

.reported-note {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

/* ---------- Profile ---------- */
.profile-card {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    padding: 28px;
    margin-bottom: 36px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 16px;
}

.profile-avatar {
    display: grid;
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    place-items: center;
    background: var(--green);
    color: var(--lime);
    border-radius: 50%;
    font-family: "Plus Jakarta Sans", sans-serif;
    font-size: 26px;
    font-weight: 800;
    text-transform: uppercase;
}

.profile-info { flex: 1; min-width: 220px; }

.profile-info h2 {
    margin-bottom: 6px;
    font-family: "Plus Jakarta Sans", sans-serif;
    font-size: 22px;
    letter-spacing: -0.6px;
}

.profile-meta { color: var(--muted); font-size: 13px; margin-bottom: 4px; }

.profile-stats {
    display: flex;
    gap: 26px;
    flex-wrap: wrap;
}

.profile-stat { text-align: center; min-width: 68px; }

.profile-stat strong {
    display: block;
    font-family: "Plus Jakarta Sans", sans-serif;
    font-size: 26px;
    color: var(--green);
}

.profile-stat span {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-section-title {
    margin: 32px 0 16px;
    font-family: "Plus Jakarta Sans", sans-serif;
    font-size: 18px;
    letter-spacing: -0.4px;
}

.profile-section-title span { color: var(--muted); font-weight: 500; }

/* ---------- My listings ---------- */
.my-row {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 16px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 14px;
    margin-bottom: 12px;
}

.my-thumb {
    display: grid;
    width: 90px;
    height: 68px;
    flex-shrink: 0;
    place-items: center;
    background: var(--mint);
    color: var(--green);
    border-radius: 10px;
    font-size: 28px;
    overflow: hidden;
}

.my-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.my-info { flex: 1; min-width: 0; }

.my-info h3 { font-size: 15px; margin-bottom: 4px; }

.my-info .meta { color: var(--muted); font-size: 12px; }

.my-views {
    flex-shrink: 0;
    min-width: 64px;
    text-align: center;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.my-views strong {
    display: block;
    color: var(--ink);
    font-family: "Plus Jakarta Sans", sans-serif;
    font-size: 20px;
}

.my-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.my-actions .btn {
    width: auto;
    padding: 9px 16px;
    font-size: 13px;
}

.btn-danger {
    background: #c0392b;
}

.btn-danger:hover { background: #a63a2e; }

/* ---------- Form page ---------- */
.form-card {
    max-width: 640px;
    margin: 0 auto;
    padding: 36px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 16px;
}

.form-card textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
    min-height: 120px;
    resize: vertical;
    transition: border-color 0.2s;
}

.form-card textarea:focus { outline: none; border-color: var(--green); }

.form-card select {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
    background: var(--white);
}

.form-card select:focus { outline: none; border-color: var(--green); }

.hint { margin-top: 4px; color: #9ba59f; font-size: 12px; }

/* Compact sell/edit form — keeps the whole form on one screen */
.form-card--compact { padding: 22px 28px; }
.form-card--compact .page-title { font-size: 24px; margin-bottom: 4px; }
.form-card--compact .page-subtitle { margin-bottom: 16px; }
.form-card--compact .form-group { margin-bottom: 10px; }
.form-card--compact .form-row { gap: 10px; }
.form-card--compact label { margin-bottom: 4px; }
.form-card--compact input,
.form-card--compact select { padding: 9px 12px; }
.form-card--compact textarea { min-height: 72px; padding: 9px 12px; }
.form-card--compact .btn { padding: 11px; }

@media (max-width: 800px) {
    .detail-grid { grid-template-columns: 1fr; }
    .my-row { flex-wrap: wrap; }
    .my-actions { width: 100%; }
}

@media (max-width: 600px) {
    .page-title { font-size: 26px; }
    .page-subtitle { margin-bottom: 20px; }

    /* Filter bar: every control full width, iOS-safe font size */
    .filter-bar { padding: 14px; gap: 10px; }
    .filter-bar input[type="search"],
    .filter-bar select,
    .filter-bar .btn {
        flex-basis: 100%;
        min-width: 0;
        font-size: 16px;
    }
    .filter-bar .btn { padding: 12px 22px; }
    .filter-bar .btn-link { margin: 0 auto; padding: 8px; }

    .listing-grid { gap: 14px; }

    .detail-image { height: 220px; font-size: 64px; }
    .detail-main,
    .seller-card { padding: 20px; }
    .detail-title { font-size: 24px; }
    .detail-price { font-size: 22px; }
    .detail-meta { gap: 10px; }

    .form-card { padding: 24px 18px; }
    .form-card select,
    .form-card textarea,
    .form-card input,
    .chat-input input[type="text"],
    .report-form select { font-size: 16px; }

    /* Action buttons share the row evenly */
    .my-actions { flex-wrap: wrap; }
    .my-actions form { flex: 1 1 0; display: flex; }
    .my-actions form .btn { width: 100%; }
    .my-actions .btn { flex: 1 1 0; }

    .empty-state { padding: 48px 16px; }
}
