/* static/css/pages/marketplace-finance.css */

/* ——————————————————————————————————————————————
   FINANCE-STYLE MARKETPLACE REDESIGN
   —————————————————————————————————————————————— */

.marketplace-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-6) var(--space-4);
}

/* ——————————————————————————————————————————————
   HEADER SECTION
   —————————————————————————————————————————————— */

.marketplace-header {
    margin-bottom: var(--space-8);
}

.market-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

/* Search Bar */
.search-wrapper {
    position: relative;
    flex: 1;
    max-width: 400px;
}


/* Search Bar */
.search-wrapper {
    position: relative;
    flex: 1;
    max-width: 400px;
}

/* Search Dropdown */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--neutral-900);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--space-2);
    margin-top: var(--space-1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.market-search {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    padding-left: 44px; /* Fixed value to ensure no overlap with icon */
    background: var(--neutral-900);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--space-2);
    color: var(--neutral-50);
    font-size: 0.875rem;
    transition: all 0.2s ease;
    -webkit-appearance: none; /* Remove default styling on iOS */
    appearance: none;
}

/* Ensure placeholder text doesn't overlap with icon */
.market-search::placeholder {
    color: var(--neutral-500);
    opacity: 1; /* Firefox fix */
}

.market-search:focus {
    outline: none;
    border-color: var(--primary-500);
    background: var(--neutral-850);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); /* Add subtle focus ring */
}

/* Change icon color when input is focused */
.search-wrapper:focus-within .search-icon {
    color: var(--primary-500);
}

.search-icon {
    position: absolute;
    left: 12px; /* Center icon in the 44px padding area */
    top: 50%;
    transform: translateY(-50%);
    color: var(--neutral-500);
    pointer-events: none; /* Prevent icon from blocking input clicks */
    z-index: 1; /* Ensure icon stays above input background but below text */
    width: 20px;
    height: 20px;
}

.search-icon svg {
    pointer-events: none; /* Ensure SVG doesn't block clicks */
    width: 100%;
    height: 100%;
}

/* Sort Controls - Enhanced with Icons */
.sort-controls {
    display: flex;
    gap: var(--space-2);
}

.sort-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-4);
    background: var(--neutral-900);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--space-2);
    color: var(--neutral-400);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.sort-btn svg {
    width: 16px;
    height: 16px;
}

.sort-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--neutral-200);
}

.sort-btn.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary-500);
    color: var(--primary-400);
}

/* ——————————————————————————————————————————————
   ITEMS GRID - 3 per row
   —————————————————————————————————————————————— */

.items-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
}

/* ——————————————————————————————————————————————
   ITEM CARD - Finance Style
   —————————————————————————————————————————————— */

.item-card {
    background: var(--neutral-900);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--space-3);
    overflow: hidden;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Subtle grid pattern for finance feel */
.item-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.01) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.01) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    opacity: 0.5;
}

.item-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Glow effect on hover */
.item-card:hover::after {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    background: linear-gradient(45deg, transparent, var(--primary-600), transparent);
    opacity: 0.1;
    border-radius: var(--space-3);
    pointer-events: none;
}

