/* Compras — densidad Odoo (RFQ / OC): limpio, azul SFE, sin chrome apilado */

.purchase-module-shell .sfe-module-shell__toolbar.purchase-odo-toolbar,
.purchase-odo-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    padding: 0 0 8px;
    border-bottom: 0;
}

.purchase-odo-toolbar__left {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.purchase-odo-toolbar .btn-primary {
    background: var(--sfe-primary, #007BFF);
    border-color: var(--sfe-primary, #007BFF);
    min-height: 32px;
    padding: 0 14px;
    font-size: .875rem;
}

.purchase-odo-toolbar .sfe-module-shell__toolbar-title {
    margin: 0 0 0 6px;
    color: var(--sfe-navy, #1e2b3c);
    font-size: 1.05rem;
    font-weight: 650;
}

.purchase-module-shell .data-table {
    font-size: .875rem;
}

.purchase-module-shell .data-table th,
.purchase-module-shell .data-table td {
    padding: 6px 10px;
}

.purchase-module-shell .list-view-table-wrap,
.purchase-module-shell .table-responsive {
    border-radius: 8px;
}

/* —— KPI RFQ: matriz Todos/Mi (paridad Odoo) + gauges —— */
.purchase-odo-kpi {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0;
    margin: 0 0 12px;
    padding: 0;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.purchase-odo-kpi__matrix {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.purchase-odo-kpi__row {
    display: flex;
    align-items: stretch;
    min-height: 52px;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
}

.purchase-odo-kpi__row:last-child {
    border-bottom: 0;
}

.purchase-odo-kpi__scope {
    display: flex;
    align-items: center;
    flex: 0 0 56px;
    padding: 6px 10px;
    border-right: 1px solid var(--gray-200, #e5e7eb);
    background: var(--gray-50, #f9fafb);
    color: var(--gray-600, #4b5563);
    text-decoration: none;
    font-size: .78rem;
    font-weight: 700;
}

.purchase-odo-kpi__scope:hover,
.purchase-odo-kpi__scope.is-active {
    color: var(--sfe-primary, #007BFF);
    background: rgba(0, 123, 255, .08);
}

.purchase-odo-kpi__scope-label {
    line-height: 1.2;
}

.purchase-odo-kpi__card {
    flex: 1 1 90px;
    min-width: 88px;
    padding: 8px 12px;
    border-right: 1px solid var(--gray-200, #e5e7eb);
    text-decoration: none;
    color: inherit;
    background: #fff;
    transition: background .12s ease, box-shadow .12s ease;
}

a.purchase-odo-kpi__card:hover,
.purchase-odo-kpi__card.is-active {
    background: var(--gray-50, #f9fafb);
    box-shadow: inset 0 -2px 0 var(--sfe-primary, #007BFF);
}

.purchase-odo-kpi__card:last-child {
    border-right: 0;
}

.purchase-odo-kpi__card--info {
    background: #e8f4fc;
}

.purchase-odo-kpi__card--warning {
    background: #f8f1e3;
}

.purchase-odo-kpi__card--cyan {
    background: #e8f7f6;
}

.purchase-odo-kpi__card--danger {
    background: #fce8eb;
}

.purchase-odo-kpi__value {
    display: block;
    color: var(--sfe-navy, #1e2b3c);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.purchase-odo-kpi__label {
    display: block;
    margin-top: 2px;
    color: var(--gray-500, #6b7280);
    font-size: .7rem;
    line-height: 1.25;
}

.purchase-odo-kpi__gauges {
    display: flex;
    flex: 0 0 220px;
    border-left: 1px solid var(--gray-200, #e5e7eb);
}

.purchase-odo-kpi__gauges .purchase-odo-kpi__card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1 1 50%;
    border-right: 1px solid var(--gray-200, #e5e7eb);
}

.purchase-odo-kpi__gauges .purchase-odo-kpi__card:last-child {
    border-right: 0;
}

.purchase-odo-kpi__card--gauge .purchase-odo-kpi__value {
    color: var(--sfe-primary, #007BFF);
}

.purchase-odo-kpi__bar {
    display: block;
    margin-top: 6px;
    height: 4px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--sfe-primary, #007BFF) 18%, #e5e7eb);
    position: relative;
    overflow: hidden;
}

.purchase-odo-kpi__bar::after {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: calc(var(--pct, 0) * 1%);
    background: var(--sfe-primary, #007BFF);
    border-radius: inherit;
}

/* legacy wrap (por si queda markup viejo) */
.purchase-odo-kpi-wrap {
    margin: 0 0 10px;
    border: 0;
    background: transparent;
}

.purchase-odo-kpi-wrap > summary {
    display: none;
}

.purchase-odo-kpi__scope-btn {
    display: none;
}

/* —— Control panel Odoo (1 fila L→R) —— */
.purchase-module-shell .sfe-collection-chrome--cp,
.purchase-module-shell .sfe-collection-chrome {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0 0 10px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.purchase-module-shell .sfe-collection-chrome__cp-row {
    display: grid;
    grid-template-columns:
        auto
        auto
        auto
        minmax(140px, 1fr)
        auto;
    align-items: center;
    gap: 10px 12px;
    width: 100%;
    min-height: 40px;
}

.purchase-module-shell .sfe-cp__actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.purchase-module-shell .sfe-cp__actions .btn {
    min-height: 32px;
    padding: 0 14px;
    font-size: .875rem;
}

.purchase-module-shell .sfe-cp__actions .btn-primary {
    background: var(--sfe-primary, #007BFF);
    border-color: var(--sfe-primary, #007BFF);
}

.purchase-module-shell .sfe-cp__title {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    white-space: nowrap;
}

.purchase-module-shell .sfe-cp__title-text {
    margin: 0;
    color: var(--sfe-navy, #1e2b3c);
    font-size: 1.05rem;
    font-weight: 650;
    line-height: 1.2;
}

.purchase-module-shell .sfe-cp__gear .o_cp_gear_btn,
.purchase-module-shell .sfe-cp__gear .sfe-collection-view-gear-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--gray-600, #4b5563);
    cursor: pointer;
}

.purchase-module-shell .sfe-cp__gear .o_cp_gear_btn:hover,
.purchase-module-shell .sfe-cp__gear .sfe-collection-view-gear-btn:hover {
    background: var(--gray-100, #f3f4f6);
    color: var(--sfe-navy, #1e2b3c);
}

.purchase-module-shell .sfe-cp__views {
    flex: 0 0 auto;
}

.purchase-module-shell .sfe-cp-view-switcher,
.purchase-module-shell .sfe-collection-chrome--cp .kanban-view-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 6px;
    background: #fff;
}

.purchase-module-shell .sfe-cp-view-switch,
.purchase-module-shell .sfe-collection-chrome--cp .kanban-switch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 4px;
    color: var(--gray-600, #4b5563);
    text-decoration: none;
}

.purchase-module-shell .sfe-cp-view-switch .icon,
.purchase-module-shell .sfe-collection-chrome--cp .kanban-switch .icon {
    width: 16px;
    height: 16px;
}

.purchase-module-shell .sfe-cp-view-switch.is-active,
.purchase-module-shell .sfe-collection-chrome--cp .kanban-switch.is-active {
    background: color-mix(in srgb, var(--sfe-primary, #007BFF) 14%, white);
    color: var(--sfe-primary, #007BFF);
}

.purchase-module-shell .sfe-cp__search {
    min-width: 0;
    width: 100%;
}

.purchase-module-shell .sfe-cp__search .sfe-collection-chrome__row--search,
.purchase-module-shell .sfe-cp__search .web-list-search-form {
    display: flex;
    align-items: center;
    width: 100%;
    margin: 0;
}

.purchase-module-shell .sfe-cp__search .web-list-search-bar,
.purchase-module-shell .sfe-cp__search .o_apps_search.web-list-search-bar {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
}

.purchase-module-shell .sfe-cp__pager {
    flex: 0 0 auto;
    justify-self: end;
}

.purchase-module-shell .sfe-cp-pager,
.purchase-module-shell .o_apps_pager.sfe-cp-pager {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    color: var(--gray-600, #4b5563);
    font-size: .8125rem;
    font-variant-numeric: tabular-nums;
}

.purchase-module-shell .o_apps_pager_nav {
    display: inline-flex;
    gap: 2px;
}

.purchase-module-shell .o_apps_pager_btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 4px;
    background: #fff;
    color: var(--gray-600, #4b5563);
}

.purchase-module-shell .o_apps_pager_btn:disabled {
    opacity: .45;
    cursor: default;
}

/* Con CP Odoo: ocultar toolbar shell duplicado si quedara */
.purchase-module-shell:has([data-sfe-cp-row]) > .sfe-module-shell__body > .sfe-module-shell__toolbar.purchase-odo-toolbar,
.purchase-module-shell:has([data-sfe-cp-row]) .sfe-module-shell__body > .purchase-odo-toolbar {
    display: none !important;
}

.purchase-module-shell .sfe-collection-chrome__row--search,
.purchase-module-shell .web-list-search .sfe-collection-chrome__row--search {
    display: flex;
    align-items: center;
    gap: 8px;
}

.purchase-module-shell .web-list-search-bar,
.purchase-module-shell .o_apps_search.web-list-search-bar {
    flex: 1 1 auto;
    min-width: 0;
}

/* Chips de estado: ocultos en listas CP Compras (RFQ=KPI; PO/contratos/proveedores=engrane). */
.purchase-module-shell .sfe-collection-chrome__row--filters,
.purchase-module-shell[data-purchase-active-nav="rfq"] .sfe-collection-chrome__row--filters,
.purchase-module-shell[data-purchase-active-nav="orders"] .sfe-collection-chrome__row--filters,
.purchase-module-shell[data-purchase-active-nav="contracts"] .sfe-collection-chrome__row--filters,
.purchase-module-shell[data-purchase-active-nav="vendors"] .sfe-collection-chrome__row--filters,
.purchase-module-shell .web-list-search-chips:empty,
.purchase-module-shell .sfe-collection-chrome--cp .sfe-collection-chrome__row--filters {
    display: none !important;
}

.purchase-module-shell .sfe-collection-chrome__row--actions:empty,
.purchase-module-shell .web-list-search-toolbar-end:empty {
    display: none;
}

.purchase-module-shell .sfe-collection-chrome__row--actions .sfe-search-panel-toggle,
.purchase-module-shell .sfe-collection-chrome__row--actions .web-list-search-drawer {
    display: none;
}

@media (max-width: 1100px) {
    .purchase-module-shell .sfe-collection-chrome__cp-row {
        grid-template-columns: auto auto 1fr auto;
        grid-template-areas:
            "actions title pager pager"
            "views search search search";
    }

    .purchase-module-shell .sfe-cp__actions { grid-area: actions; }
    .purchase-module-shell .sfe-cp__title { grid-area: title; }
    .purchase-module-shell .sfe-cp__views { grid-area: views; }
    .purchase-module-shell .sfe-cp__search { grid-area: search; }
    .purchase-module-shell .sfe-cp__pager { grid-area: pager; }
}


/* Tools secundarios: una sola línea compacta, no fila dominante */
.purchase-module-shell .sfe-doc-list-chrome {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0 0 8px;
    min-height: 0;
}

.purchase-module-shell .sfe-doc-list-chrome:empty {
    display: none;
}

.purchase-module-shell .sfe-doc-cols__toggle {
    min-height: 28px;
    padding: 2px 10px;
    font-size: .78rem;
}

/* Odoo RFQ no muestra Vista dividida / Guardar vista */
.purchase-module-shell .sfe-split-toggle,
.purchase-module-shell [data-sfe-split-toggle],
.purchase-module-shell [data-sfe-save-view],
.purchase-module-shell #sfe-facet-chips,
.purchase-module-shell .sfe-facet-chips,
.purchase-module-shell [data-sfe-facet-chips],
.purchase-module-shell [data-sfe-last-view],
.purchase-module-shell .sfe-last-view-chip,
.purchase-module-shell .sfe-list-last-view {
    display: none !important;
}

/* Bulk Odoo: solo con selección */
.purchase-module-shell .sfe-odo-selection-bar,
.sfe-odo-selection-bar {
    display: none;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    width: 100%;
    margin: 0 0 10px;
    padding: 8px 12px;
    border: 1px solid color-mix(in srgb, var(--sfe-primary, #007BFF) 22%, #e5e7eb);
    border-radius: 8px;
    background: color-mix(in srgb, var(--sfe-primary, #007BFF) 6%, #fff);
}

.purchase-module-shell .sfe-odo-selection-bar:not([hidden]),
.sfe-odo-selection-bar:not([hidden]) {
    display: flex;
}

.purchase-module-shell .sfe-odo-selection-bar[hidden],
.sfe-odo-selection-bar[hidden] {
    display: none !important;
}

.purchase-module-shell .sfe-odo-selection-bar__clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--gray-600, #4b5563);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.purchase-module-shell .sfe-odo-selection-bar__primary .btn-primary {
    background: var(--sfe-primary, #007BFF);
    border-color: var(--sfe-primary, #007BFF);
}

.purchase-module-shell .sfe-doc-list-view.has-odo-selection .purchase-odo-toolbar,
.purchase-module-shell .sfe-doc-list-view.has-odo-selection .sfe-cp__actions {
    opacity: .45;
    pointer-events: none;
}

.purchase-module-shell .sfe-doc-list-view.has-odo-selection tbody tr:has(input[type=checkbox]:checked) {
    background: color-mix(in srgb, var(--sfe-primary, #007BFF) 8%, white);
}

/* Empty state limpio */
.purchase-module-shell .list-view-wrap {
    position: relative;
}

.purchase-module-shell .list-empty-banner {
    position: absolute;
    inset: 48px 12px 12px;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    pointer-events: none;
}

.purchase-module-shell .list-empty-banner .sfe-empty-state,
.purchase-module-shell .list-empty-banner .sfe-doc-empty {
    pointer-events: auto;
    max-width: 520px;
    padding: 28px 24px;
    border: 0;
    background: transparent;
    box-shadow: none;
    text-align: center;
}

.purchase-module-shell .list-view-table-wrap.is-empty {
    opacity: .22;
    filter: saturate(.7);
    min-height: 320px;
    pointer-events: none;
}

.purchase-module-shell .sfe-empty-state__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--sfe-primary, #007BFF) 14%, white);
    color: var(--sfe-primary, #007BFF);
}

.purchase-module-shell .sfe-empty-state__title {
    color: var(--sfe-navy, #1e2b3c);
    font-size: 1.15rem;
    font-weight: 700;
}

.purchase-module-shell .sfe-empty-state__hint {
    color: var(--gray-500, #6b7280);
    font-size: .9rem;
}

.purchase-module-shell .sfe-empty-state__actions .btn-primary {
    background: var(--sfe-primary, #007BFF);
    border-color: var(--sfe-primary, #007BFF);
}

/* —— Lista: totales, fechas relativas, actividades —— */
.sfe-list-totals {
    background: var(--gray-50, #f9fafb);
    border-top: 2px solid var(--gray-200, #e5e7eb);
}

.sfe-list-totals__cell {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.sfe-list-date.is-overdue {
    color: var(--sfe-danger, #dc3545);
    font-weight: 600;
}

.sfe-list-activity {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: var(--sfe-primary, #007BFF);
    text-decoration: none;
}

.sfe-list-activity:hover {
    background: rgba(0, 123, 255, .1);
}

.sfe-list-activity.is-overdue {
    color: var(--sfe-danger, #dc3545);
}

.sfe-list-activity--empty {
    color: var(--gray-400, #9ca3af);
}

.sfe-list-activity .icon {
    width: 16px;
    height: 16px;
}

/* —— Análisis de compras —— */
.purchase-analysis__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.purchase-analysis__ranges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.purchase-analysis__kpis {
    margin: 12px 0 16px;
}

.purchase-analysis__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.purchase-analysis__panel h3 {
    margin: 0 0 10px;
    font-size: 1rem;
}

/* Split preview: no robar 25% en vacío (JS default OFF; CSS refuerzo) */
.purchase-module-shell .sfe-split-layout:not(.is-split) .sfe-split-preview,
.purchase-module-shell .sfe-split-layout:not(.is-split) [data-sfe-split-pane] {
    display: none !important;
}

.purchase-module-shell .sfe-split-layout:not(.is-split) .sfe-split-layout__list {
    width: 100%;
    max-width: 100%;
}

@media (max-width: 900px) {
    .purchase-odo-kpi {
        flex-direction: column;
    }

    .purchase-odo-kpi__gauges {
        flex: 1 1 auto;
        border-left: 0;
        border-top: 1px solid var(--gray-200, #e5e7eb);
    }

    .purchase-odo-kpi__card {
        flex: 1 1 40%;
        border-right: 0;
        border-bottom: 1px solid var(--gray-200, #e5e7eb);
    }
}


/* —— Apps header menus (Odoo: Compras + Órdenes/Productos/Reportes/Configuración) —— */
.o_apps_navbar .o_apps_navbar_menus {
    display: inline-flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    margin-left: 12px;
}

.o_apps_navbar .purchase-module-nav.purchase-module-nav--odoo-menus {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px 4px;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.o_apps_navbar .purchase-module-nav.purchase-module-nav--odoo-menus .discuss-module-nav-item,
.o_apps_navbar .purchase-module-nav.purchase-module-nav--odoo-menus .discuss-module-nav-group-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 28px;
    padding: 4px 10px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font-size: .875rem;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    box-shadow: none;
}

.o_apps_navbar .purchase-module-nav.purchase-module-nav--odoo-menus .discuss-module-nav-item.is-active,
.o_apps_navbar .purchase-module-nav.purchase-module-nav--odoo-menus .discuss-module-nav-group-toggle.is-active {
    background: color-mix(in srgb, var(--sfe-primary, #007BFF) 12%, transparent);
    color: var(--sfe-primary, #007BFF);
    font-weight: 600;
}

.o_apps_navbar .purchase-module-nav.purchase-module-nav--odoo-menus .discuss-module-nav-group-wrap {
    position: relative;
}

.o_apps_navbar .purchase-module-nav.purchase-module-nav--odoo-menus .sfe-config-dropdown-wrap,
.o_apps_navbar .purchase-module-nav.purchase-module-nav--odoo-menus .discuss-module-nav-config-wrap,
.o_apps_navbar .purchase-module-nav.purchase-module-nav--odoo-menus .purchase-module-nav-config-group {
    margin-left: 0;
}

.o_apps_navbar .o_breadcrumb_app,
.o_apps_navbar .o_breadcrumb_current.o_breadcrumb_page {
    font-weight: 700;
    font-size: 1rem;
}

/* Shell ya no lleva nav pills de Compras (viven en apps header). */
.purchase-module-shell > .purchase-module-nav {
    display: none !important;
}
