/* Diagnostic Wizard Frontend v2 — mobile-first */
.mwc-diag-wizard { max-width: 720px; margin: 0 auto; }

/* Progress */
.mwc-diag-progress { background: #e8e8e8; border-radius: 20px; height: 8px; margin-bottom: 24px; position: relative; overflow: hidden; }
.mwc-diag-progress-bar { height: 100%; background: linear-gradient(90deg, var(--mwc-secondary, #ff6b35), var(--mwc-primary, #e91e63)); border-radius: 20px; transition: width 0.4s ease; width: 0; }
.mwc-diag-progress-text { position: absolute; top: 14px; right: 0; font-size: .75em; color: #888; }

/* Screens */
.mwc-diag-screen { animation: mwcDiagIn .3s ease; }
@keyframes mwcDiagIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }
.mwc-diag-screen-inner { padding: 0 4px; }

.mwc-diag-question-text { font-size: 1.5em; font-weight: 700; margin: 0 0 8px; text-align: center; }
.mwc-diag-question-desc { text-align: center; color: #666; margin: 0 0 24px; }

/* Tiles */
.mwc-diag-tiles { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; margin-bottom: 20px; }
@media(min-width:600px) { .mwc-diag-tiles { grid-template-columns: repeat(3,1fr); } }
@media(min-width:900px) { .mwc-diag-tiles { grid-template-columns: repeat(4,1fr); } }

.mwc-diag-tile { background: #fff; border: 2px solid #e0e0e0; border-radius: 12px; overflow: hidden; cursor: pointer; transition: all .2s; text-align: center; }
.mwc-diag-tile:hover { border-color: #999; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.mwc-diag-tile.selected { border-color: var(--mwc-primary, #e91e63); background: color-mix(in srgb, var(--mwc-primary, #e91e63) 10%, white); }
.mwc-diag-tile-img { width: 100%; padding-bottom: 75%; background-size: cover; background-position: center; background-color: #f5f5f5; }
.mwc-diag-tile-placeholder { display: flex; align-items: center; justify-content: center; padding-bottom: 0; height: 80px; }
.mwc-diag-tile-placeholder .dashicons { font-size: 28px; color: #ccc; }
.mwc-diag-tile-body { padding: 10px 8px; }
.mwc-diag-tile-body strong { display: block; font-size: .9em; margin-bottom: 2px; }
.mwc-diag-tile-body span { font-size: .78em; color: #888; }

/* Back btn */
.mwc-diag-btn-back { background: none; border: none; color: #666; cursor: pointer; font-size: .9em; padding: 8px 0; }
.mwc-diag-btn-back:hover { color: #333; }

/* Result */
.mwc-diag-result-title { font-size: 1.6em; font-weight: 700; text-align: center; margin: 0 0 8px; }
.mwc-diag-result-text { text-align: center; color: #555; margin: 0 0 20px; }

.mwc-diag-badge { display: table; margin: 0 auto 24px; background: linear-gradient(135deg, var(--mwc-secondary, #ff6b35), var(--mwc-primary, #e91e63)); color: #fff; padding: 8px 20px; border-radius: 24px; font-weight: 700; font-size: .95em; }

/* Product cards */
.mwc-diag-result-products { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.mwc-diag-product-card { display: flex; gap: 14px; padding: 14px; background: #fff; border: 1px solid #eee; border-radius: 10px; align-items: center; }
.mwc-diag-product-card:hover { border-color: #ccc; }
.mwc-diag-p-img { flex-shrink: 0; width: 70px; height: 70px; border-radius: 8px; object-fit: cover; }
.mwc-diag-p-info { flex: 1; }
.mwc-diag-p-name { font-weight: 600; font-size: .95em; color: inherit; text-decoration: none; display: block; margin-bottom: 2px; }
.mwc-diag-p-name:hover { text-decoration: underline; }
.mwc-diag-p-desc { font-size: .82em; color: #888; margin: 0 0 4px; }
.mwc-diag-p-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mwc-diag-p-qty { background: #eee; padding: 2px 8px; border-radius: 4px; font-size: .82em; font-weight: 600; }
.mwc-diag-p-price { font-weight: 600; color: #333; font-size: .9em; }
.mwc-diag-p-line-total { font-size: .82em; color: #888; }

/* Selectable product cards */
.mwc-diag-product-card.mwc-diag-selectable { cursor: default; }
.mwc-diag-p-check {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    accent-color: var(--mwc-primary, #e91e63);
    cursor: pointer;
    margin-right: 4px;
}
.mwc-diag-product-card.mwc-diag-selectable:has(.mwc-diag-p-check:not(:checked)) {
    opacity: .5;
}

/* Quantity stepper (selectable mode) */
.mwc-diag-qty-stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
}
.mwc-diag-qty-stepper button {
    border: none;
    background: #f5f5f5;
    width: 28px;
    height: 28px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    color: #333;
    padding: 0;
    transition: background .15s;
}
.mwc-diag-qty-stepper button:hover { background: var(--mwc-primary, #e91e63); color: #fff; }
.mwc-diag-qty-val {
    min-width: 32px;
    text-align: center;
    font-weight: 600;
    font-size: .9em;
    padding: 0 4px;
}

/* Fallback badge */
.mwc-diag-p-fallback {
    display: inline-block;
    font-size: .72em;
    font-weight: 600;
    color: var(--mwc-primary, #e91e63);
    background: color-mix(in srgb, var(--mwc-primary, #e91e63) 12%, white);
    padding: 1px 8px;
    border-radius: 10px;
    margin-bottom: 4px;
}

/* Interleaved layout: message blocks act as section intros above their products */
#mwc-diag-products .mwc-diag-msg-block { margin-top: 8px; margin-bottom: 12px; padding-bottom: 0; border-bottom: none; }
#mwc-diag-products .mwc-diag-msg-block + .mwc-diag-product-card { margin-top: 0; }
.mwc-diag-remaining-products { margin-top: 12px; display: flex; flex-direction: column; gap: 12px; }

/* Result message blocks (article-style) */
.mwc-diag-result-messages { margin-bottom: 28px; }
.mwc-diag-msg-block {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #eee;
}
.mwc-diag-msg-block:last-child { border-bottom: none; padding-bottom: 0; }
.mwc-diag-msg-title {
    font-size: 1.25em;
    font-weight: 700;
    margin: 0 0 12px;
    color: #222;
}
.mwc-diag-msg-img {
    width: 100%;
    max-height: 360px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 12px;
}
.mwc-diag-msg-text {
    font-size: .95em;
    line-height: 1.65;
    color: #444;
}

/* Footer */
.mwc-diag-result-footer { background: #f8f8f8; border: 2px solid #e0e0e0; border-radius: 12px; padding: 16px 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.mwc-diag-price-summary { display: flex; align-items: center; gap: 10px; }
.mwc-diag-price-before { text-decoration: line-through; color: #999; font-size: .95em; }
.mwc-diag-price-after { font-size: 1.4em; font-weight: 700; color: var(--mwc-primary, #e91e63); }

.mwc-diag-btn-atc { background: linear-gradient(135deg, var(--mwc-secondary, #ff6b35), var(--mwc-primary, #e91e63)); color: #fff; border: none; padding: 14px 28px; border-radius: 8px; font-size: 1em; font-weight: 700; cursor: pointer; transition: opacity .2s, transform .1s; }
.mwc-diag-btn-atc:hover { opacity: .9; }
.mwc-diag-btn-atc:active { transform: scale(.97); }
.mwc-diag-btn-atc:disabled { opacity: .5; cursor: not-allowed; }

.mwc-diag-loading { text-align: center; padding: 40px; color: #888; }
.mwc-diag-spin { animation: mwcSpin 1s linear infinite; }
@keyframes mwcSpin { from{transform:rotate(0deg)} to{transform:rotate(360deg)} }

@media(max-width:480px) {
    .mwc-diag-question-text { font-size: 1.2em; }
    .mwc-diag-result-footer { flex-direction: column; text-align: center; }
    .mwc-diag-btn-atc { width: 100%; }
}

/* Containment: adapt to the container width, not the viewport, so the wizard
   stays inside Flatsome/UX Builder columns and other constrained wrappers. */
.mwc-diag-wizard,
.mwc-diag-wizard * { box-sizing: border-box; max-width: 100%; }
.mwc-diag-wizard { width: 100%; overflow-wrap: break-word; container-type: inline-size; }
.mwc-diag-tiles { grid-template-columns: 1fr; }
.mwc-diag-product-card,
.mwc-diag-p-info,
.mwc-diag-result-footer,
.mwc-diag-price-summary { min-width: 0; }
.mwc-diag-msg-img,
.mwc-diag-p-img { max-width: 100%; height: auto; }

@container (min-width: 600px) { .mwc-diag-tiles { grid-template-columns: repeat(3,1fr); } }
@container (min-width: 900px) { .mwc-diag-tiles { grid-template-columns: repeat(4,1fr); } }
@container (max-width: 480px) {
    .mwc-diag-result-footer { flex-direction: column; align-items: stretch; text-align: center; }
    .mwc-diag-product-card { flex-wrap: wrap; }
}

@supports not (container-type: inline-size) {
    @media (min-width: 600px) { .mwc-diag-tiles { grid-template-columns: repeat(3,1fr); } }
    @media (min-width: 900px) { .mwc-diag-tiles { grid-template-columns: repeat(4,1fr); } }
}
