/* Customer Autocomplete */
.customer-autocomplete-wrapper {
    position: relative;
}
.customer-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #CDCFD4;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.10);
    z-index: 200;
    overflow: hidden;
    max-height: 260px;
    overflow-y: auto;
}
.customer-dropdown.open {
    display: block;
}
.customer-dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 14px;
    color: #1A1A1A;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-bottom: 1px solid #F3F3F3;
    transition: background 0.15s;
}
.customer-dropdown-item:last-child {
    border-bottom: none;
}
.customer-dropdown-item:hover {
    background: var(--primary-light);
}
.customer-dropdown-item .customer-name {
    font-weight: 600;
}
.customer-dropdown-item .customer-company {
    font-size: 12px;
    color: #878D99;
}
.customer-dropdown-item .customer-warehouse-id {
    font-size: 12px;
    color: #454B54;
    font-weight: 500;
}
/* Rich customer result rows — primary contact (name + email) + default billing &
   shipping address under the name, so the picker is scannable and the searched
   values (contact email, city/state) are visible. Mirrors the Add-to-Quote popup. */
.customer-dropdown-item.atq-cust-rich .atq-cust-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.customer-dropdown-item.atq-cust-rich .atq-cust-contact {
    font-size: 12px;
    color: #454B54;
    margin-top: 3px;
}
.customer-dropdown-item.atq-cust-rich .atq-cust-contact-name { font-weight: 500; }
.customer-dropdown-item.atq-cust-rich .atq-cust-contact-email { color: #878D99; margin-left: 6px; }
.customer-dropdown-item.atq-cust-rich .atq-cust-addr {
    font-size: 11px;
    color: #878D99;
    margin-top: 2px;
}
.customer-dropdown-item.atq-cust-rich .atq-cust-addr-label {
    display: inline-block;
    min-width: 52px;
    color: #A8ADB7;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-size: 10px;
}
.customer-dropdown-create {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid #F3F3F3;
    transition: background 0.15s;
}
.customer-dropdown-create:hover {
    background: var(--primary-light);
}
/* It is now the first row of the dropdown (see renderDropdown). */
.customer-dropdown > .customer-dropdown-create:first-child {
    border-top: 0;
    border-bottom: 1px solid #ECEEF1;
    background: #F4FBF7;
}
.customer-dropdown-empty {
    padding: 14px 16px;
    font-size: 14px;
    color: #878D99;
    text-align: center;
}

/* Selected Customer Info */
.customer-info-section {
    display: none;
    margin-top: 16px;
    padding: 16px 20px;
    border-radius: 16px;
}
.customer-info-section.visible {
    display: block;
}
.customer-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.customer-info-header .customer-info-name {
    font-size: 15px;
    font-weight: 600;
    color: #1A1A1A;
}
.customer-info-header .change-customer-btn {
    font-size: 13px;
    color: var(--primary);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-weight: 500;
    text-decoration: underline;
}
.customer-info-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.customer-info-col {
    flex: 1;
    min-width: 200px;
}
.customer-info-col label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #878D99;
    display: block;
    margin-bottom: 4px;
}
.customer-info-col p {
    font-size: 13px;
    color: #1A1A1A;
    margin: 0;
    line-height: 1.5;
}

/* Create Customer Popup */
.create-customer-popup .popup-inner {
    max-width: 960px;
}
.create-customer-popup .popup-content {
    padding: 0 24px 8px;
}
.create-customer-popup .form-group {
    margin-bottom: 12px;
}

/* Orange section headings */
.cust-section-heading {
    font-size: 14px;
    font-weight: 700;
    color: #E67E22;
    margin: 20px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid #F3F3F3;
}

/* Address two-column grid */
.cust-address-grid {
    display: flex;
    gap: 20px;
}
.cust-address-col {
    flex: 1;
    min-width: 0;
}
.cust-address-type {
    font-size: 13px;
    color: #878D99;
    margin-bottom: 12px;
}
.cust-address-type strong {
    color: #1A1A1A;
}

