/* Auction-specific styling */

/* Basic grid layout for auctions container */
#auctions-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 8px;
    margin: 0;
    box-sizing: border-box;
    width: 100%;
}

/* Fix gift card styling to match collection page */
.auction-card {
    position: relative;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.auction-card:active {
    transform: scale(0.98);
}

.gift-display {
    position: relative;
    width: 100%;
    padding-top: 100%;
    background: var(--tg-theme-bg-color);
    border-radius: 8px 8px 0 0;
}

.gift-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

/* Fix background pattern display */
.gift-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.lottie-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* Gift ID/Number badge */
.gift-id {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 8px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 10px;
    z-index: 4;
}

/* Restore gift details/traits section */
.gift-details {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    z-index: 3;
    border-radius: 0 0 8px 8px;
}

.gift-number {
    font-size: 11px;
    margin-bottom: 4px;
}

.traits-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.trait {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
}

.trait-name {
    color: rgba(255, 255, 255, 0.9);
}

.trait-rarity {
    color: rgba(255, 255, 255, 0.7);
    font-size: 9px;
}

/* Reposition timer and bid badges near price */
.auction-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.auction-timer,
.bid-badge {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    padding: 3px 6px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 9px;
    color: white;
}

.auction-timer {
    background: rgba(233, 30, 99, 0.8);
}

.bid-badge {
    background: rgba(63, 81, 181, 0.8);
}

.auction-timer i,
.bid-badge i {
    font-size: 9px;
}

.auction-timer .time-left,
.bid-badge .bid-count {
    font-weight: 500;
}

/* Fix controls styling */
.gift-controls {
    padding: 8px;
    background: var(--tg-theme-secondary-bg-color);
}

.gift-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.price-display {
    text-align: center;
    padding: 6px 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--tg-theme-text-color);
    background: rgba(var(--tg-theme-bg-color-rgb, 255, 255, 255), 0.1);
    border-radius: 4px;
}

.auction-card .bid-button {
    width: 100%;
    padding: 8px;
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.auction-card .bid-button:active {
    transform: scale(0.95);
}

.auction-card .bid-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auction-card .bid-button i {
    font-size: 12px;
}

/* Display preferences section */
.display-preferences {
    display: flex;
    justify-content: space-around;
    gap: 8px;
    margin: 0 6px 12px 6px;
    background: var(--tg-theme-secondary-bg-color);
    padding: 8px;
    border-radius: 10px;
    flex-wrap: wrap;
}

.preference-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 60px;
}

.preference-toggle i {
    color: var(--tg-theme-hint-color);
    font-size: 14px;
    width: 16px;
    text-align: center;
}

/* Toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--tg-theme-hint-color);
    transition: .4s;
    border-radius: 18px;
}

.switch .slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: var(--tg-theme-bg-color);
    transition: .4s;
    border-radius: 50%;
}

.switch input:checked + .slider {
    background-color: var(--tg-theme-button-color);
}

.switch input:checked + .slider:before {
    transform: translateX(14px);
}

/* Update badge-rarity position and styling */
.badge-rarity {
    position: absolute;
    top: 8px;
    left: 2px;
    height: 20px;
    padding: 2px 8px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 4;
    cursor: pointer;
}

.badge-rarity i {
    font-size: 10px;
}

.badge-rarity .rarity-value {
    font-size: 8px;
    font-weight: 500;
}

/* Update tier styles to match collection page */
.badge-rarity[data-tier="legendary"] {
    background: rgb(241, 196, 15);
}
.badge-rarity[data-tier="legendary"] i,
.badge-rarity[data-tier="legendary"] .rarity-value {
    color: var(--tg-them-color);
}

.badge-rarity[data-tier="epic"] {
    background: rgb(155, 89, 182);
}
.badge-rarity[data-tier="epic"] i,
.badge-rarity[data-tier="epic"] .rarity-value {
    color: var(--tg-them-color);
}

.badge-rarity[data-tier="rare"] {
    background: rgb(52, 152, 219);
}
.badge-rarity[data-tier="rare"] i,
.badge-rarity[data-tier="rare"] .rarity-value {
    color: var(--tg-them-color);
}

.badge-rarity[data-tier="uncommon"] {
    background: rgb(46, 204, 113);
}
.badge-rarity[data-tier="uncommon"] i,
.badge-rarity[data-tier="uncommon"] .rarity-value {
    color: var(--tg-them-color);
}

