﻿* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    font-family: "Segoe UI", Arial, sans-serif;
    background: #05080b;
    color: #fff;
}

/* =========================
   HEADER
   ========================= */

.viewer-topbar {
    height: 62px;
    padding: 0 18px;
    background: #0d2d47;
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr) 100px;
    align-items: center;
    gap: 16px;
}

    .viewer-topbar a {
        color: #fff;
        text-decoration: none;
    }

    .viewer-topbar > div {
        min-width: 0;
        display: grid;
    }

    .viewer-topbar strong,
    .viewer-topbar span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .viewer-topbar span {
        color: #c1d1de;
        font-size: 13px;
    }

/* =========================
   TOÀN BỘ VIEWER
   ========================= */

.viewer-shell {
    height: calc(100vh - 62px);
    min-height: 0;
    display: grid;
    grid-template-columns: 135px minmax(0, 1fr);
}

/* =========================
   THUMBNAIL
   ========================= */

.thumbnail-list {
    min-height: 0;
    overflow-y: auto;
    padding: 8px;
    background: #101820;
    display: grid;
    align-content: start;
    gap: 8px;
}

    .thumbnail-list button {
        width: 100%;
        padding: 4px;
        border: 2px solid transparent;
        border-radius: 6px;
        background: #000;
        color: #fff;
        cursor: pointer;
    }

        .thumbnail-list button.active {
            border-color: #20a8ff;
        }

    .thumbnail-list img {
        display: block;
        width: 100%;
        height: 100px;
        object-fit: contain;
    }

    .thumbnail-list span {
        font-size: 12px;
    }

/* =========================
   KHU VỰC ẢNH
   ========================= */

.viewport-area {
    min-width: 0;
    min-height: 0;
    display: grid;
    /*
       minmax(0, 1fr) rất quan trọng.
       Nó buộc vùng ảnh chỉ chiếm phần chiều cao còn lại,
       không phình theo kích thước thật của ảnh DICOM.
    */
    grid-template-rows: auto minmax(0, 1fr);
}

/* =========================
   TOOLBAR
   ========================= */

.toolbar {
    min-height: 52px;
    padding: 8px 10px;
    background: #172331;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
}

    .toolbar button,
    .toolbar a {
        padding: 8px 11px;
        border: 0;
        border-radius: 6px;
        background: #34495d;
        color: #fff;
        text-decoration: none;
        cursor: pointer;
    }

        .toolbar button:hover,
        .toolbar a:hover {
            background: #49657d;
        }

    .toolbar #zoomText {
        margin-left: auto;
    }

/* =========================
   VIEWPORT
   ========================= */
#viewport {
    position: relative;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #05080b;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

    #viewport.dragging {
        cursor: grabbing;
    }

#mainImage {
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transform-origin: center center;
    user-select: none;
    pointer-events: none;
    -webkit-user-drag: none;
    will-change: transform;
}
/* =========================
   MOBILE
   ========================= */

@media (max-width: 700px) {
    .viewer-topbar {
        grid-template-columns: 100px minmax(0, 1fr) 60px;
    }

    .viewer-shell {
        grid-template-columns: 90px minmax(0, 1fr);
    }

    .thumbnail-list img {
        height: 70px;
    }

    .toolbar {
        max-height: 105px;
        overflow-y: auto;
    }
}
