/* ═══════════════════════════════════════════════════════
   CART — top-bar button, result-card Add button, drawer
   Sizes per breakpoint live in responsive.css.
   ═══════════════════════════════════════════════════════ */

/* Top-bar button and its count */
.cart-btn { position: relative; }
.cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--brand-orange);
    color: #111111;
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
}

.cart-login { margin-left: 0.3rem; padding: 0.15rem 0.55rem; border: 1px solid var(--brand-orange); border-radius: 8px; background: none; color: var(--brand-orange); font-weight: 600; font-size: 0.8rem; cursor: pointer; min-height: 28px; }
.cart-login:focus-visible { outline: 2px solid var(--brand-cyan); outline-offset: 2px; }

/* Result-card footer: Copy and Add to BOQ side by side, the same size */
/* Same box: equal shares of the row (border-box, so padding counts), same padding and height. */
.card-footer .copy-btn, .card-footer .add-cart-btn { flex: 1 1 0; min-width: 0; box-sizing: border-box; padding: 0 1rem; height: 48px; }
.card-footer .copy-btn { border: 1px solid transparent; }   /* Add to BOQ has a 1px border */
.add-cart-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    height: 48px;
    padding: 0 1.4rem;
    border-radius: 16px;
    border: 1px solid var(--brand-cyan);
    background: var(--bg-primary);
    color: var(--brand-cyan);
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    box-shadow: var(--neo-btn);
    transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.add-cart-btn:hover  { transform: translateY(-2px); box-shadow: 0 0 14px var(--neo-dark), 0 0 16px var(--brand-cyan-glow); }
.add-cart-btn:active { transform: translateY(0); box-shadow: var(--neo-pressed); }
.add-cart-btn.in-cart { box-shadow: var(--neo-pressed); }

/* Drawer: modal, above the top-bar controls (they stay reachable only while it is closed) */
.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1003;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.cart-overlay.open { opacity: 1; pointer-events: auto; }

.cart-panel {
    position: fixed;
    top: 0;
    right: -440px;
    width: 440px;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-primary);
    z-index: 1004;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    padding: 1.25rem 1.25rem 1.25rem;
    visibility: hidden;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.4s;
}
.cart-panel.open {
    right: 0;
    visibility: visible;
    box-shadow: -6px 0 24px rgba(0, 0, 0, 0.35);
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-color);
}
.cart-header h3 { margin: 0; font-size: 1.15rem; color: var(--text-primary); }
.cart-title-count { color: var(--text-muted); font-weight: 600; }
.cart-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: var(--bg-primary);
    box-shadow: var(--neo-btn);
    color: var(--text-secondary);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}
.cart-close:hover { color: var(--text-primary); }

/* What the exports will use: a disclosure, closed by default */
.cart-info {
    flex: none;
    border-radius: 12px;
    background: var(--bg-deep);
}
.cart-info summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.9rem;
    font-size: 0.83rem;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    list-style: none;
    border-radius: 12px;
}
.cart-info summary::-webkit-details-marker { display: none; }
.cart-info summary::after {
    content: "";
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    margin: 0 0.2rem 0.2rem 0;
}
.cart-info[open] summary::after { transform: rotate(-135deg); margin-bottom: -0.2rem; }
.cart-info summary:hover { color: var(--text-primary); }
.cart-info summary:focus-visible { outline: 2px solid var(--brand-orange); outline-offset: 2px; }
.cart-meta {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.45rem 0.9rem;
    font-size: 0.83rem;
    padding: 0.2rem 0.9rem 0.8rem;
}
.cart-meta dt { color: var(--text-secondary); font-weight: 700; }
.cart-meta dd { margin: 0; color: var(--text-secondary); min-width: 0; overflow-wrap: anywhere; }
.cart-rate-mode { border: none; margin: 0 0 0.3rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; }
.cart-rate-mode label { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--text-primary); cursor: pointer; }
.cart-rate-mode input { accent-color: var(--brand-orange); }
.cart-basis { color: var(--text-secondary); }

