/* Kardiotechnik Archiv - PDF Blätter-Viewer */

.kt-flipviewer {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    overflow: hidden;
    background: #1e293b;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    position: relative;
}

/* Toolbar */
.kt-fv-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

.kt-fv-toolbar-left,
.kt-fv-toolbar-center,
.kt-fv-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.kt-fv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 1rem;
    color: #374151;
    text-decoration: none;
    transition: all 0.15s;
    line-height: 1;
}

.kt-fv-btn:hover {
    background: #e0e7ff;
    border-color: #818cf8;
    color: #3730a3;
}

.kt-fv-pageinput {
    width: 50px;
    text-align: center;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 0.25rem;
    font-size: 0.9rem;
}

.kt-fv-pageinfo {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.9rem;
    color: #475569;
}

.kt-fv-zoom {
    font-size: 0.8rem;
    color: #64748b;
    min-width: 40px;
    text-align: center;
}

.kt-fv-article-hint {
    font-size: 0.8rem;
    color: #1a4d8f;
    font-weight: 600;
    background: #e0e7ff;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
}

/* Viewport - Höhe so dass eine ganze PDF-Seite sichtbar ist */
.kt-fv-viewport {
    position: relative;
    overflow: auto;
    background: #374151;
    min-height: 700px;
    height: calc(100vh - 200px);
    max-height: 1200px;
    display: flex;
    justify-content: center;
    cursor: default;
}

.kt-fv-canvas-wrap {
    display: flex;
    justify-content: center;
    padding: 16px;
}

.kt-fv-canvas {
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    background: #fff;
    display: block;
}

/* Blätter-Animation */
.kt-fv-flip {
    animation: ktFlipIn 0.3s ease-out;
}

@keyframes ktFlipIn {
    0% {
        opacity: 0.6;
        transform: perspective(800px) rotateY(-8deg) scale(0.97);
    }
    100% {
        opacity: 1;
        transform: perspective(800px) rotateY(0) scale(1);
    }
}

/* Klick-Zonen visuell (hover) */
.kt-fv-viewport::before,
.kt-fv-viewport::after {
    content: '';
    position: absolute;
    top: 0;
    width: 15%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    transition: background 0.2s;
}
.kt-fv-viewport::before { left: 0; }
.kt-fv-viewport::after { right: 0; }

.kt-fv-viewport:hover::before {
    background: linear-gradient(to right, rgba(0,0,0,0.03), transparent);
    cursor: w-resize;
}
.kt-fv-viewport:hover::after {
    background: linear-gradient(to left, rgba(0,0,0,0.03), transparent);
    cursor: e-resize;
}

/* Loading */
.kt-fv-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(30,41,59,0.7);
    z-index: 10;
}

.kt-fv-spinner {
    width: 36px;
    height: 36px;
    border: 4px solid rgba(255,255,255,0.2);
    border-top-color: #60a5fa;
    border-radius: 50%;
    animation: ktSpin 0.7s linear infinite;
}

@keyframes ktSpin { to { transform: rotate(360deg); } }

/* Error */
.kt-fv-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #f1f5f9;
    text-align: center;
    min-height: 300px;
}

/* Thumbnails */
.kt-fv-thumbs {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    background: #0f172a;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #475569 #0f172a;
}

