/*
 * Personalisierung im Kaufformular: Upload-Feld als Ablagefläche, hochgeladene Dateien als
 * Zeilen. Eigene Datei aus Resources/public wie das Skript (kein Bau). Farben und Rundung
 * kommen aus den Variablen von Bootstrap — die Fläche passt sich jedem Theme an.
 */

.axevio-dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 1.25rem 1rem;
    border: 2px dashed var(--bs-border-color, #ced4da);
    border-radius: var(--bs-border-radius-lg, 0.5rem);
    background-color: var(--bs-body-bg, #fff);
    text-align: center;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

/* Ein Element mit display: flex blendet das Attribut hidden sonst nicht aus */
.axevio-dropzone[hidden] {
    display: none;
}

.axevio-dropzone:hover,
.axevio-dropzone.is-dragover {
    border-color: var(--bs-primary, #0d6efd);
    background-color: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.05);
}

/* Das Dateifeld liegt unsichtbar über der Fläche: Klick und Ablegen treffen es */
.axevio-dropzone-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

/* Tastaturfokus auf dem unsichtbaren Feld zeigt die Fläche */
.axevio-dropzone:has(.axevio-dropzone-input:focus-visible) {
    border-color: var(--bs-primary, #0d6efd);
    outline: 2px solid var(--bs-primary, #0d6efd);
    outline-offset: 2px;
}

.axevio-dropzone-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background-color: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.1);
    color: var(--bs-link-color, var(--bs-primary, #0d6efd));
}

.axevio-dropzone-text {
    font-weight: 600;
    line-height: 1.4;
}

.axevio-dropzone-choose {
    color: var(--bs-link-color, var(--bs-primary, #0d6efd));
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

.axevio-dropzone-hint {
    color: var(--bs-secondary-color, #6c757d);
    font-size: 0.8125rem;
}

/* Ohne Maus (Touch) gibt es nichts zu ziehen: nur „Datei auswählen“ */
@media (hover: none) {
    .axevio-dropzone-drag {
        display: none;
    }
}

/* Hochgeladene Dateien */
.axevio-files:empty {
    display: none;
}

.axevio-files {
    display: grid;
    gap: 0.5rem;
}

.axevio-dropzone:not([hidden]) + .axevio-files {
    margin-top: 0.5rem;
}

.axevio-file {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    padding: 0.5rem 0.5rem 0.5rem 0.625rem;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: var(--bs-border-radius, 0.375rem);
    background-color: var(--bs-body-bg, #fff);
}

.axevio-file.is-pending {
    color: var(--bs-secondary-color, #6c757d);
}

.axevio-file-thumb,
.axevio-file-icon {
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: calc(var(--bs-border-radius, 0.375rem) * 0.75);
}

.axevio-file-thumb {
    object-fit: cover;
}

.axevio-file-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bs-tertiary-bg, #f8f9fa);
    color: var(--bs-secondary-color, #6c757d);
}

.axevio-file-text {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.axevio-file-meta {
    display: block;
    color: var(--bs-secondary-color, #6c757d);
    font-size: 0.8125rem;
}

.axevio-file-remove {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--bs-secondary-color, #6c757d);
    cursor: pointer;
}

.axevio-file-remove:hover {
    background-color: var(--bs-tertiary-bg, #f8f9fa);
    color: var(--bs-danger, #dc3545);
}

.axevio-file-remove:focus-visible {
    outline: 2px solid var(--bs-primary, #0d6efd);
    outline-offset: 1px;
}

/* Die QR-Prüfung (1.11.0): Hinweis unter der Datei, solange sie unbestätigt ist. */
.axevio-file.has-warning {
    border-color: var(--bs-warning-border-subtle, #ffe69c);
    background-color: var(--bs-warning-bg-subtle, #fff3cd);
}

.axevio-file-warning {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-top: 0.25rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--bs-warning-border-subtle, #ffe69c);
    border-radius: var(--bs-border-radius, 0.375rem);
    background-color: var(--bs-warning-bg-subtle, #fff3cd);
    color: var(--bs-body-color, #212529);
    font-size: 0.875rem;
}

.axevio-file-warning-icon {
    display: inline-flex;
    flex: 0 0 auto;
    color: var(--bs-warning-text-emphasis, #664d03);
}

.axevio-file-warning-text {
    flex: 1 1 16rem;
    min-width: 0;
}

.axevio-file-warning-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 0.5rem;
}

/* Hilfetext aus dem ERP: etwas Luft zum Feld, Absätze und Listen ohne großen Abstand */
.axevio-help {
    margin-top: 0.375rem;
}

.axevio-help p,
.axevio-help ul,
.axevio-help ol {
    margin-bottom: 0.25rem;
}

.axevio-help ul,
.axevio-help ol {
    padding-left: 1.25rem;
}

.axevio-help > :last-child {
    margin-bottom: 0;
}

@media (prefers-reduced-motion: reduce) {
    .axevio-dropzone {
        transition: none;
    }
}

/* ------------------------------------------------------------------ */
/* Foto auf Fläche: Karte unter der Ablagefläche                        */
/* ------------------------------------------------------------------ */

.axevio-photo:empty,
.axevio-photo[hidden] {
    display: none;
}

.axevio-photo {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
    padding: 0.625rem;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: var(--bs-border-radius, 0.375rem);
    background-color: var(--bs-body-bg, #fff);
}

.axevio-photo-preview {
    flex: 0 0 auto;
    max-width: 8rem;
    max-height: 6rem;
    border-radius: calc(var(--bs-border-radius, 0.375rem) * 0.75);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    object-fit: contain;
    background: #fff;
}

.axevio-photo-text {
    flex: 1 1 10rem;
    min-width: 0;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.axevio-photo-text .axevio-file-meta {
    display: block;
}

.axevio-photo-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    width: 100%;
}

.axevio-photo-level {
    font-weight: 600;
}

.axevio-photo-level[data-level="ok"] { color: var(--bs-success, #198754); }
.axevio-photo-level[data-level="warn"] { color: var(--bs-warning-text-emphasis, #997404); }
.axevio-photo-level[data-level="low"] { color: var(--bs-danger, #dc3545); }

.axevio-photo-warning {
    color: var(--bs-danger, #dc3545);
    font-size: 0.8125rem;
}

.axevio-line-item-photo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.axevio-photo-thumb {
    width: 96px;
    height: 96px;
    object-fit: contain;
    border-radius: 0.25rem;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ------------------------------------------------------------------ */
/* Der Fotoeditor                                                      */
/* ------------------------------------------------------------------ */

.axevio-photo-editor {
    position: fixed;
    inset: 0;
    z-index: 1100; /* über Bootstraps Modal (1055) — der Ändern-Dialog des Warenkorbs liegt darunter */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.6);
}

.axevio-photo-editor__dialog {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 44rem;
    max-height: 100%;
    background: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #212529);
    border-radius: var(--bs-border-radius-lg, 0.5rem);
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.axevio-photo-editor__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
}

.axevio-photo-editor__title {
    margin: 0;
    font-size: 1.1rem;
}

.axevio-photo-editor__close {
    display: inline-flex;
    width: 2.25rem;
    height: 2.25rem;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

/* Badges oben links in der Fläche: Auflösung immer, Rand nur bei Bedarf; Klick klappt den Satz aus */
.axevio-photo-editor__badges {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.375rem;
    pointer-events: none;
}

.axevio-photo-editor__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.65rem;
    border: 1px solid transparent;
    border-radius: 999px;
    background: var(--bs-tertiary-bg, #f8f9fa);
    color: var(--bs-body-color, #212529);
    font-weight: 600;
    font-size: 0.8rem;
    line-height: 1.3;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    pointer-events: auto;
}

.axevio-photo-editor__badge[hidden] {
    display: none;
}

.axevio-photo-editor__badge[aria-expanded="true"] {
    outline: 2px solid currentColor;
    outline-offset: 1px;
}

.axevio-photo-editor__badge[data-level="ok"] { background: var(--bs-success-bg-subtle, #d1e7dd); color: var(--bs-success-text-emphasis, #0a3622); }
.axevio-photo-editor__badge[data-level="warn"] { background: var(--bs-warning-bg-subtle, #fff3cd); color: var(--bs-warning-text-emphasis, #664d03); }
.axevio-photo-editor__badge[data-level="low"] { background: var(--bs-danger-bg-subtle, #f8d7da); color: var(--bs-danger-text-emphasis, #58151c); }
.axevio-photo-editor__badge--edge { background: var(--bs-danger-bg-subtle, #f8d7da); color: var(--bs-danger-text-emphasis, #58151c); }

.axevio-photo-editor__tip {
    flex: 1 0 100%;
    max-width: 28rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--bs-border-radius, 0.375rem);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    font-size: 0.85rem;
    pointer-events: auto;
}

.axevio-photo-editor__tip[hidden] {
    display: none;
}

.axevio-photo-editor__stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 18rem;
    height: 50vh;
    background: var(--bs-tertiary-bg, #e9ecef);
}

.axevio-photo-editor__canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: grab;
    outline: none;
}

.axevio-photo-editor__canvas:focus-visible {
    box-shadow: inset 0 0 0 2px var(--bs-primary, #0d6efd);
}

.axevio-photo-editor__loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bs-secondary-color, #6c757d);
}

.axevio-photo-editor__loading[hidden] {
    display: none;
}

/* Hinweise als Overlay am unteren Rand der Fläche — sie ändern die Höhe des Dialogs nie */
.axevio-photo-editor__notes {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    pointer-events: none;
}

.axevio-photo-editor__notes > [hidden] {
    display: none;
}

.axevio-photo-editor__edge,
.axevio-photo-editor__error,
.axevio-photo-editor__confirm {
    padding: 0.4rem 0.75rem;
    border-radius: var(--bs-border-radius, 0.375rem);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    font-size: 0.85rem;
    pointer-events: auto;
}

.axevio-photo-editor__edge,
.axevio-photo-editor__error {
    color: var(--bs-danger, #dc3545);
}

.axevio-photo-editor__tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--bs-border-color, #dee2e6);
}

.axevio-photo-editor__tool {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: var(--bs-border-radius, 0.375rem);
    background: var(--bs-body-bg, #fff);
    color: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.axevio-photo-editor__tool:hover {
    background: var(--bs-tertiary-bg, #f8f9fa);
}

.axevio-photo-editor__trim,
.axevio-photo-editor__confirm {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-size: 0.85rem;
}

.axevio-photo-editor__trim {
    margin-left: auto;
}

.axevio-photo-editor__confirm {
    background: var(--bs-danger-bg-subtle, #f8d7da);
}

.axevio-photo-editor__foot {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--bs-border-color, #dee2e6);
}

/* Auf dem Handy: Vollbild, die Fläche nimmt alles, was übrig bleibt */
@media (max-width: 767px) {
    .axevio-photo-editor {
        padding: 0;
    }

    .axevio-photo-editor__dialog {
        max-width: none;
        height: 100%;
        height: 100dvh;
        border-radius: 0;
    }

    .axevio-photo-editor__stage {
        height: auto;
        min-height: 0;
    }

    .axevio-photo-editor__tool span {
        display: none;
    }

    .axevio-photo-editor__tool {
        width: 2.5rem;
        height: 2.5rem;
        justify-content: center;
        padding: 0;
    }
}

/* Kopf des Formulars: Titel links, „* Pflichtfeld“ rechts (bricht bei wenig Platz um) */
.axevio-personalization-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    margin-bottom: 0.75rem;
}

.axevio-personalization-head .axevio-personalization-title {
    margin-bottom: 0;
}

.axevio-required-note {
    margin: 0;
    color: var(--bs-secondary-color, #6c757d);
    font-size: 0.8125rem;
}
