/* ============================================================
   Blackinton Builder – Front-end Styles
   ============================================================ */

/* ── Iframe container ─────────────────────────────────────── */
.bb-iframe-container {
    width: 100%;
    position: relative;
    /* No overflow:hidden here — let height be driven by JS resize */
}

.bb-iframe {
    width: 100%;
    /* No min-height — height is set dynamically by postMessage / polling */
    height: 800px;      /* safe initial render height; JS overrides this */
    border: none;
    display: block;
    overflow: hidden;   /* prevent inner scrollbar — outer page scrolls instead */
}

/* ── Loading spinner ──────────────────────────────────────── */
.bb-iframe-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 40px 0;
}

.bb-iframe-loader::after {
    content: '';
    display: block;
    width: 48px;
    height: 48px;
    border: 5px solid #e0e0e0;
    border-bottom-color: #00477a;
    border-radius: 50%;
    animation: bb-spin 1s linear infinite;
}

@keyframes bb-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ── Cart item overrides ──────────────────────────────────── */
#add_payment_method table.cart img,
.woocommerce-cart table.cart img,
.woocommerce-checkout table.cart img {
    width: 12rem;
}

.bb-thumbnail-wrap {
    position: relative;
    display: inline-block;
}

.bb-stock-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 71, 122, 0.55);
    color: #fff;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-align: center;
    pointer-events: none;
    white-space: nowrap;
}

.bb-item-desc {
    color: #555;
    font-size: 0.875rem;
    margin: 4px 0 6px;
}

.bb-item-html {
    margin-bottom: 6px;
}

.bb-item-actions {
    display: flex;
    gap: 12px;
    margin-top: 6px;
}

a.bb-btn {
    font-size: 0.8rem;
    text-decoration: none;
    padding: 3px 8px;
    border-radius: 3px;
    border: 1px solid currentColor;
    line-height: 1.4;
    display: inline-block;
}

a.bb-btn-edit   { color: #2e7d32; }
a.bb-btn-remove { color: #b71c1c; }
a.bb-btn:hover  { opacity: 0.75; }

/* ── PCS option display – clean options table ──────────────── */
.bb-options-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 10px;
    font-size: 0.85rem;
}

.bb-options-table th,
.bb-options-table td {
    padding: 3px 8px 3px 0;
    vertical-align: top;
    border: none;
    text-align: left;
}

.bb-options-table th {
    color: #555;
    font-weight: 500;
    width: 42%;
    white-space: nowrap;
}

.bb-options-table td {
    font-weight: 700;
    color: #222;
}

.bb-options-table tr:nth-child(even) th,
.bb-options-table tr:nth-child(even) td {
    background: transparent;
}

/* Legacy pcs-options passthrough (if builder sends its own HTML) */
.pcs-options {
    padding: 8px 0;
    font-size: 0.85rem;
}
.pcs-options .option.item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    padding-top: 3px;
    gap: 4px;
}
.pcs-options .option.item .title {
    font-weight: 500;
    color: #555;
    min-width: 120px;
}
.pcs-options .option.item .selection.value {
    font-weight: 700;
}

/* ── Product page button ─────────────────────────────────── */
.bb-btn-design {
    background-color: #00477a;
    color: #fff !important;
    border: none;
    border-radius: 4px;
    padding: 10px 22px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.bb-btn-design:hover {
    background-color: #005fa3;
}

/* ── Cart table ──────────────────────────────────────────── */
table.cart th,
#main-content table.cart th,
#main-content table.cart td.product-name {
    font-size: 1rem;
}

.shop_table.cart tr > td {
    vertical-align: top;
}

.shop_table.cart tr > td.product-quantity {
    text-align: center;
}

/* ── Layout overrides ─────────────────────────────────────── */
#left-area {
    padding: 0 !important;
}

#main-content .container {
    padding-top: 10px !important;
}

#main-content .container::before {
    background-color: transparent !important;
}

.woocommerce-privacy-policy-text {
    display: none;
}

