/* ================================================================
   ProductCraft — Frontend Configurator CSS
   ================================================================ */

.pc-configurator {
    --pc-primary:   #6EAAC8; /* surchargé par data-attribute */
    --pc-primary-d: color-mix(in srgb, var(--pc-primary) 80%, #000);
    --pc-light:     #F4F8FB;
    --pc-border:    #D0E4EE;
    --pc-text:      #1a1a1a;
    --pc-muted:     #777;
    --pc-radius:    12px;
    --pc-shadow:    0 4px 24px rgba(0,0,0,.06);

    font-family: inherit;
    color: var(--pc-text);
    margin: 24px 0;
}

.pc-configurator * { box-sizing: border-box; }

/* ── Loader ──────────────────────────────────────────── */
.pc-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--pc-muted);
    font-size: 14px;
}

.pc-loader__spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--pc-border);
    border-top-color: var(--pc-primary);
    border-radius: 50%;
    animation: pc-spin 0.8s linear infinite;
}

@keyframes pc-spin {
    to { transform: rotate(360deg); }
}

/* ── Progress bar ────────────────────────────────────── */
.pc-progress {
    margin-bottom: 20px;
}

.pc-progress__labels {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}

.pc-progress__labels::-webkit-scrollbar { display: none; }

.pc-progress__step {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.pc-progress__step:last-child .pc-progress__connector { display: none; }

.pc-progress__num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    background: var(--pc-border);
    color: var(--pc-muted);
    transition: background .25s, color .25s;
}

.pc-progress__step.is-active .pc-progress__num {
    background: var(--pc-primary);
    color: #fff;
}

.pc-progress__step.is-done .pc-progress__num {
    background: #46b450;
    color: #fff;
}

.pc-progress__step.is-done .pc-progress__num::before {
    content: '✓';
}

.pc-progress__label {
    font-size: 12px;
    font-weight: 500;
    color: var(--pc-muted);
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pc-progress__step.is-active .pc-progress__label { color: var(--pc-primary); font-weight: 600; }
.pc-progress__step.is-done .pc-progress__label { color: #46b450; }

.pc-progress__connector {
    width: 24px;
    height: 2px;
    background: var(--pc-border);
    flex-shrink: 0;
}

.pc-progress__bar {
    height: 4px;
    background: var(--pc-border);
    border-radius: 2px;
    overflow: hidden;
}

.pc-progress__fill {
    height: 100%;
    background: var(--pc-primary);
    border-radius: 2px;
    transition: width .4s ease;
}

/* ── Step panel ──────────────────────────────────────── */
.pc-step {
    display: none;
    animation: pc-fadein .3s ease;
}

.pc-step.is-active { display: block; }

@keyframes pc-fadein {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0);   }
}

.pc-step__header {
    margin-bottom: 16px;
}

