/**
 * Bericht Image Viewer - Lightbox mit Touch-Zoom
 * Standalone CSS für den Bild-Viewer im Bericht-Modul
 */

/* ========== Overlay (Fullscreen) ========== */
.bericht-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none; /* Verhindert Browser-Gesten */
}

.bericht-viewer-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ========== Bild-Container ========== */
.bericht-viewer-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* ========== Das Bild selbst ========== */
.bericht-viewer-image {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    transform-origin: center center;
    transition: transform 0.15s ease-out;
    cursor: grab;
    pointer-events: auto;
}

.bericht-viewer-image.dragging {
    cursor: grabbing;
    transition: none;
}

.bericht-viewer-image.zoomed {
    max-width: none;
    max-height: none;
}

/* ========== Schliessen-Button ========== */
.bericht-viewer-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.15s ease;
}

.bericht-viewer-close:hover,
.bericht-viewer-close:focus {
    background: rgba(255, 255, 255, 0.3);
    outline: none;
}

/* ========== Navigation (Pfeile) ========== */
.bericht-viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 80px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.bericht-viewer-nav:hover,
.bericht-viewer-nav:focus {
    background: rgba(255, 255, 255, 0.25);
    outline: none;
}

.bericht-viewer-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.bericht-viewer-nav.prev {
    left: 8px;
    border-radius: 4px 8px 8px 4px;
}

.bericht-viewer-nav.next {
    right: 8px;
    border-radius: 8px 4px 4px 8px;
}

/* ========== Bild-Counter (3 / 12) ========== */
.bericht-viewer-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 14px;
    border-radius: 20px;
    z-index: 10;
    font-variant-numeric: tabular-nums;
}

/* ========== Zoom-Buttons ========== */
.bericht-viewer-zoom {
    position: absolute;
    bottom: 20px;
    right: 16px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.bericht-viewer-zoom button {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.bericht-viewer-zoom button:hover,
.bericht-viewer-zoom button:focus {
    background: rgba(255, 255, 255, 0.3);
    outline: none;
}

/* ========== Titel-Anzeige ========== */
.bericht-viewer-title {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 13px;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 12px;
    border-radius: 4px;
    max-width: 80vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 10;
}

/* ========== Lade-Indikator ========== */
.bericht-viewer-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 14px;
    z-index: 5;
}

.bericht-viewer-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    margin-left: 8px;
    animation: viewer-spin 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes viewer-spin {
    to { transform: rotate(360deg); }
}

/* ========== Anhang-Vorschau klickbar machen ========== */
.att-preview {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.15s ease;
}

.att-preview:hover {
    background: rgba(0, 0, 0, 0.08);
}

.att-preview .att-icon {
    flex-shrink: 0;
}

.att-preview .att-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========== Mobile Anpassungen ========== */
@media (max-width: 768px) {
    .bericht-viewer-nav {
        width: 44px;
        height: 60px;
        font-size: 24px;
    }

    .bericht-viewer-nav.prev { left: 4px; }
    .bericht-viewer-nav.next { right: 4px; }

    .bericht-viewer-close {
        top: 8px;
        right: 8px;
        width: 40px;
        height: 40px;
        font-size: 24px;
    }

    .bericht-viewer-zoom {
        bottom: 16px;
        right: 8px;
    }

    .bericht-viewer-zoom button {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .bericht-viewer-counter {
        bottom: 16px;
        font-size: 12px;
        padding: 4px 10px;
    }

    .bericht-viewer-title {
        bottom: 50px;
        font-size: 11px;
        padding: 4px 8px;
    }

    .bericht-viewer-image {
        max-width: 100vw;
        max-height: 100vh;
    }
}

/* ========== Swipe-Hinweis (einmalig bei erstem Öffnen) ========== */
.bericht-viewer-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    text-align: center;
    pointer-events: none;
    animation: viewer-hint-fade 2s ease-out forwards;
    z-index: 15;
}

@keyframes viewer-hint-fade {
    0% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}
