/**
 * PBB UI Overrides & Enhancements
 * 
 * This file contains comprehensive styling for:
 * - LBS slider with manual input (step1)
 * - Accordion colour tiles (step2)
 * - Mini stepper buttons (step2)
 * - Stats bar and savings display (step2)
 * - Filter control layout (step2)
 */

/* ═══════════════════════════════════════════════════════════════════════════
   STEP 1: LBS MODE ENHANCEMENTS
   ═══════════════════════════════════════════════════════════════════════════ */

/* LBS Slider + Input Horizontal Layout */
.pbb-lbs-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    /* allow wrapping on smaller screens */
    gap: 10px;
    margin-bottom: 1rem;
}

.pbb-lbs-slider-wrap {
    flex: 1;
    position: relative;
    padding-bottom: 22px;
}

.pbb-lbs-slider-wrap input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    accent-color: #1a5fb4;
}

.pbb-lbs-slider-wrap input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #1a5fb4;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.pbb-lbs-slider-wrap input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #1a5fb4;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.pbb-lbs-ticks {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20px;
    font-size: 11px;
    color: #999;
}

/* LBS Manual Input Box */
.pbb-lbs-num {
    width: 80px;
    height: 36px;
    padding: 0 10px;
    border: 1.5px solid #1a5fb4;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    background: #fff;
    color: #1a1a1a;
    transition: all 0.2s;
}

.pbb-lbs-num:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(26, 95, 180, 0.2);
}

/* Remove spinner arrows from number input */
.pbb-lbs-num::-webkit-outer-spin-button,
.pbb-lbs-num::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pbb-lbs-num[type="number"] {
    -moz-appearance: textfield;
}

/* Each tick: absolutely placed at its PHP-calculated left offset */
.pbb-tick {
    position: absolute;
    transform: translateX(-50%);
    /* centre the label text under its exact point */
    cursor: pointer;
    user-select: none;
    padding: 2px 4px;
    border-radius: 3px;
    transition: all 0.2s;
    white-space: nowrap;
    font-size: 11px;
}

.pbb-tick:hover {
    color: #1a1a1a;
    background: #f0f6ff;
}

/* ═══════════════════════════════════════════════════════════════════════════
   STEP 2: FILTER ROW LAYOUT
   ═════════════════════════════════════════════════════════════════════════ */

.pbb-filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    /* margin-bottom: 1.5rem; */
    flex-wrap: wrap;
}

.pbb-filter-label {
    font-size: 13px;
    font-weight: 600;
    color: #666;
    white-space: nowrap;
}

.pbb-filter-select {
    height: 36px;
    padding: 0 10px;
    line-height: 33px;
    border: 1.5px solid #1a5fb4;
    border-radius: 6px;
    font-size: 13px;
    color: #1a1a1a;
    background: #fff;
    cursor: pointer;
    min-width: 150px;
    transition: all 0.2s;
}

.pbb-filter-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(26, 95, 180, 0.2);
}

/* ═══════════════════════════════════════════════════════════════════════════
   STEP 2: STATS BAR
   ═════════════════════════════════════════════════════════════════════════ */

.pbb-stats-bar {
    display: flex;
    gap: 2rem;
    padding: 12px 0;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 1.5rem;
}

.pbb-stat {
    flex: 1;
}

.pbb-stat-label {
    font-size: 11px;
    color: #999;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    margin-bottom: 4px;
    display: block;
}

.pbb-stat-val {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    display: block;
}

/* ═══════════════════════════════════════════════════════════════════════════
   STEP 2: SAVINGS/DISCOUNT BAR
   ═════════════════════════════════════════════════════════════════════════ */

.pbb-savings-wrap {
    margin-bottom: 1.5rem;
}

.pbb-savings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.pbb-savings-title {
    font-size: 12px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.pbb-savings-pct {
    font-size: 13px;
    font-weight: 600;
    color: #1a5fb4;
}

.pbb-savings-track {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.pbb-savings-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #1a5fb4 0%, #1a7fd4 100%);
    transition: width 0.4s ease;
    width: 0%;
}

.pbb-savings-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #999;
    margin-bottom: 8px;
    padding: 0 2px;
}

.pbb-alert-box {
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    background: #fff8e1;
    color: #856404;
    border: 1px solid #ffe082;
    display: none;
}

.pbb-alert-box.show {
    display: block;
}

.pbb-alert-box.maxed {
    background: #e8f5e9;
    color: #2e7d32;
    border-color: #a5d6a7;
}

.pbb-alert-box strong {
    font-weight: 700;
}

/* ═════════════════════════════════════════════════════════════════════════════
   STEP 2: ACCORDION COLOUR TILES
   ═════════════════════════════════════════════════════════════════════════════ */

.pbb-colour-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 1.5rem;
    align-items: start;
}

/* When a tile is expanded, span full width for room to show product rows */
/* .pbb-colour-tile:has(.pbb-tile-body.open) {
    grid-column: 1 / -1;
} */

