/*
  Minimal CSS für ein zentriertes Modal-Overlay, das zur UI passt.
  Passe Farben und Abstände ggf. an dein Design an.
*/
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.custom-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    min-width: 320px;
    max-width: 90vw;
    padding: 0;
    animation: modalIn 0.18s cubic-bezier(0.4, 1.6, 0.6, 1) both;
}
@keyframes modalIn {
    from {
        transform: scale(0.95) translateY(30px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}
.custom-modal-content {
    padding: 2rem 1.5rem 1.5rem 1.5rem;
    text-align: center;
}
.custom-modal-content h3 {
    margin-top: 0;
    margin-bottom: 0.5em;
    font-size: 1.3em;
    font-weight: 600;
}
.custom-modal-content p {
    margin-bottom: 1.5em;
    color: #444;
}
.custom-modal-actions {
    display: flex;
    gap: 1em;
    justify-content: center;
}
#customDeleteUserModal .btn {
    min-width: 100px;
}

/* Text Scan Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: var(--card-background, white);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    min-width: 500px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    animation: modalScaleIn 0.2s cubic-bezier(0.4, 1.6, 0.6, 1) both;
}

@keyframes modalScaleIn {
    from {
        transform: scale(0.9) translateY(20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--foreground, #0f172a);
}

.modal-close {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    color: var(--muted-foreground, #64748b);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--accent, #f1f5f9);
    color: var(--foreground, #0f172a);
}

.modal-body {
    padding: 1.5rem 2rem;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border, #e2e8f0);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Spinner for processing */
.spinner {
    border: 2px solid var(--accent, #f1f5f9);
    border-top: 2px solid var(--primary, #0f172a);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Image upload container */
.image-upload-container {
    width: 100%;
}

.image-drop-zone {
    border: 2px dashed var(--border, #e2e8f0);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    background: var(--accent, #f8fafc);
    cursor: pointer;
    transition: all 0.2s ease;
}

.image-drop-zone:hover {
    border-color: var(--primary, #0f172a);
    background: var(--card, #ffffff);
}

.image-drop-zone.drag-over {
    border-color: var(--primary, #0f172a);
    background: rgba(48, 70, 151, 0.05);
    border-style: solid;
    transform: scale(1.02);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.upload-trigger {
    background: none;
    border: none;
    color: var(--primary, #0f172a);
    text-decoration: underline;
    cursor: pointer;
    font-size: inherit;
}

.image-preview {
    position: relative;
    max-width: 300px;
    margin: 1rem auto;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border, #e2e8f0);
}

.image-preview img {
    width: 100%;
    height: auto;
    display: block;
}

.remove-image {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.remove-image:hover {
    background: rgba(220, 38, 38, 0.8);
}

/* Preparation steps styling (form) */
.prep-step-row {
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--card, #ffffff);
}

.prep-step-group-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.4rem 0 0.75rem;
    padding: 0.4rem 0;
    border-bottom: 1px dashed var(--border);
}

.prep-step-group-row .input {
    font-weight: 600;
}

/* Preparation steps display (dish detail) */
.prep-step-group-title {
    font-weight: 600;
    color: var(--foreground, #0f172a);
    margin: 0.75rem 0 0.25rem;
}

.prep-steps {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.prep-step {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border, #e2e8f0);
    background: var(--card, #ffffff);
}

.step-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.step-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    color: var(--foreground, #0f172a);
}


.step-content {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: start;
}

.step-description {
    line-height: 1.6;
    color: var(--foreground, #374151);
    white-space: pre-wrap;
}

.step-image {
    max-width: 200px;
    border-radius: 6px;
    overflow: hidden;
}

.step-image img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    object-fit: cover;
    max-height: 150px;
}

/* Ingredient form row styling */
.ingredient-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.ingredient-input-row .input[data-field="altUnit"] {
    font-size: 0.85rem;
    color: var(--muted-foreground, #64748b);
    font-style: italic;
}

.prep-step-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.step-number {
    background: var(--primary, #0f172a);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    flex-shrink: 0;
}

.step-title {
    flex: 1;
    font-weight: 600;
}


.prep-step-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
    gap: 1rem;
    align-items: stretch;
}

.step-text {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.step-image {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.step-image-input {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.step-image-url {
    font-size: 0.875rem;
}

.prep-step-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.step-description {
    resize: vertical;
    min-height: 60px;
}

.prep-step-row .step-text .step-description {
    height: 100%;
    min-height: 140px;
}

.step-image-file {
    width: 100%;
    padding: 0.5rem;
    border: 2px dashed var(--border, #e2e8f0);
    border-radius: 6px;
    background: var(--accent, #f8fafc);
    cursor: pointer;
    transition: all 0.2s ease;
}

.step-image-file:hover {
    border-color: var(--primary, #0f172a);
    background: var(--card, #ffffff);
}

.step-image-file:focus {
    outline: none;
    border-color: var(--primary, #0f172a);
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.1);
}

.step-image-preview {
    position: relative;
    margin-top: 0.5rem;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border, #e2e8f0);
}

.prep-step-row .step-text .input {
    width: 100%;
}

.step-image-preview .preview-img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.step-image-preview .remove-preview {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.2s;
}

.step-image-preview .remove-preview:hover {
    background: rgba(220, 38, 38, 0.8);
}

/* Responsive modal */
@media (max-width: 768px) {
    .modal-content {
        min-width: unset;
        width: 95vw;
        margin: 1rem;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem 1.5rem;
    }

    /* Mobile preparation steps (form) */
    .prep-step-content {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }


    /* Mobile preparation steps (display) */
    .step-content {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .step-image {
        max-width: 100%;
    }

    .step-image img {
        max-height: 200px;
    }

    /* Mobile ingredient rows */
    .ingredient-input-row {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .ingredient-input-row .input[data-field="name"] {
        flex-basis: 100%;
        order: 1;
    }

    .ingredient-input-row .input[data-field="altUnit"] {
        flex-basis: 100%;
        order: 2;
        margin-top: 0.25rem;
    }

    /* Mobile edit modal ingredient rows */
    #editIngredientsList .flex {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    #editIngredientsList .flex .input[data-field="name"] {
        flex-basis: 100%;
        order: 1;
    }

    #editIngredientsList .flex .input[data-field="altUnit"] {
        flex-basis: 100%;
        order: 2;
        margin-top: 0.25rem;
    }
}
