/* ============================================================
   ESAForum — Marketplace styles  v5
   Created by ESAGAMES HOSTING SHIELD SRL
   ============================================================ */

/* ---- Shared header actions ---- */
.mkt-head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}

/* ---- Filter / tab bar ---- */
.mkt-filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.mkt-tab {
    padding: 7px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.mkt-tab:hover {
    color: #fff;
    border-color: var(--primary);
    background: var(--surface-2);
}

.mkt-tab.active {
    background: var(--grad-primary);
    color: var(--on-accent, #fff);
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(var(--primary-rgb), .35);
}

/* Buy button (.btn-primary) sits on the solid accent fill — keep its label
   legible on light accents (e.g. gold) via the on-accent token. */
.mkt-card .btn-primary {
    color: var(--on-accent, #fff);
}

/* ---- Listings grid ---- */
.mkt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

/* ---- Individual listing card ---- */
.mkt-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 16px 16px;
    text-align: center;
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    overflow: hidden;
    position: relative;
}
/* Ensure buy/login buttons inside cards are full-width without overflow */
.mkt-card form { width: 100%; box-sizing: border-box; }

.mkt-card:hover {
    transform: translateY(-4px);
    border-color: rgba(var(--primary-rgb), .35);
    box-shadow: 0 10px 32px rgba(0,0,0,.35);
}

/* Top shimmer line on hover */
.mkt-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(var(--primary-rgb),.45), transparent);
    border-radius: var(--radius) var(--radius) 0 0;
    opacity: 0;
    transition: opacity var(--transition);
}
.mkt-card:hover::before { opacity: 1; }

/* Cosmetic preview area */
.mkt-preview {
    height: 64px;
    display: grid;
    place-items: center;
    margin-bottom: 10px;
    background: var(--surface-2);
    border-radius: 10px;
    border: 1px solid var(--border-soft);
    overflow: hidden;
}

.mkt-item-name {
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.7em;
    margin-bottom: 3px;
}

.mkt-type-label {
    font-size: 11.5px;
    color: var(--text-mute);
    margin-bottom: 6px;
    font-weight: 500;
}

/* Seller chip */
.mkt-seller {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-dim);
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    padding: 4px 10px;
    margin: 0 0 8px;
    min-width: 0;
    overflow: hidden;
    align-self: center;
    max-width: 100%;
}
/* Username text inside seller chip: ellipsis on narrow cards */
.mkt-seller span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.mkt-seller img {
    border-radius: 50%;
    flex-shrink: 0;
}

/* Price */
.mkt-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--amber);
    margin-bottom: 10px;
    letter-spacing: -.01em;
}

/* "Your listing" label */
.mkt-own-badge {
    display: inline-block;
    padding: 7px 13px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-mute);
    background: var(--surface-2);
    border: 1px solid var(--border);
    width: 100%;
    text-align: center;
    box-sizing: border-box;
}

/* ================================================================
   My Listings page
   ================================================================ */

/* Two-column layout */
.mkt-mine-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
    align-items: flex-start;
}

.mkt-mine-main { min-width: 0; }

/* Listing rows */
.mkt-mine-list {
    display: flex;
    flex-direction: column;
}

.mkt-mine-row {
    display: grid;
    grid-template-columns: 56px 1fr auto auto;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-soft);
    transition: background var(--transition);
}

.mkt-mine-row:last-child {
    border-bottom: none;
}

.mkt-mine-row:hover {
    background: var(--surface-2);
}

/* Small cosmetic preview inside list row */
.mkt-mine-preview {
    width: 56px;
    height: 44px;
    display: grid;
    place-items: center;
    background: var(--surface-2);
    border-radius: 10px;
    border: 1px solid var(--border);
    flex-shrink: 0;
    overflow: hidden;
}

/* Info column in listing row — must have min-width:0 so children can ellipsis */
.mkt-mine-info {
    min-width: 0;
    overflow: hidden;
}

