/* ── Frame Calculator — frontend configurator ───────────────────────────── */

/* Hide WC product gallery on FC-enabled product pages (JS also hides it, CSS is a fallback). */
.fc-product .woocommerce-product-gallery {
    display: none !important;
}

/* Woodmart Compare/Wishlist single-product buttons — removed server-side (class-fc-core.php
   hide_compare_and_wishlist()); this is just a defensive fallback in case a builder layout
   renders them through a different code path. */
.fc-product .wd-compare-btn,
.fc-product .wd-wishlist-btn {
    display: none !important;
}

.fc-configurator {
    margin: 20px 0;
    font-size: 14px;
    line-height: 1.5;
}

/* ── Dropdown selects ── */
.fc-select {
    width: 100%;
    max-width: 280px;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s;
}
.fc-select:focus {
    outline: none;
    border-color: #8a6000;
    box-shadow: 0 0 0 2px rgba(138,96,0,0.15);
}

.fc-dropdown-row {
    align-items: center;
    gap: 12px;
}
.fc-dropdown-row .fc-label {
    margin-bottom: 0;
    min-width: 90px;
    /* Match .fc-section__title (e.g. "Outer Frame") so Glass/Mirror/Backing/Hanging read as
       the same kind of label as the other section headings. */
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #333;
}

/* Re-edit link in cart */
.fc-re-edit-link {
    font-size: 11px;
    color: #8a6000;
    text-decoration: underline;
}

/* Disable style for WC button when FC is not ready */
.single_add_to_cart_button.fc-btn-disabled,
.single_add_to_cart_button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* fc-required asterisk */
.fc-required {
    color: #d32f2f;
}

.fc-section {
    border-bottom: 1px solid #e8e8e8;
    padding: 16px 0;
}
.fc-section:last-child {
    border-bottom: none;
}

.fc-section__title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 10px;
    color: #333;
}

.fc-optional {
    font-size: 10px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #999;
    background: #f0f0f0;
    border-radius: 3px;
    padding: 1px 5px;
}

.fc-row {
    margin-bottom: 8px;
}

.fc-row--inline {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.fc-label {
    display: block;
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 4px;
    color: #555;
}

.fc-input {
    width: 100%;
    max-width: 160px;
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.fc-input:focus {
    outline: none;
    border-color: #8a6000;
    box-shadow: 0 0 0 2px rgba(138, 96, 0, 0.15);
}

.fc-error {
    display: block;
    font-size: 12px;
    color: #d32f2f;
    margin-top: 3px;
    min-height: 16px;
}

.fc-error.fc-error-hard {
    font-weight: 700;
}

.fc-dim-hint {
    font-size: 12px;
    color: #888;
    margin: 4px 0 0;
}

/* ── Product pickers ── */
.fc-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.fc-picker-btn {
    background: none;
    border: 2px dashed #ccc;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.fc-picker-btn:hover {
    border-color: #8a6000;
    color: #8a6000;
}

.fc-selected-product {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 6px 10px;
}

.fc-selected-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid #ddd;
}

.fc-selected-name {
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.fc-remove-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 3px;
    transition: background 0.1s;
    margin-left: auto;
}
.fc-remove-btn:hover { background: #f0f0f0; color: #555; }

/* ── Radio groups ── */
.fc-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fc-radio-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}

.fc-radio-label:has(input:checked) {
    /* Matches the live-calculated price colour (#fc-price-display, inherited from the theme)
       so the active image type reads as tied to the price, not an arbitrary accent colour. */
    border-color: #ca3827;
    background: #fff;
    color: #ca3827;
    font-weight: 600;
}

.fc-radio-label:has(input:disabled) {
    cursor: not-allowed;
    opacity: 0.45;
}

.fc-radio-label input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Lightbox trigger — shown instead of the radio group when the admin has hidden it; always
   styled like the "active" radio (see :has(input:checked) above) since it isn't a toggle, just
   a call-to-action button. Fully self-contained with !important on every property: it's a real
   <button type="button">, and Woodmart's base.css has a same-specificity
   `:is(.btn, .button, button, [type="button"], ...)` reset (padding/border/uppercase/etc.) that
   loads after this stylesheet and would otherwise silently win each shared property — the exact
   same class of bug already fixed for .fc-lightbox-close. */
.fc-lightbox-trigger {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    font-size: 13px !important;
    line-height: 1.2 !important;
    cursor: pointer !important;
    padding: 6px 12px !important;
    min-height: 0 !important;
    border: 1px solid #ca3827 !important;
    border-radius: 4px !important;
    background: #fff !important;
    color: #ca3827 !important;
    font-weight: 600 !important;
    font-family: inherit !important;
    text-transform: none !important;
    text-shadow: none !important;
    box-shadow: none !important;
    transition: background 0.15s !important;
}
.fc-lightbox-trigger:hover {
    background: #fff5f3 !important;
}

.fc-image-scaled-notice {
    font-size: 12px;
    color: #ca3827;
    font-weight: 700;
}

.fc-canvas-notice-row {
    /* Right-aligned, inset by the same 15px the frame preview itself uses (PAD in
       drawCanvas(), assets/js/fc-configurator.js), so the notice lines up with the frame's own
       right edge above it instead of sitting flush against the wrap's border. */
    padding: 8px 15px;
    text-align: right;
    background: #f0f0f0;
}

/* ── Canvas wrap — sits in gallery column after JS moves it ── */
.fc-canvas-wrap {
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.fc-canvas-wrap.fc-canvas-in-gallery {
    width: 100%;
    margin-bottom: 16px;
}

#fc-canvas {
    display: block;
    width: 100%;
    height: auto;
    cursor: default;
}
#fc-canvas.fc-canvas-clickable {
    cursor: zoom-in;
}

