/* Shared styles also cover alerts rendered in MudBlazor's dialog portal. */
.mud-alert.mud-alert-outlined-info {
    border-radius: 18px;
}

:root {
    --kundendreher-field-radius: 18px;
    --kundendreher-button-radius: 999px;
    --kundendreher-dialog-radius: 24px;
}

body:not(.dark-mode) {
    --kundendreher-brand-fill: #ffed00;
    --kundendreher-brand-hover: #e5d500;
    --kundendreher-brand-text: #202020;
    --kundendreher-brand-soft: color-mix(in srgb, var(--kundendreher-brand-fill) 28%, white);
    --kundendreher-brand-soft-hover: color-mix(in srgb, var(--kundendreher-brand-fill) 45%, white);
    --kundendreher-accent-ink: var(--mud-palette-primary);
    --kundendreher-warning-ink: var(--mud-palette-warning);
    --kundendreher-success-ink: var(--mud-palette-success);
    --kundendreher-info-ink: var(--mud-palette-info);
    --mud-palette-primary-hover: color-mix(in srgb, var(--kundendreher-brand-fill) 18%, transparent);
}

/* Use a readable neutral edge for secondary actions. A yellow edge alone disappears on light surfaces. */
body:not(.dark-mode) .mud-button-outlined.mud-button-outlined-primary:not(:disabled, .mud-disabled) {
    border-color: var(--mud-palette-lines-inputs);
}

body:not(.dark-mode) .mud-icon-button.mud-primary-text:not(:disabled, .mud-disabled, .search-list-details, .search-tile-action--details) {
    background-color: var(--kundendreher-brand-soft);
}

body:not(.dark-mode) .mud-icon-button.mud-primary-text:not(:disabled, .mud-disabled, .search-list-details, .search-tile-action--details):is(:hover, :focus-visible) {
    background-color: var(--kundendreher-brand-soft-hover);
}

body:not(.dark-mode) .mud-icon-button.mud-primary-text:focus-visible {
    outline: 2px solid var(--kundendreher-accent-ink);
    outline-offset: 2px;
}

/* Keep yellow on solid brand surfaces with dark labels, not on text, icons or outlines. */
body:not(.dark-mode) :is(.mud-button-filled.mud-button-filled-primary, .mud-chip-filled.mud-chip-color-primary):not(:disabled, .mud-disabled) {
    --mud-palette-primary-text: var(--kundendreher-brand-text);
    background-color: var(--kundendreher-brand-fill);
}

body:not(.dark-mode) :is(.mud-button-filled.mud-button-filled-primary, .mud-chip-filled.mud-chip-color-primary.mud-clickable):not(:disabled, .mud-disabled):is(:hover, :focus-visible, :active) {
    background-color: var(--kundendreher-brand-hover);
}

body:not(.dark-mode) :where(
    .mud-picker-toolbar.mud-theme-primary,
    .BottomNavBar,
    .kundendreher-startup-progress
) {
    --mud-palette-primary: var(--kundendreher-brand-fill);
    --mud-palette-primary-text: var(--kundendreher-brand-text);
}

/* Native MudBlazor fields otherwise render placeholder text at 42% opacity. */
body:not(.dark-mode) .mud-input > :is(input, textarea).mud-input-root:not(:disabled)::placeholder {
    color: var(--mud-palette-text-disabled);
    opacity: 1;
}

/* Highlight the details action in customer and article search, not on the home tiles. */
:is(.customers-card-grid, .articles-card-grid) .mud-icon-button.search-tile-action--details,
.mud-icon-button.search-list-details {
    background-color: var(--kundendreher-brand-fill, var(--mud-palette-primary));
    color: #000;
    border-radius: 50%;
}

:is(.customers-card-grid, .articles-card-grid) .mud-icon-button.search-tile-action--details:hover,
.mud-icon-button.search-list-details:hover {
    background-color: color-mix(in srgb, var(--kundendreher-brand-fill, var(--mud-palette-primary)) 87%, black);
}

.mud-icon-button.search-list-details,
.mud-icon-button.search-list-favorite {
    width: 1.8rem;
    height: 1.8rem;
    padding: 0;
}

.mud-icon-button.search-list-favorite {
    margin-inline-start: .45rem;
}

.mud-icon-button.search-list-details:focus-visible {
    outline: 2px solid var(--mud-palette-text-secondary);
    outline-offset: 1px;
}

/* One theme-aware drop treatment for native, MudBlazor and chat report uploads. */
[data-file-drop-zone] {
    border-radius: var(--kundendreher-field-radius);
}

