/* Customer only: shared person, address and Kendo widgets retain their APIs. */
.customer-page {
    min-width: 0;
}

.customer-page .admin-page-heading {
    min-width: 0;
}

.customer-page .admin-page-title {
    overflow-wrap: anywhere;
}

.customer-page .admin-page-actions {
    flex-shrink: 0;
}

.customer-directory {
    overflow: hidden;
}

.customer-filter-toolbar {
    padding: 16px;
    border-bottom: 1px solid var(--mkp-border);
}

.customer-filters {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(280px, 360px);
    align-items: end;
    gap: 12px;
}

.customer-filter-options {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 12px;
}

.customer-field-help {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    line-height: 18px;
    color: var(--mkp-muted-foreground);
}

.customer-grid {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.customer-grid > .k-grid {
    border: 0;
    border-radius: 0;
}

/* Native split tables keep the header and pager outside the data viewport.
   The shared column adapter retains ownership of widths and user resizing. */
.customer-list-page #Grid {
    overflow: hidden;
}

.customer-list-page #Grid .k-grid-content {
    max-height: none;
    overscroll-behavior: contain;
}

.customer-list-page #Grid .k-grid-table > tbody > tr > td {
    box-sizing: border-box;
    height: 56px;
    padding: 8px;
    font-size: 14px;
}

.customer-list-page #Grid .k-grid-table > thead > tr > th {
    padding-inline: 8px;
    background: var(--mkp-muted);
    color: var(--mkp-foreground);
    font-size: 14px;
}

.customer-list-page #Grid .k-column-title {
    white-space: normal;
}

.customer-cell-text {
    display: block;
    white-space: normal;
    overflow-wrap: normal;
    line-height: 20px;
}

.customer-email {
    display: block;
    line-height: 20px;
}

/* Long names remain fully readable instead of being cut after two lines. */
.customer-list-page #Grid .customer-name-link,
.customer-list-page #Grid .mkp-grid-secondary-name .customer-cell-text {
    overflow-wrap: anywhere;
}

/* Reserve room for both the ID title and its sort indicator without reducing
   the type size or removing the native column menu. */
.customer-list-page #Grid th[data-field="Code"] .k-cell-inner,
.customer-list-page #Grid th[data-field="Id"]:not(:last-child) .k-cell-inner {
    margin-inline: -4px;
    gap: 0;
}

.customer-list-page #Grid th[data-field="Code"] .k-link,
.customer-list-page #Grid th[data-field="Id"]:not(:last-child) .k-link {
    padding-inline: 0;
    gap: 2px;
}

.customer-list-page #Grid th[data-field="Code"] .k-column-title,
.customer-list-page #Grid th[data-field="Id"]:not(:last-child) .k-column-title {
    min-width: max-content;
    flex-shrink: 0;
}

.customer-list-page #Grid th[data-field="Id"]:not(:last-child) {
    padding-inline: 0;
}

.customer-list-page #Grid th[data-field="Id"]:not(:last-child) .k-cell-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 18px;
    margin-inline: 0;
}

.customer-list-page #Grid th[data-field="Id"]:not(:last-child) .k-link {
    grid-column: 1;
    grid-row: 1;
    justify-content: center;
    padding: 0;
    margin: 0;
}

.customer-list-page #Grid th[data-field="Id"]:not(:last-child) :is(.k-grid-header-menu, .k-grid-column-menu) {
    grid-column: 2;
    grid-row: 1;
    position: static;
    margin: 0;
}

.customer-list-page #Grid a.customer-name-link {
    color: var(--mkp-foreground);
    font-weight: 500;
    text-decoration: none;
}

.customer-list-page #Grid tbody td {
    color: var(--mkp-foreground);
    font-variant-numeric: tabular-nums;
}

.customer-list-page #Grid .k-grid-table > tbody > tr > .mkp-grid-identifier {
    padding-inline: 4px;
}

.customer-list-page #Grid .mkp-grid-identifier .customer-cell-text {
    white-space: nowrap;
    overflow-wrap: normal;
}

.customer-list-page #Grid .mkp-grid-commands {
    position: static;
    box-shadow: none;
}

.customer-list-page #Grid tbody td.mkp-grid-commands .btn {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

.customer-list-page #Grid tbody td.mkp-grid-commands .btn:is(:hover, :focus-visible) {
    background: var(--mkp-muted);
    border-color: var(--mkp-border);
}

.customer-list-page #Grid a.customer-name-link:is(:hover, :focus-visible) {
    color: var(--mkp-link);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.customer-cell-text:focus-visible {
    outline: 2px solid var(--mkp-muted-foreground);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Commands follow the customer's name and ID in the initial viewport.
   Keep native scrolling; no pinned cell may cover another value. */
.customer-list-page #Grid .k-grid-table > :is(thead, tbody) > tr > .mkp-grid-commands {
    text-align: center;
    position: static;
    box-shadow: none;
}

