/*
 * Inventory module - owner-facing /inventory page styles.
 *
 * Scope rule (locked 2026-04-28): this module is owner-only.
 * Nothing here may be referenced by /my-tags or /create-tags markup.
 *
 * Token-only values: every color / spacing / font reference must resolve
 * through a CSS variable. Hard-coded hex values are forbidden - use the
 * --jbf-*, --rz-*, or module-local --inv-* tokens.
 */

/* ----------------------------------------------------------------------
 * Module token palette
 * --------------------------------------------------------------------*/

.inv-page {
    --inv-purple: var(--jbf-plum, #7d5b81);
    --inv-purple-dark: var(--rz-primary-darker, #58405b);
    --inv-border: var(--cum-border, #e6e8e9);
    --inv-muted: var(--cum-muted-foreground, #808c91);
    --inv-surface: var(--cum-secondary, #f6f5f8);
    --inv-text-primary: var(--rz-text-primary, #2a2a2a);
    --inv-success-bg: var(--jbf-status-success-bg);
    --inv-success-fg: var(--jbf-status-success-fg);
    --inv-warn-bg: var(--jbf-status-warning-bg);
    --inv-warn-fg: var(--jbf-status-warning-fg);
    --inv-danger-bg: var(--jbf-status-danger-bg);
    --inv-danger-fg: var(--jbf-status-danger-fg);
    --inv-radius-sm: 6px;
    --inv-radius-md: 10px;
    --inv-shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
}

/* When hosted under .jbf-page admin shell, prefer shared admin tokens */
.inv-page.jbf-page {
    --inv-purple: var(--cum-primary, #7d5b81);
    --inv-border: var(--cum-border, #e6e8e9);
    --inv-muted: var(--cum-muted-foreground, #808c91);
    --inv-surface: var(--cum-secondary, #f6f5f8);
}

/* ----------------------------------------------------------------------
 * Page chrome
 * --------------------------------------------------------------------*/

.inv-page .inv-page-title {
    margin: 0 0 4px 0;
    font-size: 1.5rem;
    color: var(--inv-text-primary);
}

.inv-page .inv-page-subtitle {
    margin: 0 0 16px 0;
    font-size: 0.875rem;
    color: var(--inv-muted);
}

.inv-page .inv-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 8px 0 16px;
    border-bottom: 1px solid var(--inv-border);
    margin-bottom: 16px;
}

.inv-page .inv-toolbar-spacer { flex: 1 1 auto; }

/* ----------------------------------------------------------------------
 * Tabs (HorizontalStrip variant - by-category / by-size / by-age / by-group)
 * --------------------------------------------------------------------*/

.inv-page .inv-tabs-strip {
    padding-left: 32px;
    padding-right: 32px;
}

.inv-page .inv-tab-pane {
    padding: 16px 0;
}

/* ----------------------------------------------------------------------
 * Filter bar (consignor / group / paid / created-range / no-show)
 * --------------------------------------------------------------------*/

.inv-page .inv-filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    padding: 12px 16px;
    background: var(--inv-surface);
    border: 1px solid var(--inv-border);
    border-radius: var(--inv-radius-md);
    margin-bottom: 12px;
}

.inv-page .inv-filter-bar-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--inv-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

/* ----------------------------------------------------------------------
 * Rollup grid (7 value-weighted columns)
 * --------------------------------------------------------------------*/

.inv-page .inv-rollup-grid {
    width: 100%;
    border-collapse: collapse;
    background: var(--rz-base, #fff);
    border: 1px solid var(--inv-border);
    border-radius: var(--inv-radius-md);
    overflow: hidden;
    box-shadow: var(--inv-shadow-sm);
}

.inv-page .inv-rollup-grid thead th {
    text-align: left;
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--inv-muted);
    background: var(--inv-surface);
    border-bottom: 1px solid var(--inv-border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.inv-page .inv-rollup-grid thead th[aria-sort="ascending"]::after { content: " \2191"; opacity: .8; }
.inv-page .inv-rollup-grid thead th[aria-sort="descending"]::after { content: " \2193"; opacity: .8; }

.inv-page .inv-rollup-grid tbody td {
    padding: 10px 14px;
    font-size: 0.875rem;
    color: var(--inv-text-primary);
    border-bottom: 1px solid var(--inv-border);
    vertical-align: top;
}

.inv-page .inv-rollup-grid tbody tr:last-child td { border-bottom: 0; }

.inv-page .inv-rollup-grid tbody tr:hover td { background: var(--inv-surface); cursor: pointer; }

.inv-page .inv-rollup-grid tbody tr.inv-row-selected td {
    background: var(--inv-surface);
    box-shadow: inset 3px 0 0 var(--inv-purple);
}

.inv-page .inv-rollup-grid .inv-cell-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.inv-page .inv-rollup-grid .inv-cell-sub {
    display: block;
    font-size: 0.75rem;
    color: var(--inv-muted);
}

/* ----------------------------------------------------------------------
 * Empty state - owner-facing fallback used by tabs and analysis tools
 * --------------------------------------------------------------------*/

.inv-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 8px;
    text-align: center;
}

.inv-empty-icon {
    opacity: 0.85;
    margin-bottom: 4px;
}

.inv-empty-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--jbf-plum, #7d5b81);
    margin: 0;
}

.inv-empty-subtitle {
    font-size: 0.8125rem;
    color: var(--rz-text-secondary-color, #808c91);
    max-width: 420px;
    margin: 0;
}

.inv-empty-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.inv-empty-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--inv-radius-sm, 6px);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.inv-empty-btn--primary {
    background: var(--jbf-plum, #7d5b81);
    color: var(--rz-base, #fff);
    border-color: var(--jbf-plum, #7d5b81);
}

.inv-empty-btn--primary:hover {
    background: var(--rz-primary-darker, #58405b);
    border-color: var(--rz-primary-darker, #58405b);
}

.inv-empty-btn--ghost {
    background: transparent;
    color: var(--jbf-plum, #7d5b81);
    border-color: var(--jbf-plum, #7d5b81);
}

.inv-empty-btn--ghost:hover {
    background: var(--cum-secondary, #f6f5f8);
}

/* ----------------------------------------------------------------------
 * Analysis modal - left-rail tool registry + right-pane DynamicComponent
 *
 * Full-screen variant mirrors `.jbf-event-checklist-fullscreen` and
 * `.jbf-team-schedule-builder-fullscreen` so the Inventory Analysis modal
 * shares the same titlebar + viewport-fill behavior as the Event Checklist
 * and Team Scheduling builder modals.
 * --------------------------------------------------------------------*/

.jbf-inventory-analysis-fullscreen.rz-dialog-wrapper {
    align-items: stretch !important;
    justify-content: stretch !important;
    padding: 0 !important;
}

.jbf-inventory-analysis-fullscreen .rz-dialog {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

.jbf-inventory-analysis-fullscreen .rz-dialog-titlebar {
    flex-shrink: 0;
}

.jbf-inventory-analysis-fullscreen .rz-dialog-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 !important;
}

.jbf-inventory-analysis-fullscreen .inv-analysis-shell {
    flex: 1 1 0;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.jbf-inventory-analysis-fullscreen .inv-analysis-shell > .eem-checklist-dialog-titlebar {
    flex-shrink: 0;
}

.jbf-inventory-analysis-fullscreen .inv-analysis-shell > .inv-analysis-modal {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}

.inv-analysis-modal {
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr;
    gap: 0;
    height: 100%;
}

.inv-analysis-rail {
    border-right: 1px solid var(--inv-border, #e6e8e9);
    background: var(--inv-surface, #f6f5f8);
    overflow-y: auto;
    padding: 12px 0;
}

.inv-analysis-rail-section {
    padding: 6px 16px 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--inv-muted, #808c91);
    margin-top: 12px;
}

.inv-analysis-rail-section:first-child { margin-top: 0; }

.inv-analysis-rail-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 0.875rem;
    color: var(--inv-text-primary, #2a2a2a);
    cursor: pointer;
    border: 0;
    background: transparent;
    width: 100%;
    text-align: left;
}

.inv-analysis-rail-item:hover {
    background: var(--rz-base, #fff);
}

.inv-analysis-rail-item.inv-rail-active {
    background: var(--rz-base, #fff);
    box-shadow: inset 3px 0 0 var(--jbf-plum, #7d5b81);
    font-weight: 600;
    color: var(--jbf-plum, #7d5b81);
}

.inv-analysis-rail-item[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

.inv-analysis-pane {
    overflow: auto;
    padding: 20px 24px;
    background: var(--rz-base, #fff);
}

.inv-analysis-pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.inv-analysis-pane-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--inv-text-primary, #2a2a2a);
}

/* ----------------------------------------------------------------------
 * Tool action buttons - Lost / Found / NTY / Export
 * --------------------------------------------------------------------*/

.inv-tool-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}

.inv-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--inv-radius-sm, 6px);
    border: 1px solid var(--inv-border, #e6e8e9);
    background: var(--rz-base, #fff);
    color: var(--inv-text-primary, #2a2a2a);
    cursor: pointer;
}

.inv-action-btn:hover { background: var(--inv-surface, #f6f5f8); }

.inv-action-btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ----------------------------------------------------------------------
 * Drill-down preview panel
 * --------------------------------------------------------------------*/

.inv-page .inv-preview {
    margin-top: 16px;
    padding: 16px;
    background: var(--rz-base, #fff);
    border: 1px solid var(--inv-border, #e6e8e9);
    border-radius: var(--inv-radius-md, 10px);
    box-shadow: var(--inv-shadow-sm, 0 1px 2px rgba(0,0,0,0.04));
}

.inv-page .inv-preview-title {
    margin: 0 0 8px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--inv-text-primary, #2a2a2a);
}

.inv-page .inv-preview-meta {
    font-size: 0.75rem;
    color: var(--inv-muted, #808c91);
    margin-bottom: 8px;
}

/* ---- PR 3: Inventory cube rollup grid status bar -------------------- */

.inv-rollup-grid-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inv-rollup-status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.8125rem;
    color: #374151;
}

.inv-rollup-status-bar .inv-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 999px;
    font-weight: 500;
}

.inv-rollup-status-bar .inv-status-pill-sub {
    font-weight: 400;
    opacity: 0.85;
}

.inv-rollup-status-bar .inv-status-stale  { background: #fef3c7; color: #92400e; }
.inv-rollup-status-bar .inv-status-fresh  { background: #dcfce7; color: #166534; }
.inv-rollup-status-bar .inv-status-limits { background: #ede9fe; color: #6d28d9; }
.inv-rollup-status-bar .inv-status-live   { background: #dbeafe; color: #1e40af; }
.inv-rollup-status-bar .inv-status-no-drill { background: #f3f4f6; color: #374151; }

.inv-rollup-status-bar .inv-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.7;
}

.inv-rollup-status-bar .inv-status-spacer {
    flex: 1 1 auto;
}

.inv-rollup-status-bar .inv-refresh-btn {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #1f2937;
    cursor: pointer;
}

.inv-rollup-status-bar .inv-refresh-btn:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.inv-rollup-status-bar .inv-refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Empty / loading rows inside the table body. */
.inv-rollup-grid tr.inv-row-empty td,
.inv-rollup-grid tr.inv-row-loading td {
    text-align: center;
    padding: 32px 16px;
    color: #6b7280;
    background: #fafafa;
}

.inv-rollup-grid tr.inv-row-empty .inv-row-empty-title {
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}

.inv-rollup-grid tr.inv-row-empty .inv-row-empty-sub {
    font-size: 0.875rem;
}

/* Drill-through affordance - only clickable rows show pointer / hover. */
.inv-rollup-grid tr.inv-row-clickable { cursor: pointer; }
.inv-rollup-grid tr.inv-row-clickable:hover { background: #f9fafb; }
.inv-rollup-grid tr.inv-row-static { cursor: default; }

/* PR 3 filter bar - scope mode picker + age cohort + cap toggle ------- */
.inv-filter-bar-segmented {
    display: inline-flex;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
}

.inv-filter-bar-segmented button {
    padding: 4px 10px;
    background: #ffffff;
    border: none;
    border-right: 1px solid #d1d5db;
    cursor: pointer;
    font-size: 0.8125rem;
    color: #374151;
}

.inv-filter-bar-segmented button:last-child { border-right: none; }
.inv-filter-bar-segmented button:hover     { background: #f9fafb; }
.inv-filter-bar-segmented button.is-active {
    background: #1f2937;
    color: #ffffff;
}

.inv-filter-bar-cap-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
}

.inv-filter-bar-cap-toggle .inv-cap-msg {
    color: #92400e;
    font-style: italic;
}

/* ----------------------------------------------------------------------
 * PR 4: Top Consignors right-preview panel
 * Hosted inside the .gmd-preview-col so the panel inherits the master
 * preview-pane width and container-query context.
 * --------------------------------------------------------------------*/

.inv-top-consignors {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    height: 100%;
    box-sizing: border-box;
}

.inv-top-consignors-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--inv-border, #e6e8e9);
}

.inv-top-consignors-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--inv-text-primary, #2a2a2a);
}

.inv-top-consignors-subtitle {
    font-size: 0.75rem;
    color: var(--inv-muted, #808c91);
}

.inv-top-consignors-empty {
    padding: 24px 8px;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--inv-muted, #808c91);
}

.inv-top-consignors-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.inv-top-consignors-row {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    align-items: baseline;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--inv-border, #e6e8e9);
    border-radius: var(--inv-radius-sm, 6px);
    background: var(--rz-base, #fff);
}

.inv-top-consignors-rank {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--inv-muted, #808c91);
    text-align: right;
}

.inv-top-consignors-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--inv-text-primary, #2a2a2a);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inv-top-consignors-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    grid-column: 3;
}

.inv-top-consignors-total {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--inv-text-primary, #2a2a2a);
}

.inv-top-consignors-counts {
    font-size: 0.75rem;
    color: var(--inv-muted, #808c91);
}

/* When the preview pane is narrow, drop dollars/counts onto a second line. */
@container gmdpreview (max-width: 360px) {
    .inv-top-consignors-row {
        grid-template-columns: 24px 1fr;
    }
    .inv-top-consignors-stats {
        grid-column: 2;
        align-items: flex-start;
    }
}

.inv-top-consignors-ai {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--inv-border, #e6e8e9);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.inv-top-consignors-ai-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--inv-text-primary, #2a2a2a);
}

.inv-top-consignors-ai-placeholder {
    font-size: 0.75rem;
    color: var(--inv-muted, #808c91);
    font-style: italic;
}
