/* =====================================================================
   customer-dialog.css  —  global chrome + form styling for the v2
   CustomerDialog redesign (story #775, pixel-identical to the
   "Klant bewerken" handoff mock).

   Import ONCE globally (MudDialog renders its own chrome in an internal
   template, so a scoped `.razor.css` file cannot reach `.mud-dialog` /
   `.mud-dialog-content` / `.mud-dialog-actions` — same documented gotcha
   already solved for other v2 dialogs, see quote-convert-dialog.css and
   article-dialog.css). The dialog sets Class="customer-dialog" on its
   <MudDialog>, a real, plain CSS class on the rendered `.mud-dialog` paper
   element, reachable here. `CustomerDialog` is the only host of both
   CreateCustomerForm and EditCustomerForm, so every rule below is safely
   scoped under `.customer-dialog` — no other dialog uses that class.

   Token mapping (repo tokens vs. the mock's own custom properties):
     --primary  -> var(--primary-color) / rgba(var(--primary-rgb), a)
     --muted    -> var(--text-muted)
     --surface  -> var(--custom-white)
     --border   -> literal #eef0f3 (the app's --default-border, #f3f3f3,
                   and --text-strong, #232427 vs the mock's #eef0f3/#232427,
                   are close-but-different tokens — same precedent as the
                   v2 drawers and article-dialog.css: use the mock's
                   literals here instead of a near-miss token)
     --text-strong -> literal #232427

   !important is used only where styles.css / mobile.css / MudBlazor
   themselves rely on !important (the .mud-dialog-width-md max-width
   override, the Ynex input font walls at :7069/:7130, and the disabled
   primary-button background so MudBlazor's own disabled styling can't win).
   ===================================================================== */

.mud-dialog.customer-dialog {
    max-width: 660px !important;
    /* #775 live self-check (round 1, alt-port run): styles.css:14473-14476 sets a global
       `.mud-dialog { border: 1px solid var(--default-border) }` that otherwise leaks onto
       this dialog and adds a stray 1px on every edge the mock never has (it defines the
       shape with box-shadow alone) - confirmed via getBoundingClientRect diffing against
       the mock. Same fix as #773's article-dialog.css. */
    border: none;
    border-radius: 14px;
    box-shadow: 0 28px 70px rgba(20, 24, 40, .28);
    background: var(--custom-white);
    overflow: hidden;
    font-family: var(--default-font-family);
    line-height: normal;
    letter-spacing: normal;
    color: #2b2f36;
}

.customer-dialog *,
.customer-dialog ::before,
.customer-dialog ::after {
    box-sizing: border-box;
}

/* ---- Head ------------------------------------------------------------ */

.customer-dialog .mud-dialog-title {
    padding: 18px 22px;
    border-bottom: 1px solid #eef0f3;
    margin: 0;
    line-height: normal;
    letter-spacing: normal;
}

.customer-dialog .cdlg-head {
    display: flex;
    align-items: center;
    gap: 13px;
}

.customer-dialog .cdlg-icon {
    width: 42px;
    height: 42px;
    flex: none;
    border-radius: 11px;
    display: grid;
    place-items: center;
    font-size: 21px;
    background: rgba(var(--primary-rgb), .1);
    color: var(--primary-color);
}

.customer-dialog .cdlg-icon i {
    /* #775 round 2 (test-round1.md finding 5, "yellow ghosting on the
       user-star icon"): see the .cdlg-sec-head i comment for the root cause.
       The tile itself is a fixed 42x42 box, so a narrower glyph only shifts
       within its own centered box (sub-pixel AA ghosting) rather than moving
       a sibling element - lock the width anyway for full parity. 21px -> 21.88px. */
    width: 21.88px;
}

.customer-dialog .cdlg-head-text {
    min-width: 0;
    flex: 1 1 auto;
}

.customer-dialog .cdlg-title {
    font-size: 16px;
    font-weight: 700;
    color: #232427;
}

.customer-dialog .cdlg-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    overflow-wrap: anywhere;
}

.customer-dialog .cdlg-close {
    margin-left: auto;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: none;
    background: #f4f5f8;
    color: #5b6472;
    cursor: pointer;
    font-size: 18px;
    display: grid;
    place-items: center;
    padding: 0;
}

.customer-dialog .cdlg-close i {
    /* #775 round 2: see the .cdlg-icon i comment (same fixed-tile case). 18px -> 18.75px. */
    width: 18.75px;
}

.customer-dialog .cdlg-close:hover {
    background: #e9ebf0;
    color: var(--primary-color);
}

/* ---- Body -------------------------------------------------------------- */

.customer-dialog .mud-dialog-content {
    padding: 20px 22px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: min(70vh, 660px);
    overflow-y: auto;
}