.pc-step__title {
    font-size: 17px;
    font-weight: 700;
    color: var(--pc-text);
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pc-step__required-badge {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .05em;
    color: #e44;
    background: #fee;
    padding: 2px 6px;
    border-radius: 20px;
}

.pc-step__description {
    font-size: 14px;
    color: var(--pc-muted);
    margin: 0 0 12px;
}

.pc-step__hint {
    font-size: 13px;
    color: var(--pc-primary);
    font-weight: 500;
    margin: 0 0 12px;
}

/* ── Search & filter ─────────────────────────────────── */
.pc-step__toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.pc-search {
    flex: 1;
    min-width: 180px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1.5px solid var(--pc-border);
    border-radius: 50px;
    padding: 0 14px;
    height: 40px;
    transition: border-color .2s;
}

.pc-search:focus-within { border-color: var(--pc-primary); }

.pc-search__icon { font-size: 15px; color: var(--pc-muted); flex-shrink: 0; }

.pc-search__input {
    border: none !important;
    outline: none !important;
    background: transparent !important;
    font-size: 14px !important;
    color: var(--pc-text) !important;
    width: 100% !important;
    padding: 0 !important;
    box-shadow: none !important;
    height: auto !important;
    min-height: 0 !important;
}

/* Category filter tabs */
.pc-cats {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.pc-cat-tab {
    padding: 5px 12px;
    border: 1.5px solid var(--pc-border);
    border-radius: 50px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: #fff;
    color: var(--pc-muted);
    transition: border-color .15s, color .15s, background .15s;
    white-space: nowrap;
}

.pc-cat-tab:hover { border-color: var(--pc-primary); color: var(--pc-primary); }
.pc-cat-tab.is-active { border-color: var(--pc-primary); background: var(--pc-primary); color: #fff; }

/* ── Component grid ──────────────────────────────────── */
.pc-components {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.pc-component {
    position: relative;
    background: #fff;
    border: 2px solid var(--pc-border);
    border-radius: var(--pc-radius);
    padding: 12px 10px 10px;
    cursor: pointer;
    text-align: center;
    transition: border-color .18s, box-shadow .18s, transform .15s;
    user-select: none;
}

.pc-component:hover:not(.is-disabled) {
    border-color: var(--pc-primary);
    box-shadow: 0 4px 16px rgba(110,170,200,.15);
    transform: translateY(-2px);
}

.pc-component.is-selected {
    border-color: var(--pc-primary);
    background: color-mix(in srgb, var(--pc-primary) 8%, #fff);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc-primary) 20%, transparent);
}

.pc-component.is-disabled {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
}

.pc-component__check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--pc-primary);
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.pc-component.is-selected .pc-component__check { display: flex; }

.pc-component__img-wrap {
    width: 80px;
    height: 80px;
    margin: 0 auto 8px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--pc-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pc-component__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pc-component__img-placeholder {
    font-size: 28px;
    line-height: 1;
}

.pc-component__size {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--pc-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 20px;
    letter-spacing: .04em;
}

.pc-component__name {
    font-size: 13px;
    font-weight: 600;
    color: var(--pc-text);
    margin-bottom: 4px;
    line-height: 1.3;
}

.pc-component__price {
    font-size: 12px;
    color: var(--pc-primary);
    font-weight: 600;
}

.pc-component__price.is-free { color: var(--pc-muted); }

.pc-component__stock {
    font-size: 11px;
    color: #dc3232;
    margin-top: 2px;
}

/* ── Navigation ──────────────────────────────────────── */
.pc-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 20px;
    gap: 10px;
}

.pc-nav__left,
.pc-nav__right {
    display: flex;
    gap: 8px;
}

.pc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    transition: background .18s, color .18s, border-color .18s, transform .15s;
    text-decoration: none;
    line-height: 1;
}

.pc-btn--primary {
    background: var(--pc-primary);
    color: #fff !important;
    border-color: var(--pc-primary);
}

.pc-btn--primary:hover:not(:disabled) {
    background: var(--pc-primary-d);
    border-color: var(--pc-primary-d);
    transform: translateY(-1px);
}

.pc-btn--secondary {
    background: #fff;
    color: var(--pc-text);
    border-color: var(--pc-border);
}

.pc-btn--secondary:hover {
    border-color: var(--pc-primary);
    color: var(--pc-primary);
}

.pc-btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

/* Validation error */
.pc-step-error {
    margin-top: 10px;
    padding: 10px 14px;
    background: #ffeaea;
    border: 1px solid #f5a0a0;
    border-radius: 8px;
    font-size: 13px;
    color: #dc3232;
    display: none;
}

.pc-step-error.is-visible { display: block; }

/* ── Summary panel ───────────────────────────────────── */
.pc-summary {
    background: var(--pc-light);
    border: 1px solid var(--pc-border);
    border-radius: var(--pc-radius);
    padding: 20px;
    margin-top: 20px;
}

.pc-summary__title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 14px;
    color: var(--pc-text);
}

.pc-summary__steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.pc-summary__step { }

.pc-summary__step-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--pc-muted);
    margin-bottom: 4px;
}

.pc-summary__selections {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pc-summary__chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid var(--pc-border);
    border-radius: 50px;
    padding: 4px 10px 4px 4px;
    font-size: 13px;
}

.pc-summary__chip-img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--pc-border);
}

.pc-summary__chip-name { font-weight: 500; }
.pc-summary__chip-price { color: var(--pc-primary); font-size: 12px; }

/* ── Price display ───────────────────────────────────── */
.pc-price-display {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--pc-border);
    margin-top: 8px;
}

.pc-price-line {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--pc-muted);
}

.pc-price-line.is-total {
    font-size: 18px;
    font-weight: 700;
    color: var(--pc-text);
    margin-top: 4px;
}

.pc-price-line.is-total span:last-child { color: var(--pc-primary); }

/* ── Add to cart ─────────────────────────────────────── */
.pc-atc {
    margin-top: 16px;
}

.pc-atc-btn {
    width: 100%;
    padding: 16px 24px;
    font-size: 16px;
    border-radius: 50px;
    justify-content: center;
}

.pc-atc-btn:disabled { opacity: .6; cursor: not-allowed; }

.pc-atc-message {
    margin-top: 10px;
    font-size: 13px;
    text-align: center;
    min-height: 18px;
}

.pc-atc-message.is-error { color: #dc3232; }
.pc-atc-message.is-success { color: #46b450; }

/* ── Empty state ─────────────────────────────────────── */
.pc-empty {
    padding: 32px 20px;
    text-align: center;
    color: var(--pc-muted);
    font-size: 14px;
    background: var(--pc-light);
    border-radius: var(--pc-radius);
    border: 1px dashed var(--pc-border);
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 600px) {
    .pc-components { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
    .pc-component__img-wrap { width: 60px; height: 60px; }
    .pc-progress__label { display: none; }
    .pc-atc-btn { font-size: 15px; padding: 14px 20px; }
}

@media (max-width: 400px) {
    .pc-components { grid-template-columns: repeat(3, 1fr); }
}
