/* =================================================================
   WF Portal — Report Builder panel model (Global)
   -----------------------------------------------------------------
   The chip-toolbar + docked-panel + always-visible-preview shell for
   the Data Studio Reports tab. The section CONTENT still uses the
   .ds-report-* classes in datastudio.css; this file owns only the
   redesigned chrome (.ds-rb-*). Theme-token colors only.
   ================================================================= */

.ds-rb {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ds-rb-empty {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 2rem;
    color: var(--theme-text-muted);
    font-size: var(--theme-font-size-sm);
    border: 1px dashed var(--theme-border);
    border-radius: var(--theme-radius);
}
.ds-rb-empty i { font-size: 1.4rem; opacity: 0.7; }

/* ── Toolbar: chips + actions (sticky so Run is always reachable) ──── */
.ds-rb-bar {
    position: sticky;
    top: 0;
    z-index: 6;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.5rem 0;
    background: var(--theme-background-subtle);
    border-bottom: 1px solid var(--theme-border);
}
.ds-rb-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    flex: 1;
    min-width: 0;
}
.ds-rb-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}
.ds-rb-loaded {
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    align-self: center;
}

.ds-rb-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    max-width: 20rem;
    padding: 0.35rem 0.7rem;
    background: var(--theme-background);
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius-button);
    color: var(--theme-text-secondary);
    font-size: var(--theme-font-size-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.ds-rb-chip:hover {
    border-color: var(--theme-border-subtle);
    color: var(--theme-text);
}
.ds-rb-chip > i:first-child { font-size: 0.95rem; opacity: 0.75; }
.ds-rb-chip-label { font-weight: 600; }
.ds-rb-chip-sum {
    font-size: var(--theme-font-size-xs);
    color: var(--theme-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 12rem;
}
/* Section has non-default content — subtle primary edge. */
.ds-rb-chip.is-set {
    border-color: color-mix(in srgb, var(--theme-primary) 40%, var(--theme-border));
}
.ds-rb-chip.is-set .ds-rb-chip-sum { color: var(--theme-text-secondary); }
/* Active (its panel is open). */
.ds-rb-chip.active {
    background: var(--theme-primary-muted);
    border-color: var(--theme-primary);
    color: var(--theme-primary);
}
.ds-rb-chip.active > i:first-child { opacity: 1; }
.ds-rb-chip.active .ds-rb-chip-sum { color: var(--theme-primary); }
/* Validation error (Group By). */
.ds-rb-chip.has-error { border-color: var(--theme-warning); }
.ds-rb-chip-warn { color: var(--theme-warning); font-size: 0.8rem; }

/* ── Body: docked panel + preview ─────────────────────────────────── */
.ds-rb-body {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
}

.ds-rb-panel {
    flex: 0 0 360px;
    width: 360px;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    overflow: hidden;
    background: var(--theme-background-raised);
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius);
    box-shadow: var(--theme-shadow-lg);
    animation: ds-rb-panel-in 140ms ease-out;
}
@keyframes ds-rb-panel-in {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}

.ds-rb-panel-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--theme-border);
    background: var(--theme-background-subtle);
    border-radius: var(--theme-radius) var(--theme-radius) 0 0;
    flex-shrink: 0;
}
.ds-rb-panel-head > i:first-child { color: var(--theme-primary); font-size: 1rem; }
.ds-rb-panel-title { font-weight: 600; font-size: var(--theme-font-size-sm); }
.ds-rb-panel-hint { font-size: var(--theme-font-size-xs); color: var(--theme-text-muted); }
.ds-rb-panel-close {
    margin-left: auto;
    border: none;
    background: transparent;
    color: var(--theme-text-muted);
    cursor: pointer;
    padding: 0.15rem 0.4rem;
    border-radius: var(--theme-radius-button);
    font-size: 0.8rem;
    line-height: 1;
}
.ds-rb-panel-close:hover { background: var(--theme-background-hover); color: var(--theme-text); }

.ds-rb-panel-body {
    padding: 0.8rem;
    overflow-y: auto;
    min-height: 0;
}

.ds-rb-preview {
    flex: 1;
    min-width: 0;
}

/* ── Responsive — stack the panel above the preview on narrow viewports ── */
@media (max-width: 991.98px) {
    .ds-rb-body { flex-direction: column; }
    .ds-rb-panel {
        flex-basis: auto;
        width: 100%;
        max-height: none;
    }
    .ds-rb-chip-sum { display: none; }
}
