/* Dashboard editing chrome: the widget bar (drag handle, title, kind, ⋮ menu), the resize corner, the tab
   bar's overflow menu, drag/drop states and the screen-reader announcer. Port of the Control UI's
   styles/board.css and components/solid/overlay.css (.oc-menu, .oc-menu-item), 2026.11.6; colours mapped
   onto ClawChats' theme by meaning (Control UI --text → --text-primary, --muted → --text-muted,
   --accent → --accent-color, the primary action colour). */

/* ── tab bar (board-tabs.tsx) ── */
.dashboard-panel .board-tabs {
  display: flex; align-items: center; gap: 0; min-width: 0; padding: 0 10px;
  border-bottom: 1px solid var(--board-line);
}
.dashboard-panel .board-tabs[hidden] { display: none; }
.dashboard-panel .board-tabs__track { display: flex; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.dashboard-panel .board-tabs__track::-webkit-scrollbar { display: none; }
.dashboard-panel .board-tabs__tab {
  display: inline-flex; flex: 0 0 auto; align-items: center; min-height: 38px; padding: 0 13px;
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent;
  color: var(--text-muted); font: inherit; font-size: 12.5px; cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.dashboard-panel .board-tabs__tab:hover,
.dashboard-panel .board-tabs__tab:focus-visible { background: rgba(var(--ink), 0.06); color: var(--text-primary); }
.dashboard-panel .board-tabs__tab--active { border-bottom-color: var(--accent-color); color: var(--text-primary); }
.dashboard-panel .board-tabs__tab--drop {
  background: color-mix(in srgb, var(--accent-color) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-color) 70%, transparent);
}
.dashboard-panel .board-tabs__overflow,
.dashboard-panel .board-widget__menu { position: relative; margin-left: auto; }
.dashboard-panel .board-tabs__overflow-trigger,
.dashboard-panel .board-widget__menu-trigger {
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
  border: 0; border-radius: 7px; background: transparent; color: var(--text-muted); cursor: pointer; user-select: none;
}
.dashboard-panel .board-tabs__overflow-trigger { width: 34px; height: 30px; font-size: 12px; letter-spacing: 1px; }
.dashboard-panel .board-tabs__overflow-trigger:hover,
.dashboard-panel .board-widget__menu-trigger:hover,
.dashboard-panel .board-widget__menu-trigger[aria-expanded="true"] { background: rgba(var(--ink), 0.1); color: var(--text-primary); }

/* ── menus: native popovers in the top layer (oc-overlay oc-menu) ── */
.dashboard-panel .oc-menu[popover] {
  position: fixed; inset: auto; margin: 0; box-sizing: border-box; width: max-content; min-width: 190px;
  max-width: calc(100dvw - 16px); overflow: auto; overscroll-behavior: contain;
  flex-direction: column; padding: var(--menu-padding, 4px);
  border: 1px solid var(--overlay-border); border-radius: var(--menu-radius, 8px);
  background: var(--bg-elevated, var(--popover)); box-shadow: var(--overlay-shadow);
  color: var(--text-primary); font: inherit; font-size: 13px; text-align: start; user-select: none;
}
.dashboard-panel .cc-dd[open] > .oc-menu[popover] { display: flex; }
.dashboard-panel .cc-dd:not([open]) > .oc-menu[popover] { display: none; }
.dashboard-panel .oc-menu-item {
  position: relative; display: flex; align-items: center; width: 100%; min-height: var(--menu-item-height, 30px);
  padding: 0.5em 1em; border: 0; border-radius: var(--menu-item-radius, 6px); background: transparent;
  color: var(--text-primary); font: inherit; line-height: 1.2; text-align: start; cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}
.dashboard-panel .oc-menu-item:is(:hover, :focus-visible):not([aria-disabled="true"]) { background: var(--surface-hover, rgba(var(--ink), 0.07)); outline: none; }
.dashboard-panel .oc-menu-item[aria-checked="true"]:not([aria-disabled="true"]) { background: var(--surface-selected, rgba(var(--ink), 0.1)); }
.dashboard-panel .oc-menu-item[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.dashboard-panel .oc-menu-item__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-panel .oc-menu-item__icon,
.dashboard-panel .oc-menu-item__details,
.dashboard-panel .oc-menu-item__check { display: inline-flex; flex: 0 0 auto; align-items: center; }
.dashboard-panel .oc-menu-item__icon { margin-inline-end: 0.75em; }
.dashboard-panel .oc-menu-item__details { margin-inline-start: 0.75em; color: var(--text-muted); }
.dashboard-panel .oc-menu-item__check { order: 1; width: 1em; margin-inline-start: 0.75em; color: inherit; }
.dashboard-panel .board-tabs__overflow-panel { min-width: 190px; }
.dashboard-panel .board-tabs__overflow-item { min-width: 180px; }
.dashboard-panel .board-widget__menu-panel .oc-menu-item { font-size: 11px; }
.dashboard-panel .board-widget__menu-heading {
  padding: 7px 9px 3px; color: var(--text-muted); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase;
}
.dashboard-panel .board-widget__menu-empty { padding: 5px 9px; color: var(--text-muted); font-size: 11px; }
.dashboard-panel .board-widget__menu-separator { margin: 5px 3px; border-top: 1px solid var(--board-line); }
.dashboard-panel .board-widget__menu-danger { color: var(--danger, #ef4444); }
.dashboard-panel .board-widget__menu-danger:is(:hover, :focus-visible):not([aria-disabled="true"]) { background: var(--danger-subtle, rgba(239, 68, 68, 0.08)); }
.dashboard-panel .board-widget__menu-icon,
.dashboard-panel .board-widget__menu-icon svg { width: 14px; height: 14px; }

/* ── widget chrome (board-widget-cell.solid.tsx) ── */
.dashboard-panel .board-widget {
  position: relative; overflow: visible;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.dashboard-panel .board-widget[hidden] { display: none; }
.dashboard-panel .board-widget:focus-visible { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-color) 70%, transparent); outline: none; }
.dashboard-panel .board-widget--dragging {
  z-index: 8; border-color: color-mix(in srgb, var(--accent-color) 72%, transparent);
  box-shadow: 0 16px 36px rgb(0 0 0 / 28%); opacity: 0.88; transform: scale(0.995);
}
.dashboard-panel .board-widget__chrome { display: contents; }
.dashboard-panel .board-widget__bar { gap: 7px; min-width: 0; padding: 0 6px; border-radius: 11px 11px 0 0; }
.dashboard-panel .board-widget__body { position: relative; border-radius: 0 0 11px 11px; }
.dashboard-panel .board-widget__kind {
  flex: 0 1 auto; margin-left: auto; padding: 0 5px; border: 1px solid var(--board-line); border-radius: 999px;
  font-size: 8px; letter-spacing: 0.08em; line-height: 15px; text-transform: uppercase; white-space: nowrap;
}
.dashboard-panel .board-widget__menu { margin-left: 0; }
.dashboard-panel .board-widget__menu-trigger { width: 27px; height: 27px; font-size: 21px; line-height: 1; }
.dashboard-panel .board-widget__drag-handle,
.dashboard-panel .board-widget__resize-handle { border: 0; background: transparent; color: var(--text-muted); }
.dashboard-panel .board-widget__drag-handle {
  display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; width: 25px; height: 27px; padding: 0;
  border-radius: 6px; cursor: grab; font-size: 17px; touch-action: none;
}
.dashboard-panel .board-widget__drag-handle:hover { background: rgba(var(--ink), 0.09); color: var(--text-primary); }
.dashboard-panel .board-widget--dragging .board-widget__drag-handle { cursor: grabbing; }
.dashboard-panel .board-widget__resize-handle {
  position: absolute; right: 1px; bottom: 1px; z-index: 6; width: 20px; height: 20px; cursor: nwse-resize; touch-action: none;
}
.dashboard-panel .board-widget__resize-handle::after {
  content: ""; position: absolute; right: 5px; bottom: 5px; width: 6px; height: 6px;
  border-right: 2px solid currentcolor; border-bottom: 2px solid currentcolor;
}
.dashboard-panel .board-grid__append-zone {
  position: absolute; right: 0; bottom: -42px; left: 0; z-index: 7; height: 38px;
  border-top: 1px dashed color-mix(in srgb, var(--accent-color) 48%, transparent);
}
.dashboard-panel .board-grid { position: relative; }
.dashboard-panel .board-grid[hidden],
.dashboard-panel .board-empty[hidden] { display: none; }
.dashboard-panel .board-grid:has(.board-grid__append-zone) { margin-bottom: 42px; }

/* A failed change on this card (BoardWidgetError action) and on the board (board-view__error). */
.dashboard-panel .board-widget__error-overlay { position: absolute; inset: 0; z-index: 4; }
.dashboard-panel .board-widget__error {
  display: grid; align-content: center; justify-items: center; gap: 7px; height: 100%; box-sizing: border-box; padding: 16px;
  background: color-mix(in srgb, var(--danger, #ef4444) 7%, var(--board-surface)); text-align: center;
}
.dashboard-panel .board-widget__error strong { color: var(--text-primary); font-size: 13px; }
.dashboard-panel .board-widget__error > span { max-width: 32ch; color: var(--text-muted); font-size: 11px; line-height: 1.45; }
.dashboard-panel .board-widget__error details { max-width: 100%; color: var(--text-muted); font-size: 10px; }
.dashboard-panel .board-widget__error code { display: block; max-width: 100%; margin-top: 5px; overflow-wrap: anywhere; }
.dashboard-panel .board-view__error {
  margin-top: 12px; padding: 9px 12px; border: 1px solid color-mix(in srgb, var(--danger, #ef4444) 42%, transparent); border-radius: 9px;
  background: color-mix(in srgb, var(--danger, #ef4444) 8%, var(--board-surface)); color: var(--danger, #ef4444); font-size: 12px;
}
.dashboard-panel .board-view__error[hidden] { display: none; }
.dashboard-panel .board-announcer {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* Fine pointers: the bar is a compact pill over the card, shown on hover (after a short rest), focus, an
   open menu and while dragging; the body takes the whole card. Coarse pointers (touch) keep the 38px bar in
   flow so its controls are always reachable (BOARD_WIDGET_TOUCH_BAR_PX). */
@media (hover: hover) and (pointer: fine) {
  .dashboard-panel .board-widget { grid-template-rows: minmax(0, 1fr); isolation: isolate; }
  .dashboard-panel .board-widget__body { border-radius: 11px; }
  .dashboard-panel .board-widget__chrome {
    position: absolute; inset: 0; z-index: 5; display: block; container-type: inline-size; pointer-events: none;
  }
  .dashboard-panel .board-widget__bar {
    position: absolute; top: 7px; left: 50%; z-index: 5; height: 30px; max-width: calc(100% - 176px); box-sizing: border-box; padding: 0 5px;
    border: 1px solid var(--board-line); border-radius: 999px;
    background: color-mix(in srgb, var(--board-surface) 92%, transparent); box-shadow: 0 4px 14px rgb(0 0 0 / 18%);
    backdrop-filter: blur(6px); transform: translateX(-50%); pointer-events: auto;
    opacity: 0; visibility: hidden; transition: opacity 100ms ease, visibility 0s linear 100ms;
  }
  .dashboard-panel .board-widget__bar > .board-widget__title { max-width: 200px; }
  .dashboard-panel .board-widget__bar > .board-widget__drag-handle,
  .dashboard-panel .board-widget__bar > .board-widget__menu { flex-shrink: 0; }
  .dashboard-panel .board-widget__bar > .board-widget__kind { min-width: 0; overflow: hidden; }
  @container (max-width: 264px) {
    .dashboard-panel .board-widget__bar { left: 7px; max-width: max(88px, calc(100% - 96px)); transform: none; }
  }
  /* Until the centred pill has room for its display fields, keep only move + menu. */
  @container (max-width: 376px) {
    .dashboard-panel .board-widget__bar > .board-widget__title,
    .dashboard-panel .board-widget__bar > .board-widget__kind { display: none; }
  }
  .dashboard-panel .board-widget__resize-handle { opacity: 0; visibility: hidden; transition: opacity 100ms ease, visibility 0s linear 100ms; }
  .dashboard-panel .board-widget:hover .board-widget__bar,
  .dashboard-panel .board-widget:hover .board-widget__resize-handle { opacity: 1; visibility: visible; transition-delay: 350ms; }
  .dashboard-panel .board-widget:focus-within .board-widget__bar,
  .dashboard-panel .board-widget:focus-within .board-widget__resize-handle,
  .dashboard-panel .board-widget--dragging .board-widget__bar,
  .dashboard-panel .board-widget--dragging .board-widget__resize-handle,
  .dashboard-panel .board-widget:has(.board-widget__menu-trigger[aria-expanded="true"]) .board-widget__bar,
  .dashboard-panel .board-widget:has(.board-widget__menu-trigger[aria-expanded="true"]) .board-widget__resize-handle {
    opacity: 1; visibility: visible; transition-delay: 0s;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-panel .board-widget,
  .dashboard-panel .board-widget__bar,
  .dashboard-panel .board-widget__resize-handle,
  .dashboard-panel .board-tabs__tab { animation: none; transition: none; }
}
