/* ================================================================
   GLOBAL RADIAL MENU — Coordy Quick Action Wheel
   Isolated styles — zero layout impact, zero interference
   z-index: 4500 (below modals at 6000, below companion at 5000)
   ================================================================ */

/* ── Container ──────────────────────────────────────────────────── */
.grm-container {
  position: fixed;
  bottom: 110px;
  left: 24px;
  z-index: 4500;
  /* Zero-size anchor; all children use absolute positioning */
  width: 0;
  height: 0;
  pointer-events: none;
}

.grm-container.grm-hidden {
  display: none !important;
}

/* ── Trigger ────────────────────────────────────────────────────── */
.grm-trigger {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  outline: 1px solid transparent;
  outline-offset: 2px;
  background: var(--bg-card);
  color: var(--radial-trigger-text, rgba(210, 215, 240, 0.9));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: var(--shadow-card);
  transition:
    background 0.22s ease,
    outline-color 0.22s ease,
    box-shadow 0.22s ease,
    transform 0.22s ease;
  pointer-events: all;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.grm-trigger:hover {
  transform: translateY(-2px);
  outline-color: #7c8cff;
  box-shadow: var(--shadow-card), 0 0 0 3px rgba(124, 140, 255, 0.18), 0 12px 28px rgba(0, 0, 0, 0.16);
}

.grm-trigger:focus-visible {
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.38),
    0 0 0 3px var(--focus-ring, rgba(102, 126, 234, 0.55));
}

.grm-trigger-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Trigger open state */
.grm-container.grm-open .grm-trigger {
  background: var(--nav-item-active-bg, rgba(20, 22, 44, 0.92));
  outline-color: rgba(124, 140, 255, 0.5);
  box-shadow:
    var(--radial-trigger-shadow-open, 0 6px 24px rgba(0, 0, 0, 0.48)),
    0 0 0 3px rgba(124, 140, 255, 0.2),
    0 0 28px rgba(124, 140, 255, 0.14);
}

.grm-container.grm-open .grm-trigger-icon {
  transform: rotate(45deg);
}

/* ── Wheel (arc origin = trigger center) ────────────────────────── */
.grm-wheel {
  position: absolute;
  /* Offset to trigger center: trigger is 52×52px, centered at +26,+26 from container */
  bottom: 26px;
  left: 26px;
  pointer-events: none;
}

/* ── Arc Background ─────────────────────────────────────────────── */
.grm-arc-bg {
  position: absolute;
  width: 240px;
  height: 240px;
  left: -120px;
  top: -120px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 50% 50%,
    var(--radial-backdrop, rgba(12, 12, 22, 0.28)) 0%,
    rgba(var(--radial-glow, 102, 126, 234), 0.12) 52%,
    transparent 76%
  );
  pointer-events: none;
  opacity: 0;
  transform: scale(0.72);
  transition:
    opacity 0.22s ease,
    transform 0.26s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.grm-container.grm-open .grm-arc-bg {
  opacity: 1;
  transform: scale(1);
}

/* ── Segments ───────────────────────────────────────────────────── */
.grm-segment {
  position: absolute;
  width: 46px;
  height: 46px;
  /* Center element at wheel origin before transform */
  margin-left: -23px;
  margin-top: -23px;
  border-radius: 50%;
  border: 1px solid var(--radial-segment-border, rgba(255, 255, 255, 0.08));
  background: var(--radial-segment-bg, rgba(18, 18, 28, 0.96));
  color: var(--radial-segment-text, rgba(200, 205, 235, 0.85));
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  box-shadow:
    var(--radial-segment-shadow, 0 3px 10px rgba(0, 0, 0, 0.3)),
    inset 0 1px 0 var(--border-inverse, rgba(255, 255, 255, 0.05));
  /* Collapsed initial state — centered at trigger, invisible */
  transform: translate(0px, 0px) scale(0.35);
  opacity: 0;
  pointer-events: none;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 0.26s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.18s ease,
    border-color 0.15s ease;
}

