/**
 * GBPM Sell Prices Styles
 *
 * Styles for the [gbpm_sell_grid] and [gbpm_sell_price] shortcodes.
 *
 * @package GB_Precious_Metals
 */

/* ==========================================================================
   CSS VARIABLES
   ========================================================================== */

:root {
    --gbpm-sell-gold: #b79759;
    --gbpm-sell-gold-light: #d4c4a8;
    --gbpm-sell-gold-dark: #96763d;
    --gbpm-sell-silver: #a8a8a8;
    --gbpm-sell-silver-light: #d0d0d0;
    --gbpm-sell-platinum: #6b6b6b;
    --gbpm-sell-platinum-light: #909090;
    --gbpm-sell-palladium: #5a6a7a;
    --gbpm-sell-palladium-light: #8095a8;
    --gbpm-sell-border: #e5e5e5;
    --gbpm-sell-bg: #f9f9f9;
    --gbpm-sell-text: #333;
    --gbpm-sell-text-muted: #666;
}

/* ==========================================================================
   SELL PRICES GRID
   ========================================================================== */

.gbpm-sell-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin: 0 auto;
    padding: 20px 0;
    align-items: start;
}

.gbpm-sell-column {
    background: #fff;
    border-radius: 0;
    padding: 0;
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: 30px;
    height: 100%;
}

.gbpm-sell-column-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--gbpm-sell-text);
    margin: 0 0 20px 0;
    padding: 0;
    grid-row: 1 / -1; /* Keep title outside the grid flow logic if possible, but title is INSIDE column. */
    /* Wait, title is inside column. 
       If I use grid-template-rows: 1fr 1fr, the title will take the first row? 
       No, title + 2 sections = 3 children. 
       I need to handle the title. */
    display: none; /* Hide title here to re-add it or just handle flex? */
}
/* Revert the grid on column and use Flex for safety if title is present */
.gbpm-sell-column {
    display: flex;
    flex-direction: column;
    gap: 0;
}
/* We need the sections to expand. 
   But 3 columns. 
   To align buttons in Section 1 and Section 2 across columns:
   The Section 1s must be equal height.
   The Section 2s must be equal height.
   This is best done with Subgrid (limited support) or explicit Grid on the parent.
   
   Alternative: Make .gbpm-sell-grid have 6 columns? No.
   
   Let's use the Grid approach on the column but account for the title.
   .gbpm-sell-column > h3 { ... }
   .gbpm-sell-column > .gbpm-sell-section:nth-of-type(1) { ... }
*/

.gbpm-sell-column {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.gbpm-sell-column-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--gbpm-sell-text);
    margin: 0 0 20px 0;
    padding: 0;
    flex: 0 0 auto;
}

/* ==========================================================================
   SELL SECTION
   ========================================================================== */

.gbpm-sell-section {
    margin-bottom: 30px; /* Consistent gap */
    display: flex;
    flex-direction: column;
    flex: 1; /* Expand to fill space */
}

.gbpm-sell-section:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   SELL TABLE
   ========================================================================== */

.gbpm-sell-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
    background: var(--gbpm-sell-bg);
    table-layout: fixed;
    flex: 0 0 auto;
}

.gbpm-sell-table thead th {
    font-size: 13px;
    font-weight: 500;
    color: var(--gbpm-sell-text-muted);
    padding: 10px 10px;
    border-bottom: 1px solid var(--gbpm-sell-border);
    vertical-align: middle;
}

/* Column 1: Visual (Image/Badge) */
.gbpm-sell-header-visual,
.gbpm-sell-item-visual {
    width: 60px;
    text-align: center;
    padding-left: 8px !important;
    padding-right: 8px !important;
}

/* Column 2: Name */
.gbpm-sell-header-name,
.gbpm-sell-item-name {
    text-align: left;
    /* Width is auto (remainder) */
}

/* Column 3: Price */
.gbpm-sell-header-price,
.gbpm-sell-item-price {
    width: 110px; /* Fixed width for price column */
    text-align: right;
    white-space: nowrap;
}

.gbpm-sell-header-price {
    /* Ensure header text aligns with values */
}

/* ==========================================================================
   SELL ITEM ROW
   ========================================================================== */

.gbpm-sell-item {
    transition: background-color 0.2s ease;
}

.gbpm-sell-item:hover {
    background-color: #fff;
}

.gbpm-sell-item td {
    padding: 2px 5px!important;
    border-bottom: 1px solid var(--gbpm-sell-border);
    vertical-align: middle;
}

.gbpm-sell-item:last-child td {
    border-bottom: none;
}