/* Copy Shipping button */
.copy-shipping-btn {
    background: none;
    border: none;
    color: #1A1A1A;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-decoration: underline;
}
.copy-shipping-btn:hover {
    color: var(--primary);
}

/* Contact row */
.create-customer-popup .row.fieldset {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 0;
}
.create-customer-popup .row.fieldset .col {
    flex: 1;
    min-width: 200px;
}

/* Popup footer */
.popup-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #F3F3F3;
}
.popup-footer.action-buttons {
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.popup-footer.action-buttons .btn {
    width: 100%;
    margin: 0;
    justify-content: center;
    font-size: 16px;
    line-height: 24px;
    padding: 6px 16px;
    height: 50px;
}


/* Checkbox wrapper (same as cart.css) */
.create-customer-popup .checkbox-wrapper {
    display: flex;
    gap: 12px;
    margin: 12px 0;
}
.create-customer-popup .checkbox-wrapper input {
    margin: 0 !important;
    flex-shrink: 0;
}

/* Address summary card (shown after Google Places selection) */
.cust-address-summary {
    display: none;
    margin-bottom: 12px;
}
.cust-address-summary-inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: #F8FAF8;
    border: 1px solid #D6EBE0;
    border-radius: 12px;
}
.cust-address-summary-inner > div {
    flex: 1;
    min-width: 0;
}
.cust-addr-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary);
    background: #E8F6EF;
    border-radius: 6px;
    padding: 2px 8px;
    margin-bottom: 6px;
}
.cust-address-summary-inner p {
    font-size: 13px;
    color: #1A1A1A;
    margin: 0;
    line-height: 1.5;
    word-break: break-word;
}
.cust-clear-address-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    white-space: nowrap;
    flex-shrink: 0;
}
.cust-clear-address-btn:hover {
    color: #1d7a49;
}

/* PlaceAutocompleteElement search container */
.cust-address-search-group {
    margin-bottom: 12px;
}
.cust-search-label {
    font-size: 12px;
    color: #878D99;
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}
.cust-address-search-group gmp-place-autocomplete {
    border: 1px solid #CDCFD4;
    border-radius: 16px;
    min-height: 56px;
    display: block;
    width: 100%;
    box-sizing: border-box;
}

/* Google Places dropdown above popup overlay (z-index: 9999) */
.pac-container {
    z-index: 100000 !important;
    pointer-events: auto !important;
}

/* Item Code Autocomplete */
.item-code-wrapper {
    position: relative;
}
.item-dropdown {
    display: none;
    background: #fff;
    border: 1px solid #CDCFD4;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.10);
    overflow: hidden;
    max-height: 260px;
    overflow-y: auto;
    min-width: 240px;
}
.item-dropdown.open {
    display: block;
}
.item-dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 14px;
    color: #1A1A1A;
    border-bottom: 1px solid #F3F3F3;
    transition: background 0.15s;
}
.item-dropdown-item:last-child {
    border-bottom: none;
}
.item-dropdown-item:hover {
    background: var(--primary-light);
}
.item-dropdown-item .item-code-label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: #1A1A1A;
}
.item-dropdown-item .item-desc-label {
    display: block;
    font-size: 12px;
    color: #878D99;
    margin-top: 2px;
}
.item-dropdown-empty {
    padding: 14px 16px;
    font-size: 14px;
    color: #878D99;
    text-align: center;
}

@media only screen and (max-width: 640px) {
    .cust-address-grid {
        flex-direction: column;
    }
}

/* Contact info text */
.info-contact {
    margin: 0;
    font-size: 15px;
    color: #3C3F45;
}
.info-email,
.info-phone {
    margin: 4px 0 0;
    font-size: 14px;
    color: #878D99;
}

/* Clickable icon button (edit icons in heading-wrapper) */
.icon-btn {
    cursor: pointer;
    flex-shrink: 0;
}

