/* Action Buttons Visibility Fix */
/* Ensures trade actions and coinflip actions are always visible on all screen sizes */

/* General action button container fixes */
.trade-actions,
.coinflip-actions {
    position: relative;
    z-index: 100; /* High z-index to stay above other content */
    margin-top: auto; /* Push to bottom */
    margin-bottom: 0;
    padding: 10px 0;
    flex-shrink: 0; /* Prevent shrinking */
    background: transparent;
    min-height: 60px; /* Ensure minimum height for buttons */
    display: flex !important; /* Force display even if overridden */
    align-items: center;
    justify-content: center;
}

/* Ensure glass card containers don't overflow and hide buttons */
.glass-card {
    overflow: visible !important; /* Override any hidden overflow */
    position: relative;
    padding-bottom: 70px; /* Extra space at bottom for buttons */
}

/* Fix for coinflip listings to ensure action buttons are visible */
.coinflip-listing,
.player-trade-listing,
.bot-trade-listing {
    overflow: visible !important;
    padding-bottom: 50px; /* Extra space for action buttons */
    position: relative;
}

.coinflip-listing .listing-action,
.player-trade-listing .listing-action,
.bot-trade-listing .listing-action {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    margin: 0;
    z-index: 10;
}

/* Ensure proper spacing in trade panels */
.trade-panel {
    display: flex;
    flex-direction: column;
    min-height: 400px; /* Ensure minimum height */
    padding-bottom: 20px !important; /* Force bottom padding */
}

.trade-section.active-trade {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow flexbox to work properly */
}

/* Fix trade parties to not take all space */
.trade-parties {
    flex: 1;
    min-height: 200px;
    max-height: calc(100vh - 400px); /* Limit height to leave space for buttons */
    overflow-y: auto;
}

/* Responsive improvements for mobile */
@media (max-width: 768px) {
    .glass-card {
        padding-bottom: 80px; /* More space on mobile */
    }
    
    .trade-actions,
    .coinflip-actions {
        min-height: 70px;
        padding: 15px 10px;
        gap: 10px;
    }
    
    .trade-btn {
        min-height: 48px; /* Better touch targets */
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .listing-action {
        min-height: 44px; /* Better touch targets */
        padding: 10px 15px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .glass-card {
        padding-bottom: 90px; /* Even more space on very small screens */
    }
    
    .trade-actions,
    .coinflip-actions {
        min-height: 80px;
        padding: 20px 10px;
        flex-direction: column; /* Stack buttons vertically on very small screens */
        gap: 8px;
    }
    
    .trade-btn {
        width: 100%; /* Full width buttons on small screens */
        min-height: 50px;
        padding: 14px 20px;
        font-size: 16px; /* Larger text for better accessibility */
    }
}

/* Fix for overflowing containers */
.trade-listings,
.coinflip-listings-container,
#playerCoinflipsSection,
#botCoinflipListingsContainer {
    overflow: visible !important;
    max-height: none !important;
    padding-bottom: 20px;
}

/* Ensure scrollable areas account for action buttons */
.trade-listings {
    padding-bottom: 100px; /* Space for any floating action buttons */
}

/* Fix inventory grids that might interfere with action buttons */
.inventory-grid {
    margin-bottom: 20px; /* Space below inventory */
    max-height: calc(100vh - 300px); /* Ensure space for action buttons */
}

/* Special mobile fixes for viewport issues */
@media (max-width: 768px) and (max-height: 700px) {
    /* For shorter mobile screens, reduce some spacing but keep buttons visible */
    .trade-parties {
        max-height: calc(100vh - 350px);
    }
    
    .inventory-grid {
        max-height: calc(100vh - 280px);
    }
    
    #tradeContent,
    #coinflipContent {
        padding-bottom: 160px !important; /* Even more space on short screens */
    }
}

/* Landscape mobile orientation fixes */
@media (max-width: 768px) and (orientation: landscape) and (max-height: 500px) {
    /* Special handling for landscape mobile where height is limited */
    .trade-container {
        max-height: none !important;
        overflow-y: visible !important;
    }
    
    .trade-panel {
        min-height: auto;
        padding-bottom: 60px !important;
    }
    
    .trade-parties {
        max-height: 250px;
        overflow-y: auto;
    }
    
    .trade-actions,
    .coinflip-actions {
        position: fixed; /* Fix to viewport for landscape */
        bottom: 10px;
        left: 10px;
        right: 10px;
        background: rgba(26, 26, 26, 0.95);
        backdrop-filter: blur(10px);
        padding: 10px;
        border-radius: 8px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
        z-index: 1000;
    }
    
    /* Ensure content doesn't get hidden behind fixed buttons */
    .tab-content {
        padding-bottom: 80px !important;
    }
}

/* Force visibility for buttons that might be hidden */
#makeOfferBtn,
#cancelTradeBtn,
#createCoinflipBtn,
#cancelCoinflipBtn,
.listing-action,
.trade-btn {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 50 !important;
}
