/*
 * Customer dock — buyer-side twin of the staff widgets. Reuses the
 * .xs-admin-widget shell (admin_pricing_widget.css) and only adds: per-widget
 * colour, stacked tab positions, list/summary blocks, and the mobile
 * floating button + bottom sheets.
 */

.xs-cdock {
    --xs-cdock-top: 40vh;
    --xs-cdock-step: 54px;
    /* Lift above the Google reCAPTCHA badge (60px + 14px offset) when the
       page has one — set by customer_dock.js. */
    --xs-cdock-lift: 0px;
}

.xs-cdock--recaptcha {
    --xs-cdock-lift: 74px;
}

/* Staff see the three admin tabs from 40vh down — stack ours below them. */
.xs-cdock[data-cdock-staff="1"] {
    --xs-cdock-top: calc(40vh + 170px);
}

.xs-cdock-widget {
    width: 360px;
    user-select: text;
    -webkit-user-select: text;
}

.xs-cdock-widget[data-collapsed="true"] {
    top: calc(var(--xs-cdock-top) + var(--xs-cdock-i, 0) * var(--xs-cdock-step)) !important;
}

/* Expanded widgets fan out from the bottom-right corner so two open cards
   never sit exactly on top of each other. */
/* Keep the dock tabs (48px wide, right edge) reachable next to an open card. */
.xs-cdock-widget[data-collapsed="false"] {
    bottom: calc(1rem + var(--xs-cdock-lift) + var(--xs-cdock-i, 0) * 2.4rem);
    right: calc(60px + var(--xs-cdock-i, 0) * 0.8rem);
}

