/* Products module — builds on enterprise-data-table.css */

.products-page {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.4rem 0.55rem 0.45rem;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    background: linear-gradient(180deg, #f7f9fc 0%, #eef2f7 100%);
}

.products-page__header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    flex-shrink: 0;
}

/* Top row — always 50% filters + chart (and pricing when admin) */
.products-page__top {
    display: grid;
    /* filters 50% | chart 50% */
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.45rem;
    align-items: stretch;
    flex-shrink: 0;
    width: 100%;
    min-height: 7.25rem;
}

/* filters 50% | admin pricing 15% | chart 35% */
.products-page__top--pricing {
    grid-template-columns: minmax(0, 50fr) minmax(0, 15fr) minmax(0, 35fr);
}

.products-page__filters {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
    width: 100%;
}

.products-search-bar,
.products-formula-bar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.3rem 0.35rem;
    padding: 0.4rem 0.45rem;
    /* Match sidenav / ent-dialog header navy */
    background: linear-gradient(180deg, #03142e 0%, #0a2744 100%);
    border: 2px solid #03142e;
    border-radius: 4px;
    overflow: hidden;
}

.products-formula-bar {
    justify-content: space-between;
}

.products-formula-bar__group {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.3rem 0.35rem;
    min-width: 0;
}

.products-formula-bar__group--end {
    margin-left: auto;
    flex-shrink: 0;
}

.products-search-control {
    flex: 1 1 0;
    min-width: 0;
}

.products-search-control--ddl {
    flex: 1 1 0;
    min-width: 130px;
    max-width: 180px;
}

.products-search-control--text {
    flex: 1 1 0;
    min-width: 110px;
    max-width: 160px;
}

.products-formula-bar .products-formula-field,
.products-formula-bar .e-ddl.products-formula-field {
    width: 130px !important;
    min-width: 110px !important;
    max-width: 150px !important;
}

/* Input only — CssClass is also on the body-portaled popup; do not force 100% there. */
.products-search-control--ddl > .e-input-group.e-ddl,
.products-search-control--ddl > .e-ddl.e-input-group {
    width: 100% !important;
}

.e-ddl.e-popup.products-ddl {
    min-width: 0 !important;
}

.products-search-bar .e-input-group,
.products-search-bar .e-ddl,
.products-formula-bar .e-input-group,
.products-formula-bar .e-ddl {
    background: #fff !important;
    border-radius: 3px;
}

.products-formula-bar .products-num-input {
    width: 4.25rem;
    height: 1.75rem;
    min-height: 1.75rem;
    padding: 0.15rem 0.3rem;
    border: 1px solid #c5d0de;
    border-radius: 3px;
    background: #fff;
    color: #0f172a;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
    box-sizing: border-box;
}

.products-formula-bar .products-num-input--months {
    width: 3.5rem;
}

.products-formula-bar .products-num-input:focus {
    outline: 2px solid rgba(255, 255, 255, 0.55);
    outline-offset: 1px;
}

/* Keep native spinners compact where the browser paints them */
.products-formula-bar .products-num-input::-webkit-outer-spin-button,
.products-formula-bar .products-num-input::-webkit-inner-spin-button {
    height: 1.35rem;
    opacity: 1;
}

.products-search-check {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    margin: 0;
    flex-shrink: 0;
    color: #fff;
    font-weight: 700;
    font-size: 0.8125rem;
    white-space: nowrap;
    cursor: pointer;
}

.products-search-refresh {
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-radius: 4px;
    width: 2.1rem;
    height: 2.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.products-search-refresh:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.22);
}

.products-search-refresh:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.products-formula-label {
    color: #fff;
    font-weight: 700;
    font-size: 0.8125rem;
    margin: 0 0.1rem;
    white-space: nowrap;
}

.products-formula-field {
    min-width: 96px;
}

