/**
 * Document Viewer Panel — docked, resizable FileBird document viewer for the
 * data editor and wiki editor. Uses the shared --kop-* palette.
 */

/* Floating open button */
.kop-dv-toggle {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 99000;
    background: var(--kop-teal, #33A7B5);
    color: #fff;
    border: none;
    border-radius: 24px;
    padding: 11px 18px;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 4, 53, 0.3);
}
.kop-dv-toggle:hover { background: var(--kop-navy, #000080); }
.kop-dv-toggle.is-hidden { display: none; }

/* Smooth reflow of page content when docked */
body { transition: padding-right 0.15s ease, padding-bottom 0.15s ease; }
body.kop-dv-resizing { user-select: none; cursor: col-resize; }
body.kop-dv-resizing.kop-dv-bottom { cursor: row-resize; }

/* Panel */
.kop-dv-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 480px;
    z-index: 99001;
    background: var(--kop-sand, #F2EEDF);
    border-left: 1px solid rgba(0, 4, 53, 0.18);
    box-shadow: -8px 0 28px rgba(0, 4, 53, 0.22);
    display: none;
    flex-direction: column;
}
.kop-dv-panel.is-open { display: flex; }

.kop-dv-resizer {
    position: absolute;
    left: -4px;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    background: transparent;
}
.kop-dv-resizer:hover { background: rgba(51, 167, 181, 0.4); }

.kop-dv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px;
    background: var(--kop-navy, #000080);
    color: #fff;
}
.kop-dv-title { font-weight: 700; font-size: 0.95rem; }
.kop-dv-headbtns { display: flex; align-items: center; gap: 8px; }
.kop-dv-browse {
    background: var(--kop-orange, #EF9034);
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 6px 11px;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
}
.kop-dv-browse:hover { background: var(--kop-teal, #33A7B5); }
.kop-dv-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}
.kop-dv-close:hover { color: var(--kop-orange, #EF9034); }

.kop-dv-folder {
    padding: 8px 14px;
    font-size: 0.88rem;
    border-bottom: 1px solid rgba(0, 4, 53, 0.1);
    word-break: break-word;
}
.kop-dv-folder.dk-muted { color: #999; }

/* Document list (capped height; preview takes the rest) */
.kop-dv-list {
    flex: 0 0 auto;
    max-height: 34%;
    overflow-y: auto;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(0, 4, 53, 0.12);
}
.kop-dv-filter {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 10px;
    border: 1px solid var(--kop-teal, #33A7B5);
    border-radius: 7px;
    margin-bottom: 8px;
    font-size: 0.86rem;
}
.kop-dv-items { display: flex; flex-direction: column; gap: 2px; }
.kop-dv-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 7px 9px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.86rem;
    color: var(--kop-midnight, #000435);
}
.kop-dv-item:hover { background: var(--kop-mint, #B6E3D4); }
.kop-dv-item.is-active { background: var(--kop-soft-yellow, #FFF5CB); box-shadow: inset 3px 0 0 var(--kop-orange, #EF9034); }
.kop-dv-item-icon { flex: 0 0 auto; }
.kop-dv-item-name { flex: 1 1 auto; word-break: break-word; }

.kop-dv-loading, .kop-dv-empty, .kop-dv-error {
    padding: 16px;
    font-size: 0.86rem;
    color: #777;
    text-align: center;
}
.kop-dv-error { color: #c0392b; }

/* Preview area fills remaining height */
.kop-dv-preview {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fff;
}
.kop-dv-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    background: var(--kop-soft-yellow, #FFF5CB);
    border-bottom: 1px solid rgba(0, 4, 53, 0.1);
    font-size: 0.84rem;
}
.kop-dv-preview-title { font-weight: 600; word-break: break-word; }
.kop-dv-open { flex: 0 0 auto; color: var(--kop-navy, #000080); font-weight: 600; text-decoration: none; }
.kop-dv-open:hover { color: var(--kop-orange, #EF9034); }

.kop-dv-frame {
    flex: 1 1 auto;
    width: 100%;
    border: none;
    min-height: 0;
}
.kop-dv-imgwrap {
    flex: 1 1 auto;
    overflow: auto;
    text-align: center;
    background: #2b2b2b;
}
.kop-dv-imgwrap img { max-width: 100%; height: auto; }

/* Bottom-docked (top/bottom split) layout for narrow screens.
   Driven by JS toggling body.kop-dv-bottom below the desktop breakpoint. */
body.kop-dv-bottom .kop-dv-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    height: 50vh; /* overridden inline by JS; resizable via the top edge */
    border-left: none;
    border-top: 1px solid rgba(0, 4, 53, 0.18);
    box-shadow: 0 -8px 28px rgba(0, 4, 53, 0.22);
}

/* Resizer moves to the top edge and drags vertically when bottom-docked. */
body.kop-dv-bottom .kop-dv-resizer {
    left: 0;
    right: 0;
    top: -4px;
    bottom: auto;
    width: auto;
    height: 8px;
    cursor: row-resize;
}
body.kop-dv-bottom .kop-dv-resizer:hover { background: rgba(51, 167, 181, 0.4); }
