/* PC konfigurator — koristi tokene iz main.css */
html:has(.pb), body:has(.pb) { overflow-x: clip !important; }

.pb, .pb-picker {
    --pb-ok: #1A8A4C;
    --pb-warn: #B26B00;
    --pb-err: #D93036;
}
[data-bs-theme="dark"] .pb-picker { --pb-ok: #4CC584; --pb-warn: #F2B544; --pb-err: #FF6B6F; }
.pb {
    --pb-nav-h: 92px;
    max-width: 1320px;
    margin: 0 auto;
    padding: 1.75rem clamp(1rem, 3vw, 2.5rem) 0;
}
[data-bs-theme="dark"] .pb { --pb-ok: #4CC584; --pb-warn: #F2B544; --pb-err: #FF6B6F; }

/* ---------- Zaglavlje ---------- */
.pb-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem 2rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.pb-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.8rem, 3.2vw, 2.6rem);
    letter-spacing: -0.025em;
    line-height: 1.05;
    color: var(--ink-strong);
    margin: 0 0 0.45rem;
}
.pb-lede { color: var(--ink-muted); margin: 0; max-width: 62ch; }
.pb-head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.pb-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.5rem; align-items: start; }

/* ---------- Slotovi ---------- */
.pb-slots { display: flex; flex-direction: column; gap: 0.6rem; }
.pb-slot {
    position: relative;
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.pb-slot:not(.is-filled):not(.is-unavailable) { border-style: dashed; border-color: var(--border-strong); background: transparent; }
.pb-slot.is-filled { box-shadow: var(--shadow-xs); }
.pb-slot.is-next { border-color: var(--accent); border-style: solid; background: var(--surface); }
.pb-slot.is-next .pb-slot-icon { color: var(--accent); }
.pb-slot.has-warn { border-color: color-mix(in srgb, var(--pb-warn) 55%, var(--border)); }
.pb-slot.has-error { border-color: var(--pb-err); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pb-err) 14%, transparent); }
.pb-slot.is-unavailable { opacity: .55; }

.pb-slot-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--surface-2);
    color: var(--ink-faint);
    font-size: 1.15rem;
}
.pb-slot.is-filled .pb-slot-icon { background: var(--accent-soft); color: var(--accent); }
.pb-slot-icon.has-image { overflow: hidden; background: #fff; border: 1px solid var(--border); padding: 0; }
.pb-slot-icon.has-image img { width: 100%; height: 100%; object-fit: cover; }
.pb-slot:not(.is-filled):not(.is-next) .pb-slot-icon.has-image img { filter: saturate(.55); opacity: .8; }
.pb-slot.is-unavailable .pb-slot-icon.has-image img { filter: grayscale(1); }
.pb-slot-body { min-width: 0; }
.pb-slot-label { font-family: var(--font-display); font-size: 0.82rem; font-weight: 700; color: var(--ink-muted); margin: 0 0 0.2rem; }
.pb-optional { font-family: var(--font-body); font-weight: 500; color: var(--ink-faint); margin-left: 0.25rem; }
.pb-slot-empty { margin: 0; color: var(--ink-faint); font-size: 0.95rem; }
.pb-slot-part { display: flex; align-items: center; gap: 0.85rem; min-width: 0; }
.pb-thumb { width: 48px; height: 48px; flex: none; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 9px; }
.pb-part-text { min-width: 0; flex: 1; }
.pb-part-name { display: block; font-weight: 600; color: var(--ink-strong); text-decoration: none; line-height: 1.35; }
.pb-part-name:hover { color: var(--accent); }
.pb-part-price { font-weight: 700; color: var(--ink-strong); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pb-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.25rem; }
.pb-chips span { padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--surface-2); color: var(--ink-muted); font-size: 0.78rem; font-weight: 600; }
.pb-slot-issues { list-style: none; margin: 0.45rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.pb-slot-issues:empty { display: none; }
.pb-slot-issues li { font-size: 0.85rem; font-weight: 600; }
.pb-slot-issues .is-warn { color: var(--pb-warn); }
.pb-slot-issues .is-error { color: var(--pb-err); }

.pb-slot-actions { display: flex; align-items: center; gap: 0.25rem; }
.pb-pick { min-width: 104px; }
.pb-remove {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--ink-faint);
}
.pb-remove:hover { background: color-mix(in srgb, var(--pb-err) 12%, transparent); color: var(--pb-err); }
.pb-remove:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Sažetak ---------- */
.pb-summary { position: sticky; top: calc(var(--pb-nav-h) + 0.75rem); }
.pb-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.35rem; box-shadow: var(--shadow-sm); }
.pb-total { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.pb-total-label { color: var(--ink-muted); font-weight: 600; }
.pb-total-value { font-family: var(--font-display); font-weight: 800; font-size: 1.9rem; letter-spacing: -0.02em; color: var(--ink-strong); }
.pb-progress { margin: 0.6rem 0 1.25rem; }
.pb-progress-bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.pb-progress-bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .3s ease; }
.pb-progress-text { display: block; margin-top: 0.4rem; color: var(--ink-faint); font-size: 0.84rem; }