.cart-warning {
    font-size: 0.82rem;
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    background: #fff2cc;
    color: #7f6000;
}

/* The list scrolls; header, meta and actions stay put */
.cart-list {
    list-style: none;
    margin: 0;
    padding: 0.2rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    /* A thin, faint scrollbar (owner, 2026-10-06); the default one was a dark bar with arrows */
    scrollbar-width: thin;
    scrollbar-color: rgba(128, 128, 128, 0.35) transparent;
}
.cart-list:hover { scrollbar-color: rgba(128, 128, 128, 0.6) transparent; }
/* Browsers without scrollbar-width (older Safari) */
@supports not (scrollbar-width: thin) {
    .cart-list::-webkit-scrollbar { width: 6px; }
    .cart-list::-webkit-scrollbar-track { background: transparent; }
    .cart-list::-webkit-scrollbar-thumb { background: rgba(128, 128, 128, 0.35); border-radius: 3px; }
}
.cart-item {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.65rem 0.7rem;
    border-radius: 12px;
    background: var(--bg-primary);
    box-shadow: var(--neo-btn);
}
.cart-item.unknown { box-shadow: var(--neo-btn), inset 3px 0 0 #d4a017; }
.cart-item-num { color: var(--text-muted); font-size: 0.78rem; font-weight: 700; min-width: 1.4rem; padding-top: 0.1rem; }
.cart-item-body { flex: 1 1 auto; min-width: 0; }
.cart-item-top { display: flex; align-items: baseline; gap: 0.5rem; }
.cart-item-code { color: var(--brand-orange); font-weight: 800; font-size: 0.9rem; }
.cart-item-unit { color: var(--text-secondary); font-size: 0.78rem; }
.cart-item-section { margin-left: auto; color: var(--text-muted); font-size: 0.72rem; text-align: right; }

/* Which section of the bill items added from the search go into */
.cart-section-pick { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.6rem; color: var(--text-secondary); font-size: 0.8rem; white-space: nowrap; }
.cart-section-pick input {
    flex: 1 1 auto;
    min-width: 0;
    height: 32px;
    padding: 0 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-deep);
    color: var(--text-primary);
    font: inherit;
}
.cart-item-desc {
    margin: 0.2rem 0 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.cart-item.unknown .cart-item-desc { color: #d4a017; -webkit-line-clamp: unset; }
.cart-item-remove {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}
.cart-item-remove:hover { color: #ef4444; background: var(--bg-deep); }

.cart-empty, .cart-undo {
    flex: 1 1 auto;
    color: var(--text-secondary);
    font-size: 0.88rem;
    text-align: center;
    padding: 2rem 1rem;
}
.cart-undo { display: flex; align-items: flex-start; justify-content: center; gap: 0.6rem; flex-wrap: wrap; }
.cart-undo-btn {
    border: none;
    background: none;
    color: var(--brand-cyan);
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    text-decoration: underline;
}

.cart-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border-color);
}
.cart-actions button {
    height: 42px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: var(--neo-btn);
}
.cart-actions .cart-export { background: var(--brand-orange); color: #111111; }
.cart-actions .cart-preview { color: var(--brand-cyan); border: 1px solid var(--brand-cyan); }
.cart-actions .cart-project { grid-column: 1 / -1; color: var(--brand-orange); border: 1px solid var(--brand-orange); }
.cart-actions .cart-clear { grid-column: 1 / -1; height: 36px; color: var(--text-secondary); font-weight: 600; }
.cart-actions button:disabled { opacity: 0.45; cursor: not-allowed; }

.cart-panel :focus-visible, .add-cart-btn:focus-visible, .cart-btn:focus-visible {
    outline: 2px solid var(--brand-cyan);
    outline-offset: 2px;
}

/* The BOQ space: a page of its own in a frame over this one, above the drawer, below the preview */
body.ws-open { overflow: hidden; }
.workspace-host { position: fixed; inset: 0; z-index: 1090; background: var(--bg-primary); }
.workspace-host iframe { display: block; width: 100%; height: 100%; border: 0; }

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
