/* PAN CRM v332 — customer card usability/alignment pass.
   Scope is deliberately limited to pages containing the customer identity card. */

body:has(.pc-form-card-identity) .pc-form-card{
    min-width:0 !important;
}

body:has(.pc-form-card-identity) .pc-form-card .fi-section-content{
    padding:12px !important;
}

body:has(.pc-form-card-identity) .pc-form-card .fi-sc-grid,
body:has(.pc-form-card-identity) .pc-form-card .fi-grid{
    column-gap:12px !important;
    row-gap:10px !important;
}

/* Keep labels and selected values on one clean line. */
body:has(.pc-form-card-identity) .pc-customer-field{
    min-width:0 !important;
}
body:has(.pc-form-card-identity) .pc-customer-field .fi-fo-field-wrp-label,
body:has(.pc-form-card-identity) .pc-customer-field .fi-fo-field-label-content{
    white-space:nowrap !important;
    overflow:hidden !important;
    text-overflow:ellipsis !important;
}
body:has(.pc-form-card-identity) .pc-customer-field .fi-select-input-value-ctn{
    min-width:0 !important;
    flex:1 1 auto !important;
    overflow:hidden !important;
}
body:has(.pc-form-card-identity) .pc-customer-field .fi-select-input-value-label{
    display:block !important;
    min-width:0 !important;
    max-width:100% !important;
    white-space:nowrap !important;
    overflow:hidden !important;
    text-overflow:ellipsis !important;
}
body:has(.pc-form-card-identity) .pc-customer-field .fi-select-input-btn{
    min-width:0 !important;
}

/* Stable 14-inch desktop layout. The order remains driven by the layout editor;
   only widths are normalized so long values do not push neighboring controls. */
@media (min-width:1200px){
    body:has(.pc-form-card-identity) .pc-form-card-identity .pc-customer-field-title{
        grid-column:span 6 / span 6 !important;
    }
    body:has(.pc-form-card-identity) .pc-form-card-identity .pc-customer-field-customer_code,
    body:has(.pc-form-card-identity) .pc-form-card-identity .pc-customer-field-short_name,
    body:has(.pc-form-card-identity) .pc-form-card-identity .pc-customer-field-status{
        grid-column:span 2 / span 2 !important;
    }
    body:has(.pc-form-card-identity) .pc-form-card-identity .pc-customer-field-owner_user_id,
    body:has(.pc-form-card-identity) .pc-form-card-identity .pc-customer-field-related_manager_user_id{
        grid-column:span 3 / span 3 !important;
    }
    body:has(.pc-form-card-identity) .pc-form-card-identity .pc-customer-field-customer_group{
        grid-column:span 4 / span 4 !important;
    }
    body:has(.pc-form-card-identity) .pc-form-card-identity .pc-customer-field-customer_type{
        grid-column:span 2 / span 2 !important;
    }

    body:has(.pc-form-card-identity) .pc-form-card-contact .pc-customer-field-phone,
    body:has(.pc-form-card-identity) .pc-form-card-contact .pc-customer-field-company_gsm,
    body:has(.pc-form-card-identity) .pc-form-card-contact .pc-customer-field-mobile{
        grid-column:span 4 / span 4 !important;
    }
    body:has(.pc-form-card-identity) .pc-form-card-contact .pc-customer-field-email,
    body:has(.pc-form-card-identity) .pc-form-card-contact .pc-customer-field-website{
        grid-column:span 6 / span 6 !important;
    }

    body:has(.pc-form-card-identity) .pc-form-card-address .pc-customer-field-tax_office,
    body:has(.pc-form-card-identity) .pc-form-card-address .pc-customer-field-tax_number,
    body:has(.pc-form-card-identity) .pc-form-card-address .pc-customer-field-country{
        grid-column:span 4 / span 4 !important;
    }
    body:has(.pc-form-card-identity) .pc-form-card-address .pc-customer-field-city,
    body:has(.pc-form-card-identity) .pc-form-card-address .pc-customer-field-district{
        grid-column:span 6 / span 6 !important;
    }
    body:has(.pc-form-card-identity) .pc-form-card-address .pc-customer-field-address{
        grid-column:1 / -1 !important;
    }

    body:has(.pc-form-card-identity) .pc-form-card-sales .pc-customer-field-sector,
    body:has(.pc-form-card-identity) .pc-form-card-sales .pc-customer-field-source,
    body:has(.pc-form-card-identity) .pc-form-card-sales .pc-customer-field-epson_status,
    body:has(.pc-form-card-identity) .pc-form-card-sales .pc-customer-field-epson_offer_worked_at{
        grid-column:span 3 / span 3 !important;
    }
    body:has(.pc-form-card-identity) .pc-form-card-sales .pc-customer-field-owned_printer_models{
        grid-column:1 / -1 !important;
    }
}

/* On smaller laptops/tablets, do not squeeze two half-page cards until fields break. */
@media (min-width:761px) and (max-width:1199px){
    body:has(.pc-form-card-identity) .pc-form-card-identity,
    body:has(.pc-form-card-identity) .pc-form-card-contact,
    body:has(.pc-form-card-identity) .pc-form-card-address,
    body:has(.pc-form-card-identity) .pc-form-card-sales,
    body:has(.pc-form-card-identity) .pc-form-card-follow,
    body:has(.pc-form-card-identity) .pc-form-card-notes{
        grid-column:1 / -1 !important;
    }
}

/* Customer relation tabs: use the available width instead of floating as a small island. */
body:has(.pc-form-card-identity) .fi-tabs{
    width:100% !important;
    max-width:100% !important;
    justify-content:flex-start !important;
    overflow-x:auto !important;
    scrollbar-width:thin;
}
body:has(.pc-form-card-identity) .fi-tabs-item{
    flex:0 0 auto !important;
    white-space:nowrap !important;
}

/* Small screens: preserve comfortable touch targets. */
@media (max-width:760px){
    body:has(.pc-form-card-identity) .pc-form-card .fi-section-content{
        padding:10px !important;
    }
    body:has(.pc-form-card-identity) .pc-customer-summary{
        align-items:flex-start !important;
    }
}