/* Open — fly to arc positions with stagger */
.grm-container.grm-open .grm-segment {
  transform: translate(var(--seg-x), var(--seg-y)) scale(1);
  opacity: 1;
  pointer-events: all;
  transition-delay: calc(var(--seg-index) * 0.048s);
}

/* Hover — pop outward along the radial vector */
.grm-container.grm-open .grm-segment:hover {
  transform: translate(var(--seg-hx), var(--seg-hy)) scale(1.06);
  background: var(--radial-segment-hover-bg, var(--control-bg-hover, rgba(26, 26, 46, 0.94)));
  border-color: rgba(var(--seg-color-rgb, 102, 126, 234), 0.42);
  box-shadow:
    var(--radial-segment-shadow-hover, 0 7px 20px rgba(0, 0, 0, 0.42)),
    0 0 15px rgba(var(--seg-color-rgb, 102, 126, 234), 0.24),
    inset 0 1px 0 var(--border-inverse, rgba(255, 255, 255, 0.08));
  transition-delay: 0s !important;
  z-index: 1;
}

/* Keyboard focus */
.grm-container.grm-open .grm-segment:focus-visible {
  border-color: rgba(var(--seg-color-rgb, 102, 126, 234), 0.65);
  box-shadow:
    0 5px 14px rgba(0, 0, 0, 0.38),
    0 0 0 2px rgba(var(--seg-color-rgb, 102, 126, 234), 0.55);
}

/* ── Segment Icon ───────────────────────────────────────────────── */
.grm-segment-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--radial-segment-text, rgba(185, 190, 228, 0.78));
  pointer-events: none;
  line-height: 0;
  transition: color 0.15s ease;
}

.grm-segment:hover .grm-segment-icon,
.grm-segment:focus-visible .grm-segment-icon {
  color: var(--text-primary, rgba(232, 236, 255, 0.96));
}

/* ── Segment Label ──────────────────────────────────────────────── */
.grm-segment-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.45px;
  text-transform: uppercase;
  color: var(--text-secondary, rgba(170, 175, 215, 0.52));
  white-space: nowrap;
  line-height: 1;
  pointer-events: none;
  font-family: inherit;
  transition: color 0.15s ease;
}

.grm-segment:hover .grm-segment-label,
.grm-segment:focus-visible .grm-segment-label {
  color: var(--text-primary, rgba(215, 220, 255, 0.82));
}

/* ── Mobile ─────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .grm-container {
    bottom: 90px;
    left: 24px;
  }

  .grm-trigger {
    width: 46px;
    height: 46px;
  }

  .grm-wheel {
    bottom: 23px;
    left: 23px;
  }

  .grm-segment {
    width: 44px;
    height: 44px;
    margin-left: -22px;
    margin-top: -22px;
  }

  .grm-segment-label {
    display: none;
  }
}

/* ── Reduced Motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .grm-trigger,
  .grm-trigger-icon,
  .grm-segment,
  .grm-arc-bg {
    transition-duration: 0.08s !important;
    transition-timing-function: ease !important;
  }

  .grm-container.grm-open .grm-segment {
    transition-delay: 0s !important;
  }
}

/* ================================================================
   CLIENT SELECT POPOVER
   Floats to the right of the radial arc; appears when Documents
   segment is clicked with no client pre-selected.
   ================================================================ */

/* ── Popover shell ──────────────────────────────────────────────── */
.grm-client-popover {
  position: fixed;
  /* Sits just to the right of the rightmost arc segment */
  left: 210px;
  bottom: 85px;
  z-index: 4501; /* One above radial container */
  width: 280px;
  max-height: 380px;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  background: var(--radial-popover-bg, var(--modal-bg, rgba(20, 25, 40, 0.98)));
  border: 1px solid var(--radial-popover-border, var(--modal-border, rgba(255, 255, 255, 0.08)));
  border-radius: 14px;
  box-shadow:
    var(--radial-popover-shadow, var(--modal-shadow, 0 20px 50px rgba(0, 0, 0, 0.5))),
    inset 0 1px 0 var(--border-inverse, rgba(255, 255, 255, 0.05));

  /* Hidden state */
  opacity: 0;
  transform: translateY(10px) scale(0.97);
  pointer-events: none;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}

