/* ============================================
   MARKET PAGE - Ravendawn Theme
   ============================================ */

/* Market page section */
.market-page {
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    background-attachment: fixed;
    position: relative;
    min-height: calc(100vh - 80px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.market-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(19, 20, 22, 0.6);
    z-index: 0;
}

.market-page > * {
    position: relative;
    z-index: 1;
    width: 100%;
}

/* 3-column layout: filters | items | map */
.market-layout-3col {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) 260px;
    gap: 20px;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================
   FILTER PANEL
   ============================================ */
.market-filters {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(87, 87, 87, 0.3);
    border-radius: 6px;
    padding: 20px;
}

.filter-header {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary);
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(87, 87, 87, 0.3);
    margin-bottom: 16px;
}

.filter-input,
.filter-select {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(87, 87, 87, 0.4);
    border-radius: 4px;
    color: var(--color-001);
    font-size: 13px;
    font-family: var(--font-body);
    transition: border-color 0.2s;
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(119, 212, 99, 0.15);
}

.filter-input::placeholder {
    color: var(--muted);
    opacity: 0.6;
}

.filter-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2377d463' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.filter-select option {
    background: #1a1d22;
    color: var(--color-001);
}

.rv-btn-full {
    width: 100%;
    margin-top: 8px;
}

/* ============================================
   ITEMS TABLE
   ============================================ */
.market-items {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(87, 87, 87, 0.3);
    border-radius: 6px;
    padding: 20px;
}

.items-header {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary);
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(87, 87, 87, 0.3);
    margin-bottom: 16px;
}

.items-table-wrapper {
    max-height: 500px;
    overflow-y: auto;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.items-table-wrapper::-webkit-scrollbar {
    width: 6px;
}

.items-table-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.items-table-wrapper::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.items-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.items-table th {
    background: rgba(0, 0, 0, 0.5);
    color: var(--color-001);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 12px;
    text-align: left;
    padding: 10px 8px;
    border-bottom: 2px solid var(--primary);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.items-table td {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(87, 87, 87, 0.2);
    color: var(--color-005);
    vertical-align: middle;
}

.items-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.items-table tbody tr:hover {
    background: rgba(119, 212, 99, 0.08);
}

.items-table tbody tr.selected {
    background: rgba(119, 212, 99, 0.15);
    border-left: 3px solid var(--primary);
}

/* Column widths */
.col-item { min-width: 150px; }
.col-quality { width: 80px; }
.col-plus { width: 55px; text-align: center; }
.col-gem1 { width: 100px; }
.col-gem2 { width: 100px; }
.col-seller { width: 110px; }
.col-price { width: 110px; text-align: right; }

/* Item name with icon */
.item-name-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.item-icon {
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(87, 87, 87, 0.4);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

.item-icon img {
    object-fit: contain;
    display: block;
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.item-name {
    color: var(--color-001);
    font-weight: 500;
}

/* Quality colors */
.quality-normal { color: #9e9e9e; }
.quality-enhanced { color: var(--primary); }
.quality-elite { color: #60a5fa; }
.quality-super { color: #c084fc; }
.quality-unique { color: #fb923c; }
.quality-legendary { color: #f87171; text-shadow: 0 0 8px rgba(248, 113, 113, 0.3); }

/* Plus styling */
.plus-value {
    font-weight: 700;
    text-align: center;
}

.plus-high { color: var(--primary); }
.plus-max { color: #f87171; text-shadow: 0 0 6px rgba(248, 113, 113, 0.4); }

/* Seller name */
.seller-name {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s;
}

.seller-name:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* Price */
.price-gold { color: var(--accent); font-weight: 600; }
.price-cps { color: #60a5fa; font-weight: 600; }

/* Loading / Empty states */
.loading-row td, .empty-row td {
    text-align: center;
    color: var(--muted);
    padding: 50px;
    font-style: italic;
}

/* ============================================
   BUY SECTION
   ============================================ */
.buy-section {
    padding-top: 16px;
    border-top: 1px solid rgba(87, 87, 87, 0.3);
    margin-top: 16px;
}

/* ============================================
   BUY MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-box {
    background: var(--clr-4);
    border: 1px solid rgba(87, 87, 87, 0.4);
    border-radius: 8px;
    width: 380px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(87, 87, 87, 0.3);
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    color: var(--primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.15s;
}

.modal-close:hover {
    color: var(--color-001);
}

.modal-body {
    padding: 20px;
}

.modal-body p {
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--color-005);
}

.modal-body .modal-price {
    color: var(--accent);
    font-weight: 700;
    font-size: 18px;
}

.modal-body .modal-balance {
    color: var(--primary);
}

.modal-body .modal-insufficient {
    color: #ef4444;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid rgba(87, 87, 87, 0.3);
}

.modal-cancel {
    flex: 1;
    padding: 10px;
    background: linear-gradient(var(--clr-3), var(--clr-4));
    color: var(--muted);
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-btn-surface);
    transition: all 0.15s;
}

.modal-confirm {
    flex: 1;
    padding: 10px;
    background: linear-gradient(var(--clr-3), var(--clr-4));
    color: var(--primary);
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-btn-green);
    transition: all 0.15s;
}

.modal-confirm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.modal-cancel:hover { color: var(--color-001); }
.modal-confirm:hover:not(:disabled) { box-shadow: var(--shadow-btn-green-hover); }

/* ============================================
   NOTIFICATION TOAST
   ============================================ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    animation: toastIn 0.3s ease-out;
}

.toast-success {
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid var(--primary);
    color: var(--primary);
}

.toast-error {
    background: rgba(45, 18, 21, 0.9);
    border: 1px solid #ef4444;
    color: #fca5a5;
}

.toast-info {
    background: rgba(15, 26, 46, 0.9);
    border: 1px solid #60a5fa;
    color: #93c5fd;
}

@keyframes toastIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ============================================
   MARKET MAP PANEL (Right Side)
   ============================================ */
.market-map-panel {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(87, 87, 87, 0.3);
    border-radius: 6px;
    padding: 16px;
}

.map-header {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary);
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(87, 87, 87, 0.3);
    margin-bottom: 12px;
}

.location-map {
    position: relative;
    width: 100%;
    border: 2px solid rgba(87, 87, 87, 0.4);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.location-map img {
    width: 100%;
    display: block;
}

.location-marker {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #ef4444;
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
    animation: markerPulse 1s ease-in-out infinite;
    z-index: 10;
    pointer-events: none;
    display: none;
}

.location-marker.active {
    display: block;
}

@keyframes markerPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(239, 68, 68, 0.8); }
    50% { box-shadow: 0 0 20px rgba(239, 68, 68, 1); }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1100px) {
    .market-layout-3col {
        grid-template-columns: 220px 1fr;
    }

    .market-map-panel {
        grid-column: 1 / -1;
    }
}

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

    .market-filters {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .filter-header { grid-column: 1 / -1; }
    .rv-btn-full { grid-column: 1 / -1; }

    .market-map-panel {
        grid-column: 1;
    }
}

@media (max-width: 640px) {
    .market-filters {
        grid-template-columns: 1fr;
    }

    .items-table {
        font-size: 11px;
    }

    .col-gem1, .col-gem2 {
        display: none;
    }
}

/* Wider market only; other page containers retain their dimensions. */
.market-page > .rv-section-inner { max-width: 1648px; width: 100%; box-sizing: border-box; padding: 0 24px; }
.market-items { min-width: 0; }
.items-table td:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .market-page > .rv-section-inner { padding: 0 8px; } }
