/* ============================================================
   MARKET PAGE  –  Buy / Sell Magical Items
   ============================================================ */

/* ---------- tokens ---------- */
:root {
    --rarity-common: #9e9e9e;
    --rarity-rare: #4fc3f7;
    --rarity-epic: #ab47bc;
    --rarity-legendary: #ffa726;
    --rarity-mythic: #e040fb;
    --rarity-premium: #ffd700;
}

/* ---------- page header ---------- */
.market-hero {
    text-align: center;
    padding: 60px 0 20px;
}

.market-hero h1 {
    font-size: 2.4rem;
    color: #fff;
    margin-bottom: 8px;
}

.market-hero h1 i {
    margin-right: 10px;
    color: var(--rarity-legendary);
}

.market-hero p {
    color: rgba(255, 255, 255, .55);
    font-size: 1.05rem;
}

/* ---------- toolbar ---------- */
.market-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.market-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.market-filter {
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .1);
    color: rgba(255, 255, 255, .7);
    padding: 8px 18px;
    border-radius: 24px;
    cursor: pointer;
    font-size: .88rem;
    font-weight: 500;
    transition: all .2s;
}

.market-filter:hover {
    background: rgba(255, 255, 255, .1);
    color: #fff;
}

.market-filter.active {
    background: linear-gradient(135deg, #9b59b6, #6c3483);
    border-color: #9b59b6;
    color: #fff;
}

.market-search {
    position: relative;
    flex: 0 0 260px;
}

.market-search input {
    width: 100%;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 24px;
    padding: 10px 16px 10px 38px;
    color: #fff;
    font-size: .9rem;
    outline: none;
    transition: border-color .2s;
}

.market-search input::placeholder {
    color: rgba(255, 255, 255, .35);
}

.market-search input:focus {
    border-color: #9b59b6;
}

.market-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, .35);
    font-size: .9rem;
}

.btn-sell-item {
    background: linear-gradient(135deg, #27ae60, #1e8449);
    color: #fff;
    padding: 10px 22px;
    border-radius: 24px;
    border: none;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform .2s, box-shadow .2s;
}

.btn-sell-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(39, 174, 96, .35);
}

/* ---------- items grid ---------- */
.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.market-item {
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 16px;
    padding: 20px;
    transition: transform .25s, box-shadow .3s, border-color .3s;
    position: relative;
    overflow: hidden;
}

.market-item:hover {
    transform: translateY(-4px);
}

/* rarity glow on hover */
.market-item.rarity-common:hover {
    border-color: var(--rarity-common);
    box-shadow: 0 0 25px rgba(158, 158, 158, .15);
}

.market-item.rarity-rare:hover {
    border-color: var(--rarity-rare);
    box-shadow: 0 0 25px rgba(79, 195, 247, .2);
}

.market-item.rarity-epic:hover {
    border-color: var(--rarity-epic);
    box-shadow: 0 0 25px rgba(171, 71, 188, .2);
}

.market-item.rarity-legendary:hover {
    border-color: var(--rarity-legendary);
    box-shadow: 0 0 25px rgba(255, 167, 38, .2);
}

.market-item.rarity-mythic:hover {
    border-color: var(--rarity-mythic);
    box-shadow: 0 0 25px rgba(224, 64, 251, .2);
}

.market-item.rarity-premium:hover {
    border-color: var(--rarity-premium);
    box-shadow: 0 0 25px rgba(255, 215, 0, .2);
}

/* rarity indicator bar */
.market-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 16px 16px 0 0;
}

.market-item.rarity-common::after {
    background: var(--rarity-common);
}

.market-item.rarity-rare::after {
    background: var(--rarity-rare);
}

.market-item.rarity-epic::after {
    background: var(--rarity-epic);
}

.market-item.rarity-legendary::after {
    background: var(--rarity-legendary);
}

.market-item.rarity-mythic::after {
    background: var(--rarity-mythic);
}

.market-item.rarity-premium::after {
    background: var(--rarity-premium);
}

.market-item-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.market-item-emoji {
    font-size: 2rem;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, .06);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.market-item-title {
    flex: 1;
    min-width: 0;
}