/* Mjerač potrošnje */
.pb-power {
    --pb-state: var(--accent);
    padding: 1rem;
    border-radius: var(--radius);
    background: var(--surface-2);
    margin-bottom: 1rem;
}
.pb-power.is-ok { --pb-state: var(--pb-ok); }
.pb-power.is-warn { --pb-state: var(--pb-warn); }
.pb-power.is-error { --pb-state: var(--pb-err); }
.pb-power-head { display: flex; justify-content: space-between; align-items: baseline; }
.pb-power-title { font-weight: 700; color: var(--ink); font-size: 0.92rem; }
.pb-power-title i { color: var(--pb-state); }
.pb-power-load { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; color: var(--ink-strong); font-variant-numeric: tabular-nums; }
.pb-meter {
    position: relative;
    height: 12px;
    margin: 0.65rem 0 0.55rem;
    border-radius: 999px;
    background: var(--surface-3);
}
/* Kapacitet napajanja kao svijetla podloga */
.pb-power[style*="--pb-psu"] .pb-meter::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--pb-psu);
    border-radius: inherit;
    background: color-mix(in srgb, var(--pb-state) 22%, transparent);
}
.pb-meter-load { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: var(--pb-state); transition: width .3s ease; }
.pb-meter-rec { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink-strong); border-radius: 2px; transition: left .3s ease; }
.pb-power-text { margin: 0; font-size: 0.88rem; color: var(--ink-muted); }
.pb-power-text strong { color: var(--ink-strong); }
.pb-how { margin-top: 0.5rem; font-size: 0.83rem; color: var(--ink-muted); }
.pb-how summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.pb-how p { margin: 0.45rem 0 0; }

/* Provjere */
.pb-checks { list-style: none; margin: 0 0 1.1rem; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.pb-check { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.88rem; line-height: 1.4; }
.pb-check > i { margin-top: 0.15rem; flex: none; width: 1rem; text-align: center; }
.pb-check strong { display: block; color: var(--ink); font-weight: 600; }
.pb-check span { color: var(--ink-muted); }
.pb-check.is-ok > i { color: var(--pb-ok); }
.pb-check.is-warn > i { color: var(--pb-warn); }
.pb-check.is-error > i { color: var(--pb-err); }
.pb-check.is-error strong { color: var(--pb-err); }
.pb-check.is-todo > i, .pb-check.is-info > i { color: var(--ink-faint); }
.pb-missing { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }
.pb-missing button {
    border: 1px dashed var(--border-strong);
    background: transparent;
    border-radius: 999px;
    padding: 0.1rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-muted);
}
.pb-missing button:hover { border-color: var(--accent); color: var(--accent); }

.pb-actions { display: flex; flex-direction: column; gap: 0.5rem; }
.pb-login { margin: 0.25rem 0 0; font-size: 0.86rem; color: var(--ink-muted); text-align: center; }

/* Javne konfiguracije */
.pb-public { margin-top: 1.5rem; }
.pb-section-title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; color: var(--ink-strong); margin: 0 0 0.6rem; }
.pb-public-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.5rem; }
.pb-public-list a { display: block; padding: 0.75rem 0.9rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); text-decoration: none; }
.pb-public-list a:hover { border-color: var(--accent); }
.pb-public-name { display: block; font-weight: 600; color: var(--ink-strong); }
.pb-public-meta { font-size: 0.83rem; color: var(--ink-faint); }