/* Filtering to zero records must retain the native 50/100/200 selector.
   Keep this correction local until c-grids repairs its empty-pager rule. */
.customer-page .k-grid.mkp-grid-empty > .k-grid-pager .k-pager-sizes {
    display: inline-flex !important;
}

.customer-list-page #Grid > .k-resize-handle {
    z-index: 5;
}

.customer-list-page .customer-avatar {
    display: block;
    margin-inline: auto;
}

.customer-page .k-grid-norecords {
    position: sticky;
    left: 0;
    width: 100%;
    min-height: 180px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.customer-avatar {
    object-fit: cover;
    background: var(--mkp-muted);
}

.customer-section {
    padding: 24px;
    margin-bottom: 20px;
}

.customer-section-heading {
    margin-bottom: 24px;
}

.customer-section-heading h2 {
    margin: 0 0 6px;
    color: var(--mkp-foreground);
    font-size: 16px;
    line-height: 24px;
    font-weight: 600;
    letter-spacing: -.2px;
}

.customer-section-heading p {
    margin: 0;
    color: var(--mkp-muted-foreground);
    font-size: 14px;
    line-height: 22px;
}

.customer-required-note {
    margin: -4px 0 12px;
    color: var(--mkp-muted-foreground);
    font-size: 13px;
}

.customer-form-page .admin-page-header {
    margin-bottom: 16px;
}

.customer-page #personForm .admin-person-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 8px 40px;
    --bs-gutter-x: 40px;
    margin: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.customer-page #personForm .admin-person-fields > :is(.col-xl-8, .col-xl-4) {
    width: auto;
    padding: 0;
    min-width: 0;
}

.customer-page #personForm .admin-person-fields > .col-xl-4 {
    grid-column: 2;
    grid-row: 1 / span 2;
}

.customer-page #personForm .admin-person-fields > :is(.col-xl-8, .col-xl-4) > .mb-3.row {
    --bs-gutter-x: 16px;
    row-gap: 16px;
}

.customer-page #personForm .admin-person-fields > :is(.col-xl-8, .col-xl-4) > .mb-3.row > [class*="col-md-"]:has(> .form-label):not(.col-md-12) {
    flex: 1 0 min(100%, 190px);
    width: auto;
}

.customer-subsection-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
    min-height: 45px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--mkp-border);
    color: var(--mkp-foreground);
    font-size: 16px;
    line-height: 20px;
    font-weight: 600;
}

.customer-supplemental {
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
    margin: 0;
    padding-inline: 0;
    padding-top: 24px;
    border-top: 1px solid var(--mkp-border);
}

.customer-supplemental h3 {
    margin: 0 0 16px;
    font-size: 16px;
    line-height: 20px;
    font-weight: 600;
    color: var(--mkp-foreground);
}

.customer-page #personForm .customer-supplemental > .row {
    --bs-gutter-x: 16px;
    row-gap: 16px;
}

.customer-page #personForm .customer-supplemental > .row > div {
    min-width: 0;
    flex: 0 0 50%;
    width: 50%;
}

.customer-page #personForm .customer-supplemental > .row > .col-md-12,
.customer-page #personForm .customer-supplemental > .company > .col-md-6 {
    flex-basis: 100%;
    width: 100%;
}

.customer-supplemental > .row:last-child {
    margin-bottom: 0 !important;
}

.customer-page #personForm .customer-identity-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 164px;
    gap: 16px;
}

.customer-page #personForm .customer-identity-summary > .row {
    margin: 0;
    min-width: 0;
}

.customer-page #personForm .customer-identity-summary > .row > div {
    padding: 0;
    min-width: 0;
}

.customer-page #personForm .admin-person-fields > .col-xl-4 > .customer-address-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 112px;
}

.customer-page #personForm .customer-address-summary > div {
    width: auto;
    min-width: 0;
}

.customer-access-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--mkp-border);
}

.customer-access-section .customer-section-heading {
    margin-bottom: 16px;
}

/* Street has room for a full address; the number remains a compact field. */
.customer-page #personForm .admin-person-fields > .col-xl-4 > .row:has([name="Address.Street"]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 112px;
}

.customer-page #personForm .admin-person-fields > .col-xl-4 > .row:has([name="Address.Street"]) > div {
    width: auto;
    min-width: 0;
}

.customer-page #personForm .admin-person-fields > .col-xl-4 > .row:has(#Address_Country_select) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 112px;
}