.grm-client-popover.grm-popover-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header (title + search) ────────────────────────────────────── */
.grm-popover-header {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  flex-shrink: 0;
}

.grm-popover-title {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.65px;
  text-transform: uppercase;
  color: var(--radial-popover-title, var(--text-secondary, rgba(170, 178, 220, 0.65)));
  font-family: inherit;
}

.grm-popover-search {
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: var(--radial-popover-search-bg, var(--control-bg, rgba(255, 255, 255, 0.06)));
  border: 1px solid var(--radial-popover-search-border, var(--control-border, rgba(255, 255, 255, 0.1)));
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--radial-popover-search-text, var(--control-text, rgba(220, 225, 255, 0.92)));
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
  /* Remove browser default search-input decoration */
  -webkit-appearance: none;
  appearance: none;
}

.grm-popover-search::placeholder {
  color: var(--radial-popover-search-placeholder, var(--control-placeholder, rgba(140, 148, 200, 0.38)));
}

.grm-popover-search:focus {
  border-color: var(--control-border-focus, rgba(102, 126, 234, 0.45));
  background: var(--control-bg-hover, rgba(255, 255, 255, 0.09));
}

/* Remove the × clear button on search inputs */
.grm-popover-search::-webkit-search-cancel-button {
  display: none;
}

/* ── Scrollable client list ─────────────────────────────────────── */
.grm-popover-list {
  overflow-y: auto;
  flex: 1;
  padding: 5px 0;
}

.grm-popover-list::-webkit-scrollbar {
  width: 4px;
}

.grm-popover-list::-webkit-scrollbar-track {
  background: transparent;
}

.grm-popover-list::-webkit-scrollbar-thumb {
  background: var(--radial-popover-row-border, var(--border-default, rgba(255, 255, 255, 0.1)));
  border-radius: 2px;
}

/* ── Client row ─────────────────────────────────────────────────── */
.grm-popover-client-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: var(--radial-popover-item-text, var(--text-primary, rgba(210, 215, 242, 0.88)));
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease, color 0.12s ease;
}

.grm-popover-client-item + .grm-popover-client-item {
  border-top: 1px solid var(--radial-popover-row-border, rgba(255, 255, 255, 0.08));
}

.grm-popover-client-item:hover {
  background: var(--radial-popover-row-hover, var(--accent-soft-bg, rgba(102, 126, 234, 0.14)));
}

.grm-popover-client-item:focus-visible {
  background: var(--radial-popover-row-hover, var(--accent-soft-bg, rgba(102, 126, 234, 0.2)));
}

.grm-popover-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--radial-popover-avatar-bg, var(--accent-soft-bg, rgba(102, 126, 234, 0.18)));
  border: 1px solid var(--radial-popover-avatar-border, var(--accent-soft-border, rgba(102, 126, 234, 0.2)));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--radial-popover-avatar-text, var(--accent-primary, rgba(148, 170, 252, 0.9)));
  flex-shrink: 0;
  text-transform: uppercase;
  font-family: inherit;
  letter-spacing: 0.3px;
}

.grm-popover-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  color: var(--radial-popover-name, var(--text-primary, rgba(210, 215, 242, 0.9)));
}

/* ── Empty / loading states ─────────────────────────────────────── */
.grm-popover-empty {
  padding: 22px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--radial-popover-empty, var(--text-secondary, rgba(140, 148, 200, 0.48)));
  font-family: inherit;
  margin: 0;
}

/* ── Mobile ─────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .grm-client-popover {
    /* On mobile, center above the trigger */
    left: 16px;
    right: 16px;
    width: auto;
    bottom: 140px;
  }
}

/* ── Reduced motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .grm-client-popover {
    transition-duration: 0.05s !important;
  }
}
