﻿/* ─── Reset & Base ─────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=DM+Serif+Display&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0f1117;
    --bg2: #161b26;
    --bg3: #1e2536;
    --card: #1a2035;
    --border: #2a3352;
    --border2: #3a4466;
    --text: #e8eaf0;
    --text2: #8b93a8;
    --text3: #5a6380;
    --accent: #5b7fff;
    --accent2: #7b95ff;
    --accent-bg: rgba(91,127,255,0.12);
    --green: #3ecf8e;
    --green-bg: rgba(62,207,142,0.12);
    --red: #f06060;
    --red-bg: rgba(240,96,96,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0,0,0,0.35);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.25);
    --transition: 0.18s ease;
}

html {
    font-size: 16px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--accent2);
    text-decoration: none;
    transition: color var(--transition);
}

    a:hover {
        color: #fff;
    }

img {
    display: block;
}

/* ─── Layout ────────────────────────────────────────────────────────────────── */

.page-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ─── Topbar / Nav ──────────────────────────────────────────────────────────── */

.topbar {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.site-logo {
    font-family: 'DM Serif Display', serif;
    font-size: 1.5rem;
    color: #fff;
    letter-spacing: -0.5px;
}

    .site-logo:hover {
        color: var(--accent2);
    }

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

    .topbar-nav a {
        color: var(--text2);
        font-size: 0.875rem;
        font-weight: 500;
        padding: 0.4rem 0.85rem;
        border-radius: var(--radius-sm);
        transition: background var(--transition), color var(--transition);
    }

        .topbar-nav a:hover {
            background: var(--bg3);
            color: var(--text);
        }

        /* Logout link styled as subtle danger */
        .topbar-nav a[href*="Logout"] {
            color: var(--text3);
        }

            .topbar-nav a[href*="Logout"]:hover {
                background: var(--red-bg);
                color: var(--red);
            }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border2);
    background: var(--bg3);
    color: var(--text);
    transition: all var(--transition);
    text-decoration: none;
}

    .btn:hover {
        background: var(--border);
        color: #fff;
        border-color: var(--border2);
    }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

    .btn-primary:hover {
        background: var(--accent2);
        border-color: var(--accent2);
        color: #fff;
    }

.btn-danger {
    background: var(--red-bg);
    border-color: var(--red);
    color: var(--red);
}

    .btn-danger:hover {
        background: var(--red);
        color: #fff;
    }

.btn-sm {
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
}

/* ─── Alerts ────────────────────────────────────────────────────────────────── */

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

    .alert.error {
        background: var(--red-bg);
        border-color: var(--red);
        color: var(--red);
    }

    .alert.success {
        background: var(--green-bg);
        border-color: var(--green);
        color: var(--green);
    }

/* ─── Forms ─────────────────────────────────────────────────────────────────── */

.form-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 480px;
    margin: 2rem auto;
    box-shadow: var(--shadow);
}

.form-title {
    font-family: 'DM Serif Display', serif;
    font-size: 1.5rem;
    font-weight: 400;
    margin-bottom: 1.5rem;
    color: #fff;
}

.field {
    margin-bottom: 1.1rem;
}

    .field label {
        display: block;
        font-size: 0.8rem;
        font-weight: 500;
        color: var(--text2);
        text-transform: uppercase;
        letter-spacing: 0.06em;
        margin-bottom: 0.4rem;
    }

    .field input,
    .field textarea,
    .field select {
        width: 100%;
        padding: 0.65rem 0.9rem;
        background: var(--bg2);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        color: var(--text);
        font-family: 'DM Sans', sans-serif;
        font-size: 0.9rem;
        transition: border-color var(--transition), box-shadow var(--transition);
        outline: none;
    }

        .field input:focus,
        .field textarea:focus,
        .field select:focus {
            border-color: var(--accent);
            box-shadow: 0 0 0 3px var(--accent-bg);
        }

        .field input[type="file"] {
            padding: 0.5rem;
            cursor: pointer;
            color: var(--text2);
        }

    .field textarea {
        resize: vertical;
        min-height: 100px;
    }

