/*
 * SalesGrid content components — v2.22.0
 *
 * One consistent look for the building blocks every workspace uses:
 * cards, section headings, inline notices, buttons, form controls, tables,
 * empty states, plus a phone pass (touch targets, no iOS zoom, spacing).
 *
 * Loaded after sgx-app.css. Scope prefix keeps it inside the app content.
 * Rules of thumb used here (legacy markup cannot be previewed everywhere):
 *  - Containers verified light in legacy CSS are restyled fully.
 *  - Buttons/inputs get shape, type and focus with !important, but colours
 *    WITHOUT !important, so purpose-coloured legacy controls keep their colour.
 *  - Tables get spacing/borders only — never header/cell colours, because
 *    some legacy tables use dark header rows with white text.
 *  - Order cards (navy), hero/metric panels and modals are not touched.
 */

/* ---------------------------------------------------------------- cards */
body.salesgrid-app-body .sgx-app .sg-content :is(
  .bdmom-section,.bdm-stock-section,.bdm-agent-create-section,.hr-panel,.calls-panel,
  .bdm-settings-card,.coh-card,.bdm-ops-panel,.bdm-stock-card
){
  background:var(--sgx-surface)!important;
  border:1px solid var(--sgx-line)!important;
  border-radius:var(--sgx-radius-lg)!important;
  box-shadow:var(--sgx-shadow-sm)!important;
  color:var(--sgx-ink);
}
body.salesgrid-app-body .sgx-app .sg-content :is(.bdmom-section,.bdm-stock-section,.hr-panel,.calls-panel,.bdm-settings-card,.coh-card){
  margin-bottom:20px!important;
}

/* Direct section headings only — header bars inside sections keep theirs. */
body.salesgrid-app-body .sgx-app .sg-content :is(.bdmom-section,.bdm-stock-section,.hr-panel,.calls-panel,.bdm-settings-card,.coh-card) > :is(h2,h3){
  margin:0 0 6px!important;
  color:var(--sgx-ink)!important;-webkit-text-fill-color:var(--sgx-ink)!important;
  font:700 18px/1.3 var(--sgx-font)!important;letter-spacing:-.01em!important;text-transform:none!important;
}
body.salesgrid-app-body .sgx-app .sg-content :is(.bdmom-section,.bdm-stock-section,.hr-panel,.calls-panel,.bdm-settings-card,.coh-card) > :is(h2,h3) + p{
  margin-top:0!important;color:var(--sgx-muted)!important;font-size:14px!important;line-height:1.5!important;
}
body.salesgrid-app-body .sgx-app .sg-content :is(.bdmom-section,.bdm-stock-section,.hr-panel,.calls-panel) > h4{
  margin:18px 0 8px!important;color:var(--sgx-ink-2)!important;font:650 14px/1.3 var(--sgx-font)!important;
}

/* -------------------------------------------------------- inline notices
 * Page-level notices already become toasts (bdm-notice-toasts.js); these
 * are the notices that stay inside a section. */
body.salesgrid-app-body .sgx-app .sg-content :not(.bdm-toast-content) > :is(.bdmom-notice,.bdm-account-notice,.bdm-stock-notice,.bdm-agent-notice,.notice){
  --sgx-n-bg:#eff6ff;--sgx-n-line:#bfdbfe;--sgx-n-ink:#1e4fae;
  display:block;margin:0 0 14px!important;padding:12px 14px 12px 16px!important;
  border:1px solid var(--sgx-n-line)!important;border-left:4px solid var(--sgx-n-ink)!important;border-radius:10px!important;
  background:var(--sgx-n-bg)!important;color:var(--sgx-n-ink)!important;
  font:550 14px/1.5 var(--sgx-font)!important;box-shadow:none!important;
}
body.salesgrid-app-body .sgx-app .sg-content :not(.bdm-toast-content) > :is(.bdmom-success,.bdm-account-notice-success,.notice-success,.is-success){
  --sgx-n-bg:#ecfdf3;--sgx-n-line:#abefc6;--sgx-n-ink:#067647;
}
body.salesgrid-app-body .sgx-app .sg-content :not(.bdm-toast-content) > :is(.bdmom-error,.bdm-account-notice-error,.notice-error,.is-error){
  --sgx-n-bg:#fef3f2;--sgx-n-line:#fecdca;--sgx-n-ink:#b42318;
}
body.salesgrid-app-body .sgx-app .sg-content :not(.bdm-toast-content) > :is(.bdm-account-notice-warning,.notice-warning,.bdmom-warning,.is-warning){
  --sgx-n-bg:#fffaeb;--sgx-n-line:#fedf89;--sgx-n-ink:#b54708;
}
body.salesgrid-app-body .sgx-app .sg-content :is(.bdmom-notice,.bdm-account-notice,.notice) :is(strong,b,a){color:inherit!important;-webkit-text-fill-color:currentColor!important}
body.salesgrid-app-body .sgx-app .sg-content :is(.bdmom-notice,.bdm-account-notice,.notice) p{margin:0!important}