.market-item-name {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.market-item-slot {
    font-size: .78rem;
    color: rgba(255, 255, 255, .4);
    text-transform: capitalize;
}

.market-item-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.market-stat-chip {
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .08);
    padding: 4px 10px;
    border-radius: 16px;
    font-size: .75rem;
    color: rgba(255, 255, 255, .7);
}

.market-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.market-price {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffa726;
}

.market-price i {
    font-size: .9rem;
}

.market-seller {
    display: flex;
    align-items: center;
    gap: 6px;
}

.market-seller img {
    width: 22px;
    height: 22px;
    border-radius: 50%;
}

.market-seller-name {
    font-size: .78rem;
    color: rgba(255, 255, 255, .45);
    max-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-buy {
    background: linear-gradient(135deg, #9b59b6, #6c3483);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
}

.btn-buy:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(155, 89, 182, .35);
}

.btn-buy:disabled {
    opacity: .4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* own listing badge */
.market-own-badge {
    background: rgba(39, 174, 96, .15);
    color: #27ae60;
    font-size: .75rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 16px;
    border: 1px solid rgba(39, 174, 96, .25);
}

.btn-cancel-listing {
    background: rgba(231, 76, 60, .12);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, .25);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
}

.btn-cancel-listing:hover {
    background: rgba(231, 76, 60, .22);
}

/* ---------- sell modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .7);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: #12131f;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 20px;
    max-width: 520px;
    width: 100%;
    padding: 32px;
    position: relative;
    animation: fadeSlideUp .3s ease;
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, .4);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color .2s;
}

.modal-close:hover {
    color: #fff;
}

.modal-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sell-inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 18px;
    padding-right: 4px;
}

.sell-inventory-grid::-webkit-scrollbar {
    width: 5px;
}

.sell-inventory-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .15);
    border-radius: 10px;
}

.sell-inv-item {
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all .2s;
    text-align: center;
}

.sell-inv-item:hover,
.sell-inv-item.selected {
    border-color: #9b59b6;
    background: rgba(155, 89, 182, .1);
}

.sell-inv-item .inv-emoji {
    font-size: 1.6rem;
    margin-bottom: 4px;
}

.sell-inv-item .inv-name {
    font-size: .82rem;
    color: #fff;
    font-weight: 600;
}

.sell-inv-item .inv-slot {
    font-size: .72rem;
    color: rgba(255, 255, 255, .4);
}

.sell-price-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.sell-price-row label {
    color: rgba(255, 255, 255, .6);
    font-size: .9rem;
    white-space: nowrap;
}

.sell-price-row input {
    flex: 1;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 10px;
    padding: 10px 14px;
    color: #fff;
    font-size: 1rem;
    outline: none;
}

.sell-price-row input:focus {
    border-color: #9b59b6;
}

.btn-confirm-sell {
    width: 100%;
    background: linear-gradient(135deg, #27ae60, #1e8449);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity .2s;
}

.btn-confirm-sell:disabled {
    opacity: .4;
    cursor: not-allowed;
}

/* ---------- toast ---------- */
.market-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #12131f;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 14px;
    padding: 14px 22px;
    color: #fff;
    font-size: .9rem;
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
    transform: translateY(100px);
    opacity: 0;
    transition: all .4s ease;
}

.market-toast.show {
    transform: translateY(0);
    opacity: 1;
}

.market-toast.success {
    border-color: rgba(39, 174, 96, .4);
}

.market-toast.success i {
    color: #27ae60;
}

.market-toast.error {
    border-color: rgba(231, 76, 60, .4);
}

.market-toast.error i {
    color: #e74c3c;
}

/* ---------- empty state ---------- */
.market-empty {
    text-align: center;
    padding: 80px 20px;
    color: rgba(255, 255, 255, .35);
}

.market-empty i {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
    opacity: .3;
}

.market-empty p {
    font-size: 1.1rem;
}

/* ---------- responsive ---------- */
@media (max-width: 768px) {
    .market-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .market-search {
        flex: 1 1 auto;
    }

    .market-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .modal-box {
        padding: 24px 18px;
    }
}