/**
 * Chip contrast plus opt-in soft business-status chips.
 * Default, outlined, text, and success contrast moved here from app.css.
 * Filled primary, info, warning, and error chips stay on the MudBlazor palette.
 * Soft status rules below still win for .pm-status-chip--soft.
 */
/* ========================================================================
   Chips - Flat Design with Borders
   ======================================================================== */

/* Filled chips keep MudBlazor's palette background. This rule is for default, outlined, and text chips. */
.mud-chip:not(.mud-chip-filled) {
    border: 1px solid var(--mud-palette-divider) !important;
    border-radius: 6px !important;
    background: var(--mud-palette-surface) !important;
    font-weight: 500 !important;
    padding: 0.375rem 0.75rem !important;
    color: var(--mud-palette-text-primary) !important;
}

/* Colored chips (Outlined variant) - dark text on transparent/light background for better contrast */
.mud-chip.mud-chip-outlined.mud-chip-color-primary,
.mud-chip.mud-chip-outlined.mud-chip-color-secondary,
.mud-chip.mud-chip-outlined.mud-chip-color-success,
.mud-chip.mud-chip-outlined.mud-chip-color-info,
.mud-chip.mud-chip-outlined.mud-chip-color-warning,
.mud-chip.mud-chip-outlined.mud-chip-color-error {
    color: var(--mud-palette-text-primary) !important; /* Dark text for better contrast on light backgrounds */
    background: transparent !important;
}

/* Colored chips (Text variant) - dark text, no background */
.mud-chip.mud-chip-text.mud-chip-color-primary,
.mud-chip.mud-chip-text.mud-chip-color-secondary,
.mud-chip.mud-chip-text.mud-chip-color-success,
.mud-chip.mud-chip-text.mud-chip-color-info,
.mud-chip.mud-chip-text.mud-chip-color-warning,
.mud-chip.mud-chip-text.mud-chip-color-error {
    color: var(--mud-palette-text-primary) !important; /* Dark text for better contrast */
    background: transparent !important;
    border: none !important;
}

/* Filter chips should always have readable text - override for default color */
.active-filter-chips-bar .mud-chip.mud-chip-color-default {
    color: var(--mud-palette-text-primary) !important;
    background: var(--mud-palette-surface) !important;
    border-color: var(--mud-palette-divider) !important;
}

/* Default color chips - always dark text on light background */
/* CRITICAL: MudBlazor applies inline styles, so we need !important to override */
.mud-chip.mud-chip-color-default {
    color: var(--mud-palette-text-primary) !important; /* Dark text on light default chips */
    background: var(--mud-palette-surface) !important; /* Ensure light background for contrast */
}

/* Default color chips - Outlined variant - dark text on transparent background */
.mud-chip.mud-chip-color-default.mud-chip-outlined {
    color: var(--mud-palette-text-primary) !important; /* Dark text for outlined default chips */
    background: transparent !important;
}

/* Default color chips - Text variant - dark text, no background */
.mud-chip.mud-chip-color-default.mud-chip-text {
    color: var(--mud-palette-text-primary) !important; /* Dark text for text variant default chips */
    background: transparent !important;
    border: none !important;
}

/* Default color chips - Filled variant - dark text on light background */
.mud-chip.mud-chip-color-default.mud-chip-filled {
    color: var(--mud-palette-text-primary) !important; /* Dark text on filled default chips */
    background: var(--mud-palette-surface) !important; /* Light background for contrast */
}

/* Ensure chip content (text and icons) have proper color inheritance */
.mud-chip .mud-chip-content,
.mud-chip .mud-chip-icon {
    color: inherit !important;
}

/* ========================================================================
   Chip contrast fix: light mode - force dark text on default/outlined/text chips
   ROOT CAUSE: MudBlazor (or theme) can apply styles that yield light text
   on light backgrounds. MudBlazor may also render chip label inside
   .mud-typography or other wrappers that get their own color. Ensure
   default, outlined, and text chips always have dark text when the app
   is in light mode (body without .theme-dark).
   ======================================================================== */