.kt-fv-thumbs::-webkit-scrollbar { height: 6px; }
.kt-fv-thumbs::-webkit-scrollbar-track { background: #0f172a; }
.kt-fv-thumbs::-webkit-scrollbar-thumb { background: #475569; border-radius: 3px; }

.kt-fv-thumb {
    flex-shrink: 0;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    transition: border-color 0.2s, transform 0.15s;
    position: relative;
    opacity: 0.7;
}

.kt-fv-thumb:hover {
    opacity: 1;
    transform: scale(1.05);
}

.kt-fv-thumb.active {
    border-color: #60a5fa;
    opacity: 1;
    transform: scale(1.08);
}

.kt-fv-thumb-article {
    border-color: rgba(234,179,8,0.5);
    opacity: 0.9;
}

.kt-fv-thumb-article.active {
    border-color: #eab308;
}

.kt-fv-thumb-canvas {
    display: block;
    height: 80px;
    width: auto;
}

.kt-fv-thumb-label {
    display: block;
    text-align: center;
    font-size: 0.65rem;
    color: #94a3b8;
    padding: 1px 0;
    background: #1e293b;
}

/* Fullscreen */
.kt-fv-fullscreen {
    border-radius: 0;
}

.kt-fv-fullscreen .kt-fv-viewport {
    max-height: none;
    height: calc(100vh - 110px);
}

.kt-fv-fullscreen .kt-fv-thumb-canvas {
    height: 100px;
}

/* iframe Fallback (wenn PDF.js wegen CORS nicht laden kann) */
.kt-fv-iframe {
    width: 100%;
    height: 100%;
    min-height: 700px;
    border: none;
    display: block;
    background: #fff;
}

.kt-fv-iframe-hint {
    padding: 0.5rem 1rem;
    background: #1e293b;
    color: #94a3b8;
    font-size: 0.8rem;
    text-align: center;
}

.kt-fv-iframe-hint strong {
    color: #fbbf24;
}

/* ============================== */
/* Smartphone-Optimierung         */
/* ============================== */

/* Tablets */
@media (max-width: 1024px) {
    .kt-fv-viewport {
        height: calc(100vh - 180px);
        min-height: 500px;
    }
}

/* Smartphones Landscape + Portrait */
@media (max-width: 768px) {
    .kt-flipviewer {
        margin-left: -1rem;
        margin-right: -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .kt-fv-toolbar {
        padding: 0.3rem 0.5rem;
        gap: 0.15rem;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .kt-fv-toolbar-left {
        gap: 0.1rem;
    }

    /* Erste/Letzte Seite Buttons auf Smartphone ausblenden */
    .kt-fv-btn[data-action="first"],
    .kt-fv-btn[data-action="last"],
    .kt-fv-btn[data-action="zoom-fit"] {
        display: none;
    }

    .kt-fv-toolbar-center { display: none; }

    .kt-fv-btn {
        min-width: 36px;
        height: 36px;
        font-size: 1.1rem;
        padding: 0;
        border-radius: 8px;
    }

    .kt-fv-pageinput {
        width: 36px;
        height: 32px;
        font-size: 0.85rem;
        padding: 0.15rem;
    }

    .kt-fv-zoom { font-size: 0.7rem; min-width: 30px; }

    .kt-fv-viewport {
        height: calc(100vh - 160px);
        min-height: 400px;
        max-height: none;
    }

    .kt-fv-canvas-wrap { padding: 4px; }

    /* Thumbnails kleiner */
    .kt-fv-thumbs {
        padding: 4px 6px;
        gap: 4px;
    }
    .kt-fv-thumb-canvas { height: 45px; }
    .kt-fv-thumb-label { font-size: 0.55rem; }

    /* iframe Fallback */
    .kt-fv-iframe { min-height: 500px; }
}

/* Smartphones Portrait (eng) */
@media (max-width: 480px) {
    .kt-fv-toolbar-right {
        gap: 0.1rem;
    }

    /* Zoom-Buttons ausblenden, nur Vollbild + Download */
    .kt-fv-btn[data-action="zoom-in"],
    .kt-fv-btn[data-action="zoom-out"] {
        display: none;
    }
    .kt-fv-zoom { display: none; }

    .kt-fv-viewport {
        height: calc(100vh - 140px);
        min-height: 350px;
    }

    .kt-fv-thumbs { display: none; }
}

/* Smartphone Landscape */
@media (max-height: 500px) and (orientation: landscape) {
    .kt-fv-viewport {
        height: calc(100vh - 100px);
        min-height: 250px;
    }
    .kt-fv-thumbs { display: none; }
    .kt-fv-toolbar { padding: 0.2rem 0.5rem; }
    .kt-fv-btn { min-width: 30px; height: 30px; }
}
