/* Zutatenverwaltung */

.data-table-wrapper {
    overflow-x: auto;

    border: 1px solid var(--border);
    border-radius: 0.9rem;

    background: var(--surface);
}

.data-table {
    width: 100%;
    min-width: 58rem;

    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem;

    border-bottom: 1px solid var(--border);

    text-align: left;
    vertical-align: top;
}

.data-table th {
    color: var(--text-muted);

    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:hover {
    background: var(--surface-raised);
}

.table-note {
    display: block;

    max-width: 22rem;
    margin-top: 0.35rem;

    color: var(--text-muted);

    font-size: 0.82rem;
    line-height: 1.45;
}

.table-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;

    white-space: nowrap;
}

.table-actions a {
    color: var(--accent);

    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
}

.table-actions a:hover {
    color: var(--accent-hover);
}

.table-actions .danger-link {
    color: var(--danger);
}

.table-actions .danger-link:hover {
    color: var(--danger-hover);
}

.status-badge {
    display: inline-flex;

    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.25rem 0.55rem;

    background: var(--surface-soft);
    color: var(--text-muted);

    font-size: 0.78rem;
    white-space: nowrap;
}

.form-help {
    max-width: 48rem;
    margin: -0.35rem 0 1.5rem;

    color: var(--text-muted);

    font-size: 0.92rem;
    line-height: 1.6;
}

.form-grid-three {
    grid-template-columns:
        repeat(3, minmax(0, 1fr));
}

@media (max-width: 820px) {.form-grid-three {
        grid-template-columns: 1fr;
    }
}

/* Zutaten-Autocomplete und mobiler Erstellungsdialog */

.ingredient-autocomplete {
    position: relative;
}

.ingredient-autocomplete > label {
    display: contents;
}

.autocomplete-menu {
    position: absolute;
    z-index: 30;
    top: calc(100% - 1.1rem);
    right: 0;
    left: 0;

    max-height: 20rem;
    overflow-y: auto;

    border: 1px solid var(--border-strong);
    border-radius: 0.75rem;
    padding: 0.35rem;

    background: var(--surface-raised);
    box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.38);
}

.autocomplete-option {
    width: 100%;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;

    border: 0;
    border-radius: 0.55rem;
    padding: 0.8rem 0.85rem;

    background: transparent;
    color: var(--text);

    text-align: left;
}

.autocomplete-option:hover,
.autocomplete-option:focus-visible {
    background: rgba(215, 164, 82, 0.13);
    outline: none;
}