.xs-cdock-widget .xs-admin-widget-tab {
    color: var(--xs-cdock-color, #6cd6a4);
    animation: none;
}

.xs-cdock-badge {
    position: absolute;
    top: -6px;
    left: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--xs-cdock-color, #6cd6a4);
    color: #08111f;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    pointer-events: none;
}

.xs-cdock-badge[hidden] {
    display: none;
}

.xs-cdock-title-icon svg {
    width: 16px;
    height: 16px;
    color: var(--xs-cdock-color, #6cd6a4);
    vertical-align: -3px;
}

.xs-cdock-widget .xs-admin-widget-body {
    max-height: 62vh;
}

/* ---- Lists ---- */

.xs-cdock-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.xs-cdock-line {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 8px 10px;
    padding: 8px 0;
    border-bottom: 1px solid #1f2f47;
    align-items: start;
}

.xs-cdock-line:last-child {
    border-bottom: 0;
}

.xs-cdock-line-img {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    background: #f8f9fc;
    object-fit: contain;
}

.xs-cdock-line-img--empty {
    background: #1f2f47;
}

.xs-cdock-line-name {
    color: #f5f7fa;
    font-weight: 600;
    text-decoration: none;
    display: block;
    line-height: 1.3;
}

.xs-cdock-line-name:hover {
    color: var(--xs-cdock-color, #6cd6a4);
}

.xs-cdock-line-meta {
    color: #92a3b9;
    font-size: 12px;
    margin-top: 2px;
}

.xs-cdock-line-price {
    color: #f5f7fa;
    font-weight: 700;
    white-space: nowrap;
    text-align: right;
}

.xs-cdock-line-actions {
    grid-column: 2 / 4;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.xs-cdock-remove {
    background: transparent;
    border: 0;
    color: #92a3b9;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 6px;
}

.xs-cdock-remove:hover {
    background: #1f2f47;
    color: #ffb4a8;
}

.xs-cdock-kind {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #92a3b9;
}

.xs-cdock-kind::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 5px;
    border-radius: 50%;
    background: #9ca3af;
    vertical-align: 1px;
}

.xs-cdock-kind-simple::before { background: #16a34a; }
.xs-cdock-kind-variable::before { background: #3b82f6; }
.xs-cdock-kind-configurable::before { background: #ff6a00; }

/* Small buttons used inside the dock (light on dark). */
.xs-cdock-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 7px;
    border: 1px solid #2c4062;
    background: #142544;
    color: #f5f7fa;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background 120ms ease, border-color 120ms ease;
}

.xs-cdock-btn:hover {
    background: #1f2f47;
    border-color: #3b5278;
    color: #ffffff;
}

.xs-cdock-btn--primary {
    background: var(--xs-cdock-color, #ff6a00);
    border-color: var(--xs-cdock-color, #ff6a00);
    color: #08111f;
}

.xs-cdock-btn--primary:hover {
    filter: brightness(1.08);
    color: #08111f;
}

.xs-cdock-btn.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ---- Summary / discounts / shipping ---- */

.xs-cdock-summary {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    margin: 10px 0 4px;
    padding-top: 8px;
    border-top: 1px solid #1f2f47;
}

.xs-cdock-summary dt {
    color: #92a3b9;
    margin: 0;
}

.xs-cdock-summary dd {
    margin: 0;
    color: #f5f7fa;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

.xs-cdock-summary dd.is-discount {
    color: #6cd6a4;
}

.xs-cdock-summary dt.is-total,
.xs-cdock-summary dd.is-total {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    padding-top: 4px;
    border-top: 1px dashed #2c4062;
}

.xs-cdock-section {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #1f2f47;
}

.xs-cdock-section-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #92a3b9;
    margin: 0 0 6px;
}

.xs-cdock-hint {
    color: #cad4e1;
    margin: 4px 0;
    font-size: 12px;
}

.xs-cdock-hint--good {
    color: #6cd6a4;
}

.xs-cdock-tiers {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.xs-cdock-tier {
    padding: 2px 7px;
    border-radius: 999px;
    background: #1f2f47;
    color: #cad4e1;
    font-size: 11px;
}

.xs-cdock-tier.is-active {
    background: #6cd6a4;
    color: #08111f;
    font-weight: 700;
}

.xs-cdock-ship-fields {
    display: grid;
    grid-template-columns: 1fr 110px;
    gap: 6px;
    margin-bottom: 6px;
}

.xs-cdock-ship-fields select,
.xs-cdock-ship-fields input {
    width: 100%;
    min-width: 0;
    padding: 5px 7px;
    border-radius: 6px;
    border: 1px solid #2c4062;
    background: #08111f;
    color: #f5f7fa;
    font-size: 12px;
}

.xs-cdock-ship-result {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    color: #f5f7fa;
}

.xs-cdock-ship-result strong {
    font-size: 14px;
}

.xs-cdock-empty {
    color: #92a3b9;
    padding: 10px 0 6px;
    text-align: center;
}

.xs-cdock-empty .xs-cdock-btn {
    margin-top: 8px;
}

.xs-cdock-login {
    text-align: center;
    padding: 8px 0 4px;
    color: #cad4e1;
}

.xs-cdock-login .xs-cdock-btn {
    margin: 8px 4px 0;
}

.xs-cdock-login small {
    display: block;
    margin-top: 8px;
    color: #92a3b9;
}

/* Footer holds the page links (View cart / Checkout …). */
.xs-cdock-footer {
    gap: 6px;
    flex-wrap: wrap;
    text-transform: none;
    letter-spacing: 0;
    font-size: 12px;
    padding: 8px 10px;
}

.xs-cdock-footer:empty {
    display: none;
}

.xs-cdock-footer .xs-cdock-btn {
    flex: 1 1 auto;
}

/* ---- Orders / inquiries (phase 2) ---- */

/* Tabbed widget: keep a stable height so the tab strip does not jump when
   switching between a long "Orders" list and a short "Quotations" list
   (bottom-anchored cards would otherwise move). */
.xs-admin-widget[data-cdock-widget="orders"] .xs-admin-widget-body {
    min-height: min(320px, 55vh);
}

.xs-cdock-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.xs-cdock-tab-btn {
    flex: 1 1 auto;
    padding: 5px 8px;
    border-radius: 7px;
    border: 1px solid #1f2f47;
    background: #08111f;
    color: #cad4e1;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.xs-cdock-tab-btn.is-active {
    background: var(--xs-cdock-color, #5ea0ff);
    border-color: var(--xs-cdock-color, #5ea0ff);
    color: #08111f;
}

.xs-cdock-tab-count {
    display: inline-block;
    min-width: 16px;
    padding: 0 4px;
    margin-left: 2px;
    border-radius: 999px;
    background: #1f2f47;
    color: #f5f7fa;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
}

.xs-cdock-tab-btn.is-active .xs-cdock-tab-count {
    background: rgba(8, 17, 31, 0.25);
    color: #08111f;
}

.xs-cdock-tab-count.is-flag {
    background: #ff6a00;
    color: #fff;
}

.xs-cdock-line--doc {
    grid-template-columns: 1fr auto;
}

.xs-cdock-line--doc .xs-cdock-line-actions {
    grid-column: 1 / 3;
}

.xs-cdock-pill {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #1f2f47;
    color: #cad4e1;
    font-size: 10.5px;
    font-weight: 600;
    white-space: nowrap;
}

.xs-cdock-pill.is-action {
    background: #ff6a00;
    color: #fff;
}

.xs-cdock-pill.is-ok {
    background: #6cd6a4;
    color: #08111f;
}

.xs-cdock-pill.is-muted {
    opacity: 0.6;
}

.xs-cdock-progress {
    height: 6px;
    margin: 6px 0 3px;
    border-radius: 999px;
    background: #1f2f47;
    overflow: hidden;
}

.xs-cdock-progress span {
    display: block;
    height: 100%;
    background: #6cd6a4;
}

/* ---- Mobile: FAB + bottom sheets ---- */

.xs-cdock-fab,
.xs-cdock-menu,
.xs-cdock-backdrop {
    display: none;
}

@media (max-width: 899px) {
    .xs-cdock-widget[data-collapsed="true"] {
        display: none;
    }

    .xs-cdock-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        z-index: 9000;
        right: 0.9rem;
        bottom: calc(1.1rem + var(--xs-cdock-lift));
        width: 52px;
        height: 52px;
        border-radius: 50%;
        border: 0;
        background: #0f1c2e;
        color: #ff6a00;
        box-shadow: 0 10px 26px rgba(8, 12, 22, 0.45);
        cursor: pointer;
    }

    .xs-cdock-fab-badge {
        position: absolute;
        top: -4px;
        right: -4px;
        min-width: 20px;
        height: 20px;
        padding: 0 6px;
        border-radius: 999px;
        background: #ff6a00;
        color: #fff;
        font-size: 11px;
        font-weight: 700;
        line-height: 20px;
        text-align: center;
    }

    .xs-cdock-fab-badge[hidden] {
        display: none;
    }

    .xs-cdock-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 9001;
        background: rgba(8, 12, 22, 0.55);
    }

    .xs-cdock-backdrop[hidden] {
        display: none;
    }

    .xs-cdock-menu {
        display: block;
        position: fixed;
        z-index: 9002;
        left: 0;
        right: 0;
        bottom: 0;
        background: #0f1c2e;
        color: #f5f7fa;
        border-radius: 16px 16px 0 0;
        border-top: 1px solid #1f2f47;
        box-shadow: 0 -12px 40px rgba(8, 12, 22, 0.5);
        padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
        font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
        font-size: 13px;
    }

    .xs-cdock-menu[hidden] {
        display: none;
    }

    .xs-cdock-menu-head {
        display: flex;
        align-items: center;
        gap: 8px;
        padding-bottom: 8px;
    }

    .xs-cdock-menu-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .xs-cdock-menu-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        padding: 12px 6px;
        border-radius: 12px;
        border: 1px solid #1f2f47;
        background: #142544;
        color: #f5f7fa;
        font-size: 12px;
        font-weight: 600;
        cursor: pointer;
        position: relative;
    }

    .xs-cdock-menu-item svg {
        width: 26px;
        height: 26px;
        color: var(--xs-cdock-color, #6cd6a4);
    }

    .xs-cdock-menu-item .xs-cdock-badge {
        top: 6px;
        left: auto;
        right: 6px;
    }

    /* Open widget = full-width bottom sheet; no drag on touch. */
    .xs-cdock-widget[data-collapsed="false"] {
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: auto;
        max-width: none;
        border-radius: 16px 16px 0 0;
        z-index: 9003;
    }

    .xs-cdock-widget[data-collapsed="false"] .xs-admin-widget-header {
        cursor: default;
        touch-action: auto;
    }

    .xs-cdock-widget[data-collapsed="false"] .xs-admin-widget-grip {
        display: none;
    }

    .xs-cdock-widget .xs-admin-widget-body {
        max-height: calc(78vh - 96px);
    }

    .xs-cdock-widget .xs-admin-widget-footer {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
}