.customer-page #personForm .admin-person-fields > .col-xl-4 > .row:has(#Address_Country_select) > div:last-child {
    grid-column: 1 / -1;
}

.customer-page #personForm .admin-person-fields > .col-xl-4 > .row:has(#Address_Country_select) > div {
    min-width: 0;
    width: auto;
}

/* With enough room, locality fits one row and keeps store access in view.
   Narrower layouts retain the full-width city selector. */
@media (min-width: 1400px) {
    .customer-page #personForm .admin-person-fields > .col-xl-4 > .row:has(#Address_Country_select) {
        grid-template-columns: 180px 88px minmax(0, 1fr);
    }

    .customer-page #personForm .admin-person-fields > .col-xl-4 > .row:has(#Address_Country_select) > div:last-child {
        grid-column: auto;
    }
}

.customer-address-modal #deliveryAddressForm .row:has(#Country_select) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 100px;
    row-gap: 16px;
}

.customer-address-modal #deliveryAddressForm .row:has(#Country_select) > div {
    width: auto;
    min-width: 0;
}

.customer-address-modal #deliveryAddressForm .row:has(#Country_select) > div:last-child {
    grid-column: 1 / -1;
}

.customer-page #personForm .admin-person-fields .img-thumbnail {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: var(--mkp-radius);
}

.customer-subsection-title > .img-thumbnail {
    order: -1;
}

/* OrderStatus 2 is Finalizado. Preserve its success meaning locally without
   changing the shared enum, label, icon or filter template. */
.customer-page #GridOrders .badge[data-value="2"] {
    background-color: #ecfdf3 !important;
    color: #166534 !important;
    border: 1px solid #bbf7d0;
}

.customer-page #GridOrders .badge[data-value="2"] i {
    color: inherit !important;
}

.customer-access-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 16px 24px;
}

.customer-access-fields > .mb-3 {
    margin-bottom: 0 !important;
}

.customer-access-fields > .mb-3:has(> .form-check) {
    align-self: center;
    padding-top: 24px;
}

.customer-tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin-bottom: 16px;
}

.customer-tabs .customer-required-note {
    margin: 0;
}

.customer-page #personTab {
    gap: 4px;
    flex-wrap: wrap;
    max-width: 100%;
}

.customer-page #personTab .nav-item {
    flex: 0 0 auto;
}

.customer-page .tab-content > .tab-pane:not(.active) {
    display: none;
}

.customer-audit {
    margin-top: 4px;
    color: var(--mkp-muted-foreground);
}

.customer-empty {
    padding: 40px 24px;
    text-align: center;
}

.customer-empty strong {
    display: block;
    margin-bottom: 8px;
    color: var(--mkp-foreground);
    font-weight: 600;
}

.customer-empty p {
    margin: 0;
    color: var(--mkp-muted-foreground);
}

@media (max-width: 1199.98px) {
    .customer-page #personForm .admin-person-fields {
        grid-template-columns: minmax(0, 1fr);
        row-gap: 24px;
    }

    .customer-page #personForm .admin-person-fields > .col-xl-4,
    .customer-page #personForm .admin-person-fields > .customer-supplemental {
        grid-column: 1;
        grid-row: auto;
    }

    .customer-form-page {
        padding-bottom: 80px;
    }

    .customer-form-page .admin-page-actions {
        position: fixed;
        inset: auto 0 0;
        z-index: 1020;
        justify-content: flex-end;
        margin: 0;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--mkp-border);
        background: var(--mkp-surface);
    }

    .customer-form-page .customer-delete-action {
        order: -1;
        margin-inline-end: auto;
    }
}

@media (max-width: 767.98px) {
    .customer-section,
    .customer-filter-toolbar {
        padding: 16px;
    }

    .customer-filters {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: end;
    }

    .customer-search-field {
        min-width: 0;
    }

    .customer-filters #inbox-menu {
        grid-column: 1 / -1;
    }

    .customer-access-fields {
        grid-template-columns: minmax(0, 1fr);
    }

    .customer-access-fields > .mb-3:has(> .form-check) {
        padding-top: 0;
    }

    .customer-page #personForm .admin-person-fields {
        --bs-gutter-x: 24px;
    }


    .customer-page #personTab .nav-item {
        min-width: 0;
    }

    /* Keep the native horizontal viewport on phones as well. */
    .customer-list-page #Grid .k-grid-table > :is(thead, tbody) > tr > .mkp-grid-commands {
        position: static;
        box-shadow: none;
    }

    .customer-page #personForm .customer-identity-summary {
        grid-template-columns: minmax(0, 1fr);
    }

    .customer-page #personForm .admin-person-fields > .col-xl-4 > .customer-address-summary {
        grid-template-columns: minmax(0, 1fr);
    }
}