.current-pic {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
    color: var(--text2);
    font-size: 0.85rem;
}

/* ─── Landing / Login Page ──────────────────────────────────────────────────── */

.landing-hero {
    display: flex;
    gap: 4rem;
    align-items: flex-start;
    max-width: 960px;
    margin: 3rem auto;
    padding: 0 1rem;
}

.landing-left {
    flex: 1.3;
}

.landing-title {
    font-family: 'DM Serif Display', serif;
    font-size: 3rem;
    font-weight: 400;
    line-height: 1.1;
    margin-bottom: 1rem;
    color: #fff;
}

.landing-sub {
    font-size: 1rem;
    color: var(--text2);
    margin-bottom: 2rem;
    line-height: 1.65;
    max-width: 420px;
}

.landing-features {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.landing-feature {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.feature-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
    margin-top: 2px;
    width: 40px;
    height: 40px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.landing-feature strong {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text);
}

.landing-feature p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text2);
    line-height: 1.5;
}

.landing-right {
    flex: 0 0 340px;
}

/* ─── Market / Search ───────────────────────────────────────────────────────── */

.market-header {
    margin-bottom: 1.25rem;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-input {
    flex: 1;
    padding: 0.65rem 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

    .search-input:focus {
        border-color: var(--accent);
        box-shadow: 0 0 0 3px var(--accent-bg);
    }

    .search-input::placeholder {
        color: var(--text3);
    }

/* ─── Category Bar ──────────────────────────────────────────────────────────── */

.category-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.75rem;
}

.cat-btn {
    padding: 0.4rem 1rem;
    border-radius: 999px;
    font-size: 0.825rem;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg2);
    color: var(--text2);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

    .cat-btn:hover {
        background: var(--bg3);
        border-color: var(--border2);
        color: var(--text);
    }

    .cat-btn.active {
        background: var(--accent);
        border-color: var(--accent);
        color: #fff;
    }

/* ─── Market Grid / Cards ───────────────────────────────────────────────────── */

.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
    text-decoration: none;
    color: inherit;
    display: block;
}

    .card:hover {
        transform: translateY(-3px);
        border-color: var(--border2);
        box-shadow: var(--shadow);
    }

.card-img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    background: var(--bg3);
}

.card-body {
    padding: 0.9rem 1rem;
}

.card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-price {
    font-size: 1rem;
    font-weight: 600;
    color: var(--green);
    margin-bottom: 0.4rem;
}

.card-meta {
    font-size: 0.8rem;
    color: var(--text2);
    line-height: 1.45;
}

.card-seller {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.6rem;
    font-size: 0.78rem;
    color: var(--text3);
}

.avatar-xs {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

.clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ─── Profile ───────────────────────────────────────────────────────────────── */

.profile-box {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.profile-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border2);
    flex-shrink: 0;
}

.profile-info h2 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.4rem;
    font-weight: 400;
    color: #fff;
    margin-bottom: 0.2rem;
}

.profile-info p {
    font-size: 0.875rem;
    color: var(--text2);
    margin-bottom: 0.15rem;
}

.profile-stats {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
}

.stat-box {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    text-align: center;
    min-width: 70px;
}

    .stat-box strong {
        display: block;
        font-size: 1.1rem;
        font-weight: 600;
        color: var(--accent2);
    }

    .stat-box span {
        font-size: 0.75rem;
        color: var(--text3);
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

/* ─── Listing Detail ────────────────────────────────────────────────────────── */

.listing-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    max-width: 900px;
    margin: 0 auto;
}

.listing-image {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg3);
}

.listing-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.listing-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--accent-bg);
    border: 1px solid var(--accent);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent2);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    width: fit-content;
}