/* ---------- Izbor komponente ---------- */
.pb-picker { width: min(640px, 100vw) !important; background: var(--surface); color: var(--ink); }
.pb-picker .offcanvas-header { align-items: flex-start; border-bottom: 1px solid var(--border); }
.pb-picker-title { font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; color: var(--ink-strong); margin: 0; }
.pb-picker-sub { margin: 0.2rem 0 0; color: var(--ink-faint); font-size: 0.86rem; }
.pb-picker-tools { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.6rem; }
.pb-search { position: relative; }
.pb-search i { position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%); color: var(--ink-faint); font-size: 0.85rem; }
.pb-search .form-control { padding-left: 2.3rem; height: 44px; }
.pb-picker-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.pb-picker-row .form-select { width: auto; min-width: 200px; padding-right: 2.25rem; }
.pb-switch { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0; font-weight: 600; font-size: 0.9rem; cursor: pointer; white-space: nowrap; }
@media (max-width: 640px) { .pb-picker-row .form-select { min-width: 0; flex: 0 1 auto; max-width: 52%; } }
.pb-switch .form-check-input { width: 2.2em; height: 1.2em; margin: 0; cursor: pointer; }
.pb-picker-body { padding: 0.5rem; }
.pb-options { list-style: none; margin: 0; padding: 0; }
.pb-option {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    gap: 0.85rem;
    align-items: center;
    padding: 0.75rem;
    border-radius: 12px;
}
.pb-option + .pb-option { border-top: 1px solid var(--border); }
.pb-option:hover { background: var(--surface-2); }
.pb-option.is-selected { background: color-mix(in srgb, var(--pb-ok) 9%, transparent); }
.pb-option.is-conflict { opacity: .7; }
.pb-option .pb-thumb { width: 56px; height: 56px; }
.pb-option-name { display: block; font-weight: 600; color: var(--ink-strong); line-height: 1.35; }
.pb-option-why { display: block; margin-top: 0.25rem; color: var(--pb-err); font-size: 0.82rem; font-weight: 600; }
.pb-option-hint { display: inline-block; margin-top: 0.3rem; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.76rem; font-weight: 700; background: color-mix(in srgb, var(--pb-ok) 14%, transparent); color: var(--pb-ok); }
.pb-option-hint.is-warn { background: color-mix(in srgb, var(--pb-warn) 14%, transparent); color: var(--pb-warn); }
.pb-option-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.4rem; }
.pb-option-price { font-weight: 800; color: var(--ink-strong); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pb-option-loading, .pb-option-empty { padding: 2rem 1rem; text-align: center; color: var(--ink-muted); }
#pb-save-modal .modal-content { background: var(--surface); color: var(--ink); }
body:has(.pb-picker.show) #chat-widget-container, body:has(.pb-picker.showing) #chat-widget-container { display: none; }

/* ---------- Telefon / tablet ---------- */
@media (max-width: 991.98px) {
    .pb-layout { grid-template-columns: minmax(0, 1fr); }
    .pb-summary { position: static; }
}
@media (max-width: 640px) {
    .pb { padding-top: 1.1rem; }
    .pb-slot { grid-template-columns: 40px minmax(0, 1fr); gap: 0.75rem; padding: 0.85rem; }
    .pb-slot-icon { width: 40px; height: 40px; font-size: 0.95rem; border-radius: 10px; }
    .pb-slot:not(.is-filled) { grid-template-columns: 40px minmax(0, 1fr) auto; }
    .pb-slot:not(.is-filled) .pb-pick { min-width: 0; padding: 0.4rem 0.9rem; }
    .pb-slot.is-filled { grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
    .pb-slot.is-filled .pb-slot-icon { display: none; }
    .pb-slot.is-filled .pb-slot-actions { gap: 0; }
    .pb-slot.is-filled .pb-pick { min-width: 0; padding: 0.3rem 0.7rem; font-size: 0.85rem; }
    .pb-slot-part { flex-wrap: wrap; align-items: flex-start; }
    .pb-part-text { flex: 1 1 calc(100% - 64px); }
    .pb-part-price { width: 100%; padding-left: calc(48px + 0.85rem); }
    .pb-option { grid-template-columns: 48px minmax(0, 1fr); }
    .pb-option .pb-thumb { width: 48px; height: 48px; }
    .pb-option-side { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
    .pb-total-value { font-size: 1.6rem; }
}
/* Traka na dnu (telefon): cijena i status, vodi na pregled */
.pb-mobilebar { display: none; }
@media (max-width: 991.98px) {
    .pb-mobilebar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1030;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom));
        background: var(--surface);
        border-top: 1px solid var(--border);
        box-shadow: 0 -8px 24px -12px rgba(16, 24, 40, .25);
    }
    .pb-mobilebar[hidden] { display: none; }
    .pb.summary-visible .pb-mobilebar { transform: translateY(110%); }
    .pb-mobilebar { transition: transform .2s ease; }
    .pb-mobilebar-total { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; color: var(--ink-strong); }
    .pb-mobilebar-status { flex: 1; font-size: 0.82rem; color: var(--ink-muted); line-height: 1.3; }
    .pb-mobilebar-status.is-error { color: var(--pb-err); font-weight: 600; }
    .pb-mobilebar-status.is-warn { color: var(--pb-warn); font-weight: 600; }
    body:has(.pb-mobilebar:not([hidden])) .footer { padding-bottom: 6rem; }
    body:has(.pb-mobilebar:not([hidden])) #chat-widget-container { bottom: 84px; }
}

@media (prefers-reduced-motion: reduce) {
    .pb-progress-bar span, .pb-meter-load, .pb-meter-rec { transition: none; }
}

/* Sačuvana konfiguracija */
.pb-back { display: inline-flex; align-items: center; gap: 0.4rem; margin-bottom: 0.5rem; font-weight: 600; font-size: 0.9rem; color: var(--ink-muted); text-decoration: none; }
.pb-back:hover { color: var(--accent); }
.pb-back i { font-size: 0.7rem; }
.pb-byline { color: var(--ink-faint); font-size: 0.9rem; }
.pb-head-actions form { display: inline-flex; }
@media (max-width: 640px) {
    /* Pregled sačuvane konfiguracije: slika proizvoda ostaje, cijena desno od naziva */
    .pb-view .pb-slot.is-filled { grid-template-columns: 40px minmax(0, 1fr); align-items: center; }
    .pb-view .pb-slot.is-filled .pb-slot-icon { display: grid; }
    .pb-view .pb-slot-part { flex-wrap: nowrap; align-items: flex-start; }
    .pb-view .pb-part-price { width: auto; padding-left: 0; }
}