/* Popup width variants */
.popup-inner--lg { max-width: 760px; }
.popup-inner--sm { max-width: 520px; }
.popup-inner--xl { width: 70%; max-width: 1700px; }
/* The "Add Item to Quote" popup must be 70% of the screen. global.css defines
   `.popup-inner { width:90%; max-width:710px }` and `.popup-inner:has(.popup-scroll)`
   and is loaded AFTER this file (via the layout), so a plain `.popup-inner--xl`
   (same specificity) loses the cascade and the box stays capped at 710px.
   This id-scoped selector (specificity 1,1,0) wins regardless of load order. */
#add-item-popup .popup-inner {
    width: 70%;
    max-width: 1700px;
}

/* Add-item popup: target-warehouse filter notice banner */
.popup-warehouse-notice {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #f0fff5;
    border: 1px solid #2AA466;
    border-left: 4px solid #2AA466;
    border-radius: 8px;
    color: #454B54;
    font-size: 13px;
    line-height: 1.5;
}
.popup-warehouse-notice strong { color: #2c3e50; }

/* Add Item popup pagination — numbered pager mirroring the My Equipment list.
   Pager CSS lives in myequipment.css (not loaded on the quote pages), so it is
   re-declared here scoped to #add-item-popup. */
#add-item-popup .popup-pagination {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-top: 14px;
    margin-top: 8px;
    border-top: 1px solid #F0F0F2;
}
#add-item-popup .popup-showing-count { font-size: 13px; color: #878D99; }
#add-item-popup .pagination-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    justify-content: center;
}
#add-item-popup .pagination-controls .page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #D9DDE3;
    border-radius: 8px;
    background: #fff;
    color: #2A2F3A;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.15s all;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
#add-item-popup .pagination-controls .page-btn:hover:not(:disabled):not(.active) { border-color: var(--primary); color: var(--primary); }
#add-item-popup .pagination-controls .page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; cursor: default; }
#add-item-popup .pagination-controls .page-btn:disabled { opacity: 0.45; cursor: not-allowed; }
#add-item-popup .pagination-controls .page-btn.nav-btn { padding: 0 12px; }
#add-item-popup .pagination-controls .page-ellipsis { min-width: 22px; text-align: center; color: #878D99; user-select: none; padding: 0 2px; }

/* Add-item popup: item search scroll area */
.popup-scroll {
    max-height: 400px;
    overflow-y: auto;
}

/* Add-item popup: search form group spacing */
.popup-search-group { margin-bottom: 16px; }

/* Add-item popup: empty state */
.popup-no-results {
    display: none;
    padding: 32px 0;
    text-align: center;
    color: #878D99;
}

/* Add-item popup: keep item list scroll area inside the popup boundary.
   The global .popup-inner:has(.popup-scroll) flex rule does not size .popup-content
   here (popup-scroll is a grandchild, not a direct child / not on popup-content),
   so .popup-content can grow past .popup-inner's 90vh and bleed outside the popup. */
#add-item-popup .popup-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}
#add-item-popup .popup-search-group { flex: 0 0 auto; }
#add-item-popup #popup-item-results.popup-scroll {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}

/* ── Add Items popup (multi-select) ────────────────────────────────────────
   Rows are <label>s with a checkbox; selection lives in new-quote.js. The
   footer is a sibling of .popup-content (gold-standard popup shell). */