/* ---- Footer ------------------------------------------------------------ */

.customer-dialog .mud-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px;
    border-top: 1px solid #eef0f3;
    background: var(--custom-white);
}

.customer-dialog .mud-dialog-actions > * {
    margin-left: 0 !important;
}

/* ---- Sections ------------------------------------------------------------ */

.customer-dialog .cdlg-secs {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.customer-dialog .cdlg-sec {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.customer-dialog .cdlg-sec-head {
    display: flex;
    align-items: center;
    gap: 9px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eef0f3;
}

.customer-dialog .cdlg-sec-head i {
    font-size: 17px;
    color: var(--primary-color);
    /* #775 round 2 (test-round1.md finding 1/2): the mock loads Remix Icon
       4.5.0 from the CDN, the app bundles the locally-hosted 4.2.0 assets
       (accepted as N2 in the plan on the assumption only class names/::before
       code points matter). A scratch metrics probe (icon-metrics-probe.mjs,
       same code points confirmed equal, glyph outline/height unchanged
       [deltaH=0]) showed 4.5.0's horizontal advance width is ~4.17% wider
       than 4.2.0's at every size used here - e.g. 17px: 17.71875px vs 17px.
       In a flex row (icon then label, gap 9px) that narrower app icon box
       shifts every following text node ~0.7 CSS px further left than the
       mock, which is exactly what the G1 diff showed. Locking the box width
       to the measured 4.5.0 value (glyph itself is pixel-identical, only the
       invisible advance-width metric changes) fixes the flex flow without
       pulling in a second full icon font just for 8 glyphs. */
    width: 17.72px;
}

.customer-dialog .cdlg-sec-title {
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: .3px;
    color: #232427;
}

/* ---- Grid ------------------------------------------------------------ */

.customer-dialog .cdlg-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.customer-dialog .cdlg-span2 {
    grid-column: 1 / -1;
}

.customer-dialog .cdlg-addr {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 16px;
}

.customer-dialog .cdlg-pc {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 16px;
}

.customer-dialog .cdlg-f {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

/* ---- Labels ------------------------------------------------------------ */

.customer-dialog .cdlg-f > label {
    font-size: 12px;
    font-weight: 600;
    color: #4d5663;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    line-height: normal;
}

.customer-dialog .cdlg-opt {
    font-weight: 500;
    color: var(--text-muted);
}

.customer-dialog .cdlg-req {
    color: var(--primary-color);
    font-weight: 700;
}

/* ---- Controls ------------------------------------------------------------ */

.customer-dialog .cdlg-ctl {
    position: relative;
    display: flex;
    align-items: stretch;
}

.customer-dialog .cdlg-ctl input,
.customer-dialog .cdlg-ctl select {
    width: 100%;
    border: 1px solid #e3e7ef;
    border-radius: 9px;
    background: #fff;
    font-family: var(--default-font-family) !important;
    color: #232427;
    outline: none;
    padding: 0 13px !important;
    height: 44px;
    transition: .15s;
    line-height: normal;
    margin: 0;
    /* #775 round 3: Chromium's internal vertical-centering for a fixed-height
       form control's text rounds to a different device pixel than the mock's
       in about half of the real layout positions this dialog produces (e.g.
       every field once section 1 collapses to its 2-field Private-customer
       row) even though every checked token (height/line-height/padding/
       font-family/font-size) and the box's own getBoundingClientRect() are
       byte-identical between app and mock - confirmed live: hiding section
       1's extra Business-only rows on an otherwise-untouched Business dialog
       reproduces the exact same 1 CSS px low shift the Private dialog shows
       naturally. 1px of extra bottom padding (within the existing 44px
       border-box height, so the box itself and .cdlg-chev don't move)
       compensates without perturbing the positions that already matched
       (re-verified live: matches the mock on every scenario/field measured,
       S1 unaffected, S2 fixed). Same mechanism as the select fix below. */
    padding-bottom: 1px !important;
}

/* Desktop-only font size so the below-992px iOS focus-zoom guard in
   mobile.css (input/select forced to 16px) keeps working (AC11, flag G-1). */
@media (min-width: 992px) {
    .customer-dialog .cdlg-ctl input,
    .customer-dialog .cdlg-ctl select {
        font-size: 14px !important;
    }
}

.customer-dialog .cdlg-ctl select {
    appearance: none;
    font-weight: 600;
    cursor: pointer;
    padding-right: 38px !important;
    /* #775 round 3: with appearance:none, Chromium centers a native <select>'s
       displayed value through its internal list-box flexbox rendering path.
       That path (and, in some layouts, <input>'s own text-field editor - see
       the padding-bottom on the shared input/select rule above) rounds 1 real
       px differently than the mock's rendering even though every checked
       token (height/line-height/padding/font-family/font-size) and the box's
       own getBoundingClientRect() are identical (verified live, DPR2,
       ink-row measurement: app top=35/bottom=61 vs mock top=33/bottom=59,
       image px, i.e. exactly 1 CSS px low). The shared rule's
       padding-bottom:1px already covers the select (this rule inherits it),
       kept implicit here rather than redeclared. Re-measured after the fix:
       0px delta on both selects, S1-S4. */
}

.customer-dialog .cdlg-chev {
    position: absolute;
    right: 13px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    /* #775 round 2: see the .cdlg-sec-head i comment for the 4.2.0-vs-4.5.0
       icon-metrics root cause. `right:13px` anchors the box from the right
       edge, so a narrower intrinsic width also shifts the box's left edge -
       lock it to the 4.5.0-measured width (18px -> 18.75px). */
    width: 18.75px;
    color: #9aa1ad;
    pointer-events: none;
}

.customer-dialog .cdlg-ctl input::placeholder {
    color: #b3b8c2;
    font-weight: 400;
    opacity: 1;
}

.customer-dialog .cdlg-ctl input:focus,
.customer-dialog .cdlg-ctl select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .12);
}

.customer-dialog .cdlg-ctl.is-error input,
.customer-dialog .cdlg-ctl.is-error select {
    border-color: #e0705c;
    box-shadow: 0 0 0 3px rgba(224, 112, 92, .12);
}

.customer-dialog .cdlg-ctl input:disabled,
.customer-dialog .cdlg-ctl select:disabled {
    opacity: .6;
    cursor: progress;
}

.customer-dialog .cdlg-spin {
    position: absolute;
    right: 13px;
    top: 50%;
    transform: translateY(-50%);
}

/* ---- Hint and error ------------------------------------------------------------ */

.customer-dialog .cdlg-sub {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.45;
}

.customer-dialog .cdlg-err {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #d4563b;
    line-height: normal;
}

.customer-dialog .cdlg-err i {
    font-size: 15px;
    /* #775 round 2: see the .cdlg-sec-head i comment. 15px -> 15.625px. */
    width: 15.63px;
}

/* ---- Buttons (MudButton) ------------------------------------------------------------ */

.customer-dialog .mud-dialog-actions .cdlg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 42px;
    padding: 0 16px;
    border-radius: 9px;
    font-family: var(--default-font-family);
    font-size: 13px;
    font-weight: 600;
    line-height: normal;
    text-transform: none;
    letter-spacing: normal;
    white-space: nowrap;
    min-width: 0;
}