.listing-title {
    font-family: 'DM Serif Display', serif;
    font-size: 1.8rem;
    font-weight: 400;
    color: #fff;
    line-height: 1.2;
}

.listing-price {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--green);
}

.listing-section {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem 1.1rem;
}

.listing-section-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}

.listing-section p {
    font-size: 0.9rem;
    color: var(--text2);
    line-height: 1.55;
}

.listing-seller {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

    .listing-seller img {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        object-fit: cover;
        border: 1px solid var(--border2);
    }

    .listing-seller a {
        font-weight: 500;
        font-size: 0.9rem;
    }

.listing-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ─── My Listings / Table Actions ───────────────────────────────────────────── */

.listings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
}

.listing-card-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem;
    border-top: 1px solid var(--border);
    background: var(--bg2);
}

/* ─── Inbox ─────────────────────────────────────────────────────────────────── */

.inbox-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 680px;
}

.inbox-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1.1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color var(--transition), background var(--transition);
}

    .inbox-item:hover {
        border-color: var(--border2);
        background: var(--bg3);
    }

.inbox-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border2);
}

.inbox-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 0.15rem;
}

.inbox-preview {
    font-size: 0.8rem;
    color: var(--text3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

/* ─── Chat ──────────────────────────────────────────────────────────────────── */

.chat-wrap {
    max-width: 680px;
    margin: 0 auto;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
}

    .chat-header img {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        object-fit: cover;
        border: 1px solid var(--border2);
    }

    .chat-header strong {
        font-size: 0.95rem;
        color: var(--text);
    }

.chat-messages {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-top: none;
    border-bottom: none;
    padding: 1.25rem;
    min-height: 320px;
    max-height: 500px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 72%;
}

    .chat-msg.me {
        align-self: flex-end;
        align-items: flex-end;
    }

    .chat-msg.them {
        align-self: flex-start;
        align-items: flex-start;
    }

.chat-bubble {
    padding: 0.6rem 0.9rem;
    border-radius: 16px;
    font-size: 0.875rem;
    line-height: 1.5;
}

.chat-msg.me .chat-bubble {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg.them .chat-bubble {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.chat-time {
    font-size: 0.7rem;
    color: var(--text3);
    margin-top: 0.2rem;
    padding: 0 0.25rem;
}

.chat-input-row {
    display: flex;
    gap: 0.5rem;
    padding: 0.9rem 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

    .chat-input-row input {
        flex: 1;
        padding: 0.6rem 0.9rem;
        background: var(--bg2);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        color: var(--text);
        font-family: 'DM Sans', sans-serif;
        font-size: 0.875rem;
        outline: none;
        transition: border-color var(--transition);
    }

        .chat-input-row input:focus {
            border-color: var(--accent);
        }

        .chat-input-row input::placeholder {
            color: var(--text3);
        }

/* ─── Empty state ───────────────────────────────────────────────────────────── */

.empty-box {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text3);
    font-size: 0.9rem;
    background: var(--card);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
}

    .empty-box a {
        color: var(--accent2);
        font-weight: 500;
    }

/* ─── Page headings ─────────────────────────────────────────────────────────── */

.page-title {
    font-family: 'DM Serif Display', serif;
    font-size: 1.75rem;
    font-weight: 400;
    color: #fff;
    margin-bottom: 1.25rem;
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .topbar {
        padding: 0 1rem;
    }

    .topbar-nav {
        gap: 0;
    }

        .topbar-nav a {
            padding: 0.4rem 0.5rem;
            font-size: 0.8rem;
        }

    .landing-hero {
        flex-direction: column;
        gap: 2rem;
        margin: 1.5rem auto;
    }

    .landing-title {
        font-size: 2rem;
    }

    .landing-right {
        flex: unset;
        width: 100%;
    }

    .listing-wrap {
        grid-template-columns: 1fr;
    }

    .profile-box {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .profile-stats {
        justify-content: center;
    }

    .market-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}
