/*
 * Shared floating controls
 *
 * Keep every table popover (status, members and dependencies) on the same
 * visual surface.  The menu owns its arrow so callers only need to add the
 * `floating-menu` class; positioning remains controlled by app.js.
 */
:root {
  --floating-surface: #fffefa;
  --floating-border: #dfe4ec;
  --floating-shadow: 0 20px 52px rgba(25, 35, 52, .18), 0 3px 10px rgba(25, 35, 52, .05);
  --control-chevron: #718096;
}

.floating-menu {
  --floating-arrow-size: 14px;
  position: fixed;
  z-index: 55;
  box-sizing: border-box;
  background: var(--floating-surface);
  border: 1px solid var(--floating-border);
  border-radius: 14px;
  box-shadow: var(--floating-shadow);
  isolation: isolate;
}

/*
 * A small rotated square gives us two diagonal edges and no horizontal seam
 * between the arrow and the card.  It is painted above the card border and
 * the matching surface hides the lower half of the square.
 */
.floating-menu::before {
  content: "";
  position: absolute;
  top: calc(var(--floating-arrow-size) / -2);
  left: calc(var(--floating-arrow-left, 50%) - var(--floating-arrow-size) / 2);
  width: var(--floating-arrow-size);
  height: var(--floating-arrow-size);
  box-sizing: border-box;
  background: var(--floating-surface);
  border-top: 1px solid var(--floating-border);
  border-left: 1px solid var(--floating-border);
  transform: rotate(45deg);
  pointer-events: none;
  z-index: 0;
}

.floating-menu.above::before {
  top: auto;
  bottom: calc(var(--floating-arrow-size) / -2);
  border-top: 0;
  border-left: 0;
  border-right: 1px solid var(--floating-border);
  border-bottom: 1px solid var(--floating-border);
}

/* The legacy assignee rule translated an above-menu by 4px; the shared
 * positioner already accounts for the gap, so every popover uses one anchor. */
.floating-menu.above { transform: none; }

.floating-menu > * { position: relative; z-index: 1; }

/* The menu body scrolls; the arrow and outer border never get clipped. */
.floating-menu-scroll {
  box-sizing: border-box;
  max-height: inherit;
  overflow: auto;
  border-radius: inherit;
  scrollbar-width: thin;
  scrollbar-color: #adb6c4 transparent;
}

.floating-menu-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.floating-menu-scroll::-webkit-scrollbar-thumb { background: #adb6c4; border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }

/* Existing menu names remain valid for app.js, but share one shell. */
.status-menu.floating-menu {
  width: 224px;
  padding: 16px;
}
.dependency-menu.floating-menu {
  width: 430px;
  max-height: min(560px, calc(100vh - 24px));
  padding: 0;
  overflow: visible;
}
.dependency-menu.floating-menu .floating-menu-scroll {
  padding: 20px;
}
.assignee-menu.floating-menu {
  width: 330px;
  max-height: min(500px, calc(100vh - 24px));
  padding: 0;
  overflow: visible;
}
.assignee-menu.floating-menu .floating-menu-scroll {
  padding: 0;
}
.assignee-menu-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-top: 1px solid var(--floating-border);
  background: var(--floating-surface);
}
.assignee-menu-actions > span { color: #758197; font-size: 12px; font-weight: 600; white-space: nowrap; }
.assignee-menu-actions > div { display: flex; gap: 8px; }
.assignee-menu-actions button { min-width: 68px; padding: 8px 12px; font-size: 13px; }

/* One chevron treatment for native selects and button-based pickers. */
.select-with-chevron,
.priority-select,
.dependency-owner-select,
.gantt-person-select,
#bulkOwner,
.task-modal select:not([multiple]),
.project-modal select,
.project-member-form select,
.project-member-role-select,
.detail-form select:not([multiple]) {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23718096' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 8px;
  padding-right: 32px !important;
}

.select-with-chevron:focus,
.priority-select:focus,
.dependency-owner-select:focus,
.gantt-person-select:focus,
#bulkOwner:focus,
.task-modal select:not([multiple]):focus,
.project-modal select:focus,
.project-member-form select:focus,
.project-member-role-select:focus,
.detail-form select:not([multiple]):focus {
  outline: 2px solid rgba(99, 84, 206, .18);
  outline-offset: 1px;
}

.priority-select {
  min-width: 64px;
  border-color: transparent;
  background-color: transparent;
  background-position: right 5px center;
  padding-right: 24px !important;
}

.dependency-owner-select { background-position: right 7px center; }
.assignee-chevron,
.account-menu-chevron,
.workspace-switcher .chevron,
.filter-chip > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: auto;
  color: transparent;
  font-size: 0;
  flex: 0 0 14px;
}
.assignee-chevron::before,
.account-menu-chevron::before,
.workspace-switcher .chevron::before,
.filter-chip > span::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 1.7px solid var(--control-chevron);
  border-bottom: 1.7px solid var(--control-chevron);
  transform: rotate(45deg) translate(-2px, -2px);
}

/* Native multiple selects are list boxes, not dropdown controls. */
.task-modal select[multiple],
.detail-form select[multiple] { background-image: none; padding-right: 11px !important; }

@media (max-width: 620px) {
  .dependency-menu.floating-menu { width: min(430px, calc(100vw - 24px)); }
  .assignee-menu.floating-menu { width: min(330px, calc(100vw - 24px)); }
}
