/* =========================================================
   Kontakt-Scanner – kompakte Seitenübersicht + Seiteneditor
   Ergänzung zu contact-scan.css
   ========================================================= */

.scan-test__preview-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    gap: .5rem;
    margin: 0 0 .75rem;
}

.scan-test__preview-actions .scan-test__add-page-button {
    min-height: 48px;
    font-size: .82rem;
}

.scan-test__preview-actions [data-scan-clear] {
    min-height: 48px;
    white-space: nowrap;
}

.scan-test__pages {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: .65rem;
}

.scan-test__page.scan-gallery__page {
    min-width: 0;
    padding: .4rem;
    border: 1px solid var(--aside-line);
    background: #faf8f8;
}

.scan-gallery__edit-trigger {
    position: relative;
    display: block;
    width: 100%;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    overflow: hidden;
    aspect-ratio: 3 / 4;
    background: #efefef;
    color: var(--bordeaux);
    cursor: pointer;
}

.scan-gallery__edit-trigger:hover,
.scan-gallery__edit-trigger:focus-visible {
    background: #efefef;
    color: var(--bordeaux-dark);
}

.scan-gallery__edit-trigger:focus-visible {
    outline: 2px solid var(--bordeaux);
    outline-offset: 2px;
}

.scan-gallery__page-preview {
    display: block;
    width: 100%;
    max-width: none;
    max-height: none;
    height: 100%;
    object-fit: contain;
    background: #f2f2f2;
}

.scan-gallery__edit-badge {
    position: absolute;
    right: .45rem;
    bottom: .45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255, 255, 255, .82);
    border-radius: 50%;
    background: rgba(128, 0, 0, .94);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
    font-size: .78rem;
    pointer-events: none;
}

.scan-gallery__page-caption {
    margin-top: .4rem;
    font-size: .74rem;
}

.scan-gallery__editor {
    position: fixed;
    z-index: 2147483000;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: #111111;
    color: #ffffff;
}

.scan-gallery__editor[hidden] {
    display: none !important;
}

.scan-gallery__editor-toolbar {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) 46px;
    align-items: center;
    min-height: 66px;
    padding: max(.45rem, env(safe-area-inset-top)) .65rem .45rem;
    background: rgba(0, 0, 0, .86);
    text-align: center;
}

.scan-gallery__editor-toolbar::after {
    content: "";
}

.scan-gallery__editor-toolbar strong,
.scan-gallery__editor-toolbar span {
    display: block;
}

.scan-gallery__editor-toolbar strong {
    font-size: .95rem;
    line-height: 1.25;
}

.scan-gallery__editor-toolbar span {
    margin-top: .15rem;
    color: #cccccc;
    font-size: .72rem;
    line-height: 1.25;
}

.scan-gallery__editor-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #ffffff;
    font-size: 1.15rem;
}

.scan-gallery__editor-close:hover,
.scan-gallery__editor-close:focus-visible {
    background: rgba(255, 255, 255, .12);
    color: #ffffff;
}

.scan-gallery__editor-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: .75rem;
    background: #181818;
}

.scan-gallery__editor-body canvas {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    background: #ffffff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .35);
}

.scan-gallery__editor-controls {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .45rem;
    padding: .65rem .65rem max(.65rem, env(safe-area-inset-bottom));
    background: rgba(0, 0, 0, .9);
}

.scan-gallery__editor-controls button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-width: 0;
    min-height: 46px;
    padding: .55rem .45rem;
    border: 1px solid #9b2a2a;
    border-radius: 0;
    background: #800000;
    color: #ffffff;
    font: inherit;
    font-size: .78rem;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
}

.scan-gallery__editor-controls button:hover,
.scan-gallery__editor-controls button:focus-visible {
    background: #650000;
    color: #ffffff;
}

.scan-gallery__editor-controls .scan-gallery__editor-remove {
    border-color: #d79a9a;
    background: transparent;
    color: #ffd7d7;
}

.scan-gallery__editor-controls .scan-gallery__editor-remove:hover,
.scan-gallery__editor-controls .scan-gallery__editor-remove:focus-visible {
    background: rgba(128, 0, 0, .35);
    color: #ffffff;
}

.scan-gallery__editor-controls .scan-gallery__editor-done {
    border-color: #ffffff;
    background: #ffffff;
    color: #800000;
    font-weight: 600;
}

.scan-gallery__editor-controls .scan-gallery__editor-done:hover,
.scan-gallery__editor-controls .scan-gallery__editor-done:focus-visible {
    background: #f3e9e9;
    color: #650000;
}

html[data-theme="dark"] .scan-test__page.scan-gallery__page {
    border-color: #533b3e;
    background: #2a2022;
}

html[data-theme="dark"] .scan-gallery__edit-trigger,
html[data-theme="dark"] .scan-gallery__edit-trigger:hover,
html[data-theme="dark"] .scan-gallery__edit-trigger:focus-visible {
    background: #211b1c;
}

html[data-theme="dark"] .scan-gallery__page-caption span {
    color: #b9b0b2;
}

@media (max-width: 700px) {
    .scan-test__preview-actions {
        grid-template-columns: 1fr;
    }

    .scan-test__preview-actions [data-scan-clear] {
        width: 100%;
    }

    .scan-test__pages {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .5rem;
    }

    .scan-test__page.scan-gallery__page {
        padding: .3rem;
    }


    .scan-gallery__edit-badge {
        width: 30px;
        height: 30px;
        right: .35rem;
        bottom: .35rem;
    }

    .scan-gallery__editor-controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scan-gallery__editor-controls button {
        min-height: 48px;
        font-size: .74rem;
    }
}

@media (max-width: 390px) {
    .scan-gallery__page-caption {
        font-size: .68rem;
    }

    .scan-gallery__editor-toolbar {
        grid-template-columns: 42px minmax(0, 1fr) 42px;
        padding-left: .45rem;
        padding-right: .45rem;
    }

    .scan-gallery__editor-controls {
        gap: .35rem;
        padding-left: .45rem;
        padding-right: .45rem;
    }
}