#add-item-popup .popup-inner { display: flex; flex-direction: column; max-height: 90vh; }
#add-item-popup .popup-head .popup-subtitle { display: block; font-size: 13px; color: #878D99; font-weight: 400; margin-top: 2px; }
#add-item-popup .popup-warehouse-notice { padding: 8px 12px; font-size: 13px; margin-bottom: 12px; border-width: 1px 1px 1px 4px; text-align: left; }
#add-item-popup .aiq-why-toggle { color: var(--primary); font-weight: 600; text-decoration: none; }
#add-item-popup .aiq-why-list { margin: 8px 0 0 18px; padding: 0; list-style: disc; }
#add-item-popup .aiq-why-list li { margin: 3px 0; }
#popup-item-results .aiq-card {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 14px; margin: 0 0 8px;
    border: 1px solid #ECEEF1; border-radius: 14px; background: #fff;
    cursor: pointer; text-align: left; transition: border-color .15s, background .15s;
}
#popup-item-results .aiq-card:hover { border-color: #9ED8B8; }
#popup-item-results .aiq-card.selected { border-color: var(--primary); background: #F4FBF7; }
#popup-item-results .aiq-check {
    flex: 0 0 22px; width: 22px; height: 22px; margin: 0;
    accent-color: var(--primary); cursor: pointer;
}
#popup-item-results .aiq-thumb {
    flex: 0 0 56px; width: 56px; height: 56px; border-radius: 10px; overflow: hidden;
    background: #F9F9F9; display: flex; align-items: center; justify-content: center;
}
#popup-item-results .aiq-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
#popup-item-results .aiq-name { font-weight: 600; color: #17181A; line-height: 1.3; font-size: 15px; }
#popup-item-results .aiq-meta { font-size: 12px; color: #878D99; line-height: 1.35; }
#popup-item-results .aiq-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; }
#popup-item-results .aiq-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
#popup-item-results .aiq-badge--status { background: #EAF2FE; color: #3A6FD8; }
#popup-item-results .aiq-badge--ok { background: #EAF7F0; color: #2AA466; }
#popup-item-results .aiq-badge--warn { background: #FFF3E0; color: #E65100; }
#popup-item-results .aiq-price { flex: 0 0 auto; text-align: right; display: flex; flex-direction: column; }
#popup-item-results .aiq-price-label { font-size: 11px; color: #A8ADB7; text-transform: uppercase; letter-spacing: .3px; }
#popup-item-results .aiq-price strong { font-size: 15px; color: #17181A; }
#add-item-popup .aiq-footer {
    flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
    padding: 14px 24px 20px; margin-top: 0; border-top: 1px solid #ECEEF1; background: #fff;
    border-radius: 0 0 24px 24px;
}
#add-item-popup .aiq-footer .aiq-selected-summary { flex: 1 1 auto; display: flex; flex-direction: column; text-align: left; font-size: 13px; color: #878D99; }
#add-item-popup .aiq-footer .aiq-selected-summary strong { color: #17181A; font-size: 15px; }
#add-item-popup .aiq-footer .btn { width: auto; min-width: 170px; height: 48px; margin: 0; }
#add-item-popup .aiq-footer .btn.disabled,
#add-item-popup .aiq-footer .btn:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 767px) {
    #add-item-popup .popup-inner { width: 100%; max-width: 100%; max-height: 94vh; }
    #popup-item-results .aiq-card { align-items: flex-start; gap: 10px; padding: 12px; flex-wrap: wrap; }
    #popup-item-results .aiq-thumb { flex-basis: 48px; width: 48px; height: 48px; }
    #popup-item-results .aiq-main { flex: 1 1 calc(100% - 100px); }
    #popup-item-results .aiq-name { font-size: 14px; }
    #popup-item-results .aiq-price { flex: 1 1 100%; flex-direction: row; justify-content: space-between; align-items: baseline; padding-left: 32px; }
    #add-item-popup .aiq-footer { padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); border-radius: 0; }
    #add-item-popup .aiq-footer .btn { min-width: 0; flex: 0 0 auto; padding: 0 18px; }
    #add-item-popup .popup-pagination { padding-top: 8px; }
}

/* Billing diff section and edit-bill section hidden initially (JS toggles) */
#billing-diff-section,
#edit-bill-section { display: none; }

/* Edit address popup: selected-address display hidden initially (JS shows) */
#edit-ship-show,
#edit-bill-show { display: none; }
