/* Report designer (Client/Pages/DetailView/ReportDesignerPage + Components/ReportDesign). Global because the
   host page does not load the scoped-CSS bundle (*.styles.css), so .razor.css files are not applied. */
/* RadzenLayout is a 100dvh grid and .rz-body is its only scroller, so any viewport arithmetic here
   overshoots that row by the body's own margin/padding and shows a second, page-level scrollbar.
   :has() lets the designer give its own wrapper a definite height without changing
   .app-content-reflow for every other page; the dvh value is the fallback where :has() is missing. */
.rd-root {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 150px);
    min-height: 420px;
    gap: 6px;
}

.rz-body:has(> .app-content-reflow > .rd-root) { overflow: hidden; }

.app-content-reflow:has(> .rd-root) { height: 100%; }

.app-content-reflow:has(> .rd-root) > .rd-root {
    height: 100%;
    min-height: 0;
}

.rd-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 4px 6px;
    border: 1px solid var(--rz-base-300, #ddd);
    border-radius: 6px;
    background: var(--rz-base-100, #fafafa);
}

.rd-toolbar-spacer { flex: 1; }

.rd-name { width: 280px; font-weight: 600; }

.rd-status { font-size: 0.8rem; color: var(--rz-text-secondary-color, #666); }

.rd-errors ul { margin: 0; padding-left: 1.1rem; }
.rd-errors li { font-family: Consolas, monospace; font-size: 0.8rem; }

.rd-body {
    --rd-left: 300px;
    --rd-right: 400px;
    display: grid;
    grid-template-columns: var(--rd-left) 8px minmax(0, 1fr) 8px var(--rd-right);
    gap: 0;
    flex: 1;
    min-height: 0;
}

.rd-splitter {
    cursor: col-resize;
    position: relative;
    background: transparent;
}
.rd-splitter::after {
    content: "";
    position: absolute;
    top: 0; bottom: 0; left: 3px; width: 2px;
    border-radius: 2px;
    background: var(--rz-base-300, #ddd);
    transition: background .15s;
}
.rd-splitter:hover::after, .rd-resizing .rd-splitter::after { background: var(--rz-primary, #2563eb); }
.rd-resizing { cursor: col-resize; user-select: none; }
.rd-resizing .rd-preview { pointer-events: none; } /* the iframe would otherwise swallow mousemove */

.rd-pane {
    border: 1px solid var(--rz-base-300, #ddd);
    border-radius: 6px;
    background: #fff;
    overflow: auto;
    padding: 6px;
}

.rd-center {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--rz-base-300, #ddd);
    border-radius: 6px;
    background: #eceff1;
    min-width: 0;
    overflow: hidden;
}

.rd-preview { flex: 1; width: 100%; border: 0; background: #eceff1; }

.rd-preview-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--rz-text-secondary-color, #666);
    padding: 1rem;
    text-align: center;
}

.rd-json-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    background: #fff;
    border-bottom: 1px solid var(--rz-base-300, #ddd);
    font-size: 0.85rem;
}

.rd-json {
    flex: 1;
    width: 100%;
    border: 0;
    resize: none;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    padding: 8px;
    background: #fff;
}

/* ---- shared by the designer child components (they render inside these panes) ---- */

.rd-panel-title {
    font-weight: 600;
    font-size: 0.9rem;
    padding: 4px 2px 6px;
    border-bottom: 1px solid var(--rz-base-300, #ddd);
    margin-bottom: 6px;
}

.rd-panel-title-actions { display: flex; justify-content: space-between; align-items: center; }
.rd-actions { display: flex; gap: 2px; }

.rd-section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--rz-text-secondary-color, #666);
    margin: 10px 2px 2px;
}

.rd-node {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
}

.rd-node:hover { background: var(--rz-base-200, #f0f0f0); }
.rd-node-selected, .rd-node-selected:hover { background: var(--rz-primary-lighter, #dbeafe); }
.rd-node-root { font-weight: 600; }
.rd-node-icon { font-size: 0.8rem; width: 14px; opacity: 0.8; }

/* Collapse caret. Always present (empty on leaves) so the type icons line up down the tree. */
.rd-node-caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    flex: 0 0 14px;
    opacity: 0.55;
    cursor: pointer;
}
.rd-node-caret:hover { opacity: 1; }
.rd-node-caret .rz-icon, .rd-node-caret i { font-size: 0.62rem; }
.rd-node-type { flex-shrink: 0; }
.rd-node-summary { color: var(--rz-text-secondary-color, #666); overflow: hidden; text-overflow: ellipsis; }
.rd-node-badge { margin-left: auto; font-size: 0.7rem; background: #fde68a; border-radius: 8px; padding: 0 5px; }

.rd-palette { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 2px; }
.rd-palette-btn { font-size: 0.75rem; }

.rd-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0; }
.rd-grid-2 .rz-form-field { width: 100%; }
.rd-switches { display: flex; flex-wrap: wrap; gap: 12px; margin: 6px 2px; font-size: 0.85rem; }
.rd-switches label { display: flex; align-items: center; gap: 6px; }
.rd-hint { font-size: 0.75rem; color: var(--rz-text-secondary-color, #666); margin: 4px 2px; }
.rd-fieldset { margin-top: 8px; }
.rd-inline { display: flex; gap: 4px; align-items: center; margin: 4px 0; }

.rd-column-row { display: flex; gap: 3px; align-items: center; margin: 3px 0; }
.rd-col-header { width: 90px; }
.rd-col-expr { flex: 1; min-width: 90px; }
.rd-col-fmt { width: 70px; }
.rd-col-num { width: 62px; }
.rd-col-align { width: 74px; }

.rd-param-row { display: flex; gap: 4px; align-items: center; margin: 3px 0; }
.rd-param-name { width: 110px; }
.rd-param-type { width: 90px; }
.rd-param-req { font-size: 0.75rem; display: flex; align-items: center; gap: 3px; }
.rd-param-default { flex: 1; min-width: 60px; }

.rd-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.rd-chip { background: var(--rz-base-200, #eee); border-radius: 10px; padding: 1px 8px; font-size: 0.8rem; }
.rd-chip a { cursor: pointer; margin-left: 4px; color: var(--rz-danger, #c00); }

.rd-fields { max-height: 320px; overflow: auto; border: 1px solid var(--rz-base-300, #ddd); border-radius: 4px; padding: 4px; }
.rd-field { display: flex; justify-content: space-between; gap: 6px; font-size: 0.8rem; padding: 1px 4px; cursor: pointer; border-radius: 3px; }
.rd-field:hover { background: var(--rz-base-200, #f0f0f0); }
.rd-field-reference .rd-field-name, .rd-field-collection .rd-field-name { font-weight: 600; }
.rd-field-type { color: var(--rz-text-secondary-color, #666); font-family: Consolas, monospace; font-size: 0.72rem; }

@media (max-width: 1200px) {
    .rd-body { --rd-left: 260px; --rd-right: 340px; }
}

/* ---- drag & drop, validation, field insertion ---- */
.rd-node-dragging { opacity: 0.4; }
.rd-node-drop { outline: 2px dashed var(--rz-primary, #2563eb); outline-offset: -2px; background: var(--rz-primary-lighter, #dbeafe); }
.rd-node-error { margin-left: auto; font-size: 0.7rem; font-weight: 700; color: #fff; background: var(--rz-danger, #c62828); border-radius: 8px; padding: 0 6px; }
.rd-node-error + .rd-node-badge { margin-left: 4px; }
.rd-field-error { color: var(--rz-danger, #c62828); font-size: 0.75rem; margin: -2px 2px 6px; font-family: Consolas, monospace; }
.rd-fn-menu { width: 100%; font-size: 0.8rem; }
.rd-fn-row { display: flex; gap: 6px; align-items: center; margin: 2px 0 6px; }
.rd-fn-row .rd-hint { margin: 0; flex: 1; }
.rd-fields-alias { min-width: 120px; font-size: 0.75rem; text-transform: none; letter-spacing: 0; }

/* ---- rules editor, column extras ---- */
.rd-rule { border: 1px solid var(--rz-base-300, #ddd); border-radius: 4px; padding: 4px 6px; margin: 4px 0; }
.rd-rule-when { display: flex; gap: 4px; align-items: center; }
.rd-rule-label { font-size: 0.75rem; color: var(--rz-text-secondary-color, #666); }
.rd-rule-style { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; font-size: 0.8rem; }
.rd-rule-style label { display: flex; align-items: center; gap: 4px; }
.rd-rule-color { width: 110px; }
/* Projected table parts: columns and detail cells in the tree, and the compact list in the panel. */
.rd-node-part .rd-node-type { font-weight: 500; }
.rd-node-part-head .rd-node-type { font-weight: 600; opacity: 0.75; }
.rd-part-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}
.rd-part-row:hover { background: var(--rz-base-200, #f0f0f0); }
.rd-part-name { font-weight: 600; min-width: 90px; }
.rd-part-expr {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: Consolas, monospace;
    font-size: 0.75rem;
    color: var(--rz-text-secondary-color, #666);
}
.rd-range-input { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rd-range-hint { font-size: 0.75rem; color: var(--rz-text-secondary-color, #666); }
.rd-inline-check { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; margin: 4px 0; }
.rd-column-extra { border-left: 3px solid var(--rz-primary-lighter, #dbeafe); margin: 0 0 6px 6px; padding: 2px 6px; }

/* ---- import button (file input hidden behind an icon) ---- */
.rd-import { display: inline-flex; align-items: center; padding: 4px 8px; cursor: pointer; border-radius: 4px; color: var(--rz-primary, #2563eb); }
.rd-import:hover { background: var(--rz-base-200, #f0f0f0); }
.rd-import input[type="file"] { display: none; }

/* ---- version badge, run-report page ---- */
.rd-version { font-size: 0.72rem; border-radius: 10px; padding: 1px 8px; white-space: nowrap; }
.rd-version-live { background: #dcfce7; color: #166534; }
.rd-version-stale { background: #fef3c7; color: #92400e; }
.rd-version-none { background: var(--rz-base-200, #eee); color: var(--rz-text-secondary-color, #666); }
.rr-preview-host { border: 1px solid var(--rz-base-300, #ddd); border-radius: 6px; background: #eceff1; height: calc(100vh - 180px); min-height: 480px; display: flex; }
.rr-preview { flex: 1; width: 100%; border: 0; }
.rr-preview-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--rz-text-secondary-color, #666); padding: 1rem; text-align: center; }

.rd-samples { width: 240px; font-size: 0.8rem; }

/* ---- left pane tabs ---- */
/* The pane itself must not scroll, or the tab strip scrolls away with the tree. Give the scroll to
   the panel below the strip instead; the sticky rule covers Radzen wrapping the nav in a container
   that would otherwise take the flex height. */
.rd-left {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.rd-left-tabs {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.rd-left-tabs .rz-tabview-nav {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fff;
}

.rd-left-tabs .rz-tabview-panels {
    padding: 4px 0 0;
    flex: 1;
    min-height: 0;
    overflow: auto;
}
.rd-left-tabs .rz-tabview-nav li a { padding: 6px 10px; font-size: 0.8rem; }
.rd-palette { flex-direction: column; align-items: stretch; }
.rd-palette-btn { justify-content: flex-start; }

/* Flash the structure node a preview click just selected. */
@keyframes rd-node-flash-kf {
    0%   { background: var(--rz-warning-lighter, #fde68a); }
    100% { background: var(--rz-primary-lighter, #dbeafe); }
}
.rd-node-flash { animation: rd-node-flash-kf 1.2s ease-out; }