.products-pricing {
    min-width: 0;
    min-height: 7.25rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.products-pricing-table {
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 2px solid #03142e;
    border-collapse: collapse;
    text-align: center;
    background: #fff;
    /* Match .iffys-sf-grid cell size */
    font-size: 12px;
}

.products-pricing-table th,
.products-pricing-table td {
    border: 1px solid #0a2744;
    padding: 0.2rem 0.25rem;
    line-height: 1.25;
    word-break: break-word;
    font-size: 12px;
}

.products-pricing-table th {
    font-weight: 800;
    background: linear-gradient(180deg, #03142e 0%, #0a2744 100%);
    color: #fff;
}

.products-pricing-table td.title {
    font-weight: 700;
    text-align: left;
    padding-left: 0.5rem;
}

.products-page__chart {
    min-width: 0;
    min-height: 7.25rem;
    width: 100%;
    height: 100%;
    border: 1px solid #d0d8e4;
    border-radius: 6px;
    background: #fff;
    padding: 0.15rem 0.25rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.products-page__chart .e-chart,
.products-page__chart > div {
    flex: 1 1 auto;
    min-height: 0;
    height: 100% !important;
}

.products-page__chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 600;
}

.products-thumb {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 4px;
    background: #f8fafc;
}

@media (max-width: 900px) {
    .products-page__top,
    .products-page__top--pricing {
        grid-template-columns: minmax(0, 1fr);
    }
}

.products-page__title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--ent-navy, #03142e);
    letter-spacing: -0.015em;
    line-height: 1.25;
}

.products-page__subtitle {
    margin: 0;
    font-size: 0.875rem;
    color: var(--ent-muted, #64748b);
    font-weight: 600;
}

.products-page__error {
    margin: 0;
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-shrink: 0;
}

.products-page__error button {
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.products-page__detail {
    display: grid;
    grid-template-columns: minmax(280px, 420px) 1fr;
    gap: 0.65rem;
    align-items: stretch;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--ent-border, #d0d8e4);
    border-radius: 8px;
    background: #fff;
    flex-shrink: 0;
    min-width: 0;
}

.products-page__detail-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem 0.75rem;
    align-content: center;
}

.products-page__detail-stats div {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.products-page__detail-stats span {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    font-weight: 700;
}

.products-page__detail-stats strong {
    font-size: 0.95rem;
    color: #0f172a;
    font-weight: 700;
}

.products-page__chart {
    min-width: 0;
}

.prod-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem 0.85rem;
}

.prod-form-grid > .full {
    grid-column: 1 / -1;
}

.prod-sku-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.prod-sku-row > :first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.prod-flag-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem 1rem;
}

.prod-flag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #334155;
    margin: 0;
    cursor: pointer;
}

.prod-dlg-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.55rem;
    flex-shrink: 0;
}

/* —— Product editor —— 88vh centered shell; .ped-scroll is the only scroller.
   Inner scroll + max-height fallback avoids Syncfusion/ent-dialog overflow fights. */
.product-editor-dialog.e-dialog {
    width: min(920px, calc(100vw - 1.25rem)) !important;
    /* Cap to visible viewport (dvh) so the shell never sits off-screen */
    height: min(88vh, calc(100dvh - 1rem)) !important;
    max-height: min(88vh, calc(100dvh - 1rem)) !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    /* Position via DialogPositionData (center); do not CSS-transform —
       that fights Syncfusion's top/left and can push the shell off-screen. */
}

.product-editor-dialog.e-dialog > .e-dlg-header-content,
.product-editor-dialog.e-dialog > .e-footer-content {
    flex: 0 0 auto !important;
}

.product-editor-dialog.e-dialog > .e-dlg-content {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
}

.product-editor-dialog .ped-scroll {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.65rem 0.75rem 0.85rem;
    /* Fallback when Syncfusion pins a bad content height */
    max-height: calc(min(88vh, 100dvh - 1rem) - 7.25rem);
    box-sizing: border-box;
}

.product-editor-dialog .prod-editor-body {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    height: auto;
    overflow: visible;
}

.ped-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    flex-shrink: 0;
}

.ped-tb-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 2.1rem;
    padding: 0.35rem 0.85rem;
    border: none;
    border-radius: 4px;
    background: #2563eb;
    color: #fff;
    font-size: var(--font-size-sm, 14px);
    font-weight: 600;
    cursor: pointer;
}

.ped-tb-btn:hover:not(:disabled) {
    background: #1d4ed8;
}

.ped-tb-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ped-tabs {
    display: block;
}

.ped-tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 1rem;
    border-bottom: 1px solid #cbd5e1;
    margin-bottom: 0.55rem;
}

.ped-tab {
    appearance: none;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 0.45rem 0.15rem;
    font-size: var(--font-size-sm, 14px);
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
}

.ped-tab:hover {
    color: #1e3a5f;
}

.ped-tab.is-active {
    color: #1d4ed8;
    border-bottom-color: #2563eb;
}