.fc-canvas-upload {
    padding: 10px;
    text-align: center;
    background: #f0f0f0;
}

.fc-canvas-controls {
    padding: 10px 8px;
    background: #f0f0f0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.fc-canvas-control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

/* Compact background-colour row (radios hidden): swatch then label, side by side. */
.fc-canvas-control-group--row {
    flex-direction: row;
    gap: 8px;
}

.fc-upload-label {
    font-size: 12px;
    color: #555;
    cursor: pointer;
    transition: color 0.15s;
}
.fc-upload-label:hover { color: #333; }

/* Cart thumbnail for FC items */
.fc-cart-thumb {
    object-fit: cover;
    border-radius: 3px;
}

/* ── Product picker modal ── */
.fc-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
}

.fc-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
}

.fc-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 10px;
    width: min(90vw, 760px);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.fc-modal-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.fc-modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    flex: 1;
}

.fc-modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.1s;
}
.fc-modal-close:hover { background: #f0f0f0; }

.fc-modal-body {
    overflow-y: auto;
    padding: 20px;
    flex: 1;
}

.fc-product-search {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    margin-bottom: 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}
.fc-product-search:focus {
    outline: none;
    border-color: #999;
}

/* Product grid inside modal */
.fc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.fc-product-card {
    border: 2px solid #eee;
    border-radius: 8px;
    background: #fff;
    padding: 10px;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.fc-product-card:hover {
    border-color: #8a6000;
    box-shadow: 0 2px 10px rgba(138,96,0,0.2);
}

.fc-product-card img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
}

.fc-product-card__name {
    font-weight: 600;
    color: #333;
    font-size: 12px;
    line-height: 1.3;
}

.fc-product-card__price {
    color: #8a6000;
    font-size: 11px;
}

.fc-loading {
    color: #999;
    text-align: center;
    padding: 24px;
}

body.fc-modal-open {
    overflow: hidden;
}

/* ── Preview lightbox ── */
.fc-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fc-lightbox-overlay {
    position: absolute;
    inset: 0;
    /* Set inline by openLightbox() to the customer's chosen wall/background colour — this is
       just the fallback before that runs. */
    background: #fff;
}

.fc-lightbox-content {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
}

#fc-canvas-lightbox {
    /* Size is set inline by openLightbox()/fitLightboxCanvas() (contain-fit within 90% of the
       viewport, preserving the frame's own proportions) — JS is the sole source of truth for
       sizing here on purpose. A competing CSS max-width/max-height would react to viewport
       changes on its own, a frame ahead of the (also-live) JS recalculation, producing a
       visible "shrinks, then snaps to the right size" double-step instead of a single smooth
       resize. No drop shadow either — the idea is picturing the frame flat against the chosen
       wall colour, not a photo floating with its own shadow. */
    display: block;
}

/* Pinned to the browser viewport itself (not the modal's flex layout), so it always sits at
   the window's top-right corner regardless of how large the image is. Its own opaque badge
   (not just coloured text) keeps it legible against a wall colour of any lightness.
   !important on position/top/right/z-index: Woodmart's base.css has a same-specificity
   `:is(.btn, .button, button, [type="submit"], [type="button"])" rule setting
   position:relative that loads after this stylesheet, so without !important it silently wins
   and the button ends up positioned by the lightbox's flex layout instead of the viewport. */
.fc-lightbox-close {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    z-index: 100001 !important;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: 50%;
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.35);
    transition: background 0.15s;
}
.fc-lightbox-close:hover { background: rgba(0,0,0,0.8); }

body.fc-lightbox-open {
    overflow: hidden;
}