.mkt-mine-name {
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.mkt-mine-meta {
    font-size: 12px;
    color: var(--text-mute);
    margin-top: 3px;
    line-height: 1.5;
    overflow-wrap: break-word;
    word-break: break-word;
}

.mkt-mine-price {
    font-weight: 700;
    font-size: 14px;
    color: var(--amber);
    white-space: nowrap;
}

.mkt-mine-action {
    flex-shrink: 0;
}

/* Sell form visual polish */
.mkt-sell-form-hints {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 18px;
}
.mkt-sell-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12.5px;
    color: var(--text-dim);
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 9px;
    padding: 9px 11px;
    line-height: 1.4;
}
.mkt-sell-hint-ico {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Desktop enhancements ≥1024px */
@media (min-width: 1024px) {
    .mkt-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 20px;
    }
    .mkt-card { padding: 22px 18px 18px; }
    .mkt-preview { height: 72px; border-radius: 11px; }
    .mkt-item-name { font-size: 15px; }
    .mkt-price { font-size: 15px; }
    .mkt-tab { padding: 8px 20px; font-size: 14px; }
    .mkt-mine-layout { grid-template-columns: 1fr 380px; gap: 28px; }
    .mkt-mine-row { padding: 16px 24px; gap: 16px; }
    .mkt-mine-preview { width: 62px; height: 48px; }
    .mkt-mine-name { font-size: 15px; }
    .mkt-mine-price { font-size: 14px; }
}

/* ================================================================
   Responsive
   ================================================================ */

@media (max-width: 900px) {
    .mkt-mine-layout {
        grid-template-columns: 1fr;
    }

    .mkt-mine-side {
        order: -1; /* sell form goes first on mobile */
    }

    .mkt-sell-form-hints {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .mkt-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .mkt-card { padding: 14px 12px; }
    .mkt-preview { height: 52px; border-radius: 9px; }
    .mkt-item-name { font-size: 13px; min-height: 2.65em; }
    .mkt-price { font-size: 13px; }
    .mkt-head-actions { gap: 8px; flex-wrap: wrap; }
    /* Filter tab bar: horizontal scroll on tablet too */
    .mkt-filter-bar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 3px; }
    .mkt-tab { flex-shrink: 0; }

    /* Mine listing row: collapse to 2-col + 2-row layout */
    .mkt-mine-row {
        grid-template-columns: 48px 1fr auto;
        grid-template-rows: auto auto;
        gap: 6px 12px;
        padding: 12px 14px;
    }
    /* Preview spans both rows on left */
    .mkt-mine-preview {
        grid-row: 1 / 3;
        align-self: center;
    }
    /* Price + action on second row */
    .mkt-mine-price  { grid-column: 2; grid-row: 2; }
    .mkt-mine-action { grid-column: 3; grid-row: 1 / 3; align-self: center; }
}

/* 480px — phones */
@media (max-width: 480px) {
    .mkt-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .mkt-preview  { height: 48px; }
    .mkt-card .btn { min-height: 36px; font-size: 12px; }
    .mkt-filter-bar { gap: 6px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
    .mkt-filter-bar::-webkit-scrollbar { display: none; }
    .mkt-tab { padding: 6px 12px; font-size: 12px; min-height: 36px; display: flex; align-items: center; }

    /* Points badge: prevent truncation next to buttons */
    .mkt-head-actions .points-badge { font-size: 12px; padding: 6px 10px; }

    /* Mine row: full-width single column on very small */
    .mkt-mine-row {
        grid-template-columns: 44px 1fr;
        grid-template-rows: auto auto auto;
        padding: 10px 12px;
    }
    .mkt-mine-preview { grid-row: 1 / 3; }
    .mkt-mine-price   { grid-column: 2; grid-row: 2; }
    .mkt-mine-action  { grid-column: 1 / -1; grid-row: 3; padding-top: 6px; }
    .mkt-mine-action .btn { width: 100%; min-height: 38px; }

    .mkt-sell-form-hints { grid-template-columns: 1fr; }
}

/* 390px */
@media (max-width: 390px) {
    .mkt-grid { gap: 8px; }
    .mkt-card { padding: 12px 10px; }
    .mkt-preview { height: 42px; }
    .mkt-item-name { font-size: 12px; }
    .mkt-price { font-size: 12px; }
}

/* 360px */
@media (max-width: 360px) {
    /* Keep 2 cols at 360px — 1 col makes cards too tall */
    .mkt-grid { grid-template-columns: repeat(2, 1fr); gap: 7px; }
    .mkt-filter-bar { gap: 4px; }
    .mkt-tab { padding: 5px 10px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
    .mkt-card { transition: none; }
    .mkt-card::before { display: none; }
}