.ped-tab-pane {
    padding: 0.25rem 0.15rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.ped-section {
    margin-top: 0.35rem;
    padding-top: 0.45rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.ped-section-title {
    font-size: var(--font-size-base, 16px);
    font-weight: 800;
    color: #1e3a5f;
}

.ped-row {
    display: grid;
    gap: 0.55rem 0.85rem;
}

.ped-row--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ped-row--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ped-pricing-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem 0.75rem;
}

.ped-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.ped-field--full {
    width: 100%;
}

.ped-field--check {
    justify-content: flex-end;
    padding-bottom: 0.15rem;
}

.ped-label {
    font-size: var(--font-size-sm, 14px);
    font-weight: 700;
    color: #475569;
    margin: 0;
}

.ped-field .e-input-group,
.ped-field .e-input-group input,
.ped-field .e-input-group .e-input,
.ped-field .e-control.e-textbox,
.ped-field .e-control.e-numerictextbox,
.ped-field textarea {
    font-size: var(--font-size-base, 16px) !important;
    font-weight: 600 !important;
    color: #0f2744 !important;
    line-height: 1.35 !important;
}

.ped-field .e-ddl .e-input-group input,
.ped-field .e-ddl.e-input-group input {
    font-size: var(--font-size-base, 16px) !important;
    font-weight: 600 !important;
}

.ped-check {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: var(--font-size-sm, 14px);
    font-weight: 600;
    color: #334155;
    margin: 0;
    cursor: pointer;
}

.ped-flag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
}

.ped-promo-stack {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.ped-promo-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.55rem 0.7rem 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
}

.ped-promo-card.is-on {
    background: #f0f7ff;
    border-color: #bfdbfe;
}

.ped-promo-card__head {
    display: flex;
    align-items: center;
    gap: 0.75rem 1rem;
    min-width: 0;
}

.ped-promo-card__title {
    font-size: var(--font-size-sm, 14px);
    font-weight: 800;
    color: #1e3a5f;
}

.ped-promo-card__head .ped-check {
    flex: 0 0 auto;
    font-weight: 800;
    color: #1e3a5f;
}

.ped-promo-card__head .ped-check .ped-promo-card__title {
    font-weight: 800;
}

.ped-promo-card__fields {
    display: grid;
    gap: 0.45rem 0.65rem;
    min-width: 0;
}

.ped-promo-card__fields--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ped-promo-card__fields--3 {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.05fr) minmax(0, 1.05fr);
}

.ped-promo-card__clearance {
    flex: 1 1 10rem;
    max-width: 14rem;
    margin-left: auto;
}

@media (max-width: 900px) {
    .ped-pricing-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ped-row--3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ped-promo-card__fields--3 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 640px) {
    .ped-row--2,
    .ped-row--3,
    .ped-pricing-grid,
    .ped-promo-card__fields--2,
    .ped-promo-card__fields--3 {
        grid-template-columns: 1fr;
    }

    .ped-promo-card__head {
        flex-wrap: wrap;
    }

    .ped-promo-card__clearance {
        flex: 1 1 100%;
        max-width: none;
        margin-left: 0;
    }
}

/* Inline Save / Cancel rows inside product dialogs */
.products-page .prod-form-grid .d-flex,
.product-categories-dialog .prod-form-grid .d-flex,
.product-lines-dialog .prod-form-grid .d-flex,
.product-notes-dialog .prod-form-grid .d-flex,
.product-editor-dialog .prod-form-grid .d-flex {
    gap: 0.5rem !important;
}

.prod-merge-search {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.55rem;
}

.prod-merge-picks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    align-items: center;
    margin-bottom: 0.65rem;
    padding: 0.45rem 0.65rem;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.prod-merge-picks .ent-dialog__label {
    display: block;
    margin-bottom: 0.15rem;
}

