/**
 * 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);
    grid-template-rows: auto auto;
    grid-auto-rows: auto auto;
    gap: 30px;
    margin: 0 auto;
    padding: 20px 0;
    align-items: start;
}

.gbpm-sell-column {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: span 2;
    gap: 30px;
    background: #fff;
    padding: 0;
}

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

.gbpm-sell-section {
    display: flex;
    flex-direction: column;
}

.gbpm-sell-table thead th.gbpm-sell-header-label {
    text-align: center;
    color: var(--gbpm-sell-text);
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    overflow: visible;
}

/* ==========================================================================
   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: 64px;
}

/* Uniform body row height across all tables, regardless of image/badge content */
.gbpm-sell-item td {
    height: 64px;
}

.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
   ========================================================================== */

/*
 * Badges use the UK hallmark fineness-mark shape for each metal (matches the
 * old live site): gold = cut-corner octagon, silver = oval, platinum = house,
 * palladium = three conjoined circles (GDL-371).
 */
.gbpm-sell-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 46px;
    height: 28px;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Gold badge — elongated octagon (cut corners) */
.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);
    clip-path: polygon(12% 0, 88% 0, 100% 32%, 100% 68%, 88% 100%, 12% 100%, 0 68%, 0 32%);
}

/* Silver badge — oval */
.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);
    border-radius: 50%;
}

/* Platinum badge — "house" pentagon, peak at top */
.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);
    height: 32px;
    padding-top: 6px;
    clip-path: polygon(50% 0, 100% 34%, 100% 100%, 0 100%, 0 34%);
}

/* Palladium badge — three conjoined circles */
.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);
    min-width: 56px;
    -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 56 28"><circle cx="13" cy="14" r="13"/><circle cx="28" cy="14" r="13"/><circle cx="43" cy="14" r="13"/></svg>') center / 100% 100% no-repeat;
    mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 56 28"><circle cx="13" cy="14" r="13"/><circle cx="28" cy="14" r="13"/><circle cx="43" cy="14" r="13"/></svg>') center / 100% 100% no-repeat;
}

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

.gbpm-sell-view-all {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    gap: 8px;
    padding: 8px 18px;
    background: #000;
    color: #fff !important;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    border-radius: 999px;
    transition: background-color 0.2s ease, transform 0.1s ease;
    margin-top: auto; /* Push to bottom */
}

.gbpm-sell-view-all:hover {
    background: #333;
    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;
        text-align: center; /* Centre the inline-flex view-all button */
    }

    .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: 12px;
        padding: 7px 14px;
    }
}

/* ==========================================================================
   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;
}

/* ==========================================================================
   PRICING TABLE [gbpm_pricing_table]
   Full-width price table for dedicated pricing pages
   ========================================================================== */

.gbpm-pricing-table {
    width: 100%;
}

/* Two balanced side-by-side tables on desktop (GDL-384) */
.gbpm-pricing-table--split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 32px;
    align-items: start;
}

.gbpm-pricing-table__table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.gbpm-pricing-table__table thead th {
    font-size: 14px;
    font-weight: 600;
    color: var(--gbpm-sell-text);
    padding: 12px 16px;
    border-bottom: 2px solid var(--gbpm-sell-gold, #b79759);
    text-align: left;
}

.gbpm-pricing-table__th-price {
    text-align: right !important;
    white-space: nowrap;
}

.gbpm-pricing-table__row {
    transition: background-color 0.15s ease;
}

.gbpm-pricing-table__row:hover {
    background-color: var(--gbpm-sell-bg, #f9f9f9);
}

.gbpm-pricing-table__row td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--gbpm-sell-border, #e5e5e5);
    vertical-align: middle;
}

.gbpm-pricing-table__row:last-child td {
    border-bottom: none;
}

.gbpm-pricing-table__name {
    font-size: 15px;
    font-weight: 500;
    color: var(--gbpm-sell-text, #333);
}

.gbpm-pricing-table__price {
    text-align: right;
    font-size: 16px;
    font-weight: 700;
    color: var(--gbpm-sell-text, #333);
    white-space: nowrap;
}

.gbpm-pricing-table__price .gbpm-price-amount {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Price animations for pricing table */
.gbpm-pricing-table__row .gbpm-price-amount.price-up {
    animation: gbpm-sell-flash-green 4s ease-out;
}

.gbpm-pricing-table__row .gbpm-price-amount.price-down {
    animation: gbpm-sell-flash-red 4s ease-out;
}

@media (max-width: 768px) {
    /* Stack the split columns top-to-bottom on mobile (GDL-384) */
    .gbpm-pricing-table--split {
        grid-template-columns: 1fr;
        gap: 0;
    }

    /* Hide the repeated header on the second stacked table */
    .gbpm-pricing-table--split .gbpm-pricing-table__table + .gbpm-pricing-table__table thead {
        display: none;
    }

    /* Keep the row divider where the two stacked halves meet */
    .gbpm-pricing-table--split .gbpm-pricing-table__table:first-child .gbpm-pricing-table__row:last-child td {
        border-bottom: 1px solid var(--gbpm-sell-border, #e5e5e5);
    }

    .gbpm-pricing-table__table thead th {
        font-size: 13px;
        padding: 10px 12px;
    }

    .gbpm-pricing-table__row td {
        padding: 8px 12px;
    }

    .gbpm-pricing-table__name {
        font-size: 14px;
    }

    .gbpm-pricing-table__price {
        font-size: 15px;
    }
}