/* Item Header Section */
.item-header-section {
    padding: var(--space-6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    z-index: 1;
}

.item-visual {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.item-icon-large {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    object-fit: contain;
    border-radius: var(--space-2);
    background: rgba(255, 255, 255, 0.02);
    padding: var(--space-2);
}

.item-identity {
    flex: 1;
    min-width: 0;
}

.item-name {
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--neutral-100);
    line-height: 1.3;
    margin: 0 0 var(--space-1);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.item-category {
    font-size: 0.75rem;
    color: var(--neutral-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Pricing Section */
.pricing-section {
    padding: var(--space-6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.price-display {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: var(--space-4);
}

.current-price-block {
    flex: 1;
}

.price-label {
    font-size: 0.625rem;
    color: var(--neutral-500);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.price-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--success);
    font-family: var(--font-mono);
    line-height: 1;
}

.steam-comparison {
    text-align: right;
}

.steam-price {
    font-size: 0.875rem;
    color: var(--neutral-500);
    text-decoration: line-through;
    font-family: var(--font-mono);
}

.discount-badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-2);
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-radius: var(--space-1);
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: var(--space-1);
}

/* Price Spread Visualization */
.price-spread-viz {
    margin-top: var(--space-4);
}

.spread-label {
    font-size: 0.625rem;
    color: var(--neutral-500);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    margin-bottom: var(--space-2);
}

.spread-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 40px;
    margin-bottom: var(--space-2);
}

.spread-bar {
    flex: 1;
    background: linear-gradient(to top, var(--primary-600), rgba(59, 130, 246, 0.2));
    border-radius: 2px 2px 0 0;
    min-height: 4px;
    transition: all 0.3s ease;
    position: relative;
}

.spread-bar:hover {
    background: linear-gradient(to top, var(--primary-500), rgba(59, 130, 246, 0.3));
}

/* Enhanced hover effect for spread bars */
.item-card:hover .spread-bar {
    background: linear-gradient(to top, var(--primary-500), rgba(59, 130, 246, 0.25));
}

.spread-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.625rem;
    color: var(--neutral-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* Market Stats Grid */
.market-stats-section {
    padding: var(--space-6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.stat-label {
    font-size: 0.625rem;
    color: var(--neutral-500);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--neutral-100);
    font-family: var(--font-mono);
}

/* Enhanced hover state for stat values */
.item-card:hover .stat-value {
    color: var(--neutral-50);
}

/* Price value animation on hover */
.item-card:hover .price-value {
    transform: scale(1.02);
    transition: transform 0.2s ease;
}

/* Action Section */
.card-action-section {
    padding: var(--space-6);
    background: rgba(255, 255, 255, 0.02);
}

.view-offers-btn {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--primary-600);
    border: none;
    border-radius: var(--space-2);
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.view-offers-btn:hover:not(:disabled) {
    background: var(--primary-700);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.view-offers-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--neutral-700);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-4);
    grid-column: 1 / -1;
}

.empty-icon {
    margin-bottom: var(--space-4);
    opacity: 0.2;
}

.empty-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--neutral-200);
    margin-bottom: var(--space-2);
}

.empty-message {
    color: var(--neutral-500);
}

/* Pagination */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-8);
    padding-top: var(--space-6);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.pagination-info {
    color: var(--neutral-500);
    font-size: 0.875rem;
}

.pagination-buttons {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: var(--neutral-900);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--space-2);
    color: var(--neutral-300);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(.disabled) {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--neutral-100);
}

