// ============================================================================
// Quick-Jump Drawer — Slide-out panel for fast agent switching
// Per CUB-51: slides from right, agent list with status badges,
// search/filter input, closes via ESC or outside click.
// ============================================================================

// ---------------------------------------------------------------------------
// Backdrop
// ---------------------------------------------------------------------------
.quick-jump-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 998;
  opacity: 0;
  transition: opacity 200ms ease-out;

  &.backdrop-visible {
    opacity: 1;
  }
}

// ---------------------------------------------------------------------------
// Drawer Panel
// ---------------------------------------------------------------------------
.quick-jump-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 90vw;
  background-color: var(--cc-surface-container);
  border-left: 1px solid var(--cc-outline);
  z-index: 999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);

  &--open {
    transform: translateX(0);
  }
}

// ---------------------------------------------------------------------------
// Header
// ---------------------------------------------------------------------------
.quick-jump-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--cc-outline);
}

.quick-jump-drawer__title {
  font-size: 20px;
  font-weight: 500;
  color: var(--cc-on-surface);
  margin: 0;
  letter-spacing: -0.01em;
}

.quick-jump-drawer__close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--cc-on-surface-variant);
  font-size: 18px;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;

  &:hover {
    background-color: var(--cc-surface-container-high);
    color: var(--cc-on-surface);
  }

  &:focus-visible {
    outline: 2px solid var(--status-active);
    outline-offset: 2px;
  }
}

// ---------------------------------------------------------------------------
// Search
// ---------------------------------------------------------------------------
.quick-jump-drawer__search {
  position: relative;
  display: flex;
  align-items: center;
  margin: 16px 24px 8px;
  border: 1px solid var(--cc-outline);
  border-radius: 12px;
  background-color: var(--cc-surface-container-high);
  transition: border-color 150ms ease;

  &:focus-within {
    border-color: var(--status-active);
  }
}

.quick-jump-drawer__search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 12px;
  font-family: 'Material Icons';
  font-size: 20px;
  color: var(--cc-on-surface-variant);
  pointer-events: none;
  user-select: none;

  // Use a simple "search" text since icon font may not be loaded inside
  // the drawer — rely on Material icon font from the parent app
  &::before {
    content: 'search';
    font-family: 'Material Icons';
  }
}

.quick-jump-drawer__search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 12px 8px;
  font-size: 15px;
  font-family: 'Inter', 'Roboto', sans-serif;
  color: var(--cc-on-surface);

  &::placeholder {
    color: var(--cc-on-surface-variant);
    opacity: 0.7;
  }
}

.quick-jump-drawer__search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-right: 4px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--cc-on-surface-variant);
  font-size: 14px;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;

  &:hover {
    background-color: var(--cc-surface-container);
    color: var(--cc-on-surface);
  }

  &:focus-visible {
    outline: 2px solid var(--status-active);
    outline-offset: 2px;
  }
}

// ---------------------------------------------------------------------------
// Agent List
// ---------------------------------------------------------------------------
.quick-jump-drawer__agent-list {
  list-style: none;
  margin: 0;
  padding: 8px 12px;
  overflow-y: auto;
  flex: 1;
}

.quick-jump-drawer__agent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 150ms ease;

  &:hover,
  &--highlighted {
    background-color: var(--cc-surface-container-high);
  }

  &--highlighted {
    outline: 2px solid var(--status-active);
    outline-offset: -2px;
  }

  &:focus-visible {
    outline: 2px solid var(--status-active);
    outline-offset: 2px;
  }
}

.quick-jump-drawer__agent-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0; // Allow text truncation
  flex: 1;
}

.quick-jump-drawer__agent-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--cc-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-jump-drawer__agent-role {
  font-size: 12px;
  color: var(--cc-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-jump-drawer__agent-status-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;

  &.status-label--active {
    color: var(--status-active);
    background-color: var(--status-active-bg);
  }

  &.status-label--idle {
    color: var(--status-idle);
    background-color: var(--status-idle-bg);
  }

  &.status-label--thinking {
    color: var(--status-thinking);
    background-color: var(--status-thinking-bg);
  }

  &.status-label--error {
    color: var(--status-error);
    background-color: var(--status-error-bg);
  }

  &.status-label--offline {
    color: var(--status-offline);
    background-color: rgba(100, 116, 139, 0.12);
  }
}

// ---------------------------------------------------------------------------
// Empty State
// ---------------------------------------------------------------------------
.quick-jump-drawer__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--cc-on-surface-variant);
  font-size: 14px;
  text-align: center;
}

// ---------------------------------------------------------------------------
// Footer
// ---------------------------------------------------------------------------
.quick-jump-drawer__footer {
  padding: 12px 24px 16px;
  border-top: 1px solid var(--cc-outline);
}

.quick-jump-drawer__footer-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  color: var(--cc-on-surface-variant);
  opacity: 0.7;

  kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    font-family: var(--cc-font-mono);
    background-color: var(--cc-surface-container-high);
    border: 1px solid var(--cc-outline);
    border-radius: 4px;
    color: var(--cc-on-surface-variant);
    line-height: 1.4;
  }
}

// ---------------------------------------------------------------------------
// Mobile Adjustments
// ---------------------------------------------------------------------------
@media (max-width: 599px) {
  .quick-jump-drawer {
    width: 100%;
    max-width: 100vw;
  }

  .quick-jump-drawer__header {
    padding: 16px 16px 10px;
  }

  .quick-jump-drawer__search {
    margin: 12px 16px 8px;
  }

  .quick-jump-drawer__agent-list {
    padding: 4px 8px;
  }

  .quick-jump-drawer__footer {
    padding: 10px 16px 14px;
  }
}