.kundendreher-file-drop-active {
    outline: 2px dashed var(--mud-palette-primary) !important;
    outline-offset: -2px;
    background-color: color-mix(in srgb, var(--mud-palette-primary) 12%, var(--mud-palette-surface)) !important;
    box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--mud-palette-primary) 8%, transparent);
}

.kundendreher-file-drop-hint {
    display: block;
    color: var(--mud-palette-text-secondary);
    font-size: .75rem;
    line-height: 1.5;
    margin-block: .35rem;
}

/* Upload confirmations live in the snackbar portal and share our rounded actions. */
.mud-snackbar.customer-submission-snackbar {
    border-radius: var(--kundendreher-field-radius);
    box-shadow: 0 12px 32px rgb(0 0 0 / 20%);
    max-width: calc(100vw - 1.5rem);
    overflow-wrap: anywhere;
}

.customer-submission-snackbar .mud-button-root:focus-visible {
    outline-color: currentColor;
}

@media (prefers-reduced-motion: reduce) {
    .customer-submission-snackbar {
        animation: none !important;
        transition: none !important;
    }
}

/* Dialogs render in a portal, outside page-scoped CSS. Cover standard dialogs
   and message boxes without blurring menus, pickers or unrelated overlays. */
.mud-dialog-container > .mud-overlay,
.seller-week-dialog::backdrop,
.kundendreher-native-dialog::backdrop {
    background: rgba(8, 10, 18, 0.48);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.mud-dialog-container > .mud-overlay > .mud-overlay-scrim {
    background-color: transparent;
}

/* Bound every popup, including legacy dialogs, to the available viewport.
   Only the content scrolls; titles and actions must remain reachable. */
.mud-dialog {
    min-width: 0;
    min-height: 0;
    max-height: calc(100dvh - 32px);
    overflow: hidden;
}

/* Component hosts can add any number of wrappers before MudDialog's focus trap.
   Follow the content's ancestors instead of assuming a fixed host/depth.
   Never change hidden nodes, style tags or cards/forms INSIDE the content. */
.mud-dialog :where(div, form):has(.mud-dialog-content):not(:where([hidden], .mud-dialog-content *)) {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.mud-dialog .mud-dialog-content {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.mud-dialog .mud-dialog-title,
.mud-dialog .mud-dialog-actions {
    flex: 0 0 auto;
}

/* Keep explicit fullscreen dialogs square. Component-specific mobile fullscreen
   rules remain authoritative; do not force content-sized contact dialogs tall. */
.mud-dialog:not(.mud-dialog-fullscreen),
.seller-week-dialog[open],
.kundendreher-native-dialog[open] {
    border: 1px solid color-mix(in srgb, var(--mud-palette-text-primary) 14%, transparent);
    border-radius: var(--kundendreher-dialog-radius);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
    overflow-x: hidden;
    animation: kundendreher-dialog-enter 180ms ease-out;
}

/* XL dialogs already fill the viewport via app.css. Keep fullscreen shells square
   and scroll only their content, not the portal/container or the page behind it.
   Contact popups deliberately remain content-sized, even when they use XL. */
.mud-dialog-container:has(> .mud-dialog:is(.mud-dialog-fullscreen, .mud-dialog-width-xl):not(.crm-contact-popup)) {
    padding: 0;
    overflow: hidden;
}

.mud-dialog:is(.mud-dialog-fullscreen, .mud-dialog-width-xl):not(.crm-contact-popup) {
    display: flex;
    flex-direction: column;
    width: 100% !important;
    max-width: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 0;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    overflow: hidden;
    animation: none;
}

.mud-dialog:is(.mud-dialog-fullscreen, .mud-dialog-width-xl):not(.crm-contact-popup) .mud-dialog-content {
    overflow-x: hidden;
}

/* Neutral primary text is white in the dark theme and remains legible in light mode. */
.order-amount--canceled {
    color: var(--mud-palette-text-primary);
    text-decoration: line-through;
    text-decoration-thickness: .08em;
}

.mud-dialog .mud-dialog-title {
    font-weight: 700;
}

.mud-dialog .mud-dialog-actions {
    flex-wrap: wrap;
    gap: .65rem;
    padding: .85rem 1.5rem 1.15rem;
}

.mud-dialog .mud-dialog-actions > :not(:first-child) {
    margin-inline: 0;
}

:root:has(:is(.seller-week-dialog, .kundendreher-native-dialog)[open]) {
    overflow: hidden;
}

/* The order's wide position table stays scrollable inside the mobile dialog. */
@media (max-width: 600px) {
    .mud-dialog-container:has(.order-details-dialog) {
        padding: 0;
    }

    .mud-dialog.order-details-dialog {
        display: flex;
        flex-direction: column;
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        border: 0;
        border-radius: 0;
    }

    .order-details-dialog .mud-dialog-content {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        padding: .5rem .65rem;
    }

    .order-details-dialog .mud-dialog-title,
    .order-details-dialog .mud-dialog-actions {
        flex-shrink: 0;
        padding: .65rem .8rem;
    }
}

@keyframes kundendreher-dialog-enter {
    from { opacity: 0; transform: translateY(8px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .mud-dialog,
    .mud-dialog:not(.mud-dialog-fullscreen),
    .seller-week-dialog[open],
    .kundendreher-native-dialog[open],
    .mud-dialog-container > .mud-overlay,
    .mud-dialog-container > .mud-overlay > .mud-overlay-scrim {
        animation: none !important;
        transition: none !important;
    }
}

/* One action-button standard across pages and dialog portals. Icon-only controls
   keep their compact geometry; existing primary/error/disabled colors stay intact. */
.mud-button-root.mud-button:not(.mud-icon-button):not(.mud-input-numeric-spin *) {
    border-radius: var(--kundendreher-button-radius);
    text-transform: none;
    font-weight: 600;
    transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.mud-button-root.mud-button:is(.mud-button-filled-size-medium, .mud-button-outlined-size-medium, .mud-button-text-size-medium):not(.mud-icon-button):not(.mud-input-numeric-spin *) {
    min-height: 2.65rem;
    padding: .55rem 1.15rem;
}

.mud-button-root.mud-button.mud-button-filled:not(.mud-icon-button):not(.mud-input-numeric-spin *):not(:disabled):not(.mud-disabled) {
    box-shadow: 0 3px 10px rgb(0 0 0 / 12%);
}

.mud-button-root.mud-button:not(.mud-icon-button):not(.mud-input-numeric-spin *):not(:disabled):not(.mud-disabled):hover {
    box-shadow: 0 5px 16px rgb(0 0 0 / 16%);
}

.mud-button-root.mud-button:not(.mud-icon-button):not(.mud-input-numeric-spin *):focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 3px;
}

.mud-icon-button.mud-button {
    border-radius: var(--kundendreher-field-radius);
}

@media (prefers-reduced-motion: reduce) {
    .mud-button-root.mud-button:not(.mud-icon-button):not(.mud-input-numeric-spin *) {
        transition: none !important;
        transform: none !important;
    }
}

/* Compact, genuinely circular icon actions with no background or outline. */
.kundendreher-icon-action,
.mud-button-root.kundendreher-icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--mud-palette-text-secondary);
    cursor: pointer;
    transition: color 160ms ease;
}

.kundendreher-icon-action:not(:disabled):hover {
    background: transparent !important;
    box-shadow: none !important;
    color: var(--mud-palette-text-primary);
}

.kundendreher-icon-action:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

.kundendreher-icon-action:disabled { opacity: .45; cursor: default; }

@media (prefers-reduced-motion: reduce) {
    .kundendreher-icon-action { transition: none !important; }
}

/* Apply to every field, including controls rendered in dialog/popover portals.
   Keep the square theme unchanged for unrelated components. */
.mud-input-control,
.mud-popover {
    --mud-default-borderradius: var(--kundendreher-field-radius);
}

/* Include the separate visible outline; outmatch MudBlazor's default rule. */
.mud-input-control .mud-input,
.mud-input-control .mud-input.mud-input-outlined,
.mud-input-control .mud-input.mud-input-filled,
.mud-input-control .mud-input.mud-input-outlined .mud-input-outlined-border,
.mud-popover {
    border-radius: var(--kundendreher-field-radius);
}

/* Native fields keep more specific, already-rounded or grouped-control styles.
   Do not restyle checkboxes, radios, sliders, uploads or MudBlazor's inner slots. */
:where(input:not(.mud-input-slot):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]),
       textarea:not(.mud-input-slot),
       select:not(.mud-input-slot)) {
    border-radius: var(--kundendreher-field-radius);
}

.mud-popover.kundendreher-rounded-popover {
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--mud-palette-text-primary) 12%, transparent);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

/* Pickers and selects render their menus outside the Content Hub editor shell. */
body:has(.contenthub-editor-frame) :is(.mud-popover, .mud-overlay-popover) {
    --mud-zindex-popover: calc(var(--mud-zindex-dialog, 1400) + 1);
}

/* Keep the semantic outline; tag text and icons always use the theme's text color. */
.customer-channel-chip .mud-chip-content,
.customer-channel-chip .mud-icon-root,
.tag-suggestion:not(:disabled) .mud-button-label,
.tag-suggestion:not(:disabled) .mud-icon-root {
    color: var(--mud-palette-text-primary) !important;
    text-shadow: none;
}