.badge-rarity[data-tier="common"] {
    background: rgb(169, 169, 169);
}
.badge-rarity[data-tier="common"] i,
.badge-rarity[data-tier="common"] .rarity-value {
    color: var(--tg-them-color);
}

/* Stats badge for auctions */
.stats-badge.auctions {
    background: rgba(233, 30, 99, 0.2);
}

.stats-badge.auctions .stats-badge-icon,
.stats-badge.auctions .stats-badge-value {
    color: rgb(233, 30, 99);
}

.stats-badge.highest {
    background: rgba(156, 39, 176, 0.2);
}

.stats-badge.highest .stats-badge-icon,
.stats-badge.highest .stats-badge-value {
    color: rgb(156, 39, 176);
}

.stats-badge.bids {
    background: rgba(63, 81, 181, 0.2);
}

.stats-badge.bids .stats-badge-icon,
.stats-badge.bids .stats-badge-value {
    color: rgb(63, 81, 181);
}

/* Expired badge for ended auctions */
.auction-expired {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 18px;
    font-weight: 600;
    z-index: 5;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* My auctions page filter tabs */
.my-auctions-tabs {
    display: flex;
    gap: 8px;
    margin: 0 6px 12px 6px;
    background: var(--tg-theme-secondary-bg-color);
    padding: 8px;
    border-radius: 10px;
    justify-content: space-between;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.auction-tab {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-hint-color);
    cursor: pointer;
    white-space: nowrap;
    font-size: 12px;
}

.auction-tab.active {
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
}

/* Load more button */
.load-more-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 20px auto;
    border: none;
    border-radius: 50%;
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.load-more-btn i {
    font-size: 16px;
}

.load-more-btn:active {
    transform: scale(0.95);
}

/* Loading Spinner Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(var(--tg-theme-bg-color-rgb), 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(var(--tg-theme-button-color-rgb), 0.1);
    border-radius: 50%;
    border-top-color: var(--tg-theme-button-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Pattern overlay styling */
.pattern-overlay {
    z-index: 1 !important;
    opacity: 0.2 !important;
    display: block !important;
}

/* No auctions message */
.no-auctions {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
    color: var(--tg-theme-hint-color);
}

/* Place bid popup */
.bid-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    background: var(--tg-theme-bg-color);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    padding: 24px;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease-out;
    max-width: 90%;
    width: 320px;
}

.bid-popup.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.bid-popup-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--tg-theme-text-color);
    text-align: center;
}

.bid-popup-content {
    margin-bottom: 16px;
}

.bid-popup-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.bid-popup-item {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.bid-popup-label {
    color: var(--tg-theme-hint-color);
}

.bid-popup-value {
    color: var(--tg-theme-text-color);
    font-weight: 500;
}

.bid-input-container {
    margin-bottom: 20px;
}

.bid-input-label {
    font-size: 14px;
    color: var(--tg-theme-hint-color);
    margin-bottom: 8px;
    display: block;
}

.bid-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--tg-theme-hint-color);
    border-radius: 8px;
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    font-size: 16px;
}

.bid-popup-buttons {
    display: flex;
    gap: 12px;
}

.bid-popup-button {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-align: center;
}

.bid-popup-button.cancel {
    background: var(--tg-theme-secondary-bg-color);
    color: var(--tg-theme-hint-color);
}

.bid-popup-button.confirm {
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
}

.bid-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bid-popup-overlay.show {
    opacity: 1;
}

/* Auction celebration popup */
.auction-celebration {
    background: linear-gradient(135deg, #E91E63, #9C27B0);
    color: white;
}

.auction-celebration .celebration-icon {
    font-size: 38px;
}

/* Responsive grid styles for multi-column layout */
/* Small mobile devices */
@media (max-width: 374px) {
    #auctions-container.multi-columns {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        padding: 6px;
    }
}

/* Medium-sized mobile devices */
@media (min-width: 375px) and (max-width: 767px) {
    #auctions-container.multi-columns {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        padding: 6px;
    }
}

/* Common styles for all mobile devices */
@media (max-width: 767px) {
    #auctions-container.multi-columns .gift-card {
        font-size: 75%;
    }
    
    #auctions-container.multi-columns .gift-controls {
        padding: 4px;
    }
    
    #auctions-container.multi-columns .price-display {
        font-size: 12px;
        padding: 4px;
    }
    
    #auctions-container.multi-columns .bid-button {
        font-size: 11px;
        padding: 6px;
    }
    
    #auctions-container.multi-columns .badge-points,
    #auctions-container.multi-columns .badge-rarity,
    #auctions-container.multi-columns .gift-id {
        transform: scale(0.8);
        transform-origin: top right;
    }
    
    #auctions-container.multi-columns .auction-info {
        margin-bottom: 4px;
    }
}

