/* ============================================
   CSS Design System - Variables (Figma-aligned)
   ============================================ */
:root {
  /* ===========================================
     Grey Scale (Tailwind-style)
     =========================================== */
  --blockr-grey-50: #f9fafb;   /* Page bg, subtle backgrounds */
  --blockr-grey-100: #f3f4f6;  /* Hover states, input bg */
  --blockr-grey-200: #e5e7eb;  /* Borders */
  --blockr-grey-300: #d1d5db;  /* Darker borders, dividers */
  --blockr-grey-400: #9ca3af;  /* Placeholder text */
  --blockr-grey-500: #6b7280;  /* Muted text */
  --blockr-grey-600: #4b5563;  /* Secondary icons */
  --blockr-grey-700: #374151;  /* Secondary text */
  --blockr-grey-800: #1f2937;  /* Dark text */
  --blockr-grey-900: #111827;  /* Primary text */

  /* Primary Blue */
  --blockr-blue-50: #eff6ff;
  --blockr-blue-100: #dbeafe;
  --blockr-blue-500: #3b82f6;
  --blockr-blue-600: #2563eb;
  --blockr-blue-700: #1d4ed8;

  /* Shadow - elevated dropdowns */
  --blockr-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --blockr-shadow-lg: 0 25px 50px -12px rgb(0 0 0 / 0.25);

  /* Font Sizes */
  --blockr-font-size-base: 0.875rem;      /* 14px - base for body/inputs */
  --blockr-font-size-sm: 0.8125rem;       /* 13px - helper text */
  --blockr-font-size-xs: 0.75rem;         /* 12px - meta, toggles, subtitle */
  --blockr-font-size-title: 1.25rem;      /* 20px - block title */
  --blockr-font-size-section: 1rem;       /* 16px - section headers */

  /* Font Weights */
  --blockr-font-weight-normal: 400;
  --blockr-font-weight-medium: 500;
  --blockr-font-weight-semibold: 600;

  /* Colors - Text (Figma-aligned) */
  --blockr-color-text-primary: var(--blockr-grey-900);
  --blockr-color-text-secondary: var(--blockr-grey-700);
  --blockr-color-text-muted: var(--blockr-grey-500);
  --blockr-color-text-subtle: var(--blockr-grey-400);
  --blockr-color-text-meta: var(--blockr-grey-500);

  /* Colors - UI */
  --blockr-color-border: var(--blockr-grey-200);
  --blockr-color-border-hover: var(--blockr-grey-300);
  --blockr-color-bg-subtle: var(--blockr-grey-50);
  --blockr-color-bg-hover: var(--blockr-grey-100);
  --blockr-color-bg-input: var(--blockr-grey-50);
  --blockr-color-primary: var(--blockr-blue-600);
  --blockr-color-primary-hover: var(--blockr-blue-700);
  --blockr-color-primary-bg: var(--blockr-blue-50);
  --blockr-color-error: #dc2626;
  --blockr-color-success: #16a34a;
}

/* ============================================
   Typography Classes
   ============================================ */
.blockr-title {
  font-size: var(--blockr-font-size-title);
  font-weight: var(--blockr-font-weight-semibold);
  color: var(--blockr-color-text-primary);
  margin: 0;
}

/* Inline editable title */
.blockr-inline-edit {
  position: relative;
}

.blockr-title-edit {
  position: absolute;
  top: -9px;
  left: -8px;
}

.blockr-title-edit .form-group {
  margin: 0;
}

.blockr-title-edit .form-control {
  font-size: var(--blockr-font-size-title);
  font-weight: var(--blockr-font-weight-semibold);
  color: var(--blockr-color-text-primary);
  padding: 4px 8px;
  height: auto;
  width: auto;
  min-width: 150px;
  border: 2px dashed #bbb;
  border-radius: 8px;
  background: white;
  box-shadow: none;
}

.blockr-title-edit .form-control:focus {
  border-color: #aaa;
  box-shadow: none;
  outline: none;
}

.blockr-subtitle {
  font-size: var(--blockr-font-size-sm);
  font-weight: var(--blockr-font-weight-normal);
  color: var(--blockr-color-text-muted);
  margin-left: 3px;
}