body:not(.theme-dark) .mud-chip.mud-chip-color-default,
body:not(.theme-dark) .mud-chip.mud-chip-color-default .mud-chip-content,
body:not(.theme-dark) .mud-chip.mud-chip-color-default .mud-chip-icon,
body:not(.theme-dark) .mud-chip.mud-chip-outlined,
body:not(.theme-dark) .mud-chip.mud-chip-outlined .mud-chip-content,
body:not(.theme-dark) .mud-chip.mud-chip-outlined .mud-chip-icon,
body:not(.theme-dark) .mud-chip.mud-chip-text,
body:not(.theme-dark) .mud-chip.mud-chip-text .mud-chip-content,
body:not(.theme-dark) .mud-chip.mud-chip-text .mud-chip-icon {
    color: #1e293b !important; /* Explicit dark text (Theme light TextPrimary) for readability on white/light */
}

/* Force all descendants of light chips to inherit chip color (overrides MudBlazor typography/span colors) */
body:not(.theme-dark) .mud-chip.mud-chip-color-default *,
body:not(.theme-dark) .mud-chip.mud-chip-outlined *,
body:not(.theme-dark) .mud-chip.mud-chip-text * {
    color: inherit !important;
}

/* Panel count chips (Notes count, etc.) - same fix when in light mode */
body:not(.theme-dark) .panel-count-chip,
body:not(.theme-dark) .panel-count-chip .mud-chip-content,
body:not(.theme-dark) .panel-count-chip .mud-chip-icon {
    color: #1e293b !important;
}
body:not(.theme-dark) .panel-count-chip * {
    color: inherit !important;
}

/* REMOVED: @media (prefers-color-scheme: dark) chip block.
   Chip contrast must follow app theme (body.theme-dark / body.theme-light), not system
   preference. That block caused light text on light background when system was dark and app
   was light. Chip styling is handled by body.theme-dark and body:not(.theme-dark) rules above. */

/* Success chip styling (green accent) - theme-aware for readable contrast.
   Soft status chips (.pm-status-chip--soft / .entity-view-header-status-chip)
   are excluded — they use pale semantic fills; painting success onto
   .mud-chip-content caused a nested dark-green rectangle inside Active chips. */
body:not(.theme-dark) .mud-chip.mud-chip-color-success:not(.pm-status-chip--soft):not(.entity-view-header-status-chip),
body:not(.theme-dark) .mud-chip.mud-chip-color-success:not(.pm-status-chip--soft):not(.entity-view-header-status-chip) .mud-chip-content,
body:not(.theme-dark) .mud-chip.mud-chip-color-success:not(.pm-status-chip--soft):not(.entity-view-header-status-chip) .mud-chip-icon {
    background: var(--mud-palette-success) !important;
    color: #ffffff !important;
    font-weight: 500 !important;
}
body.theme-dark .mud-chip.mud-chip-color-success:not(.pm-status-chip--soft):not(.entity-view-header-status-chip),
body.theme-dark .mud-chip.mud-chip-color-success:not(.pm-status-chip--soft):not(.entity-view-header-status-chip) .mud-chip-content,
body.theme-dark .mud-chip.mud-chip-color-success:not(.pm-status-chip--soft):not(.entity-view-header-status-chip) .mud-chip-icon {
    background: var(--mud-palette-success) !important;
    color: #ffffff !important;
    font-weight: 500 !important;
}

/*
 * Soft business-status chips (Visual Standard Phase 1).
 * Opt-in via .pm-status-chip--soft and/or .entity-view-header-status-chip.
 * Opt-in only. Does not change notification,
 * priority, or other intentionally prominent filled chips.
 */
