/* ── DICOM Viewer Core ─────────────────────────────────────────────────────── */

:root {
    --dcm-primary: #2563eb;
    --dcm-border: none;
}

/* ── Base button ── */
.dcm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-family: inherit;
    padding: 4px 10px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #222;
    color: #ccc;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.4;
    transition: background 0.15s, color 0.15s;
}

.dcm-btn:hover {
    background: #333;
    color: #fff;
}

/* ── Viewer wrap ── */
.dcm-viewer-wrap {
    position: relative;
    border: 1px solid var(--dcm-border);
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    margin-bottom: 10px;
    box-sizing: border-box;
}

/* ── Series bar ── */
.dcm-series-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #111;
    overflow-x: auto;
    flex-wrap: nowrap;
}

.dcm-grid-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    flex-wrap: wrap;
}

.dcm-pane-selector {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dcm-pane-count-btn,
.dcm-ref-toggle {
    min-width: 32px;
    min-height: 28px;
    padding: 4px 8px;
}

.dcm-pane-count-btn.is-active,
.dcm-ref-toggle.is-active {
    background: var(--dcm-primary);
    color: #fff;
    border-color: var(--dcm-primary);
}

.dcm-ref-hint {
    margin-left: auto;
    color: #888;
    font-size: 12px;
    white-space: nowrap;
}

.dcm-pane-series-select {
    min-width: 0;
    max-width: none;
}

/* ── Main viewer ── */
.dcm-viewer {
    width: 100%;
    height: 480px;
    position: relative;
    background: #000;
}

.dcm-viewer canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.dcm-grid-wrap {
    display: grid;
    grid-template-columns: repeat(var(--dcm-grid-cols, 1), minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    height: 100%;
    padding: 8px;
    box-sizing: border-box;
}

.dcm-pane {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border: 1px solid #1f1f1f;
    border-radius: 6px;
    overflow: hidden;
    background: #000;
}

.dcm-pane.is-active {
    border-color: var(--dcm-primary);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.45);
}

.dcm-pane-viewport {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    background: #000;
}

.dcm-pane-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: #0f0f0f;
    border-top: 1px solid #1f1f1f;
}

.dcm-pane-footer.is-active {
    background: #141414;
}

.dcm-pane-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 7px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: #d4d4d4;
    font-size: 11px;
    line-height: 1.1;
    white-space: nowrap;
}

.dcm-pane-color {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--dcm-pane-color, var(--dcm-primary));
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
    flex: 0 0 auto;
}

.dcm-pane-footer-controls {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
}

.dcm-pane-footer .dcm-series-select {
    width: 100%;
    min-width: 0;
    max-width: none;
    min-height: 24px;
    padding: 2px 6px;
    font-size: 12px;
    line-height: 1.2;
}

.dcm-pane-canvas,
.dcm-ref-canvas {
    position: absolute;
    inset: 0;
}

.dcm-ref-canvas {
    pointer-events: none;
}

/* ── Slice scrollbar ── */
.dcm-slice-scrollbar {
    position: absolute;
    right: 4px;
    top: 10px;
    bottom: 10px;
    width: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    z-index: 10;
}

.dcm-slice-thumb {
    position: absolute;
    left: 0;
    right: 0;
    height: 40px;
    top: 0;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 10px;
    transition: background 0.1s;
}

.dcm-slice-scrollbar:hover .dcm-slice-thumb,
.dcm-slice-scrollbar:active .dcm-slice-thumb {
    background: rgba(255, 255, 255, 0.75);
}

/* ── Overlay (loading / error) ── */
.dcm-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    pointer-events: none;
}

.dcm-loading,
.dcm-error {
    color: #aaa;
    font-size: 14px;
}

.dcm-error {
    color: #f87171;
}

/* ── Toolbar ── */
.dcm-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: #111;
    border-top: 1px solid #333;
}

.dcm-tools {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.dcm-tool-btn,
.dcm-reset-btn,
.dcm-prev,
.dcm-next {
    color: #ccc;
    border-color: #444;
    background: #222;
}

.dcm-tool-btn:hover,
.dcm-reset-btn:hover,
.dcm-prev:hover,
.dcm-next:hover,
.dcm-zoom-in:hover,
.dcm-zoom-out:hover,
.dcm-wl-inc:hover,
.dcm-wl-dec:hover {
    background: #333;
    color: #fff;
}

/* ── Button group (zoom +/-, W/L +/-) ── */
.dcm-btn-group {
    display: flex;
    border: 1px solid #444;
    border-radius: 4px;
    background: #222;
    overflow: hidden;
    margin-right: 4px;
}

.dcm-btn-group button {
    border: none !important;
    background: transparent !important;
    color: #ccc;
    min-width: 32px;
    height: 28px;
    padding: 0 8px;
    font-weight: bold;
    cursor: pointer;
}

.dcm-btn-group button:first-child {
    border-right: 1px solid #444 !important;
}

.dcm-btn-group button:hover {
    background: #333 !important;
    color: #fff !important;
}

/* ── Active tool ── */
.dcm-tool-btn.is-active {
    background: var(--dcm-primary);
    color: #fff;
    border-color: var(--dcm-primary);
}

/* ── Slice navigation ── */
.dcm-slice-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dcm-slice-nav .dcm-btn {
    min-width: 32px;
    min-height: 28px;
    padding: 4px 8px;
}

.dcm-play {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--dcm-accent, var(--dcm-primary));
}