.pagination-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-current {
    color: var(--neutral-300);
    font-size: 0.875rem;
    padding: 0 var(--space-2);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .items-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ================================================
   ENHANCED MOBILE STYLES (768px and below)
   ================================================ */
@media (max-width: 768px) {
    .marketplace-container {
        padding: var(--space-4) var(--space-3);
    }
    
    .market-controls {
        flex-direction: column;
        gap: var(--space-3);
    }
    
    /* Full width search on mobile */
    .search-wrapper {
        max-width: 100%;
        width: 100%;
    }
    
    /* Fix search icon overlap on mobile */
    .market-search {
        /* Extra padding so text never overlaps the icon */
        padding-left: 56px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .market-search::placeholder {
        color: var(--neutral-500);
        opacity: 1; /* Firefox fix */
    }

    .search-icon {
        left: 16px; /* Slightly more space from edge */
    }
    
    /* Make sort buttons fill width on mobile */
    .sort-controls {
        width: 100%;
        display: flex;
        gap: var(--space-2);
        /* Remove horizontal scroll, make buttons fill width */
        flex-wrap: nowrap;
        justify-content: stretch;
    }
    
    .sort-btn {
        flex: 1; /* Make buttons grow to fill space */
        font-size: 0.8125rem;
        padding: var(--space-2) var(--space-3);
        white-space: nowrap; /* Prevent text wrapping */
        text-align: center; /* Center text in expanded buttons */
        min-width: 0; /* Allow buttons to shrink below content width */
    }
    
    /* CHANGED: 2 cards per row on mobile */
    .items-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
    }
    
    /* Adjust card content for smaller size */
    .item-header-section {
        padding: var(--space-3);
    }
    
    .item-visual {
        flex-direction: column;
        text-align: center;
        gap: var(--space-2);
        margin-bottom: var(--space-2);
    }
    
    .item-icon-large {
        width: 60px;
        height: 60px;
        padding: var(--space-1);
    }
    
    .item-name {
        font-size: 0.875rem;
        -webkit-line-clamp: 2;
    }
    
    .item-category {
        font-size: 0.625rem;
    }
    
    /* Pricing adjustments */
    .pricing-section {
        padding: var(--space-3);
    }
    
    .price-display {
        flex-direction: column;
        gap: var(--space-2);
        align-items: flex-start;
        margin-bottom: var(--space-2);
    }
    
    .price-value {
        font-size: 1.25rem;
    }
    
    .steam-comparison {
        text-align: left;
    }
    
    .steam-price {
        font-size: 0.75rem;
    }
    
    .discount-badge {
        font-size: 0.625rem;
        padding: 2px 6px;
    }
    
    /* Price spread adjustments */
    .price-spread-viz {
        margin-top: var(--space-2);
    }
    
    .spread-bars {
        height: 30px;
    }
    
    .spread-label {
        font-size: 0.5625rem;
    }
    
    /* Market stats adjustments */
    .market-stats-section {
        padding: var(--space-3);
    }
    
    .stats-grid {
        gap: var(--space-2);
    }
    
    .stat-label {
        font-size: 0.5625rem;
    }
    
    .stat-value {
        font-size: 0.875rem;
    }
    
    /* Action section adjustments */
    .card-action-section {
        padding: var(--space-3);
    }
    
    .view-offers-btn {
        font-size: 0.75rem;
        padding: var(--space-2) var(--space-3);
    }
    
    /* Pagination mobile adjustments */
    .pagination-controls {
        flex-direction: column;
        gap: var(--space-3);
        align-items: stretch;
        padding-top: var(--space-4);
    }
    
    .pagination-info {
        text-align: center;
        font-size: 0.75rem;
    }
    
    .pagination-buttons {
        justify-content: center;
        gap: var(--space-2);
    }
    
    .pagination-btn {
        padding: var(--space-2) var(--space-3);
        font-size: 0.75rem;
    }
    
    .pagination-current {
        font-size: 0.75rem;
    }
}

/* Very small phones (less than 400px) */
@media (max-width: 400px) {
    .marketplace-container {
        padding: var(--space-3) var(--space-2);
    }
    
    /* Keep text visible but make buttons smaller */
    .sort-btn {
        padding: var(--space-1) var(--space-2);
        font-size: 0.75rem; /* Smaller font but still visible */
        gap: 2px; /* Reduce gap between icon and text */
    }
    
    .sort-btn svg {
        width: 14px;
        height: 14px;
    }
    
    .items-grid {
        gap: var(--space-2);
    }
    
    /* Further size reductions */
    .item-header-section {
        padding: var(--space-2);
    }
    
    .item-icon-large {
        width: 48px;
        height: 48px;
    }
    
    .item-name {
        font-size: 0.75rem;
    }
    
    .pricing-section {
        padding: var(--space-2);
    }
    
    .price-value {
        font-size: 1rem;
    }
    
    .market-stats-section {
        padding: var(--space-2);
    }
    
    .card-action-section {
        padding: var(--space-2);
    }
    
    .view-offers-btn {
        font-size: 0.625rem;
        padding: 6px var(--space-2);
    }
    
    /* Hide button icon on very small screens */
    .view-offers-btn svg {
        display: none;
    }
}

/* Loading Animation */
@keyframes pulse-opacity {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.marketplace-container.loading .items-grid {
    opacity: 0.5;
    pointer-events: none;
}

/* Smooth transitions for dynamic content */
.item-card {
    animation: fadeIn 0.3s ease-out;
}

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