/* Visual cell (image or badge) */
.gbpm-sell-item-visual {
    /* Width handled by header class/shared rule above */
    text-align: center;
    height: 50px;
}

.gbpm-sell-item-image {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 50%;
}

/* Item name */
.gbpm-sell-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--gbpm-sell-text);
}

/* Price cell */
.gbpm-sell-item-price {
    /* Width handled by header class/shared rule above */
    text-align: right;
    font-size: 15px;
    font-weight: 600;
    color: var(--gbpm-sell-text);
    white-space: nowrap;
}

/* Price amount span - stable sizing for animations */
.gbpm-sell-item-price .gbpm-price-amount {
    display: inline-block;
    padding: 2px 4px;
    border-radius: 3px;
}

/* ==========================================================================
   BADGES
   ========================================================================== */

.gbpm-sell-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 28px;
    padding: 0 8px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Gold badge */
.gbpm-sell-badge--gold {
    background: linear-gradient(135deg, var(--gbpm-sell-gold-light) 0%, var(--gbpm-sell-gold) 50%, var(--gbpm-sell-gold-dark) 100%);
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

/* Silver badge */
.gbpm-sell-badge--silver {
    background: linear-gradient(135deg, var(--gbpm-sell-silver-light) 0%, var(--gbpm-sell-silver) 100%);
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
}

/* Platinum badge */
.gbpm-sell-badge--platinum {
    background: linear-gradient(135deg, var(--gbpm-sell-platinum-light) 0%, var(--gbpm-sell-platinum) 100%);
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

/* Palladium badge */
.gbpm-sell-badge--palladium {
    background: linear-gradient(135deg, var(--gbpm-sell-palladium-light) 0%, var(--gbpm-sell-palladium) 100%);
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   VIEW ALL BUTTON
   ========================================================================== */

.gbpm-sell-view-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    background: var(--gbpm-sell-gold);
    color: #fff !important;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none !important;
    border-radius: 4px;
    transition: background-color 0.2s ease, transform 0.1s ease;
    margin-top: auto; /* Push to bottom */
}

.gbpm-sell-view-all:hover {
    background: var(--gbpm-sell-gold-dark);
    color: #fff !important;
    transform: translateY(-1px);
}

/* ==========================================================================
   INLINE PRICE
   ========================================================================== */

.gbpm-sell-price-inline {
    display: inline;
}

.gbpm-sell-price-inline .gbpm-price-amount {
    display: inline-block;
    font-weight: 600;
}

/* ==========================================================================
   PRICE ANIMATIONS
   Reuses the same animation pattern as other price displays
   ========================================================================== */

/* Animation keyframes */
@keyframes gbpm-sell-flash-green {
    0% {
        background-color: rgba(76, 175, 80, 0.4);
    }
    100% {
        background-color: transparent;
    }
}

@keyframes gbpm-sell-flash-red {
    0% {
        background-color: rgba(244, 67, 54, 0.4);
    }
    100% {
        background-color: transparent;
    }
}

/* Price increase animation - Updated selector for span */
.gbpm-sell-item .gbpm-price-amount.price-up,
.gbpm-sell-price-inline .gbpm-price-amount.price-up {
    animation: gbpm-sell-flash-green 4s ease-out;
}

/* Price decrease animation - Updated selector for span */
.gbpm-sell-item .gbpm-price-amount.price-down,
.gbpm-sell-price-inline .gbpm-price-amount.price-down {
    animation: gbpm-sell-flash-red 4s ease-out;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 992px) {
    .gbpm-sell-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .gbpm-sell-grid {
        grid-template-columns: 1fr;
        gap: 25px;
        padding: 15px 0;
    }

    .gbpm-sell-column {
        display: block; /* Reset flex/grid on mobile */
    }

    .gbpm-sell-section {
        display: block; /* Reset flex on mobile */
        margin-bottom: 15px;
    }

    .gbpm-sell-column-title {
        font-size: 18px;
    }

    .gbpm-sell-item td {
        padding: 10px 12px;
    }

    .gbpm-sell-item-name {
        font-size: 13px;
    }

    .gbpm-sell-item-price {
        font-size: 14px;
    }

    .gbpm-sell-view-all {
        font-size: 14px;
        padding: 12px 15px;
    }
}

/* ==========================================================================
   SINGLE COLUMN LAYOUT (Filtered by Metal)
   ========================================================================== */

.gbpm-sell-grid--single {
    grid-template-columns: 1fr;
    max-width: 500px;
}

.gbpm-sell-grid--single .gbpm-sell-column {
    display: block;
}

.gbpm-sell-grid--single .gbpm-sell-section {
    flex: none;
}