/* ── Product layout (vhb-style pages) ────────────────────── */
.pcs-product-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 40px;
    margin: 0 auto;
    padding: 40px 20px;
}

.pcs-left {
    width: 50%;
    text-align: center;
}

.pcs-right {
    width: 100%;
}

.pcs-main-image img,
.pcs-right img {
    width: 100%;
    height: auto;
}

.pcs-caption {
    font-size: 13px;
    color: #666;
    margin-top: 6px;
    line-height: 1.4;
}

.pcs-thumbnail {
    margin-top: 20px;
}

.pcs-thumbnail img {
    width: 80px;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.pcs-button-wrap {
    margin-top: 20px;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 980px) {
    .pcs-product-layout {
        flex-direction: column;
        gap: 20px;
    }
    .pcs-left,
    .pcs-right {
        width: 100%;
    }
}

@media only screen and (max-width: 768px) {
    table.cart th,
    #main-content table.cart th,
    #main-content table.cart td.product-name {
        font-size: unset;
    }

    .woocommerce-cart table.cart {
        display: block;
        width: 100%;
        overflow-x: auto;
    }

    .woocommerce-cart table.cart th,
    .woocommerce-cart table.cart td {
        display: block;
        text-align: left !important;
        width: 100%;
        border: none;
    }

    .woocommerce table.shop_table_responsive tr td::before,
    .woocommerce-page table.shop_table_responsive tr td::before {
        content: attr(data-title) ":\00a0\00a0";
        font-weight: 700;
        float: left;
    }
}

/* ── BB Options Table (cart, checkout, order) ─────────────────────────────── */
.bb-options-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 10px;
    font-size: 0.9em;
}
.bb-options-table th,
.bb-options-table td {
    text-align: left;
    padding: 3px 8px 3px 0;
    vertical-align: top;
    border: none;
}
.bb-options-table th {
    color: #555;
    font-weight: normal;
    white-space: nowrap;
    width: 45%;
}
.bb-options-table td strong {
    color: #111;
}

/* ── Cart item name area ──────────────────────────────────────────────────── */
.bb-product-name {
    display: block;
    margin-bottom: 4px;
}
.bb-item-desc {
    color: #666;
    font-size: 0.9em;
    margin: 2px 0 6px;
}
.bb-item-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.bb-btn {
    display: inline-block;
    padding: 4px 12px;
    font-size: 0.85em;
    border: 1px solid #ccc;
    border-radius: 3px;
    text-decoration: none;
    cursor: pointer;
    background: #f9f9f9;
    color: #333;
    line-height: 1.6;
}
.bb-btn:hover {
    background: #eee;
    text-decoration: none;
    color: #000;
}
.bb-btn-remove {
    border-color: #c00;
    color: #c00;
}
.bb-btn-remove:hover {
    background: #fff0f0;
    color: #900;
}

/* ── Thumbnail wrap ───────────────────────────────────────────────────────── */
.bb-thumbnail-wrap {
    position: relative;
    display: inline-block;
}
.bb-stock-badge {
    position: absolute;
    bottom: 4px;
    left: 0;
    right: 0;
    text-align: center;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 0.7em;
    font-weight: bold;
    padding: 2px 4px;
    letter-spacing: 1px;
}

/* ── Order page thumbnail ─────────────────────────────────────────────────── */
.bb-order-thumbnail {
    max-width: 150px;
    height: auto;
    display: block;
    margin-top: 8px;
}
.bb-order-thumbnail-wrap {
    padding: 8px 0;
}

/* ── Iframe container ─────────────────────────────────────────────────────── */
.bb-iframe-container {
    width: 100%;
    overflow: hidden;
}
.bb-iframe {
    width: 100%;
    border: none;
    display: block;
    min-height: 600px;
}
.bb-iframe-loader {
    text-align: center;
    padding: 40px;
    color: #888;
}
.bb-iframe-loader::before {
    content: 'Loading builder…';
}
