/* ── Dashboard page styles ───────────────────────────────────────────────────
   These rules intentionally target DevExpress component internals and child
   component elements, which is why they live in a global CSS file rather than
   a Blazor-scoped Dashboard.razor.css.
──────────────────────────────────────────────────────────────────────────── */

/* Remove the drawer panel border so it doesn't double-up with the sidebar */
.dxbl-drawer-left.dxbl-drawer-mini.dxbl-drawer.dxbl-drawer-shrink > .dxbl-drawer-panel,
.dxbl-drawer-left.dxbl-drawer-open.dxbl-drawer.dxbl-drawer-shrink > .dxbl-drawer-panel {
    border-right: 0;
}

/* ── No-scroll dashboard layout ─────────────────────────────────────────── */

/* Fixed-height container. Flex column so the topbar sits above the drawer
   area without affecting the viewport height calculation. */
.dashboard-viewport {
    height: calc(100dvh - 48px - 0.5rem);
    width: 100%;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */

/* Always-visible strip at the top containing the search-panel toggle and the
   chart-collapse toggle. Shrinks to its content height; does not scroll. */
.dashboard-topbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0 0.5rem 0;
    background: var(--bs-body-bg);
}

/* ── Drawer area ─────────────────────────────────────────────────────────── */

/* Drawer area fills the remaining height below the topbar. */
.dashboard-drawer-area {
    flex: 1;
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow: visible;
}

/* Propagate height through the DevExpress Drawer */
.dashboard-drawer-area .dxbl-drawer,
.dashboard-drawer-area .dxbl-drawer-content {
    height: 100%;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

/* Propagate height through the DevExpress LoadingPanel */
.dashboard-drawer-area .dxbl-loading-panel,
.dashboard-drawer-area .dxbl-loading-panel-content {
    height: 100%;
}

/* Force CSS grid items in DxGridLayout to allow shrinking below content size */
.dashboard-drawer-area .dxbl-grid-layout > * {
    min-height: 0;
}

/* ── Player area ─────────────────────────────────────────────────────────── */

/* Flex split container replacing DxGridLayout for chart + player */
.dashboard-split-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: visible;
}

.dashboard-chart-pane {
    flex-shrink: 0;
    min-width: 0;
    overflow: visible;
    min-height: 80px;
}

.dashboard-divider {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    height: 6px;
    cursor: ns-resize;
    background: #dee2e6;
    border-radius: 3px;
    margin: 2px 0;
    touch-action: none;
    transition: background 0.15s;
}

.dashboard-splitter-dragging,
.dashboard-splitter-dragging * {
    user-select: none !important;
    -webkit-user-select: none !important;
}

.dashboard-splitter-dragging {
    cursor: ns-resize !important;
}

.dashboard-divider:hover,
.dashboard-divider--dragging {
    background: #0d6efd;
}