.blockr-section-header {
  font-size: var(--blockr-font-size-section);
  font-weight: var(--blockr-font-weight-medium);
  color: var(--blockr-color-text-secondary);
}

.blockr-label {
  font-size: var(--blockr-font-size-sm);
  font-weight: var(--blockr-font-weight-medium);
  color: var(--blockr-color-text-secondary);
}

.blockr-helper {
  font-size: var(--blockr-font-size-sm);
  font-weight: var(--blockr-font-weight-normal);
  color: var(--blockr-color-text-muted);
}

.blockr-meta {
  font-size: var(--blockr-font-size-xs);
  font-weight: var(--blockr-font-weight-normal);
  color: var(--blockr-color-text-meta);
}

.blockr-error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  margin: 0 -16px;
  background-color: rgba(220, 38, 38, 0.08);
  color: var(--blockr-color-error);
  font-size: var(--blockr-font-size-base);
}

.blockr-error-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 3px;
}

.blockr-issues:not(:has(.blockr-issue)) {
  display: none;
}

.blockr-issues-toggle {
  cursor: pointer;
  color: var(--blockr-color-text-meta);
  font-size: var(--blockr-font-size-base);
  padding: 8px 16px;
  border-radius: 6px;
  transition: background-color 0.15s ease;
}

.blockr-issues-toggle:hover {
  background-color: var(--blockr-color-bg-hover);
}

.blockr-issues-toggle svg {
  transition: transform 0.2s ease;
}

.blockr-issues-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

/* Block eval status: on-icon status dot + empty-output placeholder.
   The dot is layered onto the block icon's lower-right corner (iOS badge
   style), matching blockr.dag's node badge placement. Its size and colour are
   set inline from `block_status_style()` -- the source of truth both
   front-ends share -- so only structure lives here. `size` is the coloured
   dot's diameter; the 2px white ring is drawn *outside* it (box-shadow, not a
   border) so the dot matches the DAG node badge, which rings its fill the same
   way. The dot output must stay in flow when empty (never display:none) so it
   is not suspended while hidden and left stuck ".recalculating", which would
   trip the busy-pulse scope; an empty inline output takes no space on its
   own. */
.blockr-block-icon {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.blockr-status-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 1;
  border-radius: 50%;
}

.blockr-status-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  color: var(--blockr-color-text-muted);
  font-size: var(--blockr-font-size-base);
}

.blockr-status-note-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--blockr-color-text-subtle);
}

/* Shared header icon button — ghost style */
.blockr-header-icon.btn.btn-light,
.blockr-section-toggle .btn.btn-light {
  background-color: transparent !important;
  border: none !important;
  border-radius: 8px;
  color: var(--blockr-grey-300) !important;
  font-size: 12px;
  padding: 6px 7px;
  margin: 0;
  transition: all 0.15s ease;
  line-height: 1;
  box-shadow: none !important;
}

.blockr-header-icon.btn.btn-light:hover,
.blockr-section-toggle .btn.btn-light:hover {
  background-color: var(--blockr-grey-100) !important;
  color: var(--blockr-grey-400) !important;
}

.blockr-section-toggle .btn-check:checked + .btn.btn-light:hover {
  background-color: var(--blockr-blue-50) !important;
  color: var(--blockr-blue-500) !important;
}

.blockr-section-toggle .btn.btn-light.active,
.blockr-section-toggle .btn-check:checked + .btn.btn-light {
  background-color: transparent !important;
  color: var(--blockr-blue-500) !important;
  box-shadow: none !important;
}

