/**
 * Rezept-Dialog — Layout analog CalendarScheduleEditorFormFields (l-sch-editor-Panels).
 */

/* Viewport-Höhe + Scroll im portierten Dialog */
.dialog-shell.recipe-dialog.e-dialog {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    max-height: calc(100dvh - var(--l-appbar-height, 56px) - (2 * var(--l-dialog-viewport-gap, 20px))) !important;
}

.dialog-shell.recipe-dialog.e-dialog .e-dlg-header-content,
.dialog-shell.recipe-dialog.e-dialog .e-footer-content {
    flex: 0 0 auto;
}

.dialog-shell.recipe-dialog.e-dialog .e-dlg-content {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    padding-top: 0.5rem;
}

/* DatePicker-Popup im Dialog-Host */
#dialog-host .e-datepicker.e-popup-wrapper,
#dialog-host .e-datepicker.e-popup-container {
    width: auto !important;
    min-width: 280px !important;
    max-width: 320px !important;
}

#dialog-host .e-datepicker .e-calendar {
    width: 100% !important;
}

/* —— Editor-Scope (wie .l-schedule-event-editor-scope) —— */
.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor {
    display: flex;
    flex-direction: column;
    gap: var(--l-space-sm);
    min-width: 0;
    font-family: var(--l-font-sans);
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__panel {
    display: flex;
    flex-direction: column;
    gap: var(--l-space-sm);
    padding: var(--l-space-sm) var(--l-space-md);
    border-radius: var(--l-radius-lg);
    border: 1px solid var(--l-border-light);
    background: var(--l-bg-elevated);
    box-shadow: 0 1px 2px color-mix(in srgb, var(--l-text) 4%, transparent);
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__panel--therapy {
    border-color: color-mix(in srgb, var(--l-primary) 22%, var(--l-border-light));
    background: linear-gradient(
        165deg,
        color-mix(in srgb, var(--l-primary) 5%, var(--l-bg-elevated)) 0%,
        var(--l-bg-elevated) 48%
    );
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__panel--compact {
    padding: var(--l-space-sm) var(--l-space-md);
    gap: var(--l-space-sm);
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__panel-head {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    align-items: flex-start;
    text-align: left;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__panel-head--inline {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--l-space-md);
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__panel-title {
    font-size: var(--l-text-base, 0.9375rem);
    font-weight: 600;
    color: var(--l-text-primary, var(--l-text));
    letter-spacing: -0.01em;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__row {
    align-items: flex-end;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__row--grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--l-space-md);
    width: 100%;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__row--grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--l-space-md);
    width: 100%;
    align-items: end;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__row--grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--l-space-md);
    width: 100%;
    align-items: end;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor__scan-ocr {
    margin-top: 0.5rem;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor__insurance-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 0.35rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--l-warning-border, #f0c36d);
    border-radius: var(--l-radius-sm, 6px);
    background: var(--l-warning-bg, #fff8e6);
    color: var(--l-warning-text, #7a4d00);
    font-size: var(--l-text-sm, 0.875rem);
    line-height: 1.4;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
    flex: 1 1 0;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-field-label {
    display: block;
    font-size: var(--l-text-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--l-text-secondary);
    margin: 0;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-field-label--required::after {
    content: " *";
    color: color-mix(in srgb, var(--l-danger, #b42318) 85%, var(--l-text));
    font-weight: 600;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-field-control {
    width: 100%;
    min-width: 0;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor .e-input-group.e-control-wrapper,
.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor .e-ddl.e-input-group,
.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor .e-date-wrapper {
    width: 100% !important;
    max-width: 100%;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__divider {
    height: 1px;
    margin: 0;
    background: var(--l-border-light);
    border: none;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__group-label {
    margin: 0;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--l-text-secondary);
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__allday {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--l-space-sm) var(--l-space-lg);
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__allday .l-checkbox {
    margin: 0;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__allday .l-checkbox__label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--l-text-secondary);
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__notes-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0 var(--l-space-xs);
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__notes-label {
    font-size: var(--l-text-sm);
    font-weight: 500;
    color: var(--l-text-secondary);
    margin: 0;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__optional {
    font-weight: 400;
    color: var(--l-text-secondary);
    opacity: 0.85;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-schedule-editor-notes {
    width: 100%;
    min-height: 3.25rem;
    field-sizing: content;
    resize: vertical;
    border-radius: var(--l-radius-md);
    border: 1px solid var(--l-border);
    background: var(--l-bg-elevated);
    color: var(--l-text);
    padding: var(--l-space-xs) var(--l-space-md);
    font-size: var(--l-text-sm);
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-schedule-editor-notes.invalid {
    border-color: var(--l-danger, #b42318);
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__computed-end {
    display: flex;
    align-items: center;
    min-height: 2.25rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--l-border-light);
    border-radius: var(--l-radius-md);
    background: color-mix(in srgb, var(--l-bg-surface-alt, var(--l-bg-elevated)) 72%, var(--l-bg-elevated));
    font-size: 0.8125rem;
    color: var(--l-text-primary, var(--l-text));
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__computed-end-value {
    font-variant-numeric: tabular-nums;
    color: var(--l-text-primary, var(--l-text));
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor__validity-compact {
    cursor: help;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor__field-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--l-space-sm);
    flex-wrap: wrap;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor__field-head .l-checkbox {
    flex-shrink: 0;
    font-size: 0.8125rem;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor__draft-hint {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--l-text-muted);
    line-height: 1.35;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__loading {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0;
    font-size: 0.8125rem;
    color: var(--l-text-secondary);
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .validation-message {
    font-size: 0.75rem;
    color: var(--l-danger, #b42318);
    margin-top: 0.15rem;
}

/* Heilmittel-Pills im Panel */
.dialog-shell.recipe-dialog .l-recipe-editor-scope .therapy-compact {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .therapy-compact__row {
    display: grid;
    grid-template-columns: 7rem minmax(0, 1fr);
    gap: var(--l-space-sm);
    align-items: end;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .therapy-compact__pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .therapy-compact__pill-group {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .therapy-code {
    font-family: monospace;
    font-size: 0.8rem;
    padding: 0 0.35rem;
    border: 1px solid var(--l-border-light);
    background: var(--l-bg-surface);
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .therapy-doppel-add {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    appearance: none;
    border: 1px dashed var(--l-border) !important;
    border-radius: 50%;
    background: transparent !important;
    color: var(--l-text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .therapy-doppel-add:hover {
    border-color: var(--l-primary) !important;
    border-style: solid !important;
    color: var(--l-primary);
    background: var(--l-primary-soft) !important;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .btn-icon:hover {
    opacity: 1;
    background: color-mix(in srgb, currentColor 10%, transparent);
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-pill-edit__qty {
    width: 3.25rem !important;
    min-width: 3.25rem !important;
    max-width: 3.25rem;
}

/* Scan-Anhang */
.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor__scan-attached {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid color-mix(in srgb, var(--l-success) 45%, var(--l-border-light));
    border-radius: var(--l-radius-md);
    background: color-mix(in srgb, var(--l-success) 8%, var(--l-bg-elevated));
    color: var(--l-success);
    font-size: 0.8125rem;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor__scan-attached span {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Pause / Lifecycle */
.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor__lifecycle {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--l-space-md);
    padding: 0.625rem 0.75rem;
    border-radius: var(--l-radius-md);
    border: 1px solid var(--l-border-light);
    background: var(--l-bg-elevated);
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor__lifecycle--warning {
    border-color: color-mix(in srgb, var(--l-warning, #c9a227) 40%, transparent);
    background: color-mix(in srgb, var(--l-warning, #f5e6a3) 18%, var(--l-bg-elevated));
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor__lifecycle-text {
    font-size: 0.8125rem;
    color: var(--l-text-secondary);
    margin: 0;
    line-height: 1.4;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor__lifecycle-title {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--l-text-primary);
    margin: 0 0 0.25rem;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor__lifecycle--warning .l-recipe-editor__lifecycle-title {
    color: color-mix(in srgb, var(--l-warning, #9a7b0a) 90%, var(--l-text));
}

/* Termin-Panel (RecipeAppointmentLinkPanel im Editor) */
.dialog-shell.recipe-dialog .l-recipe-editor-scope .recipe-appointment-link-panel {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.dialog-shell.recipe-dialog .l-recipe-editor-scope .recipe-appointment-link-panel .recipe-appointment-status__summary {
    margin-top: 0.15rem;
    margin-bottom: 0;
}

@media (max-width: 860px) {
    .dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__row--grid-2,
    .dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__row--grid-3,
    .dialog-shell.recipe-dialog .l-recipe-editor-scope .l-sch-editor__row--grid-4 {
        grid-template-columns: 1fr;
    }

    .dialog-shell.recipe-dialog .l-recipe-editor-scope .therapy-compact__row {
        grid-template-columns: 1fr;
    }

    .dialog-shell.recipe-dialog .l-recipe-editor-scope .l-recipe-editor__lifecycle {
        flex-direction: column;
        align-items: stretch;
    }
}