.pbb-colour-tile {
    border: 1.5px solid #1a5fb4;
    border-radius: 8px;
    overflow: hidden;
}

.pbb-tile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    cursor: pointer;
    background: #fff;
    user-select: none;
    transition: all 0.2s;
}

.pbb-tile-header:hover {
    background: #f0f6ff;
}

.pbb-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.pbb-colour-swatch {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.pbb-tile-name {
    font-size: 11px;
    font-weight: 600;
    color: #1a5fb4;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.pbb-tile-badge {
    font-size: 10px;
    background: #1a5fb4;
    color: #fff;
    border-radius: 8px;
    padding: 2px 6px;
    font-weight: 600;
}

.pbb-tile-badge.show {
    display: inline-block;
}

.pbb-tile-arrow {
    font-size: 10px;
    color: #1a5fb4;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.pbb-tile-arrow.open {
    transform: rotate(180deg);
}

.pbb-tile-body {
    display: none;
    padding: 10px;
    border-top: 1px solid #c5ddf7;
    background: #f7faff;
}

.pbb-tile-body.open {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* ═════════════════════════════════════════════════════════════════════════════
   STEP 2: SIZE ROWS WITH MINI STEPPERS
   ═════════════════════════════════════════════════════════════════════════════ */

.pbb-size-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    padding: 8px;
    border: 1px solid #e8f0f8;
    border-radius: 6px;
    background: #fff;
}

.pbb-size-row:last-child {
    margin-bottom: 0;
}

.pbb-size-tag {
    font-size: 10px;
    color: #888;
    min-width: 45px;
    font-weight: 500;
}

.pbb-mini-stepper {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid #ddd;
    border-radius: 6px;
}

.pbb-qty-minus {
    border-radius: 5px 0px 0px 5px !important;
}

.pbb-qty-plus {
    border-radius: 0px 5px 5px 0px !important;
}

.pbb-qty-minus,
.pbb-qty-plus {
    width: 35px;
    height: 30px;
    /* border-radius: 4px; */
    background: #1a5fb4;
    border: none;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    line-height: 0 !important;
    transition: all 0.2s;
    font-weight: 600;
}

.pbb-qty-minus:hover,
.pbb-qty-plus:hover {
    background: #1450a0;
}

.pbb-qty-minus:active,
.pbb-qty-plus:active {
    transform: scale(0.95);
}

.pbb-qty-val {
    width: 24px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #1a1a1a;
    display: block;
}

.pbb-qty-input {
    width: 35px;
    height: 30px;
    border: none;
    border-radius: 0;
    padding: 0 6px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    /* display: none; */
}

.pbb-qty-input:focus {
    outline: none;
    border-color: #1a5fb4;
    box-shadow: 0 0 0 2px rgba(26, 95, 180, 0.1);
}

.pbb-filter-row .select2-container .select2-selection--single .select2-selection__rendered {
    line-height: 3 !important;
    padding-left: 5px !important;
}

/* ═════════════════════════════════════════════════════════════════════════════
   RESPONSIVE ADJUSTMENTS
   ═════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .pbb-colour-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .pbb-stats-bar {
        gap: 1rem;
        font-size: 0.9rem;
    }

    .pbb-lbs-row {
        gap: 8px;
    }

    .pbb-filter-row {
        gap: 8px;
        margin-bottom: auto;
    }

    .pbb-filter-select {
        min-width: 120px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .pbb-colour-grid {
        grid-template-columns: 1fr;
    }

    .pbb-filter-row {
        flex-direction: row;
        align-items: center;
    }

    .pbb-lbs-row {
        flex-wrap: wrap;
    }

    .pbb-lbs-slider-wrap {
        flex: 1 1 100%;
        margin-bottom: 12px;
    }

    /* Reduce density of ticks on mobile */
    .pbb-lbs-ticks .pbb-tick:not(:first-child):not(:last-child):nth-child(odd) {
        display: none;
    }

    .pbb-filter-select {
        width: 100%;
        min-width: auto;
    }

    .pbb-stats-bar {
        flex-direction: column;
        gap: 1rem;
    }

    .pbb-size-row {
        gap: 4px;
    }
}

/* ═════════════════════════════════════════════════════════════════════════════
   MESSAGES & UTILITIES
   ═════════════════════════════════════════════════════════════════════════════ */

.pbb-messages {
    margin-bottom: 1rem;
}

.pbb-message {
    padding: 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pbb-message.pbb-message-error {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

.pbb-message.pbb-message-success {
    background: #efe;
    color: #3c3;
    border: 1px solid #cfc;
}

.pbb-message.pbb-message-warning {
    background: #ffe;
    color: #993;
    border: 1px solid #ffc;
}

.pbb-empty-message {
    text-align: center;
    color: #999;
    font-size: 14px;
    padding: 2rem;
    background: #f9f9f9;
    border-radius: 6px;
    border: 1px dashed #ddd;
}

@media (max-width: 992px) {
    .pbb-tile-body.open {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .pbb-tile-body.open {
        grid-template-columns: 1fr;
    }
}