.dashboard-player-pane {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

/* Player area fills its pane */
.dashboard-player-area {
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* The stack-source-container inside StackofImageSource fills the player area */
.dashboard-player-area .stack-source-container {
    flex: 1;
    min-height: 0;
}

/* Visibility-toggle wrapper must participate in the flex column */
.dashboard-player-area-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* output-wrapper becomes a flex column so the camera-name title stacks
   above the player and the player takes the remaining height */
.dashboard-player-area .output-wrapper {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Camera-name title line does not grow */
.dashboard-player-area .output-wrapper > .fw-bold {
    flex-shrink: 0;
}

.dashboard-player-area .player-toolbar,
.dashboard-player-area .player-toolbar * {
    user-select: none;
    -webkit-user-select: none;
}

/* ── Chart area ──────────────────────────────────────────────────────────── */

/* Chart area fills its grid cell; canvas fills all available space. */
.dashboard-chart-item {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    position: relative;
    z-index: 0;
}

/* Chart canvas fills remaining space. Keep overflow visible so chart tooltips
   can escape the pane and render above the pill strip. */
.dashboard-chart-canvas {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: visible;
}

/* DxStackLayout (and any other direct child) fills the canvas */
.dashboard-chart-canvas > * {
    min-height: 0;
    height: 100% !important;
}

/* EventCollectionChart flex layout (toolbar + chart body) */
.event-chart-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    gap: 0;
    position: relative;
    z-index: 0;
}

.event-chart-toolbar {
    flex-shrink: 0;
    min-width: 0;
    margin-bottom: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
    z-index: 1;
}

.event-chart-body {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: visible;
    position: relative;
    z-index: 2;
}

/* Left/right "scroll" arrows overlaid on the chart edges. Clicking shifts the
   visible period, and — once at the edge of the currently loaded data — asks
   the parent to fetch the next period/eventbucket (see NavigatePeriodAsync). */
.chart-scroll-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    color: #495057;
    opacity: 0.55;
    transition: opacity 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

.chart-scroll-arrow:hover {
    opacity: 1;
    background: #ffffff;
}

.chart-scroll-arrow--left {
    left: 4px;
}

.chart-scroll-arrow--right {
    right: 4px;
}

/* ── Chart tooltip ──────────────────────────────────────────────────────── */

/* DevExpress sets dxbl-chart-tooltip at z-index:1; raise it above chart headers. */
.event-chart-body .dxbl-chart-tooltip {
    z-index: 2000 !important;
    /* Keep tooltip close to the bar baseline (just above the x-axis labels). */
    top: auto !important;
    bottom: 68px !important;
    transform: translateX(-50%) !important;
    width: max-content !important;
    max-width: min(80vw, 960px) !important;
}

/* The chart is nested inside a DxDrawer whose wrapper (.dxbl-drawer) and content
   (.dxbl-drawer-content) both clip with overflow:hidden. Chart tooltips use
   translate(-50%,-100%), so for tall bars the top of the tooltip extends above
   the drawer's top edge (right below the class-toggle topbar) and gets clipped,
   leaving the tooltip's top hidden behind that bar. Let tooltips escape the
   drawer bounds. The closed search panel is visibility:hidden and the open one
   is in-flow (shrink) with its own overflow:hidden, so this does not expose it. */
.dashboard-drawer-area .dxbl-drawer,
.dashboard-drawer-area .dxbl-drawer .dxbl-drawer-content {
    overflow: visible;
    min-width: 0;
}

.chart-tooltip {
    display: inline-block;
    box-sizing: border-box;
    width: max-content;
    font-size: 0.82rem;
    line-height: 1.4;
    min-width: 140px;
    max-width: min(78vw, 920px);
    overflow: hidden;
}

.chart-tooltip-header {
    font-weight: 600;
    margin-bottom: 4px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 3px;
}

.chart-tooltip-total {
    font-weight: 600;
    margin-bottom: 3px;
}

.chart-tooltip-items {
    display: block;
}

/* When the class list is long, render exactly two in-box columns so items do
   not spill outside the tooltip rectangle. */
.chart-tooltip-items--columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px 16px;
    max-width: min(72vw, 860px);
    width: max-content;
    max-width: min(76vw, 900px);
}

.chart-tooltip-item {
    break-inside: avoid;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 1px 0;
}

.chart-tooltip-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Time/timezone debug overlay (toggled via chart toolbar bug icon) ───── */

.chart-time-debug-overlay {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-family: monospace;
    font-size: 11px;
    line-height: 1.4;
    padding: 6px 8px;
    border-radius: 4px;
    pointer-events: none;
    white-space: nowrap;
}

/* ── Event class pill filter strip ──────────────────────────────────────── */

/* Single-line scrollable pill container; expands to wrap when toggled */
.pill-strip {
    display: flex;
    flex-wrap: nowrap;
    overflow: hidden;
    gap: 0.25rem;
    align-items: center;
    min-width: 0;
    flex: 1;
}

.pill-strip--expanded {
    flex-wrap: wrap;
}

.event-class-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 50rem;
    padding: 2px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
    border: 2px solid transparent;
    transition: opacity 0.15s, background-color 0.15s;
    font-weight: 500;
}

.event-class-pill--off {
    background-color: transparent;
    opacity: 0.65;
}

/* Blur state: solid fill like --on but with reduced opacity and a dashed border
   to signal that the class is counted in the chart but blurred in the player. */
.event-class-pill--blur {
    opacity: 0.80;
    border-style: dashed !important;
}

/* Keep zero-count classes visible for stable layout, but de-emphasized. */
.event-class-pill--zero {
    opacity: 0.45;
}

.event-class-count {
    font-weight: 400;
    opacity: 0.85;
}

/* Blur radius slider — appears inline next to the pill strip when blur is active */
.blur-radius-control {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    white-space: nowrap;
}

.blur-radius-slider {
    width: 70px;
    padding: 0;
    cursor: pointer;
}