.dcm-play-icon {
    position: relative;
    display: block;
    width: 14px;
    height: 14px;
}

.dcm-play-icon::before,
.dcm-play-icon::after {
    content: "";
    position: absolute;
}

.dcm-play-icon::before {
    top: 0;
    left: 2px;
    width: 0;
    height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-left: 10px solid currentColor;
}

.dcm-play-icon::after {
    display: none;
}

.dcm-play.is-playing .dcm-play-icon::before,
.dcm-play.is-playing .dcm-play-icon::after {
    top: 1px;
    width: 3px;
    height: 12px;
    background: currentColor;
    border: 0;
}

.dcm-play.is-playing .dcm-play-icon::before {
    left: 2px;
}

.dcm-play.is-playing .dcm-play-icon::after {
    display: block;
    right: 2px;
}

.dcm-slice-info {
    color: #aaa;
    font-size: 13px;
    min-width: 50px;
    text-align: center;
}

/* ── Download bar ── */
.dcm-download-bar {
    padding: 8px 12px;
    background: #111;
    border-top: 1px solid #333;
}

.dcm-download {
    display: inline-block;
    padding: 4px 12px;
    font-size: 13px;
    color: #ccc;
    border: 1px solid #444;
    border-radius: 4px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.dcm-download:hover {
    background: #333;
    color: #fff;
}

.dcm-download-name {
    color: #888;
    font-size: 12px;
    margin-left: 4px;
}

/* Series bar: dropdown mode */
.dcm-series-bar .dcm-series-label {
    color: #aaa;
    font-size: 12px;
    white-space: nowrap;
    user-select: none;
}

.dcm-series-select {
    font-size: 13px;
    font-family: inherit;
    background: #222;
    color: #ccc;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    min-width: 160px;
    max-width: 320px;
    flex: 1 1 auto;
    line-height: 1.4;
}

.dcm-series-select:hover {
    border-color: #666;
    background: #2a2a2a;
}

.dcm-series-select:focus {
    outline: 2px solid var(--dcm-primary);
    outline-offset: 1px;
}

.dcm-info-modal {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: none;
    align-items: stretch;
    justify-content: flex-end;
    padding-left: 32px;
    background: rgba(0, 0, 0, 0.72);
}

.dcm-info-modal.is-open {
    display: flex;
}

.dcm-info-panel {
    display: flex;
    flex-direction: column;
    width: min(520px, 100%);
    height: 100%;
    background: #0d0d0d;
    border-left: 1px solid #262626;
    color: #d4d4d4;
    box-shadow: -24px 0 48px rgba(0, 0, 0, 0.35);
    outline: none;
}

.dcm-info-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 14px;
    border-bottom: 1px solid #242424;
    background: #111;
}

.dcm-info-heading {
    min-width: 0;
}

.dcm-info-kicker {
    color: #7a7a7a;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dcm-info-title {
    margin: 4px 0 0;
    color: #f5f5f5;
    font-size: 18px;
    line-height: 1.2;
}

.dcm-info-subtitle {
    margin-top: 6px;
    color: #9b9b9b;
    font-size: 12px;
}

.dcm-info-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-bottom: 1px solid #1f1f1f;
    background: #0f0f0f;
}

.dcm-info-search {
    width: 100%;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #2f2f2f;
    border-radius: 6px;
    background: #181818;
    color: #e7e7e7;
    font: inherit;
}

.dcm-info-search:focus {
    outline: 2px solid var(--dcm-primary);
    outline-offset: 1px;
}

.dcm-info-summary {
    flex: 0 0 auto;
    color: #8f8f8f;
    font-size: 12px;
    white-space: nowrap;
}

.dcm-info-body {
    flex: 1 1 auto;
    overflow: auto;
    padding: 10px 18px 18px;
}

.dcm-info-list {
    display: flex;
    flex-direction: column;
}

.dcm-info-row {
    display: grid;
    grid-template-columns: minmax(0, 180px) minmax(0, 1fr);
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid #202020;
}

.dcm-info-modal [hidden] {
    display: none !important;
}

.dcm-info-meta {
    min-width: 0;
    padding-left: calc(var(--dcm-info-depth, 0) * 14px);
}

.dcm-info-label {
    color: #efefef;
    font-size: 13px;
    font-weight: 600;
}

.dcm-info-tagline {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.dcm-info-tag {
    color: #7f7f7f;
    font-size: 11px;
    font-family: Consolas, Monaco, "Courier New", monospace;
}

.dcm-info-vr {
    padding: 1px 6px;
    border: 1px solid #333;
    border-radius: 999px;
    color: #a5a5a5;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.dcm-info-value {
    min-width: 0;
    color: #c7c7c7;
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
}

.dcm-info-row.is-item .dcm-info-label {
    color: #cbb78e;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dcm-info-row.is-sequence .dcm-info-label {
    color: #8fc5ff;
}

.dcm-info-empty {
    margin: 14px 18px 18px;
    color: #9b9b9b;
    font-size: 13px;
}

/* Select2 dark theme overrides (only active when Select2 is present) */
.dcm-select2-dropdown {
    background: #1a1a1a;
    border: 1px solid #444;
    color: #ccc;
}

@media (max-width: 640px) {
    .dcm-info-modal {
        padding-left: 0;
    }

    .dcm-info-panel {
        width: 100%;
        border-left: 0;
    }

    .dcm-info-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .dcm-info-tools {
        flex-direction: column;
        align-items: stretch;
    }

    .dcm-info-summary {
        white-space: normal;
    }
}