body .mud-chip.mud-chip-filled.pm-status-chip--soft,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip {
    height: 22px !important;
    min-height: 22px !important;
    font-size: var(--pm-font-size-micro, 11px) !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em;
    border-radius: var(--pm-radius-badge, 3px);
    border-style: solid;
    border-width: 1px;
    box-shadow: none;
}
/*
 * Critical: app.css paints solid success (and similar) backgrounds onto
 * .mud-chip-content as well as the chip root. Soft chips must keep a single
 * pale surface — content/icon backgrounds stay transparent.
 */
body .mud-chip.mud-chip-filled.pm-status-chip--soft .mud-chip-content,
body .mud-chip.mud-chip-filled.pm-status-chip--soft .mud-chip-icon,
body .mud-chip.mud-chip-filled.pm-status-chip--soft .mud-chip-content *,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip .mud-chip-content,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip .mud-chip-icon,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip .mud-chip-content * {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    font-size: var(--pm-font-size-micro, 11px) !important;
    font-weight: 600 !important;
}

body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-warning,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-warning {
    background: var(--pm-status-warning-bg, #FFF8EB) !important;
    border-color: var(--pm-status-warning-border, #F7D9A8) !important;
    color: var(--pm-status-warning-fg, #B54708) !important;
}
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-warning .mud-chip-content,
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-warning .mud-chip-icon,
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-warning .mud-chip-content *,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-warning .mud-chip-content,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-warning .mud-chip-icon,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-warning .mud-chip-content * {
    color: var(--pm-status-warning-fg, #B54708) !important;
}

body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-success,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-success {
    background: var(--pm-status-success-bg, #ECFDF3) !important;
    border-color: var(--pm-status-success-border, #ABEFC6) !important;
    color: var(--pm-status-success-fg, #067647) !important;
}
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-success .mud-chip-content,
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-success .mud-chip-icon,
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-success .mud-chip-content *,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-success .mud-chip-content,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-success .mud-chip-icon,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-success .mud-chip-content * {
    color: var(--pm-status-success-fg, #067647) !important;
}

body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-error,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-error {
    background: var(--pm-status-error-bg, #FEF3F2) !important;
    border-color: var(--pm-status-error-border, #FECDCA) !important;
    color: var(--pm-status-error-fg, #B42318) !important;
}
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-error .mud-chip-content,
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-error .mud-chip-icon,
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-error .mud-chip-content *,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-error .mud-chip-content,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-error .mud-chip-icon,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-error .mud-chip-content * {
    color: var(--pm-status-error-fg, #B42318) !important;
}

body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-info,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-info {
    background: var(--pm-status-info-bg, #EFF8FF) !important;
    border-color: var(--pm-status-info-border, #B2DDFF) !important;
    color: var(--pm-status-info-fg, #175CD3) !important;
}
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-info .mud-chip-content,
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-info .mud-chip-icon,
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-info .mud-chip-content *,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-info .mud-chip-content,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-info .mud-chip-icon,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-info .mud-chip-content * {
    color: var(--pm-status-info-fg, #175CD3) !important;
}

body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-default,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-default,
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-primary,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-primary {
    background: var(--pm-status-neutral-bg, #F2F4F7) !important;
    border-color: var(--pm-status-neutral-border, #D0D5DD) !important;
    color: var(--pm-status-neutral-fg, #344054) !important;
}
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-default .mud-chip-content,
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-default .mud-chip-icon,
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-default .mud-chip-content *,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-default .mud-chip-content,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-default .mud-chip-icon,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-default .mud-chip-content *,
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-primary .mud-chip-content,
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-primary .mud-chip-icon,
body .mud-chip.mud-chip-filled.pm-status-chip--soft.mud-chip-color-primary .mud-chip-content *,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-primary .mud-chip-content,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-primary .mud-chip-icon,
body .mud-chip.mud-chip-filled.entity-view-header-status-chip.mud-chip-color-primary .mud-chip-content * {
    color: var(--pm-status-neutral-fg, #344054) !important;
}