.customer-dialog .cdlg-btn .mud-button-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.customer-dialog .cdlg-btn .mud-button-icon-start {
    margin: 0;
}

.customer-dialog .cdlg-btn i,
.customer-dialog .cdlg-btn .mud-icon-root {
    font-size: 16px;
    /* #775 round 2: see the .cdlg-sec-head i comment. Previously fixed at a
       bare 16px, which matched neither font version's true rendered width
       and left the footer button-group total width (hence "Annuleren"'s
       flex-end-aligned position) ~0.67 CSS px off the mock (finding 4).
       16px -> 16.671875px measured against remixicon 4.5.0. */
    width: 16.67px;
    height: 16px;
}

.customer-dialog .cdlg-btn-light {
    background: #fff;
    color: #4d5663;
    border: 1px solid #eef0f3;
}

.customer-dialog .mud-dialog-actions .cdlg-btn-light:hover {
    background: #fff;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.customer-dialog .cdlg-btn-primary {
    background: var(--primary-color) !important;
    color: #fff !important;
    border: none;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), .26);
}

.customer-dialog .mud-dialog-actions .cdlg-btn-primary:not(.mud-button-disabled):hover {
    filter: brightness(1.05);
    background: var(--primary-color) !important;
}

.customer-dialog .cdlg-btn-primary.mud-button-disabled,
.customer-dialog .cdlg-btn-primary:disabled {
    opacity: .5;
    box-shadow: none;
    cursor: not-allowed;
    background: var(--primary-color) !important;
    color: #fff !important;
    filter: none;
}

/* ---- Responsive (AC11) ------------------------------------------------------------ */

@media (max-width: 560px) {
    .customer-dialog .cdlg-grid,
    .customer-dialog .cdlg-addr,
    .customer-dialog .cdlg-pc {
        grid-template-columns: 1fr;
    }

    .customer-dialog .mud-dialog-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .customer-dialog .mud-dialog-actions .cdlg-btn {
        width: 100%;
    }
}