.autocomplete-option-name {
    min-width: 0;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.autocomplete-option-meta {
    flex: 0 0 auto;

    color: var(--text-muted);

    font-size: 0.78rem;
}

.autocomplete-create-option {
    border-top: 1px solid var(--border);
    border-radius: 0 0 0.55rem 0.55rem;

    color: var(--accent);
}

.autocomplete-create-symbol {
    flex: 0 0 auto;

    font-size: 1.35rem;
    line-height: 1;
}

.field-message {
    min-height: 1.15rem;
    margin: 0;

    color: var(--text-muted);

    font-size: 0.76rem;
}

.field-message.is-selected {
    color: var(--success);
}

.ingredient-editor-row.has-selection-error {
    border-color: var(--danger);
}

.ingredient-editor-row.has-selection-error .field-message {
    color: var(--danger);
}

.ingredient-dialog,
.premix-dialog,
.catalog-dialog {
    width: min(42rem, calc(100% - 2rem));
    max-height: min(48rem, calc(100dvh - 2rem));

    border: 1px solid var(--border-strong);
    border-radius: 1rem;
    padding: 0;

    background: var(--surface);
    color: var(--text);

    box-shadow: 0 2rem 6rem rgba(0, 0, 0, 0.55);
}

.ingredient-dialog::backdrop,
.premix-dialog::backdrop,
.catalog-dialog::backdrop {
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
}

.dialog-form {
    max-height: inherit;

    display: flex;
    flex-direction: column;
}

.dialog-header,
.dialog-actions {
    flex: 0 0 auto;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;

    padding: 1.25rem;

    background: var(--surface);
}

.dialog-header {
    border-bottom: 1px solid var(--border);
}

.dialog-header h2 {
    margin: 0;
}

.dialog-close {
    width: 2.75rem;
    height: 2.75rem;

    border: 1px solid var(--border);
    border-radius: 999px;

    background: var(--surface-soft);
    color: var(--text-muted);

    font-size: 1.5rem;
    line-height: 1;
}

.dialog-close:hover {
    color: var(--text);
}

.dialog-body {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;

    display: grid;
    gap: 1rem;

    padding: 1.25rem;
}

.dialog-actions {
    border-top: 1px solid var(--border);

    justify-content: flex-end;
}

.dialog-help {
    margin: 0;
}

.dialog-errors {
    border: 1px solid rgba(223, 107, 107, 0.55);
    border-radius: 0.75rem;
    padding: 0.9rem 1rem;

    background: var(--danger-background);
    color: var(--danger);
}

.dialog-errors ul {
    margin: 0;
    padding-left: 1.2rem;
}

@media (max-width: 600px) {.ingredient-dialog,
.premix-dialog,
.catalog-dialog {
        width: 100%;
        max-width: none;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;

        border: 0;
        border-radius: 0;
    }

    .dialog-header,
    .dialog-body,
    .dialog-actions {
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-left: max(1rem, env(safe-area-inset-left));
    }

    .dialog-header {
        padding-top: max(1rem, env(safe-area-inset-top));
    }

    .dialog-actions {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .dialog-actions > * {
        min-height: 3rem;
    }

    .autocomplete-menu {
        position: fixed;
        z-index: 40;
        top: auto;
        right: 0.75rem;
        bottom: max(0.75rem, env(safe-area-inset-bottom));
        left: 0.75rem;

        max-height: min(18rem, 42dvh);
    }
}

.card-meta {
    color: var(--text-muted);
    font-size: 0.86rem;
}

.form-grid-four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.recipe-meta-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1px;
    border-bottom: 1px solid var(--border);
    background: var(--border);
}

.recipe-meta-grid > div {
    display: grid;
    gap: 0.35rem;
    padding: 1.1rem 1.25rem;
    background: var(--surface-soft);
}

.recipe-meta-grid span {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.recipe-step-list {
    display: grid;
    gap: 1rem;
    margin: 0;
    padding-left: 1.5rem;
    color: var(--text-muted);
    line-height: 1.65;
}

.recipe-step-list li::marker {
    color: var(--accent);
    font-weight: 800;
}

.step-editor-list {
    display: grid;
    gap: 1rem;
}

.step-editor-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    padding: 1rem;
    background: var(--surface-soft);
}

.step-number {
    width: 2.25rem;
    height: 2.25rem;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(215, 164, 82, 0.15);
    color: var(--accent);
    font-weight: 800;
}

.inventory-entry-list {
    display: grid;
    gap: 1rem;
}

.inventory-entry-row {
    display: grid;
    grid-template-columns: minmax(14rem, 2fr) 1fr 0.65fr auto;
    align-items: end;
    gap: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    padding: 1rem;
    background: var(--surface-soft);
}

.result-card {
    margin-top: 1.5rem;
}

@media (max-width: 980px) {.form-grid-four,
    .recipe-meta-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .inventory-entry-row {
        grid-template-columns: minmax(12rem, 2fr) 1fr 0.7fr;
    }

    .inventory-entry-row .remove-row-button {
        grid-column: 1 / -1;
        justify-self: end;
    }
}

@media (max-width: 720px) {.form-grid-four,
    .recipe-meta-grid,
    .inventory-entry-row {
        grid-template-columns: 1fr;
    }

    .step-editor-row {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .step-editor-row .remove-row-button {
        grid-column: 2;
        justify-self: end;
    }
}

