@keyframes chatStatusBreathe {
  0%,
  100% {
    opacity: 0.65;
    box-shadow: 0 0 0 0 rgba(20, 184, 166, 0.55);
    transform: scale(1);
  }

  50% {
    opacity: 1;
    box-shadow: 0 0 10px 3px rgba(20, 184, 166, 0.35);
    transform: scale(1.12);
  }
}

@keyframes sidebarStatusBreathe {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ── Base item styles ─────────────────────────────────────────────────── */

.item {
  position: relative;
  display: flex;
  cursor: pointer;
  transition: background 0.15s;
  min-width: 0;

  &.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
  }
}

/* ── Drawer variant ───────────────────────────────────────────────────── */

.drawer {
  min-height: 77px;
  flex-shrink: 0;
  border-radius: 6px;
  gap: 8px;
  background-color: var(--colorBgBase, #fff);
  overflow: hidden;

  &:hover {
    background-color: var(--colorBgBase, #fff);
    background-image: linear-gradient(
      var(--color-fill-tertiary, rgba(43, 18, 0, 0.03)),
      var(--color-fill-tertiary, rgba(43, 18, 0, 0.03))
    );

    .moreBtn {
      opacity: 1;
      pointer-events: auto;
    }

    .iconPlaceholder {
      &::before {
        background-color: var(--colorBorder, #c1bebb);
      }

      &::after {
        border: 1px solid var(--colorBorder, #c1bebb);
      }
    }
  }

  &.active {
    background: var(--color-fill-secondary, rgba(43, 18, 0, 0.08));
  }

  &.editing .content {
    padding-right: 12px;
  }

  &.dropdownOpen {
    .moreBtn {
      opacity: 1;
      pointer-events: auto;
    }
  }
}

/* ── Sidebar variant ──────────────────────────────────────────────────── */

.sidebar {
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 2px;

  &:hover {
    background: var(--color-fill-tertiary, rgba(43, 18, 0, 0.05));

    .moreBtn {
      opacity: 1;
      pointer-events: auto;
    }

    .statusSlot {
      opacity: 0;
    }
  }

  &.active {
    background: var(--color-fill-secondary, rgba(43, 18, 0, 0.08));

    .name {
      font-weight: 500;
      color: var(--colorText, rgba(26, 23, 22, 0.88));
    }

    &:hover {
      background: var(--color-fill-secondary, rgba(43, 18, 0, 0.1));
    }
  }

  &.dropdownOpen {
    .moreBtn {
      opacity: 1;
      pointer-events: auto;
    }

    .statusSlot {
      opacity: 0;
    }
  }
}

/* ── Icon placeholder (drawer only) ───────────────────────────────────── */

.iconPlaceholder {
  width: 24px;
  flex-shrink: 0;
  position: relative;

  &::before {
    content: "";
    position: absolute;
    left: calc(50% - 0.5px);
    top: 0;
    bottom: 0;
    width: 1px;
    background-color: var(--colorBorder, #d9d9d9);
  }

  &::after {
    content: "";
    position: absolute;
    left: calc(50% - 3px);
    top: 20px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: var(--colorBgBase, #fff);
    border: 1px solid var(--colorBorder, #d9d9d9);
    z-index: 1;
  }
}

/* ── Content area ─────────────────────────────────────────────────────── */

.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;

  .drawer & {
    padding-top: 14px;
    padding-right: 16px;
  }
}

/* ── Title row (drawer only) ──────────────────────────────────────────── */

.titleRow {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.statusWrap {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

/* ── Name ─────────────────────────────────────────────────────────────── */

.name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 24px;
  color: var(--colorText, rgba(26, 23, 22, 0.88));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  .drawer & {
    max-width: 180px;
  }
}

/* ── Status indicators ────────────────────────────────────────────────── */

.statusSlot {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;

  .sidebar & {
    width: 14px;
    height: 14px;
  }
}

.statusDot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.statusDotIdle {
  background: #94a3b8;
  box-shadow: none;
}

.statusDotActive {
  background: rgba(20, 184, 166, 1);
  animation: chatStatusBreathe 1.6s ease-in-out infinite;
}

.runningDot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #52c41a;
  animation: sidebarStatusBreathe 1.5s ease-in-out infinite;
  pointer-events: none;
}

.idleDot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--colorTextQuaternary, rgba(26, 23, 22, 0.25));
  pointer-events: none;
}

/* ── Meta row (drawer only) ───────────────────────────────────────────── */

.metaRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.time {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  line-height: 18px;
  color: var(--colorTextSecondary, rgba(26, 23, 22, 0.45));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Channel tag ──────────────────────────────────────────────────────── */

.channelTag {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  opacity: 0.55;

  .drawer & {
    max-width: 52%;
    gap: 5px;
    padding: 1px 6px 1px 4px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    line-height: 18px;
    color: var(--colorTextSecondary, rgba(26, 23, 22, 0.55));
    background: var(--color-fill-tertiary, rgba(43, 18, 0, 0.06));
    min-width: 0;
    opacity: 1;
  }
}

.channelTagText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ── Pin button (drawer only) ─────────────────────────────────────────── */

.pinButton {
  position: absolute;
  right: 16px;
  top: 14px;
  width: 24px;
  height: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  color: var(--colorText, rgba(26, 23, 22, 0.88));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10;
  cursor: pointer;

  .item:hover &,
  &[data-pinned="true"] {
    opacity: 1;
    pointer-events: auto;
  }

  &[data-pinned="true"] {
    color: var(--colorPrimary, #ff9d4d);
  }
}

/* ── Action buttons (drawer only) ─────────────────────────────────────── */

.actions {
  position: absolute;
  right: 48px;
  top: 14px;
  display: flex;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.actionButton {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 4px;
  border: none;
  background: transparent;
  border-radius: 4px;
  color: var(--colorText, rgba(26, 23, 22, 0.88));
  cursor: pointer;
  transition: background 0.15s;

  &:hover {
    background: var(--color-fill-secondary, rgba(43, 18, 0, 0.08));
  }
}

/* ── More button ─────────────────────────────────────────────────────── */

.moreBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  font-size: 14px;
  color: var(--colorTextTertiary, rgba(26, 23, 22, 0.45));
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: all 0.15s;
  flex-shrink: 0;

  &:hover {
    background: var(--color-fill-secondary, rgba(43, 18, 0, 0.08));
    color: var(--colorText, rgba(26, 23, 22, 0.88));
  }

  .sidebar & {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
  }

  .drawer & {
    position: absolute;
    right: 12px;
    top: 14px;
  }
}

/* ── Rename input ─────────────────────────────────────────────────────── */

.renameInput {
  flex: 1;
  min-width: 0;
  font-size: 13px;
}

/* ── Dark mode ────────────────────────────────────────────────────────── */

:global(.dark-mode) {
  .drawer {
    background-color: #1f1f1f;

    &:hover {
      background: rgba(255, 255, 255, 0.08);
    }

    &.active {
      background: rgba(255, 255, 255, 0.15);
    }
  }

  .sidebar {
    &:hover {
      background: rgba(255, 255, 255, 0.06);
    }

    &.active {
      background: rgba(255, 255, 255, 0.1);

      .name {
        color: rgba(255, 255, 255, 0.95);
      }

      &:hover {
        background: rgba(255, 255, 255, 0.12);
      }
    }
  }

  .iconPlaceholder {
    &::before {
      background-color: rgba(255, 255, 255, 0.2);
    }

    &::after {
      background-color: #1f1f1f;
      border-color: rgba(255, 255, 255, 0.2);
    }
  }

  .name {
    color: rgba(255, 255, 255, 0.95);
  }

  .statusDotIdle {
    background: rgba(255, 255, 255, 0.35);
  }

  .time {
    color: rgba(255, 255, 255, 0.5);
  }

  .channelTag {
    .drawer & {
      color: rgba(255, 255, 255, 0.65);
      background: rgba(255, 255, 255, 0.1);
    }
  }

  .pinButton {
    color: rgba(255, 255, 255, 0.72);

    &[data-pinned="true"] {
      color: var(--colorPrimary, #ff9d4d);
    }
  }

  .actionButton {
    color: rgba(255, 255, 255, 0.72);

    &:hover {
      background: rgba(255, 255, 255, 0.1);
    }
  }

  .moreBtn {
    color: rgba(255, 255, 255, 0.45);

    &:hover {
      background: rgba(255, 255, 255, 0.1);
      color: rgba(255, 255, 255, 0.88);
    }
  }
}