.products-page .products-cmdbar {
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 0.55rem 0.85rem;
    align-items: center;
    padding: 0.55rem 0.75rem;
    border: 1px solid #c5d0de;
    border-radius: 10px;
    background: linear-gradient(180deg, #ffffff 0%, #eef3f8 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 3px rgba(3, 20, 46, 0.06);
}

.products-page .products-cmdbar__start,
.products-page .products-cmdbar__end {
    padding: 0.3rem 0.4rem;
    border-radius: 8px;
    background: rgba(3, 20, 46, 0.04);
    border: 1px solid rgba(15, 76, 117, 0.12);
}

.products-page .products-cmdbar__btn,
.products-page .products-cmdbar .ent-cmdbar__btn {
    background: #fff;
    border-color: #b8c7d8;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.products-page .products-cmdbar .ent-cmdbar__btn:hover:not(:disabled) {
    background: #e8f1f8;
    border-color: #0f4c75;
    color: #03142e;
}

.products-page .products-cmdbar .ent-cmdbar__btn--primary {
    background: linear-gradient(180deg, #0f4c75 0%, #03142e 100%);
    border-color: #03142e;
    color: #fff;
}

.products-page .products-cmdbar .ent-cmdbar__search {
    background: #fff;
    border-color: #b8c7d8;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.products-page .products-cmdbar__start,
.products-page .products-cmdbar__end {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.products-page .products-cmdbar__end {
    margin-left: auto;
}

.products-page .products-cmdbar .ent-cmdbar__group + .ent-cmdbar__group {
    border-left: none;
    padding-left: 0;
    margin-left: 0;
}

.products-page .products-cmdbar__search {
    flex: 0 0 260px;
    min-width: 200px;
    max-width: 280px;
}

.products-page .iffys-sf-grid-host {
    flex: 1 1 0;
    min-height: 0;
}

.products-page .iffys-sf-grid-host .e-grid .e-rowcell,
.products-page .iffys-sf-grid-host .e-grid .e-headercell {
    padding-top: 0.28rem !important;
    padding-bottom: 0.28rem !important;
}

/* Money / index cells — same type scale as Threshold; right-aligned */
.products-page .iffys-sf-grid-host .e-grid .e-rowcell .products-grid-num {
    display: block;
    width: 100%;
    text-align: right;
    font-size: 12px !important;
    font-weight: 700 !important;
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif !important;
    letter-spacing: 0 !important;
    white-space: nowrap !important;
}

.products-page .ent-table-host {
    border-radius: 6px;
    border-color: #9eb0c4;
}

.products-page .ent-table {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.products-page .ent-table thead th {
    background: #0f4c75;
    color: #fff;
    border-bottom: 1px solid #0a3552;
    font-size: var(--ent-font, 0.90rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: none;
    padding: 0.45rem 0.55rem;
}

.products-page .ent-table tbody td {
    font-size: var(--ent-font, 0.90rem);
    font-weight: 400;
    color: #1a1a1a;
    padding: 0.32rem 0.55rem;
    line-height: 1.3;
    border-bottom: 1px solid #e2e8f0;
}

.products-page .ent-table tbody tr:nth-child(even) {
    background: #f5f7fa;
}

.products-page .ent-table tbody tr:hover {
    background: #e8f1f8;
}

.products-page .ent-table tbody tr.is-selected {
    background: #d9eaf7;
}

.products-page .prod-desc-cell {
    font-weight: 600;
    color: #0f172a;
}

.products-page .prod-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.products-page .prod-sortable:hover {
    color: #dbeafe;
}

.products-page .prod-grid tbody tr {
    height: auto;
    min-height: 34px;
}

.products-page .prod-grid tbody td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 14rem;
    vertical-align: top;
}

.products-page .prod-grid tbody td.wrap,
.products-page .prod-grid tbody td.prod-desc-cell {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-overflow: unset;
    overflow: visible;
    max-width: 18rem;
}

.products-page .prod-grid tbody td.actions {
    max-width: none;
    overflow: visible;
}

@media (min-width: 1920px) {
    .products-page .ent-table thead th,
    .products-page .ent-table tbody td {
        font-size: var(--ent-font-lg, 1rem);
    }
}

.tablet-layout .products-page .ent-table thead th,
.tablet-layout .products-page .ent-table tbody td {
    font-size: var(--ent-font-tablet, 0.75rem);
}

@media (max-width: 1024px) {
    .products-page .ent-table thead th,
    .products-page .ent-table tbody td {
        font-size: var(--ent-font-tablet, 0.75rem);
    }

    .products-page__detail {
        grid-template-columns: 1fr;
    }
}

.mobile-layout .products-page .ent-table thead th,
.mobile-layout .products-page .ent-table tbody td {
    font-size: var(--ent-font-mobile, 0.65rem);
}

@media (max-width: 768px) {
    .products-page .ent-table thead th,
    .products-page .ent-table tbody td {
        font-size: var(--ent-font-mobile, 0.65rem);
    }
}