/* -------------------------------------------------------------- buttons */
body.salesgrid-app-body .sgx-app .sg-content :is(.button,button,input[type=submit],input[type=button],input[type=reset]){
  border-radius:10px!important;
  font-family:var(--sgx-font)!important;
  letter-spacing:normal;
  cursor:pointer;
}
body.salesgrid-app-body .sgx-app .sg-content :is(a.button,.button,button[type=submit],input[type=submit]){
  font-weight:650!important;
}
body.salesgrid-app-body .sgx-app .sg-content :is(.button,button,input[type=submit]):not(:disabled):hover{filter:brightness(.97)}
/* The generic primary class was an off-brand blue; main actions use the brand orange. */
body.salesgrid-app-body .sgx-app .sg-content :is(.button-primary,button.button-primary){
  background:var(--sgx-brand)!important;border-color:var(--sgx-brand)!important;color:#fff!important;-webkit-text-fill-color:#fff!important;
  box-shadow:0 4px 12px rgba(245,130,32,.22)!important;
  display:inline-flex!important;align-items:center;justify-content:center;gap:8px;
  min-height:40px;padding:0 18px!important;font-size:14px!important;line-height:1.2!important;text-decoration:none!important;
}
body.salesgrid-app-body .sgx-app .sg-content :is(.button-primary,button.button-primary):not(:disabled):hover{background:#e57412!important;border-color:#e57412!important;filter:none}

/* -------------------------------------------------------- form controls */
body.salesgrid-app-body .sgx-app .sg-content :is(
  input[type=text],input[type=tel],input[type=number],input[type=email],input[type=search],
  input[type=password],input[type=date],input[type=datetime-local],input[type=time],input[type=url],input:not([type]),
  select,textarea
){
  box-sizing:border-box;
  min-height:42px!important;
  border-radius:10px!important;
  font-family:var(--sgx-font)!important;
  transition:border-color .15s,box-shadow .15s;
}
/* Defaults with zero specificity: any legacy/component rule wins. */
:where(body.salesgrid-app-body .sgx-app .sg-content) :where(
  input[type=text],input[type=tel],input[type=number],input[type=email],input[type=search],
  input[type=password],input[type=date],input[type=datetime-local],input[type=time],input[type=url],input:not([type]),
  select,textarea
){
  font-size:14px;line-height:1.4;padding:8px 12px;
  border:1px solid var(--sgx-line-2);background-color:var(--sgx-surface);color:var(--sgx-ink);
}
body.salesgrid-app-body .sgx-app .sg-content textarea{min-height:96px!important;line-height:1.5}
body.salesgrid-app-body .sgx-app .sg-content :is(input,select,textarea)::placeholder{color:#94a3b8;opacity:1}
body.salesgrid-app-body .sgx-app .sg-content :is(input,select,textarea):disabled{background-color:var(--sgx-surface-2);color:var(--sgx-muted);cursor:not-allowed}
body.salesgrid-app-body .sgx-app .sg-content :is(input[type=checkbox],input[type=radio]){accent-color:var(--sgx-brand)}

/* Field labels (wrapping <label class="…-field">Label <input></label>). */
body.salesgrid-app-body .sgx-app .sg-content :is(.bdmom-field,.bdm-agent-field,.bdm-stock-field,.bdmom-commission-field,.bdm-setting-field){
  gap:6px;color:var(--sgx-ink-2);font:600 13px/1.35 var(--sgx-font);
}

/* --------------------------------------------------------------- tables
 * Spacing and rules only — header/cell colours stay with legacy CSS. */
@media (min-width:768px){
  :where(body.salesgrid-app-body .sgx-app .sg-content) :where(table){width:100%;border-collapse:collapse;font-size:14px}
  :where(body.salesgrid-app-body .sgx-app .sg-content) :where(table) :where(th,td){padding:10px 12px;vertical-align:middle;border-bottom:1px solid var(--sgx-line);text-align:left}
  :where(body.salesgrid-app-body .sgx-app .sg-content) :where(table thead th){font-weight:650;font-size:12px;letter-spacing:.03em;white-space:nowrap;color:var(--sgx-muted);text-transform:uppercase}
  :where(body.salesgrid-app-body .sgx-app .sg-content) :where(table tbody tr:last-child) > :where(td,th){border-bottom:0}
  body.salesgrid-app-body .sgx-app .sg-content .bdm-mobile-table-scroll{border-color:var(--sgx-line)!important;border-radius:12px!important;background:var(--sgx-surface)}
}

/* --------------------------------------------------------- empty states */
body.salesgrid-app-body .sgx-app .sg-content :is(.bdm-agent-empty,.bdmom-profit-list-empty,.bdm-empty,.bdmom-empty){
  padding:28px 16px!important;border:1px dashed var(--sgx-line-2)!important;border-radius:12px!important;
  background:var(--sgx-surface-2)!important;color:var(--sgx-muted)!important;text-align:center;font:500 14px/1.5 var(--sgx-font)!important;
}

/* --------------------------------------------------------- media safety */
body.salesgrid-app-body .sgx-app .sg-content :is(img,video,canvas,iframe){max-width:100%}
body.salesgrid-app-body .sgx-app .sg-content img{height:auto}

/* =============================================================== phones */
@media (max-width:767px){
  body.salesgrid-app-body .sgx-app .sg-content :is(
    .bdmom-section,.bdm-stock-section,.bdm-agent-create-section,.hr-panel,.calls-panel,
    .bdm-settings-card,.coh-card,.bdm-ops-panel,.bdm-stock-card
  ){
    padding:16px!important;border-radius:14px!important;margin-bottom:14px!important;
    background:var(--sgx-surface)!important;
  }
  body.salesgrid-app-body .sgx-app .sg-content :is(.bdmom-section,.bdm-stock-section,.hr-panel,.calls-panel,.bdm-settings-card,.coh-card) > :is(h2,h3){font-size:17px!important}

  /* 16px stops iOS Safari zooming into a field; 44px is the touch minimum. */
  body.salesgrid-app-body .sgx-app .sg-content :is(
    input[type=text],input[type=tel],input[type=number],input[type=email],input[type=search],
    input[type=password],input[type=date],input[type=datetime-local],input[type=time],input[type=url],input:not([type]),
    select,textarea
  ){font-size:16px!important;min-height:46px!important}
  body.salesgrid-app-body .sgx-app .sg-content :is(.button,button[type=submit],input[type=submit],input[type=button]){min-height:44px!important}
  body.salesgrid-app-body .sgx-app .sg-content :is(input[type=checkbox],input[type=radio]){width:20px;height:20px}

  /* A form's main submit becomes a full-width, thumb-reachable bar. */
  body.salesgrid-app-body .sgx-app .sg-content :is(.bdmom-section,.bdm-stock-section,.hr-panel,.calls-panel,.bdm-settings-card) form > :is(button[type=submit],input[type=submit]):last-child{
    width:100%!important;
  }
}