/* Ensure all header icons have consistent square hit area */
.blockr-header-icon.btn.btn-light,
.blockr-section-toggle .btn.btn-light {
  min-width: 28px;
  height: 28px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Constrain any SVG inside toggle buttons to match icon size */
.blockr-section-toggle .btn.btn-light svg {
  width: 14px;
  height: 14px;
}

.blockr-section-toggle .btn-group {
  gap: 2px;
}

/* Package badge - Figma-aligned subtle style */
.badge-two-tone {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.625rem;
  border-radius: 4px;
  background-color: var(--blockr-grey-100);
  color: var(--blockr-color-text-muted);
  border: 1px solid var(--blockr-color-border);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ============================================
   Bootstrap Base Overrides
   ============================================ */

/* --- Typography --- */
body {
  font-size: var(--blockr-font-size-base);
}

h4, .h4 {
  font-size: var(--blockr-font-size-section);
  font-weight: var(--blockr-font-weight-medium);
  font-variant-caps: all-small-caps;
  color: var(--blockr-color-text-secondary);
  letter-spacing: 0.5px;
}

h5, .h5 {
  font-size: var(--blockr-font-size-section);
  font-weight: var(--blockr-font-weight-medium);
}

h6, .h6 {
  font-size: var(--blockr-font-size-base);
  font-weight: var(--blockr-font-weight-medium);
}

small, .small {
  font-size: var(--blockr-font-size-sm);
}

/* --- Labels --- */
label,
.form-label,
.shiny-input-container .control-label {
  font-size: var(--blockr-font-size-xs);
  color: var(--blockr-color-text-secondary);
  margin-bottom: 0.25rem;
}

label:has(input[type="file"]) {
  margin-bottom: 0;
}

/* --- Form Controls (Figma-aligned) --- */
.form-control,
.form-select {
  font-size: var(--blockr-font-size-base);
  background-color: var(--blockr-color-bg-input);
  border: 1px solid var(--blockr-color-border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--blockr-color-text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.form-control:focus,
.form-select:focus {
  background-color: #ffffff;
  border-color: var(--blockr-color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  outline: none;
}

.form-control::placeholder {
  color: var(--blockr-grey-400);
}

.input-group-sm > .form-control,
.input-group-sm > .form-select,
.input-group-sm > .input-group-text,
.input-group-sm > .btn {
  font-size: var(--blockr-font-size-sm);
  padding: 6px 10px;
}

/* Selectize - Figma-aligned */
.selectize-control,
.selectize-input,
.selectize-dropdown {
  font-size: var(--blockr-font-size-base);
}

.selectize-input {
  background-color: var(--blockr-color-bg-input) !important;
  border: 1px solid var(--blockr-color-border) !important;
  border-radius: 8px !important;
  padding: 0 12px !important;
  min-height: 42px !important;
  display: flex !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  box-shadow: none !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.selectize-input.focus {
  background-color: #ffffff !important;
  border-color: var(--blockr-color-primary) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

.selectize-dropdown {
  border: 1px solid var(--blockr-color-border) !important;
  border-radius: 8px !important;
  box-shadow: var(--blockr-shadow-lg) !important;
  margin-top: 4px !important;
}

.selectize-dropdown-content .option {
  padding: 10px 14px !important;
  color: var(--blockr-color-text-primary);
}

.selectize-dropdown-content .option.active {
  background-color: var(--blockr-color-bg-hover) !important;
  color: var(--blockr-color-text-primary) !important;
}

/* --- Buttons (Figma-aligned) --- */
.btn {
  font-size: var(--blockr-font-size-base);
  font-weight: var(--blockr-font-weight-medium);
  border-radius: 6px;
  padding: 8px 16px;
  transition: all 0.15s ease;
}

.btn-sm {
  font-size: var(--blockr-font-size-sm);
  padding: 6px 12px;
}

/* File input: stretch button to match form-control height */
.input-group .input-group-btn {
  display: flex;
}

/* Primary button - blue */
.btn-primary {
  background-color: var(--blockr-color-primary);
  border-color: var(--blockr-color-primary);
  color: #ffffff;
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--blockr-color-primary-hover);
  border-color: var(--blockr-color-primary-hover);
  color: #ffffff;
}

/* Secondary/Outline button - gray */
.btn-secondary,
.btn-outline-secondary,
.btn-light {
  background-color: var(--blockr-grey-100);
  border: 1px solid var(--blockr-color-border);
  color: var(--blockr-color-text-primary);
}

.btn-secondary:hover,
.btn-secondary:focus,
.btn-outline-secondary:hover,
.btn-outline-secondary:focus,
.btn-light:hover,
.btn-light:focus {
  background-color: var(--blockr-color-border);
  border-color: var(--blockr-color-border-hover);
  color: var(--blockr-color-text-primary);
}

/* Default/outline button */
.btn-default,
.btn-outline-default {
  background-color: var(--blockr-grey-100);
  border: 1px solid var(--blockr-color-border);
  color: var(--blockr-color-text-primary);
}

.btn-default:hover,
.btn-default:focus,
.btn-outline-default:hover,
.btn-outline-default:focus {
  background-color: var(--blockr-color-border);
  border-color: var(--blockr-color-border-hover);
}

/* Icon-only action buttons (remove row, etc.) */
.btn-link.text-muted {
  background: transparent !important;
  border: none !important;
  border-radius: 4px !important;
  color: var(--blockr-grey-400) !important;
  transition: background-color 0.15s ease, color 0.15s ease !important;
}

.btn-link.text-muted:hover,
.btn-link.text-muted:focus {
  background-color: var(--blockr-grey-100) !important;
  color: var(--blockr-grey-600) !important;
  text-decoration: none !important;
}

/* ============================================
   Offcanvas / Sidebar Styling (Figma-aligned)
   ============================================ */
.offcanvas {
  width: 320px !important;
  border-left: 1px solid var(--blockr-color-border) !important;
}

.offcanvas-header {
  border-bottom: 1px solid var(--blockr-color-border);
  padding: 16px 20px;
}

.offcanvas-title {
  font-size: 1.125rem;
  font-weight: var(--blockr-font-weight-semibold);
  color: var(--blockr-color-text-primary);
}

.offcanvas-body {
  font-size: var(--blockr-font-size-sm);
  padding: 20px;
  background: #ffffff;
}

.offcanvas .accordion {
  margin: 0 -20px;
}

.offcanvas .accordion-button {
  font-size: var(--blockr-font-size-section);
  font-weight: var(--blockr-font-weight-semibold);
  font-variant-caps: all-small-caps;
  color: var(--blockr-color-text-secondary);
  letter-spacing: 0.5px;
  background: transparent;
}

.offcanvas .accordion-button:not(.collapsed) {
  background: var(--blockr-color-bg-subtle);
  box-shadow: none;
}

/* Export button adjustments */
.offcanvas .shiny-download-link i,
.offcanvas .shiny-download-link svg,
.offcanvas .shiny-download-link .bsicon {
  display: none;
}

.offcanvas .shiny-download-link {
  margin-top: -5px;
}

/* Make Show code button smaller */
.offcanvas .btn-default,
.offcanvas .btn-outline-default {
  font-size: var(--blockr-font-size-sm);
  padding: 6px 12px;
}

.offcanvas hr {
  margin-left: -20px;
  margin-right: -20px;
  border-color: var(--blockr-color-border);
  opacity: 1;
}

/* ============================================
   Tooltip & Popover Styling (Figma-aligned)
   ============================================ */
.tooltip {
  --bs-tooltip-bg: white;
  --bs-tooltip-color: var(--blockr-color-text-secondary);
  --bs-tooltip-opacity: 1;
}

.tooltip-inner {
  font-size: var(--blockr-font-size-sm);
  font-weight: var(--blockr-font-weight-normal);
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: var(--blockr-shadow-lg);
  border: 1px solid var(--blockr-color-border);
  max-width: 250px;
  text-align: left;
}

.tooltip-arrow::before {
  border-top-color: white !important;
  border-bottom-color: white !important;
}

/* Popover - light style matching tooltips */
.popover {
  --bs-popover-bg: white;
  --bs-popover-border-color: var(--blockr-color-border);
  --bs-popover-body-color: var(--blockr-color-text-secondary);
  border-radius: 12px;
  box-shadow: var(--blockr-shadow-lg);
  border: 1px solid var(--blockr-color-border);
  max-width: 280px;
}

.popover-body {
  font-size: var(--blockr-font-size-sm);
  padding: 12px 14px;
}

.popover-header,
.popover .btn-close {
  display: none;
}

.popover-arrow::before {
  border-top-color: var(--blockr-color-border) !important;
  border-bottom-color: var(--blockr-color-border) !important;
}

.popover-arrow::after {
  border-top-color: white !important;
  border-bottom-color: white !important;
}

/* ============================================
   DataTables Styling (Figma-aligned)
   ============================================ */

/* Grey stripes */
.table-striped {
  --bs-table-striped-bg: var(--blockr-color-bg-subtle);
}

.table {
  border-color: var(--blockr-color-border);
}

.table > thead {
  background: var(--blockr-color-bg-subtle);
}

.table > thead > tr > th {
  font-weight: var(--blockr-font-weight-medium);
  color: var(--blockr-color-text-secondary);
  border-bottom: 2px solid var(--blockr-color-border);
  padding: 12px 16px;
}

.table > tbody > tr > td {
  color: var(--blockr-color-text-primary);
  border-bottom: 1px solid var(--blockr-grey-100);
  padding: 12px 16px;
}

.table > tbody > tr:hover {
  background-color: var(--blockr-color-bg-subtle);
}

/* Info text - small and muted */
.dataTables_wrapper .dataTables_info {
  font-size: var(--blockr-font-size-sm) !important;
  color: var(--blockr-color-text-muted) !important;
  padding-top: 0.5rem;
}

/* Smaller paginator */
.dataTables_wrapper .dataTables_paginate .page-link {
  padding: 0.2rem 0.5rem;
  font-size: var(--blockr-font-size-xs);
  border-radius: 6px;
}

/* ============================================
   G6 Graph Toolbar Override
   ============================================ */
.g6-toolbar {
  box-shadow: none !important;
}

/* ============================================
   Block Dropdown Menu Styling (Figma-aligned)
   ============================================ */
.blockr-block-dropdown {
  font-size: var(--blockr-font-size-base) !important;
  border-radius: 12px !important;
  border: 1px solid var(--blockr-color-border) !important;
  box-shadow: var(--blockr-shadow-lg) !important;
  padding: 12px 8px 8px !important;
  margin-top: 8px !important;
}

/* Arrow pointing up toward the trigger button */
.blockr-block-dropdown::before,
.blockr-block-dropdown::after {
  content: "";
  position: absolute;
  right: 16px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
}

.blockr-block-dropdown::before {
  top: -9px;
  border-bottom: 9px solid var(--blockr-color-border);
}

.blockr-block-dropdown::after {
  top: -8px;
  border-bottom: 8px solid #fff;
}

.blockr-block-dropdown .dropdown-header,
.blockr-block-dropdown h6.dropdown-header {
  font-size: var(--blockr-font-size-xs) !important;
  font-weight: var(--blockr-font-weight-medium) !important;
  color: var(--blockr-color-text-muted) !important;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-variant-caps: normal;
  padding: 8px 12px 4px;
}

.blockr-block-dropdown .dropdown-item {
  font-size: var(--blockr-font-size-sm) !important;
  padding: 10px 12px 10px 2.5rem !important;
  border-radius: 8px !important;
  color: var(--blockr-color-text-primary) !important;
}

.blockr-block-dropdown .dropdown-item:hover,
.blockr-block-dropdown .dropdown-item:focus {
  background-color: var(--blockr-color-bg-hover) !important;
  color: var(--blockr-color-text-primary) !important;
}

.blockr-block-dropdown .text-muted,
.blockr-block-dropdown span.text-muted {
  color: var(--blockr-color-text-muted) !important;
  font-size: var(--blockr-font-size-sm) !important;
}

.blockr-block-dropdown .small,
.blockr-block-dropdown span.small {
  font-size: var(--blockr-font-size-sm) !important;
}

.blockr-block-dropdown .fw-medium,
.blockr-block-dropdown span.fw-medium {
  font-weight: var(--blockr-font-weight-medium) !important;
  font-size: var(--blockr-font-size-sm) !important;
}

/* ============================================
   Dockview Left Actions (Plus Button)
   ============================================ */
.dv-left-actions-container {
  display: flex;
  align-items: center;
}

.dv-left-actions-container .fa-plus {
  font-size: 12px;
  color: var(--blockr-color-text-muted);
  padding: 8px 8px;
  margin-left: -4px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.dv-left-actions-container .fa-plus:hover {
  background-color: var(--blockr-color-bg-hover);
  color: var(--blockr-color-text-secondary);
}
/* ============================================
   Navbar Styling
   ============================================ */
.blockr-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 48px;
  padding: 0 16px;
  background-color: white;
  border-bottom: 1px solid var(--blockr-grey-300);
}

.blockr-navbar-left {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.blockr-navbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.blockr-navbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--blockr-color-text-muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.blockr-navbar-icon-btn:hover {
  background-color: var(--blockr-grey-300);
  color: var(--blockr-color-text-secondary);
}

/* Read-only / locked-mode indicator. Styled as a static status pill,
   not a button -- no hover state, no pointer cursor. Sits between the
   view nav and the settings gear in the navbar right slot. */
.blockr-lock-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  height: 28px;
  border-radius: 999px;
  color: var(--blockr-color-text-secondary);
  background-color: var(--blockr-color-bg-subtle);
  border: 1px solid var(--blockr-color-border);
  font-size: var(--blockr-font-size-sm);
  font-weight: var(--blockr-font-weight-medium);
  cursor: default;
  user-select: none;
}

.blockr-lock-indicator-label {
  white-space: nowrap;
}

/* ============================================
   View Navigation
   ============================================ */

/* Dropdown toggle */
.blockr-view-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: auto;
  padding: 4px 10px;
  font-size: var(--blockr-font-size-sm);
  font-weight: var(--blockr-font-weight-medium);
  color: var(--blockr-color-text-secondary);
}

.blockr-view-toggle-label {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.blockr-view-toggle::after {
  margin-left: 2px;
}

/* Dropdown menu */
.blockr-view-nav.dropdown-menu {
  min-width: 200px;
  padding: 4px;
}

/* View item */
.blockr-view-item.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: var(--blockr-font-size-sm);
  color: var(--blockr-color-text-primary);
  cursor: pointer;
}

.blockr-view-item.dropdown-item.active {
  background-color: var(--blockr-blue-100);
  color: var(--blockr-blue-700);
  font-weight: var(--blockr-font-weight-semibold);
}

.blockr-view-item.dropdown-item:hover {
  background-color: var(--blockr-grey-100);
}

.blockr-view-item.dropdown-item.active:hover {
  background-color: var(--blockr-blue-100);
}

/* Item name */
.blockr-view-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* CRUD action buttons — use opacity instead of display to prevent layout jump */
.blockr-view-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.1s ease;
}

.blockr-view-item.dropdown-item:hover .blockr-view-item-actions {
  opacity: 1;
}

.blockr-view-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--blockr-color-text-muted);
  cursor: pointer;
  font-size: 11px;
}

.blockr-view-action:hover {
  background-color: var(--blockr-grey-300);
  color: var(--blockr-color-text-secondary);
}

.blockr-view-remove:hover {
  color: var(--blockr-color-danger, #dc3545);
}

/* Inline rename input */
.blockr-view-rename-input {
  flex: 1;
  padding: 2px 6px;
  border: 1px solid var(--blockr-color-primary);
  border-radius: 4px;
  font-size: var(--blockr-font-size-sm);
  background-color: var(--blockr-color-bg-input);
  color: var(--blockr-color-text-primary);
  outline: none;
}

.blockr-view-rename-input:focus {
  border-color: var(--blockr-color-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* Add button */
.blockr-view-add {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: var(--blockr-font-size-sm);
  color: var(--blockr-color-text-muted);
}

.blockr-view-add:hover {
  background-color: var(--blockr-grey-100);
  color: var(--blockr-color-text-primary);
}

/* ============================================
   Multi-dock stacking (views)
   ============================================ */

.blockr-view-container {
  overflow: hidden;
}

.blockr-view-dock {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
}

.blockr-view-dock-active {
  z-index: 1;
  pointer-events: auto;
  opacity: 1;
}

/* Empty dock prompt — overlays the dockview when no panels are present */
.blockr-empty-dock-prompt {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--blockr-color-text-muted, #6b7280);
  pointer-events: auto;
}

.blockr-empty-dock-prompt p {
  margin: 0;
  font-size: var(--blockr-font-size-sm, 14px);
}

/* ============================================
   Edit Board Extension
   ============================================ */

/* Padded container with consistent vertical rhythm so content does not hug
   the panel borders, matching a block panel's internal gutter. */
.blockr-ext-edit {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}

/* A divider above every section after the first (and above the footer) so the
   block / link / stack sections read as distinct groups, not one dense run. */
.blockr-ext-edit > * + * {
  border-top: 1px solid var(--bs-border-color, #dee2e6);
  padding-top: 16px;
}

.blockr-ext-edit-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.blockr-ext-edit-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

/* The single, global apply button sits in its own footer, right-aligned. */
.blockr-ext-edit-footer {
  display: flex;
  justify-content: flex-end;
}

/* Inputs and the buttons that act on them share a baseline-aligned row, so
   action buttons no longer float above their inputs' labels. */
.blockr-ext-edit-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

/* Match the action buttons' height to the inputs they sit beside. */
.blockr-ext-edit .btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* The flex gaps are the single source of spacing within the extension. */
.blockr-ext-edit .form-group {
  margin-bottom: 0;
}

/* Keep the links and stacks tables within the panel: the input cells flex to
   fit instead of overflowing at a fixed width and clipping a column. At panel
   widths too narrow for the cells' min-width, the table scrolls horizontally
   rather than clipping. */
.blockr-ext-edit-links,
.blockr-ext-edit-stacks {
  overflow-x: auto;
}

.blockr-ext-edit table.dataTable {
  width: 100% !important;
  margin: 0 !important;
}

.blockr-ext-edit table.dataTable td,
.blockr-ext-edit table.dataTable th {
  padding: 8px 10px;
}

/* A small gap above the table (DataTables resets this margin with a
   higher-specificity rule, so scope through .dataTables_wrapper to win). */
.blockr-ext-edit .dataTables_wrapper .dataTables_paginate {
  margin-top: 6px;
}

/* Space the page buttons; Bootstrap butts them together with collapsed
   borders by default. */
.blockr-ext-edit .dataTables_paginate .pagination {
  gap: 4px;
}

.blockr-ext-edit .dataTables_paginate .pagination .page-link {
  margin-left: 0;
}

/* Semantic action buttons must win over the .btn-default that Shiny's
   actionButton() always carries; these scoped rules out-specify it so the
   constructive and destructive actions are visually distinguishable. */
.blockr-ext-edit .btn-primary {
  background-color: var(--blockr-color-primary);
  border-color: var(--blockr-color-primary);
  color: #ffffff;
}

.blockr-ext-edit .btn-primary:hover,
.blockr-ext-edit .btn-primary:focus {
  background-color: var(--blockr-color-primary-hover);
  border-color: var(--blockr-color-primary-hover);
  color: #ffffff;
}

.blockr-ext-edit .btn-danger {
  background-color: var(--blockr-color-error);
  border-color: var(--blockr-color-error);
  color: #ffffff;
}

.blockr-ext-edit .btn-danger:hover,
.blockr-ext-edit .btn-danger:focus {
  background-color: #b91c1c;
  border-color: #b91c1c;
  color: #ffffff;
}

.blockr-ext-edit .btn-success {
  background-color: var(--blockr-color-success);
  border-color: var(--blockr-color-success);
  color: #ffffff;
}

.blockr-ext-edit .btn-success:hover,
.blockr-ext-edit .btn-success:focus {
  background-color: #15803d;
  border-color: #15803d;
  color: #ffffff;
}

/* ============================================
   Busy pulse — scope to real computation
   ============================================ */

/* Shiny's page pulse (enabled in serve() via useBusyIndicators(pulse = TRUE))
   shows whenever the session is busy, i.e. on any observer flush. A plain panel
   switch round-trips to the server -- the on-screen visibility report and the
   layout fold -- without recomputing any visible output, so the pulse would
   fire for what is only layout bookkeeping. Gate it on a genuinely
   recalculating output inside the visible view container: block evaluation
   marks its output "recalculating" there, bookkeeping does not. Scoping to the
   view container is deliberate -- an off-screen block parked in the (hidden)
   offcanvas pool stays "recalculating" while it waits for evaluation, and that
   pool sits outside the container, so a pending hidden block never forces the
   pulse. Startup and real recompute still pulse; a bare panel switch does not. */
html[data-shiny-busy-pulse].shiny-busy:not(:has(.blockr-view-container .recalculating))::after {
  display: none;
}