/* Tablets */
@media (min-width: 768px) and (max-width: 1023px) {
    #auctions-container.multi-columns {
        grid-template-columns: repeat(4, 1fr);
    }
    
    #auctions-container.multi-columns .gift-card {
        font-size: 85%;
    }
}

/* Desktop and larger screens */
@media (min-width: 1024px) {
    #auctions-container.multi-columns {
        grid-template-columns: repeat(5, 1fr);
        max-width: 1200px;
        margin: 0 auto;
    }
    
    #auctions-container.multi-columns .gift-card {
        font-size: 90%;
    }
}

/* Ensure minimum size for cards */
#auctions-container.multi-columns .gift-card {
    min-width: 90px;
}

/* Preserve aspect ratio for gift display */
#auctions-container.multi-columns .gift-display {
    padding-top: 100%;
}

/* Additional padding for the bottom of the page to ensure scrollability when keyboard is visible */
body {
    padding-bottom: 60vh; /* Large enough padding to account for keyboard height */
}

/* Ensure the main container has room to scroll */
#auctions-container {
    margin-bottom: 20vh; /* Additional margin to ensure the load more button is visible */
}

/* Make sure the load more button stays visible even with keyboard open */
.load-more-btn {
    margin-bottom: 30vh;
}

/* Enhanced timer styling for seconds display */
.auction-timer {
    background: rgba(233, 30, 99, 0.8);
    min-width: 65px; /* Ensure enough space for the longer time format */
    text-align: center;
}

.auction-timer .time-left {
    font-variant-numeric: tabular-nums; /* For better alignment when numbers change */
}

/* Ensure bid popup is always visible with keyboard */
.bid-popup {
    max-height: 80vh;
    overflow-y: auto;
    position: fixed;
    top: 10vh; /* Position it higher on the screen */
    transform: translate(-50%, 0) scale(0.7);
}

.bid-popup.show {
    transform: translate(-50%, 0) scale(1);
}

/* Add media query to adjust position on smaller devices */
@media (max-height: 600px) {
    .bid-popup {
        top: 5vh;
        max-height: 85vh;
    }
}

/* WebSocket Status Indicator Styles */
.ws-status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 16px;
    background-color: var(--tg-theme-secondary-bg-color);
    margin-left: auto;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    position: relative;
}

.ws-status-indicator:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.ws-status-icon {
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ws-status-text {
    font-size: 12px;
    font-weight: 500;
    color: var(--tg-theme-text-color);
}

/* Pulse animation for "live" status */
@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.ws-status-indicator[data-status="live"] .ws-status-icon i {
    animation: pulse 2s infinite;
}

/* Tooltip for status indicator */
.ws-status-indicator[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background-color: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 11px;
    white-space: pre-line;
    width: max-content;
    max-width: 200px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Make filter bar accommodate the status indicator */
.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .ws-status-text {
        display: none;
    }
    
    .ws-status-indicator {
        padding: 6px;
    }
    
    .ws-status-icon {
        font-size: 12px;
    }
}

/* Floor badges container */
.floor-badges {
    display: flex;
    flex-direction: row;
    gap: 3px;
    margin-bottom: 1px;
    align-items: center;
}

/* Individual floor badge */
.floor-badge {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 3px 6px;
    border-radius: 6px;
    background: var(--tg-theme-secondary-bg-color);
    color: var(--tg-theme-text-color);
    font-size: 9px;
}

.floor-badge .badge-icon {
    font-size: 7px;
}

.floor-badge .badge-value {
    font-weight: 500;
}

/* Adjustments for three column layout */
#auctions-container.multi-columns .floor-badge {
    padding: 2px 4px;
    font-size: 7px;
}

#auctions-container.multi-columns .floor-badge .badge-icon {
    font-size: 6px;
}

#auctions-container.multi-columns .floor-badges {
    gap: 1px;
}

/* Top Navigation - Two Rows */
.top-nav {
    display: flex;
    flex-direction: column;
    background: var(--tg-theme-secondary-bg-color);
    padding: 8px;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    gap: 8px;
}

.nav-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
}

.nav-link {
    color: var(--tg-theme-hint-color);
    text-decoration: none;
    padding: 8px 0;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.nav-link.active {
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
}
